<script type="text/javascript" src="psensor.js"></script>
<script>
$(document).ready(function() {
- $.getJSON("/api/1.0/sensors", function(data) {
- $.each(data, function(i, item) {
- var sname = item["name"];
- var svalue = item["last_measure"]["value"];
- var smin = item["min"];
- var smax = item["max"];
- var stype = item["type"];
- var stype_str;
- var unit;
-
- unit = type_to_unit(stype);
- stype_str = type_to_str(stype);
-
- $("#sensors").append("<tr>"
- +"<td>"
- +"<a href='details.html?id="+escape("/api/1.0/sensors/"+item["id"])
- +"'>"+sname+"</a></td>"
- +"<td>"+svalue+unit+"</td><td>"+smin+unit+"</td><td>"+smax+unit+"</td><td>"+stype_str+"</td></tr>");
- });
- });
+
+ update_summary_sensors();
$.getJSON("/api/1.0/sysinfo", function(data) {
var load = Math.round(data["load"] * 100);
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;
$("#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("<tr>"
+ +"<td><a href='"+url+"'>"+name+"</a></td>"
+ +"<td>"+value_str+"</td>"
+ +"<td>"+min_str+"</td>"
+ +"<td>"+max_str+"</td>"
+ +"<td>"+type_str+"</td>"
+ +"</tr>");
+ });
+ });
}
\ No newline at end of file