The unified diff between revisions [70f0d046..] and [ba58d8b0..] is displayed below. It can also be downloaded as a raw diff.
#
#
# patch "Info.plist"
# from [82dc5169a6f8407f0c336baa5f43b40964dc006f]
# to [19d1aebdd8699087b4228d797ac6fe819ab4ab48]
#
# patch "Webcams.html"
# from [9741c507ac7545abbf43550b0857da193e417031]
# to [33f5d0e56580aab8fba184ea25552ca82e0ceb33]
#
# patch "Webcams.js"
# from [d5460619bbb70e1fb828043a32c23c3c6fcfb97b]
# to [1ebd4b4765d90ee05425e176ec1e36eb3094f835]
#
============================================================
--- Info.plist 82dc5169a6f8407f0c336baa5f43b40964dc006f
+++ Info.plist 19d1aebdd8699087b4228d797ac6fe819ab4ab48
@@ -11,9 +11,9 @@
<key>CFBundleName</key>
<string>UCC Webcams</string>
<key>CFBundleShortVersionString</key>
- <string>1.0</string>
+ <string>1.1</string>
<key>CFBundleVersion</key>
- <string>1.0</string>
+ <string>1.1</string>
<key>CloseBoxInsetX</key>
<integer>16</integer>
<key>CloseBoxInsetY</key>
============================================================
--- Webcams.html 9741c507ac7545abbf43550b0857da193e417031
+++ Webcams.html 33f5d0e56580aab8fba184ea25552ca82e0ceb33
@@ -26,6 +26,7 @@
<option value="webcam1">2: Colour on Maroon</option>
<option value="webcam3">3: Colour on Novorossiisk</option>
<option value="bw-webcam">4: B&W on Kormoran</option>
+ <option value="rotate">Rotate through all cameras</option>
</select>
</div>
<div id="doneButton"></div>
============================================================
--- Webcams.js d5460619bbb70e1fb828043a32c23c3c6fcfb97b
+++ Webcams.js 1ebd4b4765d90ee05425e176ec1e36eb3094f835
@@ -1,13 +1,23 @@
+// in milliseconds
+imageUpdateInterval = 60 * 1000;
+imageRotateInterval = 5 * 1000;
// fires when updates of the image are needed
var timer = null;
+// fires when rotation of camera is needed
+var rotateTimer = 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";
+var webcams = new Array("webcam", "webcam1", "webcam3", "bw-webcam", "rotate");
+webcams["webcam"] = "http://webcam.ucc.asn.au/webcam.jpg";
+webcams["webcam1"] = "http://webcam.ucc.asn.au/webcam1.jpg";
+webcams["webcam3"] = "http://webcam.ucc.asn.au/webcam3.jpg";
+webcams["bw-webcam"] = "http://webcam.ucc.asn.au/bw-webcam.jpg";
+webcams["rotate"] = "rotate";
+
// the default camera..
var defaultCam = "webcam1";
+// if we're rotating through the cams, this is the index we're
+// up to
+var rotationIndex = 0;
// stock buttons
var gDoneButton;
var gInfoButton;
@@ -44,21 +54,34 @@ function updateImage()
function updateImage()
{
- var finalUri = "";
+ var uri = "";
+ var webcam;
+ var img = document.getElementById("webcam");
- if (window.widget) {
- var webcamPref = widget.preferenceForKey('webcam');
- finalUri = webcams[webcamPref];
+ if (!window.widget) {
+ return;
}
- if (!finalUri || !(finalUri.length > 0)) {
+ var webcam = widget.preferenceForKey('webcam');
+
+ if (!webcams[webcam]) {
widget.setPreferenceForKey(defaultCam, 'webcam');
- finalUri = webcams[defaultCam];
+ webcam = defaultCam;
}
+ if (webcam == 'rotate') {
+ webcam = webcams[rotationIndex];
+ }
+
+ // images reload once every sixty seconds
+ // seems to generate a GET the first time round; then
+ // another get the second time round;
+ // then no GET from then on (sticks in the cache)
var now = new Date();
- img = document.getElementById("webcam");
- img.src = finalUri + "?forceReload=" + now.getTime();
+ var reloadTime = now.getTime() - (now.getTime() % imageUpdateInterval);
+ uri = webcams[webcam] + "?forceReload=" + reloadTime;
+
+ img.src = uri;
}
function camChanged()
@@ -66,6 +89,7 @@ function camChanged()
var sel = document.getElementById("camToView");
var cam = sel.options[sel.selectedIndex].value;
widget.setPreferenceForKey(cam, 'webcam');
+ checkRotation();
updateImage();
}
@@ -84,12 +108,47 @@ function camComboInit()
sel.selectedIndex = idx;
}
+function rotateImage()
+{
+ // -1 as the final webcam is the rotate magic one
+ rotationIndex = (rotationIndex + 1) % (webcams.length - 1);
+ updateImage();
+}
+
+function checkRotation()
+{
+ var webcamPref = widget.preferenceForKey('webcam');
+ if (webcamPref == "rotate") {
+ startRotation();
+ } else {
+ stopRotation();
+ }
+}
+
+function startRotation()
+{
+ if (rotateTimer == null) {
+ rotateTimer = setInterval("rotateImage();", imageRotateInterval);
+ }
+}
+
+function stopRotation()
+{
+ if (rotateTimer != null) {
+ clearInterval(rotateTimer);
+ rotateTimer = null;
+ }
+}
+
function onShow()
{
+ var webcamPref = widget.preferenceForKey('webcam');
+
if (timer == null) {
updateImage();
- timer = setInterval("updateImage();", 1000*60);
+ timer = setInterval("updateImage();", imageUpdateInterval);
}
+ checkRotation();
}
function onHide()
@@ -98,6 +157,7 @@ function onHide()
clearInterval(timer);
timer = null;
}
+ stopRotation();
}
function setup()