diff options
author | Christian Franke <nobody@nowhere.ws> | 2014-03-19 16:35:56 +0100 |
---|---|---|
committer | Christian Franke <nobody@nowhere.ws> | 2014-03-19 16:43:55 +0100 |
commit | 80efed22b3c0d43d285ebade7eb99259da2071b5 (patch) | |
tree | 38e584b3ec67621ebd558fe2414d79589f34408d /public | |
parent | 47685493bc961f0186bab00b24eaf7367468af06 (diff) |
Reload images if mjpegplexer is broken
Diffstat (limited to 'public')
-rw-r--r-- | public/cam.html | 1 | ||||
-rw-r--r-- | public/js/cctv-control.js | 31 |
2 files changed, 23 insertions, 9 deletions
diff --git a/public/cam.html b/public/cam.html index 5ab2aaf..4149c77 100644 --- a/public/cam.html +++ b/public/cam.html @@ -8,6 +8,7 @@ </head> <body onkeydown="keyDown(event)" id='body'> <div id="screen"> + <p class="camNumber">23</p> <img src="img/testbild.gif" id="camImage"> </div> <div id="form"> diff --git a/public/js/cctv-control.js b/public/js/cctv-control.js index 8f8e777..8ac8b0c 100644 --- a/public/js/cctv-control.js +++ b/public/js/cctv-control.js @@ -12,9 +12,9 @@ // This Software is licensed under the GPL Version 3, 29 June 2007 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 camHost = "192.168.1.66:8080"; +var controlHost = "192.168.1.66:8080"; +var submitHost = "192.168.1.66:8080"; var formActive = 0; //crazy errors if boolean is used here... //create event which is triggered when DOM is ready @@ -30,9 +30,16 @@ function initReady(fn) { } } +function reloadSrc() { + var camImage = document.getElementById('camImage'); + camImage.setAttribute('src', camImage.getAttribute('src')); + window.setTimeout(reloadSrc, 5000); +} + //hide the form, and switch on camera function initViewer() { var display = document.getElementById('screen'); + var camImage = document.getElementById('camImage'); var tempCam = parseInt(localStorage.getItem('cam')); formActive = localStorage.getItem("formActive"); @@ -43,7 +50,8 @@ function initViewer() { //if form was displayed, when page was reloaded, display form if (formActive == 1) { displayCamNumber(); - display.innerHTML += '<img id="camImage" src="http://' + camHost + '/cam/' + cam + '/stream.mjpeg" />'; + camImage.setAttribute('src', + 'http://' + camHost + '/cam/' + cam + '/stream.mjpeg'); showForm(); } else { @@ -51,25 +59,30 @@ function initViewer() { document.getElementById('form').style.visibility = "hidden"; changeCam(); } + + reloadSrc(); } function displayCamNumber() { - var display = document.getElementById('screen'); - camDisplay = cam + 1; - display.innerHTML = '<p class="camNumber">' + camDisplay + '</p>'; + var camNumber = cam + 1; + var camDisplay = document.getElementsByClassName('camNumber')[0]; + + camDisplay.innerText = camNumber; } //change currently displayed camera to the one in cam variable function changeCam() { var display = document.getElementById('screen'); + var camImage = document.getElementById('camImage'); if (cam <= 7 && cam >= 0) { displayCamNumber(); - display.innerHTML += '<img id="camImage" src="http://' + camHost + '/cam/' + cam + '/stream.mjpeg" />'; + camImage.setAttribute('src', + 'http://' + camHost + '/cam/' + cam + '/stream.mjpeg'); localStorage.setItem("cam", cam); } else { - display.innerHTML = '<img id="camImage" src="img/testbild.gif" />'; + camImage.setAttribute('src', 'img/testbild.gif'); } } |