summaryrefslogtreecommitdiffstats
path: root/htdocs/webiopi.js
diff options
context:
space:
mode:
Diffstat (limited to 'htdocs/webiopi.js')
-rw-r--r--htdocs/webiopi.js37
1 files changed, 37 insertions, 0 deletions
diff --git a/htdocs/webiopi.js b/htdocs/webiopi.js
index c7eae66..04029d7 100644
--- a/htdocs/webiopi.js
+++ b/htdocs/webiopi.js
@@ -665,6 +665,10 @@ WebIOPi.prototype.newDevice = function(type, name) {
665 if (type == "Distance") { 665 if (type == "Distance") {
666 return new Distance(name); 666 return new Distance(name);
667 } 667 }
668
669 if (type == "Duration") {
670 return new Duration(name);
671 }
668 672
669 if (type == "PiFaceDigital") { 673 if (type == "PiFaceDigital") {
670 return new PiFaceDigital(name); 674 return new PiFaceDigital(name);
@@ -1347,6 +1351,39 @@ Distance.prototype.refreshUI = function() {
1347 }); 1351 });
1348} 1352}
1349 1353
1354function Duration(name) {
1355 this.name = name;
1356 this.url = "/devices/" + name + "/sensor";
1357 this.refreshTime = 1000;
1358}
1359
1360Duration.prototype.toString = function() {
1361 return this.name + ": Duration";
1362}
1363
1364Duration.prototype.getMillimeter = function(callback) {
1365 $.get(this.url + "/duration/ms", function(data) {
1366 callback(this.name, data);
1367 });
1368}
1369
1370Duration.prototype.refreshUI = function() {
1371 var dist = this;
1372 var element = this.element;
1373
1374 if ((element != undefined) && (element.header == undefined)) {
1375 element.header = $("<h3>" + this + "</h3>");
1376 element.append(element.header);
1377 }
1378
1379 this.getMillimeter(function(name, data){
1380 if (element != undefined) {
1381 element.header.text(dist + ": " + data + "ms");
1382 }
1383 setTimeout(function(){dist.refreshUI()}, dist.refreshTime);
1384 });
1385}
1386
1350function PiFaceDigital(name) { 1387function PiFaceDigital(name) {
1351 this.name = name; 1388 this.name = name;
1352 this.url = "/devices/" + name + "/digital"; 1389 this.url = "/devices/" + name + "/digital";