modules/admin-full: fix bad colspan in lease status template
[project/luci.git] / modules / admin-full / luasrc / view / admin_network / lease_status.htm
1 <script type="text/javascript"><![CDATA[
2 var stxhr = new XHR();
3 (function() {
4 stxhr.get('<%=luci.dispatcher.build_url("admin", "network", "dhcplease_status")%>', null,
5 function(x)
6 {
7 var st = x.responseText ? eval('(' + x.responseText + ')') : null;
8 var tb = document.getElementById('lease_status_table');
9
10 if (st && tb)
11 {
12 /* clear all rows */
13 while( tb.rows.length > 1 )
14 tb.rows[1].parentNode.removeChild(tb.rows[1]);
15
16 for( var i = 0; i < st.length; i++ )
17 {
18 var timestr;
19
20 if (st[i].expires <= 0)
21 {
22 timestr = '<em><%:expired%></em>';
23 }
24 else
25 {
26 var d = 0;
27 var h = 0;
28 var m = 0;
29 var s = st[i].expires;
30
31 if (s > 60) {
32 m = Math.floor(s / 60);
33 s = (s % 60);
34 }
35
36 if (m > 60) {
37 h = Math.floor(m / 60);
38 m = (m % 60);
39 }
40
41 if (h > 24) {
42 d = Math.floor(h / 24);
43 h = (h % 24);
44 }
45
46 timestr = (d > 0)
47 ? String.format('%dd %dh %dm %ds', d, h, m, s)
48 : String.format('%dh %dm %ds', h, m, s);
49 }
50
51 var tr = document.createElement('tr');
52 tr.className = 'cbi-section-table-row cbi-rowstyle-' + ((i % 2) + 1);
53
54 tr.innerHTML = String.format(
55 '<td class="cbi-section-table-cell">%s</td>' +
56 '<td class="cbi-section-table-cell">%s</td>' +
57 '<td class="cbi-section-table-cell">%s</td>' +
58 '<td class="cbi-section-table-cell">%s</td>',
59 st[i].hostname ? st[i].hostname : '?',
60 st[i].ipaddr,
61 st[i].macaddr,
62 timestr
63 );
64
65 tb.rows[0].parentNode.appendChild(tr);
66 }
67
68 if( tb.rows.length == 1 )
69 {
70 var tr = document.createElement('tr');
71 tr.className = 'cbi-section-table-row';
72 tr.innerHTML = '<td colspan="4"><em><br /><%:There are no active leases.%></em></td>';
73
74 tb.rows[0].parentNode.appendChild(tr);
75 }
76 }
77 }
78 )
79
80 window.setTimeout(arguments.callee, 5000);
81 })();
82 ]]></script>
83
84 <fieldset class="cbi-section">
85 <legend><%:Active Leases%></legend>
86 <table class="cbi-section-table" id="lease_status_table">
87 <tr class="cbi-section-table-titles">
88 <th class="cbi-section-table-cell"><%:Hostname%></th>
89 <th class="cbi-section-table-cell"><%:IPv4-Address%></th>
90 <th class="cbi-section-table-cell"><%:MAC-Address%></th>
91 <th class="cbi-section-table-cell"><%:Leasetime remaining%></th>
92 </tr>
93 <tr class="cbi-section-table-row">
94 <td colspan="4"><em><br /><%:Collecting data...%></em></td>
95 </tr>
96 </table>
97 </fieldset>