summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian <stayawake@lavabit.com>2014-02-14 20:34:55 +0100
committerFlorian <stayawake@lavabit.com>2014-02-14 20:34:55 +0100
commitbb851f65b09d5fe4102057969a18bdee4eccfa31 (patch)
treee176ce8948c73f008fd532d05607ba8f029b2af0
parent7e5443f9221ba6526522a0e04a4f1a6b1d6c2554 (diff)
page reload will display form if displayed when f5 was hit
-rw-r--r--cam.html2
-rw-r--r--js/cctv-control.js29
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 @@
</textarea>
<p>
- <a href="#" id='printButton' onclick='printForm()'>&nbsp</a>
+ <a href="#" id='printButton' onclick='hideForm()'>&nbsp</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;