UI cleanup, phase 5, ARM (functional changes)
[tomato.git] / release / src-rt-6.x.4708 / router / www / bwm-hist.js
blob321bd022469b3c05a3acb69351167ba9b8717d81
2 var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
3 var snames = [' KB', ' MB', ' GB'];
4 var scale = 2;
6 function rescale(n, z)
8         if ((z) && (n == 0)) return '-';
9         return (((z) && (n > 0)) ? '+' : '') + comma((n / ((scale == 2) ?  1048576 : ((scale == 1) ? 1024 : 1))).toFixed(2)) + snames[scale];
12 function changeScale(e)
14         scale = e.value * 1;
15         redraw();
16         save();
19 function makeRow(rclass, rtitle, dl, ul, total)
21         return '<tr class="' + rclass + '">' +
22                 '<td class="rtitle">' + rtitle + '</td>' +
23                 '<td class="dl">' + dl + '</td>' +
24                 '<td class="ul">' + ul + '</td>' +
25                 '<td class="total">' + total + '</td>' +
26                 '</tr>';
29 function makeRowIP(rclass, rtitle, ip, dl, ul, total)
31         return '<tr class="' + rclass + '">' +
32                 '<td class="rtitle">' + rtitle + '</td>' +
33                 '<td class="ip">' + ip + '</td>' +
34                 '<td class="dl">' + dl + '</td>' +
35                 '<td class="ul">' + ul + '</td>' +
36                 '<td class="total">' + total + '</td>' +
37                 '</tr>';
40 function cmpHist(a, b)
42         a = parseInt(a[0], 0);
43         b = parseInt(b[0], 0);
44         if (a < b) return 1;
45         if (a > b) return -1;
46         return 0;
49 function checkRstats()
51         if (nvram.rstats_enable != '1') {
52                 W('<div class="note-disabled">Bandwidth monitoring disabled.</b><br><br><a href="admin-bwm.asp">Enable &raquo;</a></div>');
53                 E('rstats').style.display = 'none';
54         }
55         else if (rstats_busy) {
56                 W('<div class="note-warning">The rstats program is not responding or is busy. Try reloading after a few seconds.</div>');
57         }
60 function checkCstats()
62         if (nvram.cstats_enable != '1') {
63                 W('<div class="note-disabled">IP Traffic monitoring disabled.</b><br><br><a href="admin-iptraffic.asp">Enable &raquo;</a></div>');
64                 E('cstats').style.display = 'none';
65         }
66         else if (cstats_busy) {
67                 W('<div class="note-warning">The cstats program is not responding or is busy. Try reloading after a few seconds.</div>');
68         }
73 0       yyyy-mm-dd
74 1       mm-dd-yy
75 2       mmm, dd, yyyy
76 3       dd.mm.yyyy
80 var dateFormat = -1;
82 function ymText(yr, mo)
84         switch (dateFormat) {
85         case 1:
86                 return (mo + 1).pad(2) + '-' + yr;
87         case 2:
88                 return months[mo] + ' ' + yr;
89         case 3:
90                 return (mo + 1).pad(2) + '.' + yr;
91         }
92         return yr + '-' + (mo + 1).pad(2);
95 function ymdText(yr, mo, da)
97         switch (dateFormat) {
98         case 1:
99                 return (mo + 1) + '-' + da.pad(2) + '-' + yr;
100         case 2:
101                 return months[mo] + ' ' + da + ', ' + yr;
102         case 3:
103                 return da.pad(2) + '.' + (mo + 1).pad(2) + '.' + yr;
104         }
105         return yr + '-' + (mo + 1).pad(2) + '-' + da.pad(2);
108 function changeDate(e, c)
110         dateFormat = e.value * 1;
111         cookie.set(c, e.value, 31);
112         redraw();
115 function initDate(c)
117         dateFormat = fixInt(cookie.get(c), 0, 3, 0);
118         E('dafm').value = dateFormat;