2008-06-26 16:09:04 +02:00
|
|
|
/* Copyright (C) 2007 Richard Atterer, richard©atterer.net
|
|
|
|
This program is free software; you can redistribute it and/or modify it
|
|
|
|
under the terms of the GNU General Public License, version 2. See the file
|
|
|
|
COPYING for details. */
|
|
|
|
|
|
|
|
var imageNr = 0; // Serial number of current image
|
|
|
|
var finished = new Array(); // References to img objects which have finished downloading
|
|
|
|
var paused = false;
|
|
|
|
|
|
|
|
function createImageLayer() {
|
|
|
|
var img = new Image();
|
|
|
|
img.style.position = "absolute";
|
|
|
|
img.style.zIndex = -1;
|
|
|
|
img.style.width = "400px";
|
|
|
|
img.style.height = "320px";
|
|
|
|
img.onload = imageOnload;
|
|
|
|
img.onclick = imageOnclick;
|
|
|
|
img.src = "http://fotokiste:8081/?action=snapshot&n=" + (++imageNr);
|
|
|
|
var webcam = document.getElementById("live_pic");
|
|
|
|
webcam.insertBefore(img, webcam.firstChild);
|
|
|
|
}
|
|
|
|
|
2008-07-01 22:50:14 +02:00
|
|
|
|
|
|
|
|
2008-06-26 16:09:04 +02:00
|
|
|
// Two layers are always present (except at the very beginning), to avoid flicker
|
|
|
|
function imageOnload() {
|
|
|
|
this.style.zIndex = imageNr; // Image finished, bring to front!
|
|
|
|
while (1 < finished.length) {
|
|
|
|
var del = finished.shift(); // Delete old image(s) from document
|
|
|
|
del.parentNode.removeChild(del);
|
|
|
|
}
|
|
|
|
finished.push(this);
|
2008-07-01 22:50:14 +02:00
|
|
|
if (!paused) window.setTimeout(createImageLayer(), 1000);
|
2008-06-26 16:09:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function imageOnclick() { // Clicking on the image will pause the stream
|
|
|
|
paused = !paused;
|
|
|
|
if (!paused) createImageLayer();
|
|
|
|
}
|
|
|
|
|