feat(verif): add a confirm dialog for tocards #3
@@ -17,6 +17,7 @@
|
|||||||
__OPTIONS__
|
__OPTIONS__
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<div id="confirmation"></div>
|
||||||
<h2 id="result"></h2>
|
<h2 id="result"></h2>
|
||||||
|
|
||||||
<!-- Christmas tree -->
|
<!-- Christmas tree -->
|
||||||
@@ -70,22 +71,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 = `Hoho! Tu as pioché ${text} ;`;
|
).textContent = `Hoho! Tu as pioché ${text} ;`;
|
||||||
document.getElementById("person").remove();
|
document.getElementById("person").remove();
|
||||||
});
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
Reference in New Issue
Block a user