dhcp列表按IP地址排序 (#106)

This commit is contained in:
big fox tail 2022-03-26 01:15:56 +08:00 committed by GitHub
parent 95f010a8e5
commit 18a591f400
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -11,6 +11,20 @@
return null;
}
var compare = function (prop) {
return function (obj1, obj2) {
var val1 = Number(obj1[prop].replaceAll(".",""));
var val2 = Number(obj2[prop].replaceAll(".",""));
if (val1 < val2) {
return -1;
} else if (val1 > val2) {
return 1;
} else {
return 0;
}
}
}
var hosts = <%=luci.http.write_json(luci.sys.net.host_hints())%>;
XHR.poll(5, '<%=url('admin/network/dhcplease_status')%>', null,
@ -19,6 +33,7 @@
var tb = document.getElementById('lease_status_table');
if (st && st[0] && tb)
{
st[0] = st[0].sort(compare("ipaddr"));
/* clear all rows */
while( tb.rows.length > 1 )
tb.deleteRow(1);