mirror of
https://github.com/kmitresse/Cards-Rush.git
synced 2026-05-16 17:11:48 +00:00
fix(DevWeb): Import static files
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
const ERROR_MESSAGE = {
|
||||
"expired-token": "Lien expiré, veuillez recommencer la procédure de récupération de mot de passe.",
|
||||
"invalid-token": "Lien invalide, veuillez recommencer la procédure de récupération de mot de passe.",
|
||||
};
|
||||
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
const error = urlParams.get('error');
|
||||
|
||||
if (error) {
|
||||
const errorMessage = ERROR_MESSAGE[error];
|
||||
console.error(errorMessage);
|
||||
window.alert(errorMessage);
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
const loginForm = document.getElementById("login-form");
|
||||
|
||||
loginForm.addEventListener("submit", (event) => {
|
||||
event.preventDefault();
|
||||
|
||||
const formData = new FormData(loginForm);
|
||||
const data = {};
|
||||
formData.forEach((value, key) => data[key] = value);
|
||||
|
||||
fetch(loginForm.getAttribute("action"), {
|
||||
headers: {"Content-Type": "application/json"},
|
||||
body: JSON.stringify(data),
|
||||
method: loginForm.getAttribute("method"),
|
||||
})
|
||||
.then(res => res.json())
|
||||
.then(d => window.location.href = "./main-menu")
|
||||
.catch(error => console.error("Error:", error));
|
||||
});
|
||||
|
||||
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
if (urlParams.has('success')) {
|
||||
if (urlParams.get('success') === "account-created") {
|
||||
window.alert("Compte créé avec succès.");
|
||||
}
|
||||
if (urlParams.get('success') === "password-reseted") {
|
||||
window.alert("Mot de passe réinitialisé avec succès.");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
let cb = document.querySelectorAll(".close");
|
||||
for (let i = 0; i < cb.length; i++) {
|
||||
cb[i].addEventListener("click", function() {
|
||||
const dia = this.parentNode.parentNode; /* You need to update this part if you change level of close button */
|
||||
dia.style.display = "none";
|
||||
});
|
||||
}
|
||||
|
||||
let mt = document.querySelectorAll(".modal-toggle");
|
||||
for (let i = 0; i < mt.length; i++) {
|
||||
mt[i].addEventListener("click", function() {
|
||||
const targetId = this.getAttribute("data-target");
|
||||
const target = document.querySelector(targetId);
|
||||
target.style.display = "block";
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
const nbColorsElement = document.getElementById("nbColors");
|
||||
const nbValuesElement = document.getElementById("nbValues");
|
||||
const nbRoundsElement = document.getElementById("nbRounds")
|
||||
|
||||
/**
|
||||
* Mise à jour du nombre de rounds max en fonction du nombre de couleurs et de valeurs séléctionnés
|
||||
*/
|
||||
function updateOnChange() {
|
||||
nbRoundsElement.max = nbColorsElement.value * nbValuesElement.value;
|
||||
|
||||
nbRoundsElement.value =
|
||||
(nbRoundsElement.value > nbRoundsElement.max)
|
||||
? nbRoundsElement.max
|
||||
: nbRoundsElement.value
|
||||
;
|
||||
}
|
||||
|
||||
nbColorsElement.addEventListener("change", updateOnChange);
|
||||
nbValuesElement.addEventListener("change", updateOnChange);
|
||||
@@ -0,0 +1,21 @@
|
||||
const registerForm = document.getElementById("register-form");
|
||||
const confirmPassword = document.getElementById("confirmPassword");
|
||||
|
||||
registerForm.addEventListener("submit", (event) => {
|
||||
event.preventDefault();
|
||||
const formData = new FormData(registerForm);
|
||||
|
||||
const data = {};
|
||||
formData.forEach((value, key) => data[key] = value);
|
||||
|
||||
fetch(registerForm.getAttribute("action"), {
|
||||
method: registerForm.getAttribute("method"),
|
||||
headers: {"Content-Type": "application/json"},
|
||||
body: JSON.stringify(data)
|
||||
})
|
||||
.then(res => res.json())
|
||||
.then(_ => {
|
||||
window.location.href = "./login"
|
||||
})
|
||||
.catch(error => console.error("Error: " + error))
|
||||
});
|
||||
@@ -0,0 +1,31 @@
|
||||
const resetPasswordForm = document.getElementById("resetPasswordForm");
|
||||
const confirmPassword = document.getElementById("confirmPassword");
|
||||
|
||||
resetPasswordForm.addEventListener("submit", function (event) {
|
||||
event.preventDefault();
|
||||
const formData = new FormData(resetPasswordForm);
|
||||
|
||||
const data = {};
|
||||
formData.forEach((value, key) => data[key] = value);
|
||||
|
||||
const action = loginForm.getAttribute("action")
|
||||
const method = loginForm.getAttribute("method")
|
||||
|
||||
fetch("/reset-password", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
body: JSON.stringify(data)
|
||||
}).then(response => {
|
||||
if (response.ok) {
|
||||
window.location.href = "/login";
|
||||
} else {
|
||||
response.json().then(data => {
|
||||
alert(data.message);
|
||||
});
|
||||
}
|
||||
}).catch(error => {
|
||||
console.error("Error:", error);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user