39 lines
824 B
JavaScript
39 lines
824 B
JavaScript
function add_user(ip, mac)
|
|
{
|
|
const tabel = document.querySelector("#user-list");
|
|
|
|
const tr = document.createElement('tr');
|
|
|
|
const rdIP = document.createElement('td');
|
|
rdIP.textContent = ip;
|
|
|
|
const rdMAC = document.createElement('td');
|
|
rdMAC.textContent = mac;
|
|
|
|
tr.appendChild(rdIP);
|
|
tr.appendChild(rdMAC);
|
|
|
|
tabel.appendChild(tr);
|
|
}
|
|
|
|
async function update_user_list()
|
|
{
|
|
const res = await fetch("/user_list", {
|
|
method: "GET"
|
|
});
|
|
|
|
if (res.ok)
|
|
{
|
|
const body = await res.json();
|
|
|
|
const tabel = document.querySelector("#user-list");
|
|
tabel.textContent = '';
|
|
|
|
for (let i = 0; i < body.user_ip.length; i++) {
|
|
add_user(body.user_ip[i], body.user_mac[i]);
|
|
}
|
|
}
|
|
}
|
|
|
|
update_user_list();
|
|
setInterval(update_user_list, 10000); |