|
|
@@ -8,13 +8,22 @@ var i = 0;
|
|
|
var pictures = [];
|
|
|
var interval = null;
|
|
|
|
|
|
+var origin = '';
|
|
|
+// var origin = 'http://growcam';
|
|
|
+
|
|
|
function reload() {
|
|
|
+ if (pictures.length === 0) return;
|
|
|
+
|
|
|
if (i >= pictures.length) i = 0;
|
|
|
|
|
|
- document.getElementById('picture').src = '/pictures/' + pictures[i++];
|
|
|
+ document.getElementById('stream').src = origin + '/pictures/' + pictures[i++];
|
|
|
document.getElementById('currentPictureLabel').innerText = pictures[i++];
|
|
|
}
|
|
|
|
|
|
+function takePicture() {
|
|
|
+ document.getElementById('picture').src = origin + '/picture?' + Date.now();
|
|
|
+}
|
|
|
+
|
|
|
function getPictureList() {
|
|
|
var req = new XMLHttpRequest();
|
|
|
req.addEventListener('load', function () {
|
|
|
@@ -22,7 +31,7 @@ function getPictureList() {
|
|
|
|
|
|
document.getElementById('pictureCount').innerText = pictures.length;
|
|
|
});
|
|
|
- req.open('GET', '/pictures');
|
|
|
+ req.open('GET', origin + '/pictures');
|
|
|
req.send();
|
|
|
}
|
|
|
|
|
|
@@ -31,7 +40,7 @@ function pausePlay() {
|
|
|
clearInterval(interval);
|
|
|
interval = null;
|
|
|
} else {
|
|
|
- interval = setInterval(reload, 100);
|
|
|
+ interval = setInterval(reload, 500);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -48,7 +57,11 @@ window.onload = function () {
|
|
|
<body>
|
|
|
|
|
|
<p>Pictures available: <span id="pictureCount"></span> showing <span id="currentPictureLabel"></span></p>
|
|
|
- <img id="picture" width="800" height="600" onclick="pausePlay()"/>
|
|
|
+ <img id="stream" width="800" onclick="pausePlay()"/>
|
|
|
+
|
|
|
+ <br/>
|
|
|
+
|
|
|
+ <img id="picture" width="400" height="400" onclick="takePicture()"/>
|
|
|
|
|
|
</body>
|
|
|
</html>
|