added missing js file
authorJean-Philippe Orsini <jeanfi@gmail.com>
Thu, 14 Jul 2011 15:02:42 +0000 (15:02 +0000)
committerJean-Philippe Orsini <jeanfi@gmail.com>
Thu, 14 Jul 2011 15:02:42 +0000 (15:02 +0000)
www/psensor.js [new file with mode: 0644]

diff --git a/www/psensor.js b/www/psensor.js
new file mode 100644 (file)
index 0000000..79757ea
--- /dev/null
@@ -0,0 +1,53 @@
+function format_mem_size(s) {
+    var mo_bytes = 1024 * 1024;
+    var go_bytes = 1024 * mo_bytes;
+
+    var o = s % 1024;
+    var k = Math.round((s / 1024) % 1024);
+    var m = Math.round((s / (1024*1024)) % 1024);
+    var g = Math.round(s / (1024*1024*1024));
+
+    if (g >= 1)
+        return g+"Go ";
+
+    if (m >= 1)
+        return m+"Mo";
+
+    if (k >= 1)
+        return k+"Ko";
+    
+    if (o > 0)
+        return o+"o";
+
+    return "0";
+};
+
+function type_to_str(stype) {
+    var 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 & 0x0800) {
+        stype_str = "Fan";
+    }
+
+   if (stype & 0x0001) {
+        stype_str += " Temperature";
+   }
+
+    return stype_str;
+};
+
+function type_to_unit(stype) {
+    if (stype & 0x0001) {
+        unit = " C";
+    } else if (stype & 0x0002) {
+        unit = " RPM";
+    }
+
+    return unit;
+}