上传disen修改版
This commit is contained in:
parent
34dd311567
commit
eee29c3750
68
www/fw.html
68
www/fw.html
|
@ -36,11 +36,11 @@
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<div>
|
<div>
|
||||||
<form onsubmit="return post_ip(this);" class="blackfrom">
|
<form class="blackfrom">
|
||||||
<label>ip地址:</label>
|
<label>ip地址:</label>
|
||||||
<input name="ipaddr">
|
<input name="ipaddr" id="ipInputID">
|
||||||
<button type="submit">添加</button>
|
<button type="button" onclick="add_ip()">添加</button>
|
||||||
<button type="button" id="del">删除</button>
|
<button type="button" id="del" onclick="del_ip()">删除</button>
|
||||||
</form>
|
</form>
|
||||||
<table class="balckTable back" width="250" align="center" border="1" cellspacing="0">
|
<table class="balckTable back" width="250" align="center" border="1" cellspacing="0">
|
||||||
<thead>
|
<thead>
|
||||||
|
@ -52,7 +52,8 @@
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<script>
|
<script>
|
||||||
window.onload = function () {
|
|
||||||
|
function loadData() {
|
||||||
fetch("/cgi-bin/fw.cgi").then(resp => resp.json()).then(data => {
|
fetch("/cgi-bin/fw.cgi").then(resp => resp.json()).then(data => {
|
||||||
blackTableBody.innerText = "";
|
blackTableBody.innerText = "";
|
||||||
data.forEach(rowData => {
|
data.forEach(rowData => {
|
||||||
|
@ -64,37 +65,50 @@
|
||||||
tr.append(td1);
|
tr.append(td1);
|
||||||
blackTableBody.append(tr);
|
blackTableBody.append(tr);
|
||||||
});
|
});
|
||||||
}
|
})
|
||||||
)
|
|
||||||
|
}
|
||||||
|
window.onload = function () {
|
||||||
|
loadData();
|
||||||
|
|
||||||
let del = document.getElementById("del");
|
|
||||||
del.addEventListener("click", (event) => {
|
|
||||||
fetch("/cgi-bin/send.cgi").then(resp => resp.json()).then(data => {
|
|
||||||
if (data.code == 1) {
|
|
||||||
alert("删除成功!");
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function post_ip(form) {
|
function add_ip() {
|
||||||
let form_data = {
|
let url = "/cgi-bin/send.cgi";
|
||||||
ip: form.ipaddr.value
|
let data = {
|
||||||
|
"code": 0,
|
||||||
|
"ip": ipInputID.value.trim()
|
||||||
};
|
};
|
||||||
fetch("/cgi-bin/send.cgi", {
|
|
||||||
|
fetch(url, {
|
||||||
method: "post",
|
method: "post",
|
||||||
body: JSON.stringify(form_data),
|
body: JSON.stringify(data),
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json;charset=utf-8"
|
"Content-Type": "application/json;charset=utf-8"
|
||||||
}
|
}
|
||||||
}).then(resp => resp.json()).then(data => {
|
}).then(resp => resp.json()).then(d => {
|
||||||
if (data.code == 0) {
|
console.log(d);
|
||||||
alert("添加成功!");
|
loadData();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function del_ip() {
|
||||||
|
let url = "/cgi-bin/send.cgi";
|
||||||
|
let data = {
|
||||||
|
"code": 1,
|
||||||
|
"ip": ipInputID.value.trim()
|
||||||
|
};
|
||||||
|
|
||||||
|
fetch(url, {
|
||||||
|
method: "post",
|
||||||
|
body: JSON.stringify(data),
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json;charset=utf-8"
|
||||||
}
|
}
|
||||||
})
|
}).then(resp => resp.json()).then(d => {
|
||||||
onload();
|
console.log(d);
|
||||||
return false;
|
loadData();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|
Loading…
Reference in New Issue