feat: un truc bien moche

This commit is contained in:
Laureηt 2022-05-29 15:04:49 +02:00
parent 9dc30fd47c
commit 332dc760db
No known key found for this signature in database
GPG key ID: D88C6B294FD40994
3 changed files with 38 additions and 12 deletions

View file

@ -12,7 +12,6 @@ import javax.ws.rs.FormParam;
import javax.ws.rs.GET; import javax.ws.rs.GET;
import javax.ws.rs.NotFoundException; import javax.ws.rs.NotFoundException;
import javax.ws.rs.POST; import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path; import javax.ws.rs.Path;
import javax.ws.rs.PathParam; import javax.ws.rs.PathParam;
import javax.ws.rs.Produces; import javax.ws.rs.Produces;

View file

@ -1,15 +1,44 @@
// fonction qui s'execute quand la page a finie de charger // fonction qui s'execute quand la page a finie de charger
function pageLoaded() { function pageLoaded() {
let forms = document.forms; document.forms["pay-form"].addEventListener("submit", (event) => {
for (form of forms) {
form.addEventListener("submit", (event) => {
event.preventDefault(); event.preventDefault();
fetch(event.target.action, { fetch(event.target.action, {
method: event.target.method, method: event.target.method,
body: new URLSearchParams(new FormData(event.target)), body: new URLSearchParams(new FormData(event.target)),
}); }).then(async (resp) => {
}); if (resp.ok) {
updateSolde();
} }
});
});
document.forms["modify-form"].addEventListener("submit", (event) => {
event.preventDefault();
fetch(event.target.action, {
method: event.target.method,
body: new URLSearchParams(new FormData(event.target)),
}).then(async (resp) => {
if (resp.ok) {
updatePixelGrid();
updateSolde();
togglePopup("modify");
}
});
});
document.forms["buy-form"].addEventListener("submit", (event) => {
event.preventDefault();
fetch(event.target.action, {
method: event.target.method,
body: new URLSearchParams(new FormData(event.target)),
}).then(async (resp) => {
if (resp.ok) {
updatePixelGrid();
updateSolde();
pixelClick(event.target.action.split("/")[5]);
}
});
});
document.forms["login-form"].addEventListener("submit", (event) => { document.forms["login-form"].addEventListener("submit", (event) => {
event.preventDefault(); event.preventDefault();

View file

@ -44,7 +44,6 @@ async function userLogin() {
updateSolde(); updateSolde();
localStorage.setItem("logged", "true"); localStorage.setItem("logged", "true");
console.log("logged in");
} }
}); });
} }
@ -65,7 +64,6 @@ function userLogout() {
} }
localStorage.setItem("logged", "false"); localStorage.setItem("logged", "false");
console.log("logged out");
} }
}); });
} }