Merge pull request #278 from nmav/ocserv
[project/luci.git] / modules / admin-full / luasrc / view / admin_network / switch_status.htm
1 <script type="text/javascript">//<![CDATA[
2 var switches = [ '<%=table.concat(self.switches, "', '")%>' ];
3 XHR.poll(5, '<%=luci.dispatcher.build_url("admin", "network", "switch_status")%>/' + switches.join(','), null,
4 function(x, st)
5 {
6 for (var i = 0; i < switches.length; i++)
7 {
8 var ports = st[switches[i]];
9 var th0 = document.getElementById('portstatus-' + switches[i]);
10
11 if (th0 && ports && ports.length)
12 {
13 if (!th0.innerHTML)
14 th0.innerHTML = '<%:Port status:%>';
15
16 for (var j = 0; j < ports.length; j++)
17 {
18 var th = th0.parentNode.parentNode.childNodes[j+1];
19
20 if (ports[j].link)
21 {
22 th.innerHTML = String.format(
23 '<small><img src="<%=resource%>/icons/port_up.png" />' +
24 '<br />%d<%:baseT%><br />%s</small>',
25 ports[j].speed, ports[j].duplex
26 ? '<%:full-duplex%>' : '<%:half-duplex%>'
27 );
28 }
29 else
30 {
31 th.innerHTML = String.format(
32 '<small><img src="<%=resource%>/icons/port_down.png" />' +
33 '<br /><%:no link%></small>'
34 );
35 }
36 }
37 }
38 }
39 }
40 );
41 //]]></script>