switch_status.htm 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. if (th0 && ports && ports.length)
  11. {
  12. if (!th0.innerHTML)
  13. th0.innerHTML = '<%:Port status:%>';
  14. for (var j = 0; j < ports.length; j++)
  15. {
  16. var th = th0.parentNode.parentNode.childNodes[j+1];
  17. if (ports[j].link)
  18. {
  19. th.innerHTML = String.format(
  20. '<small><img src="<%=resource%>/icons/port_up.png" />' +
  21. '<br />%d<%:baseT%><br />%s</small>',
  22. ports[j].speed, ports[j].duplex
  23. ? '<%:full-duplex%>' : '<%:half-duplex%>'
  24. );
  25. }
  26. else
  27. {
  28. th.innerHTML = String.format(
  29. '<small><img src="<%=resource%>/icons/port_down.png" />' +
  30. '<br /><%:no link%></small>'
  31. );
  32. }
  33. }
  34. }
  35. }
  36. }
  37. );
  38. //]]></script>