let rbtn = document.getElementById("btn-reset"); let infoBox = document.getElementById("general-info"); rbtn.addEventListener("click", e => { e.preventDefault(); toggleDisabled(rbtn, "on"); setInfo(infoBox, "Processing Request...", "purple", "grey1"); toggleHidden(infoBox, "off"); fetch("/database", { method: "PATCH" }).then(res => { if (res.status == 200) { setInfo(infoBox, "Success", "green", "grey1"); setTimeout(() => { toggleHidden(infoBox, "on"); }, 2000); } else { setInfo(infoBox, "Failure", "red", "grey1"); toggleHidden(infoBox, "off"); setTimeout(() => { toggleHidden(infoBox, "on"); }, 2000); } toggleDisabled(rbtn, "off"); }); });