fixed IE8 bug (page title change not allowed).
[psensor.git] / www / psensor.js
index d3372d0..b002c41 100644 (file)
@@ -54,6 +54,8 @@ function type_to_str(stype) {
         stype_str = "NVidia";
     else if (stype & 0x0400)
         stype_str = "HDD";
+    else if (stype & 0x0800)
+        stype_str = "CPU Usage Percentage";
     else if (stype & 0x1000) 
         stype_str = "AMD";
  
@@ -98,11 +100,19 @@ function update_chart(chart_id, title, data) {
     var measures, data_chart, date, entry;
     var style;
 
+    $("#"+chart_id).html("");
+
     measures = data["measures"];
     data_chart = [];
     
+    $("h1").html("");
     $("h1").append(data["name"]);
-    $("title").append(data["name"]);
+
+    try {
+       $("title").html(data["name"]);
+    } catch(ignore) {
+       // IE8 doesn't allow to modify the page title
+    }
     
     $.each(measures, function(i, item) {
         value = item["value"];
@@ -144,14 +154,17 @@ function update_chart(chart_id, title, data) {
        } ]
     };
 
+
     $.jqplot (chart_id, [data_chart], style);
 }
 
 function update_menu() {
     var name, link, url, str;
 
+    str = "";
+
     $.getJSON("/api/1.0/sensors", function(data) {
-       str = "<li><em>Sensors</em>\n<ul>";
+       str += "<li><em>Sensors</em>\n<ul>";
 
        $.each(data, function(i, item) {
             name = item["name"];
@@ -159,10 +172,17 @@ function update_menu() {
            link = "<a href='"+url+"'>"+name+"</a>";
            str += "<li>"+link+"</li>";
        });
+       str += "</li></ul>";
 
-       str += "</ul>";
-
+       str += "<li><em>CPU</em><ul>";
+       url = "details.html?id="+escape("/api/1.0/cpu/usage");
+       link = "<a href='"+url+"'>usage</a>";
+       str += "<li>"+link+"</li>";
+       
+       str += "</li></ul>";
+       
        $("#menu-list").append(str);
+
     });
 
 }
@@ -211,7 +231,7 @@ function update_summary_sysinfo() {
         var uptime_h = Math.floor((uptime / (60*60)) % 24);
         var uptime_d = Math.floor(uptime / (60*60*24));
        
-        $("#cpu").append("<tr><td>"+load+"%</td><td>"
+        $("#cpu").append("<tr><td><a href='details.html?id=/api/1.0/cpu/usage'>"+load+"%</a></td><td>"
                         +load_1+"</td><td>"
                         +load_5+"</td><td>"
                         +load_15+"</td></tr>");