Tomato 1.28
[tomato.git] / release / src / router / www / bwm-realtime.asp
blob6527b2d8cc8d3f8091ad86f07557d607cdb9271e
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: Real-Time</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 <style type='text/css'>
22 #txt {
23 width: 550px;
24 white-space: nowrap;
26 #bwm-controls {
27 text-align: right;
28 margin-right: 5px;
29 margin-top: 5px;
30 float: right;
31 visibility: hidden;
33 </style>
35 <script type='text/javascript' src='debug.js'></script>
36 <script type='text/javascript' src='bwm-common.js'></script>
38 <script type='text/javascript'>
39 // <% nvram("wan_ifname,lan_ifname,wl_ifname,wan_proto,web_svg,rstats_colors"); %>
41 var cprefix = 'bw_r';
42 var updateInt = 2;
43 var updateDiv = updateInt;
44 var updateMaxL = 300;
45 var updateReTotal = 1;
46 var prev = [];
47 var debugTime = 0;
48 var avgMode = 0;
49 var wdog = null;
50 var wdogWarn = null;
53 var ref = new TomatoRefresh('update.cgi', 'exec=netdev', 2);
55 ref.stop = function() {
56 this.timer.start(1000);
59 ref.refresh = function(text) {
60 var c, i, h, n, j, k;
62 watchdogReset();
64 ++updating;
65 try {
66 netdev = null;
67 eval(text);
69 n = (new Date()).getTime();
70 if (this.timeExpect) {
71 if (debugTime) E('dtime').innerHTML = (this.timeExpect - n) + ' ' + ((this.timeExpect + 2000) - n);
72 this.timeExpect += 2000;
73 this.refreshTime = MAX(this.timeExpect - n, 500);
75 else {
76 this.timeExpect = n + 2000;
79 for (i in netdev) {
80 c = netdev[i];
81 if ((p = prev[i]) != null) {
82 h = speed_history[i];
84 h.rx.splice(0, 1);
85 h.rx.push((c.rx < p.rx) ? (c.rx + (0xFFFFFFFF - p.rx)) : (c.rx - p.rx));
87 h.tx.splice(0, 1);
88 h.tx.push((c.tx < p.tx) ? (c.tx + (0xFFFFFFFF - p.tx)) : (c.tx - p.tx));
90 else if (!speed_history[i]) {
91 speed_history[i] = {};
92 h = speed_history[i];
93 h.rx = [];
94 h.tx = [];
95 for (j = 300; j > 0; --j) {
96 h.rx.push(0);
97 h.tx.push(0);
99 h.count = 0;
101 prev[i] = c;
103 loadData();
105 catch (ex) {
107 --updating;
110 function watchdog()
112 watchdogReset();
113 ref.stop();
114 wdogWarn.style.display = '';
117 function watchdogReset()
119 if (wdog) clearTimeout(wdog)
120 wdog = setTimeout(watchdog, 10000);
121 wdogWarn.style.display = 'none';
124 function init()
126 speed_history = [];
128 initCommon(2, 1, 1);
130 wdogWarn = E('warnwd');
131 watchdogReset();
133 ref.start();
135 </script>
137 </head>
138 <body onload='init()'>
139 <form>
140 <table id='container' cellspacing=0>
141 <tr><td colspan=2 id='header'>
142 <div class='title'>Tomato</div>
143 <div class='version'>Version <% version(); %></div>
144 </td></tr>
145 <tr id='body'><td id='navi'><script type='text/javascript'>navi()</script></td>
146 <td id='content'>
147 <div id='ident'><% ident(); %></div>
149 <!-- / / / -->
151 <div id='rstats'>
152 <div id='tab-area'></div>
154 <script type='text/javascript'>
155 if (nvram.web_svg != '0') {
156 // without a div, Opera 9 moves svgdoc several pixels outside of <embed> (?)
157 W("<div style='border-top:1px solid #f0f0f0;border-bottom:1px solid #f0f0f0;visibility:hidden;padding:0;margin:0' id='graph'><embed src='bwm-graph.svg?<% version(); %>' style='width:760px;height:300px;margin:0;padding:0' type='image/svg+xml' pluginspage='http://www.adobe.com/svg/viewer/install/'></embed></div>");
159 </script>
161 <div id='bwm-controls'>
162 <small>(10 minute window, 2 second interval)</small><br>
163 <br>
164 Avg:&nbsp;
165 <a href='javascript:switchAvg(1)' id='avg1'>Off</a>,
166 <a href='javascript:switchAvg(2)' id='avg2'>2x</a>,
167 <a href='javascript:switchAvg(4)' id='avg4'>4x</a>,
168 <a href='javascript:switchAvg(6)' id='avg6'>6x</a>,
169 <a href='javascript:switchAvg(8)' id='avg8'>8x</a><br>
170 Max:&nbsp;
171 <a href='javascript:switchScale(0)' id='scale0'>Uniform</a>,
172 <a href='javascript:switchScale(1)' id='scale1'>Per IF</a><br>
173 Display:&nbsp;
174 <a href='javascript:switchDraw(0)' id='draw0'>Solid</a>,
175 <a href='javascript:switchDraw(1)' id='draw1'>Line</a><br>
176 Color:&nbsp; <a href='javascript:switchColor()' id='drawcolor'>-</a><br>
177 <small><a href='javascript:switchColor(1)' id='drawrev'>[reverse]</a></small><br>
179 <br><br>
180 &nbsp; &raquo; <a href="admin-bwm.asp">Configure</a>
181 </div>
183 <br><br>
184 <table border=0 cellspacing=2 id='txt'>
185 <tr>
186 <td width='8%' align='right' valign='top'><b style='border-bottom:blue 1px solid' id='rx-name'>RX</b></td>
187 <td width='15%' align='right' valign='top'><span id='rx-current'></span></td>
188 <td width='8%' align='right' valign='top'><b>Avg</b></td>
189 <td width='15%' align='right' valign='top' id='rx-avg'></td>
190 <td width='8%' align='right' valign='top'><b>Peak</b></td>
191 <td width='15%' align='right' valign='top' id='rx-max'></td>
192 <td width='8%' align='right' valign='top'><b>Total</b></td>
193 <td width='14%' align='right' valign='top' id='rx-total'></td>
194 <td>&nbsp;</td>
195 </tr>
196 <tr>
197 <td width='8%' align='right' valign='top'><b style='border-bottom:blue 1px solid' id='tx-name'>TX</b></td>
198 <td width='15%' align='right' valign='top'><span id='tx-current'></span></td>
199 <td width='8%' align='right' valign='top'><b>Avg</b></td>
200 <td width='15%' align='right' valign='top' id='tx-avg'></td>
201 <td width='8%' align='right' valign='top'><b>Peak</b></td>
202 <td width='15%' align='right' valign='top' id='tx-max'></td>
203 <td width='8%' align='right' valign='top'><b>Total</b></td>
204 <td width='14%' align='right' valign='top' id='tx-total'></td>
205 <td>&nbsp;</td>
206 </tr>
207 </table>
208 </div>
209 <br>
210 <br>
212 <!-- / / / -->
214 </td></tr>
215 <tr><td id='footer' colspan=2>
216 <span id='warnwd' style='display:none'>Warning: 10 second timeout, restarting...&nbsp;</span>
217 <span id='dtime'></span>
218 <img src='spin.gif' id='refresh-spinner' onclick='javascript:debugTime=1'>
219 </td></tr>
220 </table>
221 </form>
222 </body>
223 </html>