From bb851f65b09d5fe4102057969a18bdee4eccfa31 Mon Sep 17 00:00:00 2001 From: Florian Date: Fri, 14 Feb 2014 20:34:55 +0100 Subject: page reload will display form if displayed when f5 was hit --- cam.html | 2 +- js/cctv-control.js | 29 ++++++++++++++++++++--------- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/cam.html b/cam.html index 4359f31..c0db634 100644 --- a/cam.html +++ b/cam.html @@ -30,7 +30,7 @@

-   +  

diff --git a/js/cctv-control.js b/js/cctv-control.js index 40a7bf4..5f18108 100644 --- a/js/cctv-control.js +++ b/js/cctv-control.js @@ -14,7 +14,7 @@ var cam = 0; var camHost = "127.0.0.1:8080"; var controlHost = "127.0.0.1:8080"; -var formActive = false; +var formActive = 0; //create event which is triggered when DOM is ready window.onDomReady = initReady; @@ -31,9 +31,18 @@ function initReady(fn) { //hide the form, and switch on camera function initViewer() { - document.getElementById('form').style.visibility = "hidden"; - changeCam(); + + formActive = localStorage.getItem("formActive"); + + if (formActive == 1) { + showForm(); } + else { + formActive == 0; + document.getElementById('form').style.visibility = "hidden"; + changeCam(); + } +} //change currently displayed camera to the one in cam variable function changeCam() { @@ -94,14 +103,14 @@ function saveImage() { }; fileReader.readAsDataURL(blob); - showImage(); + showForm(); } }, false); xhr.send(); } -function showImage() { +function showForm() { //load snapshot from localstorage an display in background var display1 = document.getElementById("camImage"), @@ -115,20 +124,22 @@ function showImage() { //make form visible document.getElementById("form").style.visibility = 'visible'; - formActive = true; + formActive = 1; + localStorage.setItem("formActive", formActive); } -function printForm() { +function hideForm() { document.getElementById("form").style.visibility = 'hidden'; - formActive = false; + formActive = 0; + localStorage.setItem("formActive", formActive); changeCam(); } function keyDown(event) { - if (formActive == false) { + if (formActive != 1) { switch(event.keyCode) { case 49: // 1 cam = 0; -- cgit v1.2.1