summaryrefslogtreecommitdiffstats
path: root/modules/admin-full/luasrc/view/admin_network/switch_status.htm
blob: b299575e2f2ad9d51fb803e0ba1260772391c00b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<script type="text/javascript">//<![CDATA[
	var switches = [ '<%=table.concat(self.switches, "', '")%>' ];
	XHR.poll(5, '<%=luci.dispatcher.build_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 = th0.parentNode.parentNode.childNodes[j+1];

						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>