luci/modules/luci-mod-admin-full/luasrc/view/admin_network/switch_status.htm
Jo-Philipp Wich 19981732fc luci-mod-admin-full: properly skip over unused switch ports
Fix incomplete port status display on vlan setup page when ports in the middle
are not used, e.g. some Lantiq boards use ports 0, 1, 2 and 4 for LAN ports so
JS code should not attempt to reference an undefined status element for port 3.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2016-08-18 10:02:53 +02:00

44 lines
1.1 KiB
HTML

<script type="text/javascript">//<![CDATA[
var switches = [ '<%=table.concat(self.switches, "', '")%>' ];
XHR.poll(5, '<%=url('admin/network/switch_status')%>/' + switches.join(','), null,
function(x, st)
{
for (var i = 0; i < switches.length; i++)
{
var ports = st[switches[i]];
var th0 = document.getElementById('portstatus-' + switches[i]);
if (th0 && ports && ports.length)
{
if (!th0.innerHTML)
th0.innerHTML = '<%:Port status:%>';
for (var j = 0; j < ports.length; j++)
{
var th = document.getElementById('portstatus-' + switches[i] + '-' + j);
if (!th)
continue;
if (ports[j].link)
{
th.innerHTML = String.format(
'<small><img src="<%=resource%>/icons/port_up.png" />' +
'<br />%d<%:baseT%><br />%s</small>',
ports[j].speed, ports[j].duplex
? '<%:full-duplex%>' : '<%:half-duplex%>'
);
}
else
{
th.innerHTML = String.format(
'<small><img src="<%=resource%>/icons/port_down.png" />' +
'<br /><%:no link%></small>'
);
}
}
}
}
}
);
//]]></script>