Merge pull request #83 from jtanx/master
[matches/MCTX3420.git] / testing / MCTXWeb / public_html / static / mctx.gui.js
index 13ca08e..1c3eb1f 100644 (file)
@@ -227,6 +227,40 @@ $.fn.logout = function () {
     });
 };
 
+/**
+* Sets the camera autoupdater
+* Obsolete?
+* @returns {$.fn}
+*/
+$.fn.setCamera = function () {
+  var url = mctx.api + "image"; //http://beaglebone/api/image
+  var update = true;
+
+  //Stop updating if we can't retrieve an image!
+  this.error(function() {
+    update = false;
+  });
+  
+  var parent = this;
+  
+  var updater = function() {
+    if (!update) {
+      parent.parent().text("Cam fail");
+      parent.attr("src", "");
+      return;
+    }
+    
+    parent.attr("src", url + "#" + (new Date()).getTime());
+    
+    setTimeout(updater, 2000);
+  };
+  
+  updater();
+  return this;
+};
+
+
+
 /**
 * Sets the error log to continuously update.
 * @returns itself */

UCC git Repository :: git.ucc.asn.au