summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
Diffstat (limited to 'js')
-rw-r--r--js/cctv-control.js26
1 files changed, 21 insertions, 5 deletions
diff --git a/js/cctv-control.js b/js/cctv-control.js
index 54d158a..8ffefbc 100644
--- a/js/cctv-control.js
+++ b/js/cctv-control.js
@@ -31,11 +31,18 @@ function initReady(fn) {
//hide the form, and switch on camera
function initViewer() {
+
+ var tempCam = parseInt(localStorage.getItem('cam'));
formActive = localStorage.getItem("formActive");
-
+ if (tempCam <= 7 && tempCam >= 0) {
+ cam = tempCam;
+ }
+
+ //if form was displayed, when page was reloaded, display form
if (formActive == 1) {
showForm();
+ displayCamNumber();
}
else {
formActive == 0;
@@ -44,14 +51,20 @@ function initViewer() {
}
}
+function displayCamNumber() {
+ var display = document.getElementById('screen');
+ camDisplay = cam + 1;
+ display.innerHTML = '<p class="camNumber">' + camDisplay + '</p>';
+}
+
//change currently displayed camera to the one in cam variable
function changeCam() {
var display = document.getElementById('screen');
if (cam <= 7 && cam >= 0) {
- camDisplay = cam + 1;
- display.innerHTML = '<p class="camNumber">' + camDisplay + '</p>';
+ displayCamNumber();
display.innerHTML += '<img id="camImage" src="http://' + camHost + '/cam/' + cam + '/stream.mjpeg" />';
+ localStorage.setItem("cam", cam);
}
else {
display.innerHTML = '<img id="camImage" src="img/testbild.gif" />';
@@ -112,11 +125,12 @@ function saveImage() {
function showForm() {
- //load snapshot from localstorage an display in background
+ //load snapshot from localstorage
var display1 = document.getElementById("camImage"),
display2 = document.getElementById("formImage"),
stor = localStorage.getItem("snapShot");
+ //display loaded image
if (stor) {
display1.setAttribute("src", stor);
display2.setAttribute("src", stor);
@@ -131,7 +145,7 @@ function showForm() {
function hideForm() {
- //save data
+ //save form data in local storage for later use
localStorage.setItem("formName", document.getElementById('formName').value);
localStorage.setItem("formDate", document.getElementById('formDate').value);
localStorage.setItem("formAnalysis1", document.getElementById('formAnalysis1').value);
@@ -148,7 +162,9 @@ function hideForm() {
function keyDown(event) {
+ // chaning the camera is only possible if the form is not displayed
if (formActive != 1) {
+ //numpad has different keycodes!
switch(event.keyCode) {
case 49: // 1
cam = 0;