3 Commits

Author SHA1 Message Date
qdegrandmaison
e5e23caab8 feat(verif): no need for a DOM node 2022-11-30 16:10:09 +01:00
qdegrandmaison
21bb6add65 feat(verif): add a confirm dialog for tocards 2022-11-30 16:08:41 +01:00
gvcgael
c39968865c french lang 2022-11-30 14:39:47 +01:00

View File

@@ -13,7 +13,7 @@
<h1>Secret Santa</h1> <h1>Secret Santa</h1>
<select id="person"> <select id="person">
<option selected disabled>Who are you?</option> <option selected disabled>Qui es-tu?</option>
__OPTIONS__ __OPTIONS__
</select> </select>
@@ -70,22 +70,28 @@
<script> <script>
document.getElementById("person").addEventListener("change", (event) => { document.getElementById("person").addEventListener("change", (event) => {
const options = { if (
method: "POST", window.confirm(
headers: { "Content-Type": "application/json" }, `Vérification! Tu es ${event.target.value}, c'est bien ça?`
body: JSON.stringify({ person: event.target.value }), )
}; ) {
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) fetch("api", options)
.then((response) => response.text()) .then((response) => response.text())
.then((text) => { .then((text) => {
document.getElementById( document.getElementById(
"result" "result"
).textContent = `Your draw: ${text}`; ).textContent = `Hoho! Tu as pioché ${text} ;`;
document.getElementById("person").remove(); document.getElementById("person").remove();
}); });
}
}); });
</script> </script>
</body> </body>