index.html: DHCP client list re-order

This commit is contained in:
Bobby 2022-04-03 12:47:40 +08:00 committed by GitHub
parent 6482d2270c
commit f5307dff2a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -188,6 +188,20 @@
}); });
} }
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;
}
}
};
XHR.poll(1, '<%=REQUEST_URI%>', { status: 1 }, XHR.poll(1, '<%=REQUEST_URI%>', { status: 1 },
function(x, info) function(x, info)
{ {
@ -381,6 +395,7 @@
var ls = document.getElementById('lease_status_table'); var ls = document.getElementById('lease_status_table');
if (ls) if (ls)
{ {
info.leases = info.leases.sort(compare("ipaddr"));
/* clear all rows */ /* clear all rows */
while( ls.rows.length > 1 ) while( ls.rows.length > 1 )
ls.rows[0].parentNode.deleteRow(1); ls.rows[0].parentNode.deleteRow(1);