aboutsummaryrefslogtreecommitdiff
path: root/superadmin/public/script.js
diff options
context:
space:
mode:
authorLarsVomMars2021-02-01 15:44:01 +0100
committerLarsVomMars2021-02-01 15:44:01 +0100
commitb01a04200deaad168342ba170a94dd15bad0ae79 (patch)
treebf303a2d3981de4bc74ecd29e1559e94984e020f /superadmin/public/script.js
parent099de3b0a7c4f57dfed65f41596e28fd36194024 (diff)
just for the lulz
Diffstat (limited to 'superadmin/public/script.js')
-rw-r--r--superadmin/public/script.js23
1 files changed, 23 insertions, 0 deletions
diff --git a/superadmin/public/script.js b/superadmin/public/script.js
index c3f9c0f..e0c5efe 100644
--- a/superadmin/public/script.js
+++ b/superadmin/public/script.js
@@ -1,6 +1,10 @@
const pullButton = document.getElementById("pull-button");
const pullResponse = document.getElementById("pull-response");
+const resetInput = document.getElementById("reset-input");
+const resetButton = document.getElementById("reset-button");
+const resetResponse = document.getElementById("reset-response");
+
const queryForm = document.getElementById("query-form");
const queryResponse = document.getElementById("query-response");
@@ -15,6 +19,25 @@ pullButton.addEventListener("click", async e => {
}
});
+resetButton.addEventListener("click", async e => {
+ const uid = resetInput.value;
+ const body = JSON.stringify({ uid });
+ const method = "POST";
+ const resp = await fetch("api/reset", { method, body, headers: { "Content-Type": "application/json" } });
+ const res = await resp.json();
+ while (resetResponse.children.length > 0) resetResponse.removeChild(resetResponse.children[0]);
+ if (res.success) {
+ const b = document.createElement("b");
+ b.textContent = `${res.uid}: `;
+ const span = document.createElement("span");
+ span.textContent = res.pwd;
+ resetResponse.append(b, span);
+ } else {
+ console.log(res);
+ resetResponse.textContent = JSON.stringify(res.e);
+ }
+});
+
queryForm.addEventListener("submit", async e => {
e.preventDefault();
const textarea = queryForm.querySelector("textarea");