Developing lightweight computation at the DSG edge

tools.htm 2.37 KB
Newer Older
1
2
3
4
5
6
7
8
<%+header%>

<script type="text/javascript">

function do_test(ip,index,key,tool) {
	var output = document.getElementById('output_'+index);

	if (output) {
9
		output.innerHTML ='<%:Collecting data... %><img src="/luci-static/resources/icons/loading.gif" height="20px" alt="Loading" style="vertical-align:middle"/> ';
10
11
12
13
14
15
16
17
18
19
20
21
                output.style.display = 'inline';
		XHR.get("/cgi-bin/tools",[ key ,  tool ,  ip] ,
                function(x) {
                	    output.innerHTML= parse_result(x.responseText);

                } )
	}
}
function parse_result(txt) {
	var t = new String(txt);

	if (t.indexOf("Cannot") >= 0)
22
23
		//return("&lt;font color='#f00'&gt;<%:Cannot connecto to netserver%>&lt;/font&gt;");
		return("<font color='#a00'><%:Cannot connect to netserver%></font>");
24
	else
25
26
		//return("&lt;font color='#0a0'&gt;"+txt+"&lt;/font&gt;");
		return("<font color='#050'>"+txt+"</font>");
27
28
29
30
}

</script>

31
<h2>Network testing tools</h2>
32
33
34
35

<div class="cbi-map">
<form>
<fieldset class="cbi-section">
36
<legend><%:Test network parameters with the nodes available in the network%></legend>
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57

	<table class="cbi-section-table" >
	<tr class="cbi-section-table-titles">
	<th class="cbi-section-table-cell"></th>
	<th class="cbi-section-table-cell"></th>
	<th class="cbi-section-table-cell"></th>
	</tr>
<% for i,n in ipairs(nodes) do %>
	<tr>
		<td title="<%=n[2]%>" style="padding-left:10px;width:15%;text-align:left;"><%=n[1]%></td>
		<td style="width:18%;text-align:right;">
			<input type="button" value="bandwidth" onclick="do_test('<%=n[2]%>',<%=i%>,'<%=key%>','bwtest')" />
			<input type="button" value="ping" onclick="do_test('<%=n[2]%>',<%=i%>,'<%=key%>','ping')" />
			<input type="button" value="trace" onclick="do_test('<%=n[2]%>',<%=i%>,'<%=key%>','traceroute')" />
		</td>
		<td style="text-align:left;padding-left:10px;"><span id="output_<%=i%>"></span></td>
	</tr>
<% end %>
</table>
<br /><br />
	<div style="clear:both;height:30px;float:left">
58
	<strong>Test a custom IP address:</strong>
59
60
61
62
63
64
65
66
67
68
69
	<input type="text" name="custom" />
	<input type="button" value="bandwidth" onclick="do_test(this.form.custom.value,'custom','<%=key%>','bwtest')" />
	<input type="button" value="ping" onclick="do_test(this.form.custom.value,'custom','<%=key%>','ping')"  />
	<span style="display:none;margin-left:5px;border:1px solid #000;padding:0.1em 0.4em" id="output_custom"></span>
	</div>
</fieldset>
</form>
</div>

<%+footer%>