modules/admin-full: more javascript fixes
[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
4 (function() {
5 var func = arguments.callee;
6
7 stxhr.get('<%=luci.dispatcher.build_url("admin", "network", "dhcplease_status")%>', null,
8 function(x, st)
9 {
10 var tb = document.getElementById('lease_status_table');
11 if (st && tb)
12 {
13 /* clear all rows */
14 while( tb.rows.length > 1 )
15 tb.deleteRow(1);
16
17 for( var i = 0; i < st.length; i++ )
18 {
19 var timestr;
20
21 if (st[i].expires <= 0)
22 {
23 timestr = '<em><%:expired%></em>';
24 }
25 else
26 {
27 timestr = String.format('%t', st[i].expires);
28 }
29
30 var tr = tb.insertRow(-1);
31 tr.className = 'cbi-section-table-row cbi-rowstyle-' + ((i % 2) + 1);
32
33 tr.insertCell(-1).innerHTML = st[i].hostname ? st[i].hostname : '?';
34 tr.insertCell(-1).innerHTML = st[i].ipaddr;
35 tr.insertCell(-1).innerHTML = st[i].macaddr;
36 tr.insertCell(-1).innerHTML = timestr;
37 }
38
39 if( tb.rows.length == 1 )
40 {
41 var tr = tb.insertRow(-1);
42 tr.className = 'cbi-section-table-row';
43
44 var td = tr.insertCell(-1);
45 td.colSpan = 4;
46 td.innerHTML = '<em><br /><%:There are no active leases.%></em>';
47 }
48 }
49
50 window.setTimeout(func, 5000);
51 }
52 )
53 })();
54 //]]></script>
55
56 <fieldset class="cbi-section">
57 <legend><%:Active Leases%></legend>
58 <table class="cbi-section-table" id="lease_status_table">
59 <tr class="cbi-section-table-titles">
60 <th class="cbi-section-table-cell"><%:Hostname%></th>
61 <th class="cbi-section-table-cell"><%:IPv4-Address%></th>
62 <th class="cbi-section-table-cell"><%:MAC-Address%></th>
63 <th class="cbi-section-table-cell"><%:Leasetime remaining%></th>
64 </tr>
65 <tr class="cbi-section-table-row">
66 <td colspan="4"><em><br /><%:Collecting data...%></em></td>
67 </tr>
68 </table>
69 </fieldset>