diff options
author | Florian <stayawake@lavabit.com> | 2014-02-14 20:34:55 +0100 |
---|---|---|
committer | Florian <stayawake@lavabit.com> | 2014-02-14 20:34:55 +0100 |
commit | bb851f65b09d5fe4102057969a18bdee4eccfa31 (patch) | |
tree | e176ce8948c73f008fd532d05607ba8f029b2af0 | |
parent | 7e5443f9221ba6526522a0e04a4f1a6b1d6c2554 (diff) |
page reload will display form if displayed when f5 was hit
-rw-r--r-- | cam.html | 2 | ||||
-rw-r--r-- | js/cctv-control.js | 29 |
2 files changed, 21 insertions, 10 deletions
@@ -30,7 +30,7 @@ </textarea> <p> - <a href="#" id='printButton' onclick='printForm()'> </a> + <a href="#" id='printButton' onclick='hideForm()'> </a> </p> </div> 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; |