1 <script type=
"text/javascript">//<![CDATA[
2 function duid2mac(duid) {
4 if (duid.length ===
28 && duid.substr(
0,
8) === '
00010001')
5 return duid.substr(
16).replace(/(..)(?=..)/g, '$
1:').toUpperCase();
8 if (duid.length ===
24 && duid.substr(
0,
8) === '
00030001')
9 return duid.substr(
8).replace(/(..)(?=..)/g, '$
1:').toUpperCase();
14 var hosts = <%=luci.http.write_json(luci.sys.net.host_hints())%
>;
16 XHR.poll(
5, '<%=url('admin/network/dhcplease_status')%
>', null,
19 var tb = document.getElementById('lease_status_table');
20 if (st && st[
0] && tb)
23 while( tb.rows.length
> 1 )
26 for( var i =
0; i < st[
0].length; i++ )
30 if (st[
0][i].expires === false)
31 timestr = '
<em><%:unlimited%
></em>';
32 else if (st[
0][i].expires <=
0)
33 timestr = '
<em><%:expired%
></em>';
35 timestr = String.format('%t', st[
0][i].expires);
37 var tr = tb.insertRow(-
1);
38 tr.className = 'cbi-section-table-row cbi-rowstyle-' + ((i %
2) +
1);
40 tr.insertCell(-
1).innerHTML = st[
0][i].hostname ? st[
0][i].hostname : '?';
41 tr.insertCell(-
1).innerHTML = st[
0][i].ipaddr;
42 tr.insertCell(-
1).innerHTML = st[
0][i].macaddr;
43 tr.insertCell(-
1).innerHTML = timestr;
46 if( tb.rows.length ==
1 )
48 var tr = tb.insertRow(-
1);
49 tr.className = 'cbi-section-table-row';
51 var td = tr.insertCell(-
1);
53 td.innerHTML = '
<em><br /><%:There are no active leases.%
></em>';
57 var tb6 = document.getElementById('lease6_status_table');
58 if (st && st[
1] && tb6)
60 tb6.parentNode.style.display = 'block';
63 while( tb6.rows.length
> 1 )
66 for( var i =
0; i < st[
1].length; i++ )
70 if (st[
1][i].expires === false)
71 timestr = '
<em><%:unlimited%
></em>';
72 else if (st[
1][i].expires <=
0)
73 timestr = '
<em><%:expired%
></em>';
75 timestr = String.format('%t', st[
1][i].expires);
77 var tr = tb6.insertRow(-
1);
78 tr.className = 'cbi-section-table-row cbi-rowstyle-' + ((i %
2) +
1);
80 var host = hosts[duid2mac(st[
1][i].duid)];
82 tr.insertCell(-
1).innerHTML = String.format(
83 '
<div style=
"max-width:200px;overflow:hidden;text-overflow:ellipsis">%s
</div>',
84 ((host.name && (host.ipv4 || host.ipv6))
85 ? '%h (%s)'.format(host.name, host.ipv4 || host.ipv6)
86 : '%h'.format(host.name || host.ipv4 || host.ipv6)).nobr()
89 tr.insertCell(-
1).innerHTML = st[
1][i].hostname ? st[
1][i].hostname : '?';
91 tr.insertCell(-
1).innerHTML = st[
1][i].ip6addr;
92 tr.insertCell(-
1).innerHTML = st[
1][i].duid;
93 tr.insertCell(-
1).innerHTML = timestr;
96 if( tb6.rows.length ==
1 )
98 var tr = tb6.insertRow(-
1);
99 tr.className = 'cbi-section-table-row';
101 var td = tr.insertCell(-
1);
103 td.innerHTML = '
<em><br /><%:There are no active leases.%
></em>';
110 <fieldset class=
"cbi-section">
111 <legend><%:Active DHCP Leases%
></legend>
112 <table class=
"cbi-section-table" id=
"lease_status_table">
113 <tr class=
"cbi-section-table-titles">
114 <th class=
"cbi-section-table-cell"><%:Hostname%
></th>
115 <th class=
"cbi-section-table-cell"><%:IPv4-Address%
></th>
116 <th class=
"cbi-section-table-cell"><%:MAC-Address%
></th>
117 <th class=
"cbi-section-table-cell"><%:Leasetime remaining%
></th>
119 <tr class=
"cbi-section-table-row">
120 <td colspan=
"4"><em><br /><%:Collecting data...%
></em></td>
125 <fieldset class=
"cbi-section" style=
"display:none">
126 <legend><%:Active DHCPv6 Leases%
></legend>
127 <table class=
"cbi-section-table" id=
"lease6_status_table">
128 <tr class=
"cbi-section-table-titles">
129 <th class=
"cbi-section-table-cell"><%:Host%
></th>
130 <th class=
"cbi-section-table-cell"><%:IPv6-Address%
></th>
131 <th class=
"cbi-section-table-cell"><%:DUID%
></th>
132 <th class=
"cbi-section-table-cell"><%:Leasetime remaining%
></th>
134 <tr class=
"cbi-section-table-row">
135 <td colspan=
"4"><em><br /><%:Collecting data...%
></em></td>