summaryrefslogtreecommitdiff
path: root/public/js
diff options
context:
space:
mode:
Diffstat (limited to 'public/js')
-rw-r--r--public/js/cctv-control.js72
-rw-r--r--public/js/print.js72
2 files changed, 62 insertions, 82 deletions
diff --git a/public/js/cctv-control.js b/public/js/cctv-control.js
index 6db2932..ddbdbb4 100644
--- a/public/js/cctv-control.js
+++ b/public/js/cctv-control.js
@@ -14,6 +14,7 @@
var cam = 0;
var camHost = "192.168.1.20:8080";
var controlHost = "192.168.1.20:8080";
+var submitHost = "192.168.1.20:8080";
var formActive = 0; //crazy errors if boolean is used here...
//create event which is triggered when DOM is ready
@@ -161,28 +162,79 @@ function showForm() {
//make form visible
document.getElementById("form").style.visibility = 'visible';
+ document.getElementById("printButton").onclick = completeForm;
formActive = 1;
localStorage.setItem("formActive", formActive);
}
+var errorTimeout = null;
+function setError(message) {
+ var error_box = document.getElementById('errorBox');
+ error_box.innerText = message;
+ if (errorTimeout !== null)
+ window.clearTimeout(errorTimeout);
+ errorTimeout = window.setTimeout(function() {
+ error_box.innerHTML = ' ';
+ errorTimeout = null;
+ }, 5000);
+ return false;
+}
-function hideForm() {
-
- //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);
- localStorage.setItem("formAnalysis2", document.getElementById('formAnalysis2').value);
- localStorage.setItem("formAnalysis3", document.getElementById('formAnalysis3').value);
- //hide form and unfocus button
+function completeForm() {
+ var formName = document.getElementById('formName');
+ var formDate = document.getElementById('formDate');
+ var formAnalysis1 = document.getElementById('formAnalysis1');
+ var formAnalysis2 = document.getElementById('formAnalysis2');
+ var formAnalysis3 = document.getElementById('formAnalysis3');
+
+ if (formName.value.length < 3)
+ return setError("Personalkennzeichung unzureichend!");
+ if (formAnalysis1.value.length < 3)
+ return setError("Analyse der Aufnahme unzureichend!");
+ if (formAnalysis2.value.length < 3)
+ return setError("Bemerkungen zum Untersuchungsverlauf unzureichend!");
+/* if (formAnalysis3.value.length < 3)
+ return setError("Analyse der Aufnahme unzureichend!");*/
+
+ // unfocus and disable button
//otherwise next enter press will trigger print-function
document.getElementById('printButton').blur();
- window.open('print.html', 'Printlayout');
+ document.getElementById('printButton').onclick = function() {
+ return false;
+ };
+
+ var request = new XMLHttpRequest();
+ request.open("post", "http://" + submitHost + "/submit", false);
+
+ var post_object = {
+ 'formName': formName.value,
+ 'formDate': formDate.value,
+ 'formAnalysis1': formAnalysis1.value,
+ 'formAnalysis2': formAnalysis2.value,
+ 'formAnalysis3': formAnalysis3.value,
+ 'formImage': localStorage.getItem("snapShot")
+ };
+
+ var post_data = JSON.stringify(post_object);
+ request.setRequestHeader('Content-Type', 'application/json');
+ request.send(post_data);
+
+ // clear the input fields so they are not
+ // visible during next usage of the form.
+ // XXX: Leave the name in?
+ document.getElementById('formName').value = '';
+ document.getElementById('formAnalysis1').value = '';
+ document.getElementById('formAnalysis2').value = '';
+ document.getElementById('formAnalysis3').value = '';
+
+ //hide form and unfocus button
+ //otherwise next enter press will trigger print-function
document.getElementById("form").style.visibility = 'hidden';
formActive = 0;
localStorage.setItem("formActive", formActive);
changeCam();
+ return false;
}
diff --git a/public/js/print.js b/public/js/print.js
deleted file mode 100644
index 7375047..0000000
--- a/public/js/print.js
+++ /dev/null
@@ -1,72 +0,0 @@
-// CCTV Control
-//
-// Author: Florian Raemisch
-// Email: olf@subsignal.org
-//
-// cctv-control is a webinterface to control and view
-// mjpeg encoded videos by cctv cameras which are
-// proxied by mjpegplexer. camera control is possible
-// with arrow-keys, if mjpegplexer is configured
-// properly.
-//
-// This Software is licensed under the GPL Version 3, 29 June 2007
-
-var popen = '<p id="text">',
- pclose = '</p>';
-
-//create event which is triggered when DOM is ready
-window.onDomReady = initReady;
-
-//change from testbild to default cam when DOM is ready
-window.onDomReady(initViewer);
-
-
-function initReady(fn) {
- if(document.addEventListener) {
- document.addEventListener("DOMContentLoaded", fn, false);
- }
-}
-
-function initViewer() {
-
- //load contents from localStorage
- var display = document.getElementById("camImage"),
- meta = document.getElementById("metaContainer"),
- text = document.getElementById("textContainer"),
- formName = localStorage.getItem("formName"),
- formDate = localStorage.getItem("formDate"),
- formAnalysis1 = localStorage.getItem("formAnalysis1"),
- formAnalysis2 = localStorage.getItem("formAnalysis2"),
- formAnalysis3 = localStorage.getItem("formAnalysis3"),
- camera = localStorage.getItem("cam");
- stor = localStorage.getItem("snapShot");
-
- //cameraname is cameraID + 1
- camera = parseInt(camera) + 1;
-
- //display loaded data
- if (stor) {
- display.setAttribute("src", stor);
- meta.innerHTML += popen + formName + pclose;
- meta.innerHTML += popen + formDate + pclose;
- meta.innerHTML += popen + 'Kamera ' + camera + pclose;
- text.innerHTML += popen + formAnalysis1 + pclose;
- text.innerHTML += popen + formAnalysis2 + pclose;
- text.innerHTML += popen + formAnalysis3 + pclose;
- }
-
- //commented out for debugging and layouting purposes
- print();
-
- //reset localStorage to default values
- //localStorage.setItem("formName", "Untersucher");
- //localStorage.setItem("formDate", "Datum");
- //localStorage.setItem("formAnalysis1", "Dein Bericht 1");
- //localStorage.setItem("formAnalysis2", "Dein Bericht 2");
- //localStorage.setItem("formAnalysis3", "Dein Bericht 3"):
-
- //commented out for debugging and layouting purposes
- window.close();
-
-}
-