MiniDLNA update: 1.0.19.1 to 1.0.20
[tomato.git] / release / src / router / www / bwm-daily.asp
blobb3d8f265e1a8995191ede3358a52a6f3d7bab24b
1 <!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.0//EN'>
2 <!--
3 Tomato GUI
4 Copyright (C) 2006-2010 Jonathan Zarate
5 http://www.polarcloud.com/tomato/
7 For use with Tomato Firmware only.
8 No part of this file may be used without permission.
9 -->
10 <html>
11 <head>
12 <meta http-equiv='content-type' content='text/html;charset=utf-8'>
13 <meta name='robots' content='noindex,nofollow'>
14 <title>[<% ident(); %>] Bandwidth: Daily</title>
15 <link rel='stylesheet' type='text/css' href='tomato.css'>
16 <link rel='stylesheet' type='text/css' href='color.css'>
17 <script type='text/javascript' src='tomato.js'></script>
19 <!-- / / / -->
21 <script type='text/javascript' src='debug.js'></script>
22 <script type='text/javascript' src='bwm-hist.js'></script>
24 <script type='text/javascript'>
26 // <% nvram("wan_ifname,lan_ifname,rstats_enable"); %>
27 try {
28 // <% bandwidth("daily"); %>
30 catch (ex) {
31 daily_history = [];
33 rstats_busy = 0;
34 if (typeof(daily_history) == 'undefined') {
35 daily_history = [];
36 rstats_busy = 1;
39 function save()
41 cookie.set('daily', scale, 31);
44 function genData()
46 var w, i, h, t;
48 w = window.open('', 'tomato_data_d');
49 w.document.writeln('<pre>');
50 for (i = 0; i < daily_history.length; ++i) {
51 h = daily_history[i];
52 t = getYMD(h[0]);
53 w.document.writeln([t[0], t[1] + 1, t[2], h[1], h[2]].join(','));
55 w.document.writeln('</pre>');
56 w.document.close();
59 function getYMD(n)
61 // [y,m,d]
62 return [(((n >> 16) & 0xFF) + 1900), ((n >>> 8) & 0xFF), (n & 0xFF)];
65 function redraw()
67 var h;
68 var grid;
69 var rows;
70 var ymd;
71 var d;
72 var lastt;
73 var lastu, lastd;
75 if (daily_history.length > 0) {
76 ymd = getYMD(daily_history[0][0]);
77 d = new Date((new Date(ymd[0], ymd[1], ymd[2], 12, 0, 0, 0)).getTime() - ((30 - 1) * 86400000));
78 E('last-dates').innerHTML = '(' + ymdText(ymd[0], ymd[1], ymd[2]) + ' to ' + ymdText(d.getFullYear(), d.getMonth(), d.getDate()) + ')';
80 lastt = ((d.getFullYear() - 1900) << 16) | (d.getMonth() << 8) | d.getDate();
83 lastd = 0;
84 lastu = 0;
85 rows = 0;
86 block = '';
87 gn = 0;
89 grid = '<table class="bwmg" cellspacing="1">';
90 grid += makeRow('header', 'Date', 'Download', 'Upload', 'Total');
92 for (i = 0; i < daily_history.length; ++i) {
93 h = daily_history[i];
94 ymd = getYMD(h[0]);
95 grid += makeRow(((rows & 1) ? 'odd' : 'even'), ymdText(ymd[0], ymd[1], ymd[2]), rescale(h[1]), rescale(h[2]), rescale(h[1] + h[2]));
96 ++rows;
98 if (h[0] >= lastt) {
99 lastd += h[1];
100 lastu += h[2];
104 E('bwm-daily-grid').innerHTML = grid + '</table>';
106 E('last-dn').innerHTML = rescale(lastd);
107 E('last-up').innerHTML = rescale(lastu);
108 E('last-total').innerHTML = rescale(lastu + lastd);
111 function init()
113 var s;
115 if (nvram.rstats_enable != '1') return;
117 if ((s = cookie.get('daily')) != null) {
118 if (s.match(/^([0-2])$/)) {
119 E('scale').value = scale = RegExp.$1 * 1;
123 initDate('ymd');
124 daily_history.sort(cmpHist);
125 redraw();
127 </script>
129 </head>
130 <body onload='init()'>
131 <form>
132 <table id='container' cellspacing=0>
133 <tr><td colspan=2 id='header'>
134 <div class='title'>Tomato</div>
135 <div class='version'>Version <% version(); %></div>
136 </td></tr>
137 <tr id='body'><td id='navi'><script type='text/javascript'>navi()</script></td>
138 <td id='content'>
139 <div id='ident'><% ident(); %></div>
141 <!-- / / / -->
143 <div class='section-title'>WAN Bandwidth - Daily</div>
144 <div id='bwm-daily-grid' style='float:left'></div>
145 <div style="float:right;text-align:right">
148 <table class='tomato-grid' style='width:150px'>
149 <tr class='header'><td colspan=2 style='text-align:center'>Last 30 Days<br><span style='font-weight:normal' id='last-dates'></span></td></tr>
150 <tr class='even'><td>Down</td><td id='last-dn'>-</td></tr>
151 <tr class='odd'><td>Up</td><td id='last-up'>-</td></tr>
152 <tr class='footer'><td>Total</td><td id='last-total'>-</td></tr>
153 </table>
155 <br>
156 <hr size=1>
157 <br>
159 <b>Date</b> <select onchange='changeDate(this, "ymd")' id='dafm'><option value=0>yyyy-mm-dd</option><option value=1>mm-dd-yyyy</option><option value=2>mmm dd, yyyy</option><option value=3>dd.mm.yyyy</option></select><br>
160 <b>Scale</b> <select onchange='changeScale(this)' id='scale'><option value=0>KB</option><option value=1>MB</option><option value=2 selected>GB</option></select><br>
161 <br>
162 &raquo; <a href="javascript:genData()">Data</a>
163 <br>
164 &raquo; <a href="admin-bwm.asp">Configure</a>
165 <br><br><br>
166 </div>
167 <br>
169 </script>
171 <!-- / / / -->
173 </td></tr>
174 <tr><td id='footer' colspan=2>
175 <input type='button' value='Refresh' onclick='reloadPage()'>
176 </td></tr>
177 </table>
178 </form>
179 </body>
180 </html>