modules/admin-core, modules/admin-full: fix switch port status for devices with multi...
[project/luci.git] / modules / admin-full / luasrc / view / admin_network / switch_status.htm
index 0b28483..b299575 100644 (file)
@@ -1,31 +1,28 @@
 <script type="text/javascript">//<![CDATA[
-       var tb;
-       var ths = document.getElementsByTagName('th');
-       for (var i = 0; i < ths.length; i++)
-               if (ths[i].className = 'cbi-section-table-cell' && !ths[i].innerHTML)
+       var switches = [ '<%=table.concat(self.switches, "', '")%>' ];
+       XHR.poll(5, '<%=luci.dispatcher.build_url("admin", "network", "switch_status")%>/' + switches.join(','), null,
+               function(x, st)
                {
-                       ths[i].innerHTML = '<%:Port status:%>';
-                       tb = ths[i].parentNode;
-                       break;
-               }
-
-       if (tb)
-       {
-               XHR.poll(5, '<%=luci.dispatcher.build_url("admin", "network", "switch_status", self.switch)%>', null,
-                       function(x, st)
+                       for (var i = 0; i < switches.length; i++)
                        {
-                               if (st && st.length)
+                               var ports = st[switches[i]];
+                               var th0 = document.getElementById('portstatus-' + switches[i]);
+
+                               if (th0 && ports && ports.length)
                                {
-                                       for (var i = 0; i < st.length; i++)
+                                       if (!th0.innerHTML)
+                                               th0.innerHTML = '<%:Port status:%>';
+
+                                       for (var j = 0; j < ports.length; j++)
                                        {
-                                               var th = tb.childNodes[i+1];
+                                               var th = th0.parentNode.parentNode.childNodes[j+1];
 
-                                               if (st[i].link)
+                                               if (ports[j].link)
                                                {
                                                        th.innerHTML = String.format(
                                                                '<small><img src="<%=resource%>/icons/port_up.png" />' +
                                                                '<br />%d<%:baseT%><br />%s</small>',
-                                                               st[i].speed, st[i].duplex
+                                                               ports[j].speed, ports[j].duplex
                                                                        ? '<%:full-duplex%>' : '<%:half-duplex%>'
                                                        );
                                                }
@@ -39,6 +36,6 @@
                                        }
                                }
                        }
-               );
-       }
+               }
+       );
 //]]></script>