diff options
author | LarsVomMars | 2021-02-01 15:44:01 +0100 |
---|---|---|
committer | LarsVomMars | 2021-02-01 15:44:01 +0100 |
commit | b01a04200deaad168342ba170a94dd15bad0ae79 (patch) | |
tree | bf303a2d3981de4bc74ecd29e1559e94984e020f /superadmin/public/script.js | |
parent | 099de3b0a7c4f57dfed65f41596e28fd36194024 (diff) |
just for the lulz
Diffstat (limited to 'superadmin/public/script.js')
-rw-r--r-- | superadmin/public/script.js | 23 |
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"); |