arp表中添加黑名单显示

This commit is contained in:
zifan 2023-09-23 14:00:26 +08:00
parent 8e27a9484d
commit a21e259272
1 changed files with 39 additions and 3 deletions

View File

@ -42,8 +42,31 @@
</tbody> </tbody>
</table> </table>
</div> </div>
<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>
<script> <script>
window.onload = function () {
var blackData;
function loadBlackData() {
fetch("/cgi-bin/fw.cgi").then(resp => resp.json()).then(data => {
blackData = data;
loadData();
})
}
function loadData() {
fetch("/cgi-bin/arp.cgi").then(resp => resp.json()).then(data => { fetch("/cgi-bin/arp.cgi").then(resp => resp.json()).then(data => {
arpTableBody.innerText = ""; arpTableBody.innerText = "";
data.forEach(rowData => { data.forEach(rowData => {
@ -57,10 +80,23 @@
td3.innerText = rowData.mac; td3.innerText = rowData.mac;
tr.append(td1, td2, td3); tr.append(td1, td2, td3);
for (let i = 0; i < blackData.length; i++) {
if (blackData[i].ip == rowData.ip) {
tr.style = "color:red;";
break;
}
}
arpTableBody.append(tr); arpTableBody.append(tr);
}); });
})
} }
)
window.onload = function () {
loadBlackData();
} }
</script> </script>
</body> </body>