-
Notifications
You must be signed in to change notification settings - Fork 0
/
camera-preset-activator.html
103 lines (95 loc) · 3.97 KB
/
camera-preset-activator.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<!DOCTYPE html>
<html>
<head>
<!--Import Google Icon Font-->
<!-- <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"> -->
<!--Import materialize.css-->
<link type="text/css" rel="stylesheet" href="css/materialize.min.css" media="screen,projection" />
<!--Let browser know website is optimized for mobile-->
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<style>
.btn-large {
margin: 5px;
}
</style>
</head>
<body>
<div class="container">
<ul class="collapsible">
<li>
<div class="collapsible-header">Konfiguration</div>
<div class="collapsible-body"></span>
<input placeholder="zB. 192.168.0.99" id="textCameraIP" type="text" class="validate" onchange='saveCameraIP(this)'>
<label for="textCameraIP">IP der Kamera</label>
<input id="textCameraPresets" type="text" class="validate" onchange='saveCameraPresets(this)'>
<label for="textCameraPresets">Kamerabezeichnungen</label>
</div>
</li>
<li class="active">
<div class="collapsible-header">Kamera</div>
<div class="collapsible-body" id="divForButtons"></span>
</div>
</li>
</ul>
<!--JavaScript at end of body for optimized loading-->
<script type="text/javascript" src="js/materialize.min.js"></script>
<script>
var cameraIP;
var cameraPresets;
function initVariables(){
if (localStorage.getItem("cameraPresets") === null) {
localStorage.setItem("cameraPresets", JSON.stringify(["Redner", "Leser", "Tisch", "Totale"]));
}
cameraIP = localStorage.getItem("cameraIP")
cameraPresets = JSON.parse(localStorage.getItem("cameraPresets"))
fillVariablesFromLocalStorage();
document.addEventListener('DOMContentLoaded', function() {
var elems = document.querySelectorAll('.collapsible');
var options=[];
var instances = M.Collapsible.init(elems, options);
});
}
function initPresetButtons(){
var divForButtons = document.getElementById('divForButtons');
let i = 0;
var innerHTML ="";
while (i < cameraPresets.length) {
innerHTML +="<a class='waves-effect waves-light btn-large' onclick='selectPTZOpticsCameraPreset("+(i+1)+")'>"+cameraPresets[i]+"</a>\r\n";
i++;
}
console.log(innerHTML);
divForButtons.innerHTML = innerHTML;
}
function selectPTZOpticsCameraPreset(presetNumber){
if (cameraIP == null){
alert("Bitte zuerst die IP der Kamera eintragen");
return;
}
var url = "http://" + cameraIP + "/cgi-bin/ptzctrl.cgi?ptzcmd&poscall&"+presetNumber;
console.log(url);
var xhr = new XMLHttpRequest();
xhr.open("GET", url, true);
xhr.send();
}
function fillVariablesFromLocalStorage(){
if (localStorage.getItem("cameraIP") !== null) {
document.getElementById('textCameraIP').value=localStorage.getItem("cameraIP")
}
if (localStorage.getItem("cameraPresets") !== null) {
document.getElementById('textCameraPresets').value=localStorage.getItem("cameraPresets")
}
}
function saveCameraIP(input){
localStorage.setItem("cameraIP", input.value)
cameraIP=localStorage.cameraIP;
}
function saveCameraPresets(input){
localStorage.setItem("cameraPresets", input.value)
cameraPresets=localStorage.cameraPresets;
location.reload();
}
initVariables();
initPresetButtons();
</script>
</body>
</html>