diff --git a/static/js/admin.js b/static/js/admin.js index bd038ff..efb2dff 100644 --- a/static/js/admin.js +++ b/static/js/admin.js @@ -18,11 +18,11 @@ async function run() { item.append(id, username, permissions, edit, del); usersDiv.appendChild(item); edit.addEventListener("click", async () => { - await fetch("/admin/edit/user", {method: "POST", body: JSON.stringify({"id": users[i][0], "username": username.value, "permissions": parseInt(permissions.value)})}); + await fetch("/admin/edit/user", { method: "POST", body: JSON.stringify({ "id": users[i][0], "username": username.value, "permissions": parseInt(permissions.value) }) }); window.location.reload(); }) del.addEventListener("click", async () => { - await fetch("/admin/delete/user", {method:"POST", body: JSON.stringify({"id": users[i][0]})}); + await fetch("/admin/delete/user", { method: "POST", body: JSON.stringify({ "id": users[i][0] }) }); window.location.reload(); }) } @@ -30,7 +30,7 @@ async function run() { let players = await fetch("/admin/players").then(r => r.json()); let playersDiv = document.getElementById("players"); - for (let i=0; i { - await fetch("/admin/edit/player", {method: "POST", body: JSON.stringify({"id": players[i]["id"], "name": name.value})}); + await fetch("/admin/edit/player", { method: "POST", body: JSON.stringify({ "id": players[i]["id"], "name": name.value }) }); window.location.reload(); }) del.addEventListener("click", async () => { - await fetch("/admin/delete/player", {method:"POST", body: JSON.stringify({"id": players[i]["id"]})}); + await fetch("/admin/delete/player", { method: "POST", body: JSON.stringify({ "id": players[i]["id"] }) }); window.location.reload(); }) } @@ -62,7 +62,7 @@ async function run() { item.append(name, save); playersDiv.appendChild(item); save.addEventListener("click", async () => { - await fetch("/admin/new/player", {method:"POST", body: JSON.stringify({"name": name.value})}) + await fetch("/admin/new/player", { method: "POST", body: JSON.stringify({ "name": name.value }) }) window.location.reload(); }) }) @@ -74,7 +74,7 @@ async function run() { today.textContent = `Aujourd'hui il y a ${count.length} votes`; let votesDiv = document.getElementById("votes"); - for (let i=0; i { - await fetch("/admin/edit/vote", {method: "POST", body: JSON.stringify({"id": votes[i]["id"], + await fetch("/admin/edit/vote", { + method: "POST", body: JSON.stringify({ + "id": votes[i]["id"], "submit_date": submit_date.value, "plus_player_id": parseInt(plus_id.value), "plus_nickname": plus_nickname.value, "plus_reason": plus_reason.value, "minus_player_id": parseInt(minus_id.value), "minus_nickname": minus_nickname.value, - "minus_reason": minus_reason.value})}); + "minus_reason": minus_reason.value + }) + }); window.location.reload(); }) del.addEventListener("click", async () => { - await fetch("/admin/delete/vote", {method:"POST", body: JSON.stringify({"id": votes[i]["id"]})}); + await fetch("/admin/delete/vote", { method: "POST", body: JSON.stringify({ "id": votes[i]["id"] }) }); window.location.reload(); }) } } -let _ = run(); \ No newline at end of file +let _ = run();