luci-mod-admin-full: fix script regression after 152ba9ab228ad4ea4c1748f29fe4ffa5f8f74ac6
[project/luci.git] / modules / luci-mod-admin-full / luasrc / view / admin_network / iface_status.htm
1 <%+cbi/valueheader%>
2
3 <script type="text/javascript">//<![CDATA[
4         XHR.poll(5, '<%=url('admin/network/iface_status', self.network)%>', null,
5                 function(x, ifc)
6                 {
7                         if (ifc && (ifc = ifc[0]))
8                         {
9                                 var html = '';
10
11                                 var s = document.getElementById('<%=self.option%>-ifc-signal');
12                                 if (s)
13                                         s.innerHTML = String.format(
14                                                 '<img src="<%=resource%>/icons/%s%s.png" style="width:16px; height:16px" />' +
15                                                 '<br /><small>%s</small>',
16                                                         ifc.type, ifc.is_up ? '' : '_disabled',
17                                                         ifc.name
18                                         );
19
20                                 var d = document.getElementById('<%=self.option%>-ifc-description');
21                                 if (d && ifc.ifname)
22                                 {
23                                         if (ifc.is_up)
24                                         {
25                                                 html += String.format('<strong><%:Uptime%>:</strong> %t<br />', ifc.uptime);
26                                         }
27
28                                         if (ifc.macaddr)
29                                         {
30                                                 html += String.format('<strong><%:MAC-Address%>:</strong> %s<br />', ifc.macaddr);
31                                         }
32
33                                         html += String.format(
34                                                 '<strong><%:RX%></strong>: %.2mB (%d <%:Pkts.%>)<br />' +
35                                                 '<strong><%:TX%></strong>: %.2mB (%d <%:Pkts.%>)<br />',
36                                                         ifc.rx_bytes, ifc.rx_packets,
37                                                         ifc.tx_bytes, ifc.tx_packets
38                                         );
39
40                                         if (ifc.ipaddrs && ifc.ipaddrs.length)
41                                         {
42                                                 html += '<strong><%:IPv4%>: </strong>';
43
44                                                 for (var i = 0; i < ifc.ipaddrs.length; i++)
45                                                         html += String.format(
46                                                                 '%s%s',
47                                                                 i ? ', ' : '',
48                                                                 ifc.ipaddrs[i]
49                                                         );
50
51                                                 html += '<br />';
52                                         }
53
54                                         if (ifc.ip6addrs && ifc.ip6addrs.length)
55                                         {
56                                                 html += '<strong><%:IPv6%>: </strong>';
57
58                                                 for (var i = 0; i < ifc.ip6addrs.length; i++)
59                                                         html += String.format(
60                                                                 '%s%s',
61                                                                 i ? ', ' : '',
62                                                                 ifc.ip6addrs[i].toUpperCase()
63                                                         );
64
65                                                 html += '<br />';
66                                         }
67
68                                         d.innerHTML = html;
69                                 }
70                                 else if (d)
71                                 {
72                                         d.innerHTML = '<em><%:Interface not present or not connected yet.%></em>';
73                                 }
74                         }
75                 }
76         );
77 //]]></script>
78
79 <table>
80         <tr class="cbi-section-table">
81                 <td></td>
82                 <td class="cbi-value-field" style="min-width:16px; padding:3px; text-align:center" id="<%=self.option%>-ifc-signal">
83                         <img src="<%=resource%>/icons/ethernet_disabled.png" style="width:16px; height:16px" /><br />
84                         <small>?</small>
85                 </td>
86                 <td class="cbi-value-field" style="vertical-align:middle; text-align:left; padding:3px" id="<%=self.option%>-ifc-description">
87                         <em><%:Collecting data...%></em>
88                 </td>
89         </tr>
90 </table>
91
92 <%+cbi/valuefooter%>