X-Git-Url: https://git.wpitchoune.net/gitweb/?a=blobdiff_plain;f=www%2Fpsensor.js;h=3e902853faa99053eb469f835de90d936cdcdd7c;hb=e6444eb3fa27922e70f4ae2bbcd32a3d6f295ab8;hp=e77fc01d270c7b001c4832f3cf60b6e2261ae061;hpb=6d9ffc592752d89835629ec8ae9ff0dd6ea6603e;p=psensor.git diff --git a/www/psensor.js b/www/psensor.js index e77fc01..3e90285 100644 --- a/www/psensor.js +++ b/www/psensor.js @@ -41,41 +41,51 @@ function format_mem_size(s) { return o+"o"; return "0"; -}; +} function type_to_str(stype) { var stype_str; - stype_str = "N/A"; - - if (stype & 0x0100) - stype_str = "Sensor"; - else if (stype & 0x0200) - stype_str = "NVidia"; - else if (stype & 0x0400) - stype_str = "HDD"; - else if (stype & 0x1000) - stype_str = "AMD"; + if (stype & 0x0200) + stype_str = "NVidia "; + else if (stype & 0x0800) + stype_str = "ATI/AMD "; + else + stype_str = ""; - if (stype & 0x0001) - stype_str += " Temperature"; + if (stype & 0x04000) + stype_str += "HDD "; + else if (stype & 0x08000) + stype_str += "CPU "; + else if (stype & 0x10000) + stype_str += "GPU "; + else if (stype & 0x20000) + stype_str += "Fan "; + + if (stype & 0x0001) + stype_str += "Temperature"; else if (stype & 0x0002) - stype_str += " Fan"; + stype_str += "RPM"; + else if (stype & 0x0004) + stype_str += "Load"; return stype_str; -}; +} function type_to_unit(stype) { if (stype & 0x0001) - unit = " C"; + unit = "C"; else if (stype & 0x0002) - unit = " RPM"; + unit = "RPM"; return unit; } -function get_url_params() -{ +function value_to_str(value, type) { + return value+type_to_unit(type); +} + +function get_url_params() { var vars, hashes, i; vars = []; @@ -95,11 +105,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"]; @@ -137,32 +155,124 @@ function update_chart(chart_id, title, data) { }, series: [ { lineWidth: 1, - showMarker:false + showMarker: false } ] }; + $.jqplot (chart_id, [data_chart], style); } function update_menu() { var name, link, url, str; - $.getJSON("/api/1.0/sensors", function(data) { - str = "