1 <!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML
4.0//EN'
>
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.
12 <meta http-equiv='content-type' content='text/html;charset=utf-
8'
>
13 <meta name='robots' content='noindex,nofollow'
>
14 <title>[<%
ident(); %>] Tools: Trace
</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>
20 <style type='text/css'
>
21 #ttr-grid .co1
, #ttr-grid
.co3
{
30 #ttr-grid .co4
, #ttr-grid
.co5
, #ttr-grid
.co6
{
34 #ttr-grid .header
.co1
{
39 <script type='text/javascript' src='debug.js'
></script>
41 <script type='text/javascript'
>
42 // <% nvram(''); %> // http_id
46 var tg
= new TomatoGrid();
47 tg
.setup = function() {
48 this.init('ttr-grid');
49 this.headerSet(['Hop', 'Address', 'Min (ms)', 'Max (ms)', 'Avg (ms)', '+/- (ms)']);
51 tg
.populate = function() {
53 var buf
= tracedata
.split('\n');
56 var addr
, emsg
, min
, max
, avg
;
61 for (i
= 0; i
< buf
.length
; ++i
) {
62 if (!buf
[i
].match(/^\s*(\d+)\s+(.+)$/)) continue;
63 if (RegExp
.$1 != seq
) continue;
67 if (s
.match(/^([\w\.-]+)\s+\(([\d\.]+)\)/)) {
69 if (addr
!= RegExp
.$2) addr
+= ' (' + RegExp
.$2 + ')';
75 if (time
= s
.match(/(\d+\.\d+) ms/g)) { // odd: captures 'ms'
79 for (j
= 0; j
< time
.length
; ++j
) {
80 f
= parseFloat(time
[j
]);
81 if (isNaN(f
)) continue;
91 change
= change
.toFixed(2);
105 if (s
.match(/ (![<>\w
+-]+)/)) emsg
= RegExp
.$1;
108 this.insertData(-1, [seq
, addr
, min
, max
, avg
, change
])
112 E('debug').value
= tracedata
;
117 function verifyFields(focused
, quiet
)
124 if (!s
.match(/^[\w\.-]+$/)) {
125 ferror
.set(e
, 'Invalid address', quiet
);
130 return v_range('_f_hops', quiet
, 2, 40) && v_range('_f_wait', quiet
, 2, 10);
137 E('traceb').disabled
= x
;
138 E('_f_addr').disabled
= x
;
139 E('_f_hops').disabled
= x
;
140 E('_f_wait').disabled
= x
;
141 E('wait').style
.visibility
= x
? 'visible' : 'hidden';
142 if (!x
) tracer
= null;
147 // Opera 8 sometimes sends 2 clicks
150 if (!verifyFields(null, 0)) return;
152 E('trace-error').style
.visibility
= 'hidden';
154 tracer
= new XmlHttp();
155 tracer
.onCompleted = function(text
, xml
) {
159 tracer
.onError = function(x
) {
161 E('trace-error').innerHTML
= 'ERROR: ' + E('_f_addr').value
+ ' - ' + x
;
162 E('trace-error').style
.visibility
= 'visible';
165 var addr
= E('_f_addr').value
;
166 var hops
= E('_f_hops').value
;
167 var wait
= E('_f_wait').value
;
168 tracer
.post('trace.cgi', 'addr=' + addr
+ '&hops=' + hops
+ '&wait=' + wait
);
170 cookie
.set('traceaddr', addr
);
171 cookie
.set('tracehops', hops
);
172 cookie
.set('tracewait', wait
);
179 if ((s
= cookie
.get('traceaddr')) != null) E('_f_addr').value
= s
;
180 if ((s
= cookie
.get('tracehops')) != null) E('_f_hops').value
= s
;
181 if ((s
= cookie
.get('tracewait')) != null) E('_f_wait').value
= s
;
183 E('_f_addr').onkeypress = function(ev
) { if (checkEvent(ev
).keyCode
== 13) trace(); }
188 <body onload='init()'
>
189 <form action='javascript:{}'
>
190 <table id='container' cellspacing=
0>
191 <tr><td colspan=
2 id='header'
>
192 <div class='title'
>Tomato
</div>
193 <div class='version'
>Version <%
version(); %></div>
195 <tr id='body'
><td id='navi'
><script type='text/javascript'
>navi()</script></td>
197 <div id='ident'
><%
ident(); %></div>
201 <div class='section-title'
>Traceroute
</div>
202 <div class='section'
>
203 <script type='text/javascript'
>
204 createFieldTable('', [
205 { title
: 'Address', name
: 'f_addr', type
: 'text', maxlen
: 64, size
: 32, value
: '', suffix
: ' <input type="button" value="Trace" onclick="trace()" id="traceb">' },
206 { title
: 'Maximum Hops', name
: 'f_hops', type
: 'text', maxlen
: 2, size
: 4, value
: '20' },
207 { title
: 'Maximum Wait Time', name
: 'f_wait', type
: 'text', maxlen
: 2, size
: 4, value
: '3', suffix
: ' <small>(seconds per hop)</small>' }
212 <div style='visibility:hidden' id='trace-error'
></div>
214 <div style='visibility:hidden;text-align:right' id='wait'
>Please wait...
<img src='spin.gif' style='vertical-align:top'
></div>
216 <table id='ttr-grid' class='tomato-grid' cellspacing=
1></table>
218 <div style='height:
10px;' onclick='javascript:E(
"debug").style.
display=
""'
></div>
219 <textarea id='debug' style='width:
99%;height:
300px;display:none'
></textarea>
224 <tr><td id='footer' colspan=
2> </td></tr>
227 <script type='text/javascript'
>tg
.setup();</script>