arp列表终版

This commit is contained in:
zifan 2023-09-21 10:47:57 +08:00
parent 80d9ba5f9e
commit 6e3d9489fb
1 changed files with 49 additions and 25 deletions

View File

@ -6,39 +6,63 @@
<meta name="author" content="zifan"> <meta name="author" content="zifan">
<meta name="keywords" content="物联网"> <meta name="keywords" content="物联网">
<title>ARP列表</title> <title>ARP列表</title>
<style>
html,
body {
height: 100%;
margin: 0;
padding: 0;
}
body {
display: flex;
flex-direction: column;
justify-content: space-between;
}
#arpTable {
background-color: rgba(41, 117, 117, 0.667);
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.5);
}
</style>
</head> </head>
<body> <body>
<table id="arpTable" width="700" align="center" border="1"> <div></div>
<thead> <div class="tablecenter">
<th>ID</th> <table id="arpTable" width="700" align="center" border="1" cellspacing="0">
<th>ip地址</th> <thead>
<th>mac地址</th> <th>ID</th>
</thead> <th>ip地址</th>
<tbody id="arpTableBody" align="center"> <th>mac地址</th>
</thead>
<tbody id="arpTableBody" align="center">
</tbody> </tbody>
</table> </table>
</div>
<div></div>
<div></div>
<script> <script>
window.onload = function () { window.onload = function () {
fetch("/cgi-bin/ip.cgi").then(resp => resp.json()).then(data => { fetch("/cgi-bin/arp.cgi").then(resp => resp.json()).then(data => {
if (data.code == 0) { arpTableBody.innerText = "";
arpTableBody.innerText = ""; data.forEach(rowData => {
data.data.forEach(rowData => { let tr = document.createElement("tr");
let tr = document.createElement("tr"); let td1 = document.createElement("td");
let td1 = document.createElement("td"); let td2 = document.createElement("td");
let td2 = document.createElement("td"); let td3 = document.createElement("td");
let td3 = document.createElement("td");
td1.innerText = rowData.id; td1.innerText = rowData.id;
td2.innerText = rowData.ip; td2.innerText = rowData.ip;
td3.innerText = rowData.mac; td3.innerText = rowData.mac;
tr.append(td1, td2, td3); tr.append(td1, td2, td3);
arpTableBody.append(tr); arpTableBody.append(tr);
}); });
} }
}) )
} }
</script> </script>
</body> </body>