From b01a04200deaad168342ba170a94dd15bad0ae79 Mon Sep 17 00:00:00 2001 From: LarsVomMars Date: Mon, 1 Feb 2021 15:44:01 +0100 Subject: just for the lulz --- superadmin/public/script.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'superadmin/public/script.js') 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"); -- cgit v1.2.3