diff options
| author | manuel <manuel@mausz.at> | 2013-12-25 18:31:56 +0100 |
|---|---|---|
| committer | manuel <manuel@mausz.at> | 2013-12-25 18:31:56 +0100 |
| commit | d70072c2f4c348ba2f6a562fa31e3245209cf21f (patch) | |
| tree | dd77a2ad352d8965965833a86922e26e67693e80 /htdocs | |
| parent | 4306c0ed8d95bbaca875f4f1d9badb436cb4e2b9 (diff) | |
| download | webiopi-d70072c2f4c348ba2f6a562fa31e3245209cf21f.tar.gz webiopi-d70072c2f4c348ba2f6a562fa31e3245209cf21f.tar.bz2 webiopi-d70072c2f4c348ba2f6a562fa31e3245209cf21f.zip | |
add support for ICMP
Diffstat (limited to 'htdocs')
| -rw-r--r-- | htdocs/webiopi.js | 37 |
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 | ||
| 1354 | function Duration(name) { | ||
| 1355 | this.name = name; | ||
| 1356 | this.url = "/devices/" + name + "/sensor"; | ||
| 1357 | this.refreshTime = 1000; | ||
| 1358 | } | ||
| 1359 | |||
| 1360 | Duration.prototype.toString = function() { | ||
| 1361 | return this.name + ": Duration"; | ||
| 1362 | } | ||
| 1363 | |||
| 1364 | Duration.prototype.getMillimeter = function(callback) { | ||
| 1365 | $.get(this.url + "/duration/ms", function(data) { | ||
| 1366 | callback(this.name, data); | ||
| 1367 | }); | ||
| 1368 | } | ||
| 1369 | |||
| 1370 | Duration.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 | |||
| 1350 | function PiFaceDigital(name) { | 1387 | function PiFaceDigital(name) { |
| 1351 | this.name = name; | 1388 | this.name = name; |
| 1352 | this.url = "/devices/" + name + "/digital"; | 1389 | this.url = "/devices/" + name + "/digital"; |
