feat(frontend): add button to clear configuration

This commit is contained in:
Mariano Riefolo 2024-09-03 17:17:04 +02:00
parent b6ef022f15
commit 41e5fd5f13
2 changed files with 15 additions and 1 deletions

View File

@ -169,11 +169,20 @@ function select_class() {
Cookies.set("class", student_class); Cookies.set("class", student_class);
} }
function delete_cookies() {
Cookies.remove("id");
Cookies.remove("type");
Cookies.remove("teacher");
Cookies.remove("class");
}
if (Cookies.get("id") && Cookies.get("type")) { if (Cookies.get("id") && Cookies.get("type")) {
if (Cookies.get("type") === "teacher" && Cookies.get("teacher")) { if (Cookies.get("type") === "teacher" && Cookies.get("teacher")) {
make_teacher_table(Cookies.get("id"), Cookies.get("teacher")); make_teacher_table(Cookies.get("id"), Cookies.get("teacher"));
document.getElementById("dashboard").removeAttribute("hidden");
} else if (Cookies.get("type") === "student" && Cookies.get("class")) { } else if (Cookies.get("type") === "student" && Cookies.get("class")) {
make_student_table(Cookies.get("id"), Cookies.get("class")); make_student_table(Cookies.get("id"), Cookies.get("class"));
document.getElementById("dashboard").removeAttribute("hidden");
} }
} else { } else {
document.getElementById("forms").removeAttribute("hidden"); document.getElementById("forms").removeAttribute("hidden");

View File

@ -64,7 +64,12 @@
</formfield> </formfield>
</form> </form>
</div> </div>
<div id="dashboard" hidden>
<table id="table" class="striped"></table> <table id="table" class="striped"></table>
<form>
<input type="submit" onclick="delete_cookies()" value="Reimposta" />
</form>
</div>
</main> </main>
</body> </body>
</html> </html>