luci-mod-admin-full: use switch toplogy information for vlan setup
[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 (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>