2092509ff6aef41863f2becf0cfc08b4be332226
[psensor.git] / www / psensor.js
1 function format_mem_size(s) {
2     var mo_bytes = 1024 * 1024;
3     var go_bytes = 1024 * mo_bytes;
4
5     var o = s % 1024;
6     var k = Math.round((s / 1024) % 1024);
7     var m = Math.round((s / (1024*1024)) % 1024);
8     var g = Math.round(s / (1024*1024*1024));
9
10     if (g >= 1)
11         return g+"Go ";
12
13     if (m >= 1)
14         return m+"Mo";
15
16     if (k >= 1)
17         return k+"Ko";
18     
19     if (o > 0)
20         return o+"o";
21
22     return "0";
23 };
24
25 function type_to_str(stype) {
26     var stype_str = "N/A";
27
28     if (stype & 0x0100) {
29         stype_str = "Sensor";
30     } else if (stype & 0x0200) {
31         stype_str = "NVidia";
32     } else if (stype & 0x0400) {
33         stype_str = "HDD";
34     } else if (stype & 0x1000) {
35         stype_str = "AMD";
36     }
37
38    if (stype & 0x0001) {
39        stype_str += " Temperature";
40    } else if (stype & 0x0002) {
41        stype_str += " Fan";
42    }
43
44     return stype_str;
45 };
46
47 function type_to_unit(stype) {
48     if (stype & 0x0001) {
49         unit = " C";
50     } else if (stype & 0x0002) {
51         unit = " RPM";
52     }
53
54     return unit;
55 }