feat(verif): add a confirm dialog for tocards #3

Merged
inso merged 2 commits from feat/french_with_check into french 2022-11-30 15:20:40 +00:00
Showing only changes of commit 21bb6add65 - Show all commits

View File

@@ -17,6 +17,7 @@
__OPTIONS__
</select>
<div id="confirmation"></div>
<h2 id="result"></h2>
<!-- Christmas tree -->
@@ -70,22 +71,28 @@
<script>
document.getElementById("person").addEventListener("change", (event) => {
const options = {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ person: event.target.value }),
};
if (
window.confirm(
`Vérification! Tu es ${event.target.value}, c'est bien ça?`
)
) {
const options = {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ person: event.target.value }),
};
console.log(options);
console.log(options);
fetch("api", options)
.then((response) => response.text())
.then((text) => {
document.getElementById(
"result"
).textContent = `Hoho! Tu as pioché ${text} ;`;
document.getElementById("person").remove();
});
fetch("api", options)
.then((response) => response.text())
.then((text) => {
document.getElementById(
"result"
).textContent = `Hoho! Tu as pioché ${text} ;`;
document.getElementById("person").remove();
});
}
});
</script>
</body>