c-router-emulator/www/arp.html

104 lines
2.6 KiB
HTML
Raw Normal View History

2023-09-20 20:52:46 +08:00
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="author" content="zifan">
<meta name="keywords" content="物联网">
<title>ARP列表</title>
2023-09-21 10:47:57 +08:00
<style>
html,
body {
height: 100%;
margin: 0;
padding: 0;
}
body {
display: flex;
flex-direction: column;
justify-content: space-between;
2023-09-22 10:45:43 +08:00
padding: 50px;
2023-09-21 10:47:57 +08:00
}
#arpTable {
background-color: rgba(41, 117, 117, 0.667);
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.5);
}
</style>
2023-09-20 20:52:46 +08:00
</head>
<body>
2023-09-21 10:47:57 +08:00
<div class="tablecenter">
<table id="arpTable" width="700" align="center" border="1" cellspacing="0">
<thead>
<th>ID</th>
<th>ip地址</th>
<th>mac地址</th>
</thead>
<tbody id="arpTableBody" align="center">
</tbody>
</table>
</div>
2023-09-23 14:00:26 +08:00
<div style="display: none;">
<table id="balckTable" width="250" align="center" border="1" cellspacing="0">
<thead>
<th>ip地址</th>
</thead>
<tbody id="blackTableBody" align="center">
</tbody>
</table>
</div>
2023-09-20 20:52:46 +08:00
<script>
2023-09-23 14:00:26 +08:00
var blackData;
function loadBlackData() {
fetch("/cgi-bin/fw.cgi").then(resp => resp.json()).then(data => {
blackData = data;
loadData();
})
}
function loadData() {
2023-09-21 10:47:57 +08:00
fetch("/cgi-bin/arp.cgi").then(resp => resp.json()).then(data => {
arpTableBody.innerText = "";
data.forEach(rowData => {
let tr = document.createElement("tr");
let td1 = document.createElement("td");
let td2 = document.createElement("td");
let td3 = document.createElement("td");
td1.innerText = rowData.id;
td2.innerText = rowData.ip;
td3.innerText = rowData.mac;
tr.append(td1, td2, td3);
2023-09-23 14:00:26 +08:00
for (let i = 0; i < blackData.length; i++) {
if (blackData[i].ip == rowData.ip) {
tr.style = "color:red;";
break;
}
}
2023-09-21 10:47:57 +08:00
arpTableBody.append(tr);
});
2023-09-23 14:00:26 +08:00
})
}
window.onload = function () {
loadBlackData();
2023-09-20 20:52:46 +08:00
}
</script>
</body>
</html>