1 <script type=
"text/javascript">//<![CDATA[
2 var switches = [ '<%=table.concat(self.switches,
"', '")%
>' ],
3 tables = document.querySelectorAll('.cbi-section-table');
5 function add_status_row(table) {
6 var first_row = table.querySelector('.cbi-section-table-row');
7 if (first_row.classList.contains('port-status'))
10 var status_row = first_row.parentNode.insertBefore(
11 E('div', { 'class': first_row.className }), first_row);
13 first_row.querySelectorAll('.td').forEach(function(td) {
14 status_row.appendChild(td.cloneNode(false));
15 status_row.lastElementChild.removeAttribute('data-title');
18 status_row.firstElementChild.innerHTML = '<%:Port status:%
>';
19 status_row.classList.add('port-status') ;
24 XHR.poll(
5, '<%=url('admin/network/switch_status')%
>/' + switches.join(','), null,
27 for (var i =
0; i < switches.length; i++)
29 var ports = st[switches[i]];
30 var tr = add_status_row(tables[i]);
32 if (tr && ports && ports.length)
34 for (var j =
0; j < ports.length; j++)
36 var th = tr.querySelector('[
data-name=
"%d"]'.format(j));
43 th.innerHTML = String.format(
44 '
<small><img src=
"<%=resource%>/icons/port_up.png" />' +
45 '
<br />%d<%:baseT%
><br />%s
</small>',
46 ports[j].speed, ports[j].duplex
47 ? '<%:full-duplex%
>' : '<%:half-duplex%
>'
52 th.innerHTML = String.format(
53 '
<small><img src=
"<%=resource%>/icons/port_down.png" />' +
54 '
<br /><%:no link%
></small>'