X-Git-Url: https://git.wpitchoune.net/gitweb/?a=blobdiff_plain;f=www%2Fpsensor.js;fp=www%2Fpsensor.js;h=862aa1d26dae0de65906d24886ca185111ceafcd;hb=759199c3e1e9b2edc919379058b9893266952f08;hp=28d9c46f22cd02ef2fd3594744a7545695cd6b4c;hpb=bc0151ee30377de6c211d0e9660b5a1ad0aa5131;p=psensor.git diff --git a/www/psensor.js b/www/psensor.js index 28d9c46..862aa1d 100644 --- a/www/psensor.js +++ b/www/psensor.js @@ -67,13 +67,17 @@ function type_to_str(stype) { function type_to_unit(stype) { if (stype & 0x0001) - unit = " C"; + unit = "C"; else if (stype & 0x0002) - unit = " RPM"; + unit = "RPM"; return unit; } +function value_to_str(value, type) { + return value+type_to_unit(type); +} + function get_url_params() { var vars, hashes, i; @@ -162,4 +166,28 @@ function update_menu() { $("#menu-list").append(str); }); +} + +function update_summary_sensors() { + var name, value_str, min_str, max_str, type, type_str, url; + + $.getJSON("/api/1.0/sensors", function(data) { + $.each(data, function(i, item) { + name = item["name"]; + type = item["type"]; + value_str = value_to_str(item["last_measure"]["value"], type); + min_str = value_to_str(item["min"], type); + max_str = value_to_str(item["max"], type); + type_str = type_to_str(type); + url = "details.html?id="+escape("/api/1.0/sensors/"+item["id"]); + + $("#sensors").append("" + +""+name+"" + +""+value_str+"" + +""+min_str+"" + +""+max_str+"" + +""+type_str+"" + +""); + }); + }); } \ No newline at end of file