96fbffdb02866f3aac317d13a212015f4cd85c3d
[project/luci.git] / modules / luci-mod-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, '<%=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 = document.getElementById('portstatus-' + switches[i] + '-' + j);
19
20                                                 if (!th)
21                                                         continue;
22
23                                                 if (ports[j].link)
24                                                 {
25                                                         th.innerHTML = String.format(
26                                                                 '<small><img src="<%=resource%>/icons/port_up.png" />' +
27                                                                 '<br />%d<%:baseT%><br />%s</small>',
28                                                                 ports[j].speed, ports[j].duplex
29                                                                         ? '<%:full-duplex%>' : '<%:half-duplex%>'
30                                                         );
31                                                 }
32                                                 else
33                                                 {
34                                                         th.innerHTML = String.format(
35                                                                 '<small><img src="<%=resource%>/icons/port_down.png" />' +
36                                                                 '<br /><%:no link%></small>'
37                                                         );
38                                                 }
39                                         }
40                                 }
41                         }
42                 }
43         );
44 //]]></script>