1 <?xml version=
"1.0" standalone=
"no"?>
2 <!DOCTYPE svg PUBLIC
"-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
5 Copyright (C) 2006-2010 Jonathan Zarate
6 http://www.polarcloud.com/tomato/
8 For use with Tomato Firmware only.
9 No part of this file may be used without permission.
11 <svg width=
"100%" height=
"100%" version=
"1.1" xmlns=
"http://www.w3.org/2000/svg" onload=
"init(evt)"
12 onmousemove=
"mMove(evt)" onclick=
"mClick(evt)">
14 <style type='text/css'
>
45 <script type='text/ecmascript'
><![CDATA[
48 Hi there! What are you looking at? Messy isn't it?
54 var week = ['Sun','Mon','Tue','Wed','Thu','Fri','Sat'];
73 return document.getElementById(id);
79 while (n.length <
2) n = '
0' + n;
86 return (n *
8).toFixed(
2) + ' kbit/s (' + n.toFixed(
2) + ' KB/s)';
89 function setText(e, text)
91 // Adobe/IE doesn't do textContent=
92 if (e.firstChild) e.removeChild(e.firstChild);
93 e.appendChild(document.createTextNode(text));
100 if (typeof(svgDocument) == 'undefined') svgDocument = evt.target.ownerDocument;
102 crossX = E('crossX');
103 crossY = E('crossY');
104 polyRx = E('polyRx');
105 polyTx = E('polyTx');
106 pointTextBack = E('pointTextBack');
107 pointText = E('pointText');
108 pointG = E('pointGroup');
109 crossTextBack = E('crossTextBack');
110 crossText = E('crossText');
111 crossTime = E('crossTime');
112 maxText = E('maxText');
115 for (n =
0; n <
24; ++n) {
116 tickLines[n] = E('tick' + n);
119 for (n =
0; n <
12; ++n) {
120 tickHours[n] = E('h' + n);
124 for (n =
0; n <
3; ++n)
125 xpst[n] = E('xpst' + n);
127 time24 = ((new Date(
2000,
0,
1,
23,
0,
0,
0)).toLocaleString().indexOf('
23') != -
1);
129 top.updateSVG = updateSVG;
134 function drawData(poly, data, mode, color)
141 if (data.length ==
0) return;
145 poly.setAttribute('fill-opacity', '
0.5');
149 poly.setAttribute('fill-opacity', '
0');
152 poly.setAttribute('stroke', color);
153 poly.setAttribute('fill', color);
155 for (i = data.length - maxL; i < data.length; ++i) {
159 else if (i
>= samp) {
161 for (j = samp -
1; j
>=
0; --j) {
164 d /= (dataDiv * samp);
167 d = data[i] / dataDiv;
169 y = (vHeight - Math.floor((d * vHeight) / maxV))
170 pt += ' ' + Math.floor(x) + ',' + y;
173 pt += ' ' + (vWidth +
5) + ',' + y + ' ' + (vWidth +
10) + ',' + vHeight;
174 poly.setAttribute('points', pt);
177 function updateSVG(rxData, txData, maxValue, mode, rxColor, txColor, intv, maxLen, dataD, avgSamp, clock)
185 advX = vWidth / maxL;
190 // tockD = new Date();
191 tock = tockD.getTime();
195 x = z = (vWidth /
5);
196 for (i =
0; i <
4; ++i) {
197 tickLines[i].setAttribute('x1', Math.round(x));
198 tickLines[i].setAttribute('x2', Math.round(x));
203 advM = (
60 / interval) * advX;
204 x = (
60 - tockD.getMinutes()) * advM;
206 for (i =
0; i <
24; ++i) {
208 y = (new Date(tock - (Math.round((vWidth - z -
1) / advX) * interval *
1000))).getHours();
212 e.setAttribute('x1', z);
213 e.setAttribute('x2', z);
214 e.setAttribute('class', (y &
1) ? 'a' : 'b');
217 e = tickHours[i
>> 1];
218 e.setAttribute('x', z);
237 polyRx.setAttribute('points', '');
238 polyTx.setAttribute('points', '');
242 if (crossV
> 0) drawCross(crossH, vHeight - Math.floor((crossV / maxV) * vHeight));
243 drawData(polyRx, rxData, mode, rxColor);
244 drawData(polyTx, txData, mode, txColor);
246 setText(maxText, xps(maxV) + '
>');
248 setText(xpst[
0], xps(maxV *
0.75));
249 setText(xpst[
1], xps(maxV *
0.5));
250 setText(xpst[
2], xps(maxV *
0.25));
253 if (--eraseL ==
0) pointG.setAttribute('visibility', 'hidden');
259 return maxV - (maxV * (y / vHeight))
262 function pointTime(x)
266 t = new Date(tock - (Math.round((vWidth - x -
1) / advX) * interval *
1000));
268 s = week[t.getDay()] + ' ';
270 s += pad(h) + ':' + pad(t.getMinutes());
274 s += pad((hh ==
0) ?
12 : hh) + ':' + pad(t.getMinutes()) + ((h <
12) ? ' am' : ' pm');
284 if (maxV <=
0) return;
285 if (evt.clientX
> (vWidth -
120)) {
287 if (evt.clientY <
30) {
289 pointText.setAttribute('y', '
98%');
290 pointTextBack.setAttribute('y', '
94%');
294 if (evt.clientY
> (vHeight -
30)) {
296 pointText.setAttribute('y', '
5%');
297 pointTextBack.setAttribute('y', '
1%');
302 setText(pointText, pointTime(evt.clientX) + ' / ' + xps(vY(evt.clientY)));
304 x = pointText.getComputedTextLength();
305 pointTextBack.setAttribute('x', (vWidth - x) -
22);
306 pointTextBack.setAttribute('width', x +
20);
307 if (eraseL ==
0) pointG.setAttribute('visibility', 'visible');
311 function setXY(e, x, y)
313 e.setAttribute('x', x);
314 e.setAttribute('y', y);
317 function drawCross(x, y)
321 crossX.setAttribute('x1', x -
10);
322 crossX.setAttribute('x2', x +
10);
323 crossX.setAttribute('y1', y);
324 crossX.setAttribute('y2', y);
326 crossY.setAttribute('x1', x);
327 crossY.setAttribute('x2', x);
328 crossY.setAttribute('y1', y -
10);
329 crossY.setAttribute('y2', y +
10);
331 n = Math.max(crossText.getComputedTextLength(), crossTime.getComputedTextLength()) +
20;
332 crossTextBack.setAttribute('width', n);
334 if (x
> (vWidth - n -
10)) {
335 crossText.setAttribute('style', 'text-anchor:end');
336 crossTime.setAttribute('style', 'text-anchor:end');
337 crossTextBack.setAttribute('x', (x - n) -
10);
341 crossText.setAttribute('style', '');
342 crossTime.setAttribute('style', '');
343 crossTextBack.setAttribute('x', x +
10);
347 crossTextBack.setAttribute('y', y -
17);
348 setXY(crossTime, x, y -
5);
349 setXY(crossText, x, y +
10);
358 if (maxV <=
0) return;
360 crossH = evt.clientX;
361 crossV = vY(evt.clientY);
362 setText(crossText, xps(crossV));
363 setText(crossTime, pointTime(crossH));
364 drawCross(evt.clientX, evt.clientY);
366 E('cross').setAttribute('visibility', (evt.clientY
> (vHeight -
20)) ? 'hidden' : 'visible');
369 function toggleXpst()
371 E('xpst').setAttribute('visibility', (xpstVis ^=
1) ? 'visible' : 'hidden');
376 <rect x=
"0" y=
"0" width=
"100%" height=
"100%" style=
"fill:#fff" />
378 <line x1=
"0" y1=
"50%" x2=
"100%" y2=
"50%" />
379 <line x1=
"0" y1=
"25%" x2=
"100%" y2=
"25%" />
380 <line x1=
"0" y1=
"75%" x2=
"100%" y2=
"75%" />
382 <line x1=
"0" y1=
"0%" x2=
"0" y2=
"100%" id=
"tick0" />
383 <line x1=
"0" y1=
"0%" x2=
"0" y2=
"100%" id=
"tick1" />
384 <line x1=
"0" y1=
"0%" x2=
"0" y2=
"100%" id=
"tick2" />
385 <line x1=
"0" y1=
"0%" x2=
"0" y2=
"100%" id=
"tick3" />
386 <line x1=
"0" y1=
"0%" x2=
"0" y2=
"100%" id=
"tick4" />
387 <line x1=
"0" y1=
"0%" x2=
"0" y2=
"100%" id=
"tick5" />
388 <line x1=
"0" y1=
"0%" x2=
"0" y2=
"100%" id=
"tick6" />
389 <line x1=
"0" y1=
"0%" x2=
"0" y2=
"100%" id=
"tick7" />
390 <line x1=
"0" y1=
"0%" x2=
"0" y2=
"100%" id=
"tick8" />
391 <line x1=
"0" y1=
"0%" x2=
"0" y2=
"100%" id=
"tick9" />
392 <line x1=
"0" y1=
"0%" x2=
"0" y2=
"100%" id=
"tick10" />
393 <line x1=
"0" y1=
"0%" x2=
"0" y2=
"100%" id=
"tick11" />
394 <line x1=
"0" y1=
"0%" x2=
"0" y2=
"100%" id=
"tick12" />
395 <line x1=
"0" y1=
"0%" x2=
"0" y2=
"100%" id=
"tick13" />
396 <line x1=
"0" y1=
"0%" x2=
"0" y2=
"100%" id=
"tick14" />
397 <line x1=
"0" y1=
"0%" x2=
"0" y2=
"100%" id=
"tick15" />
398 <line x1=
"0" y1=
"0%" x2=
"0" y2=
"100%" id=
"tick16" />
399 <line x1=
"0" y1=
"0%" x2=
"0" y2=
"100%" id=
"tick17" />
400 <line x1=
"0" y1=
"0%" x2=
"0" y2=
"100%" id=
"tick18" />
401 <line x1=
"0" y1=
"0%" x2=
"0" y2=
"100%" id=
"tick19" />
402 <line x1=
"0" y1=
"0%" x2=
"0" y2=
"100%" id=
"tick20" />
403 <line x1=
"0" y1=
"0%" x2=
"0" y2=
"100%" id=
"tick21" />
404 <line x1=
"0" y1=
"0%" x2=
"0" y2=
"100%" id=
"tick22" />
405 <line x1=
"0" y1=
"0%" x2=
"0" y2=
"100%" id=
"tick23" />
407 <text x=
"0" y=
"98%" class=
"tickH" id=
"h0" />
408 <text x=
"0" y=
"98%" class=
"tickH" id=
"h1" />
409 <text x=
"0" y=
"98%" class=
"tickH" id=
"h2" />
410 <text x=
"0" y=
"98%" class=
"tickH" id=
"h3" />
411 <text x=
"0" y=
"98%" class=
"tickH" id=
"h4" />
412 <text x=
"0" y=
"98%" class=
"tickH" id=
"h5" />
413 <text x=
"0" y=
"98%" class=
"tickH" id=
"h6" />
414 <text x=
"0" y=
"98%" class=
"tickH" id=
"h7" />
415 <text x=
"0" y=
"98%" class=
"tickH" id=
"h8" />
416 <text x=
"0" y=
"98%" class=
"tickH" id=
"h9" />
417 <text x=
"0" y=
"98%" class=
"tickH" id=
"h10" />
418 <text x=
"0" y=
"98%" class=
"tickH" id=
"h11" />
419 <text x=
"0" y=
"98%" class=
"tickH" id=
"h12" />
422 <text x=
"18" y=
"25%" id=
"xpst0" />
423 <text x=
"18" y=
"50%" id=
"xpst1" />
424 <text x=
"18" y=
"75%" id=
"xpst2" />
427 <polyline id=
"polyTx" style=
"stroke-width:1" points=
"" />
428 <polyline id=
"polyRx" style=
"stroke-width:1" points=
"" />
430 <g id=
"pointGroup" visibility=
"hidden">
431 <rect x=
"490" y=
"0" width=
"268" height=
"15" id=
"pointTextBack" class=
"back" />
432 <text x=
"99%" y=
"12" id=
"pointText" />
435 <rect x=
"0" y=
"0" width=
"15" height=
"100%" id=
"maxTextBack" class=
"back" onclick=
"toggleXpst()"/>
436 <text x=
"-2%" y=
"12" transform=
"rotate(-90)" text-anchor=
"end" id=
"maxText" onclick=
"toggleXpst()"/>
438 <g id=
"cross" visibility=
"hidden">
439 <line x1=
"0" y1=
"0" x2=
"0" y2=
"0" id=
"crossX" />
440 <line x1=
"0" y1=
"0" x2=
"0" y2=
"0" id=
"crossY" />
441 <rect x=
"0" y=
"-100" width=
"10" height=
"35" id=
"crossTextBack" class=
"back" />
442 <text x=
"0" y=
"-50" id=
"crossTime" />
443 <text x=
"0" y=
"0" id=
"crossText" />