The unified diff between revisions [1d341395..] and [5cecdf60..] is displayed below. It can also be downloaded as a raw diff.
#
#
# patch "Webcams.js"
# from [41b20bb1d1c9691e641c6a912aa3478f76fa08fb]
# to [3a39e7fb4d085d5883bc16c6d66f7c7992e8925a]
#
============================================================
--- Webcams.js 41b20bb1d1c9691e641c6a912aa3478f76fa08fb
+++ Webcams.js 3a39e7fb4d085d5883bc16c6d66f7c7992e8925a
@@ -1,3 +1,14 @@
+// fires when updates of the image are needed
+var timer = null;
+// UCC webcams
+var webcams = new Array();
+webcams["webcam"] = "http://webcam.ucc.asn.au/webcam.php";
+webcams["webcam1"] = "http://webcam.ucc.asn.au/webcam1.php";
+webcams["webcam3"] = "http://webcam.ucc.asn.au/webcam3.php";
+webcams["bw-webcam"] = "http://webcam.ucc.asn.au/bw-webcam.php";
+// the default camera..
+var defaultCam = "webcam1";
+// stock buttons
var gDoneButton;
var gInfoButton;
@@ -33,13 +44,6 @@ function updateImage()
function updateImage()
{
- var webcams = new Array();
- defaultCam = "webcam1";
- webcams["webcam"] = "http://webcam.ucc.asn.au/webcam.php";
- webcams["webcam1"] = "http://webcam.ucc.asn.au/webcam1.php";
- webcams["webcam3"] = "http://webcam.ucc.asn.au/webcam3.php";
- webcams["bw-webcam"] = "http://webcam.ucc.asn.au/bw-webcam.php";
-
var finalUri = "";
if (window.widget) {
@@ -52,8 +56,9 @@ function updateImage()
finalUri = webcams[defaultCam];
}
+ var now = new Date();
img = document.getElementById("webcam");
- img.src = finalUri;
+ img.src = finalUri + "?forceReload=" + now.getTime();
}
function camChanged()
@@ -79,11 +84,28 @@ function camComboInit()
sel.selectedIndex = idx;
}
+function onShow()
+{
+ if (timer == null) {
+ updateImage();
+ timer = setInterval("updateImage();", 1000*60);
+ }
+}
+
+function onHide()
+{
+ if (timer != null) {
+ clearInterval(timer);
+ timer = null;
+ }
+}
+
function setup()
{
gDoneButton = new AppleGlassButton(document.getElementById("doneButton"), "Done", hidePrefs);
gInfoButton = new AppleInfoButton(document.getElementById("infoButton"), document.getElementById("front"), "white", "white", showPrefs);
- updateImage();
camComboInit();
+ widget.onshow = onShow;
+ widget.onhide = onHide;
}