wait for sound end before confirm
This commit is contained in:
parent
e9d74efed9
commit
a03e5b567a
14
script.js
14
script.js
@ -83,10 +83,13 @@ function nouvelEssai() {
|
|||||||
input.disabled = true
|
input.disabled = true
|
||||||
input.value = lettre
|
input.value = lettre
|
||||||
})
|
})
|
||||||
play(sonPerdu)
|
sonPerdu.onended = function() {
|
||||||
if (confirm(`Perdu ! Le mot à trouver était : ${motATrouver.toUpperCase()}.\nRéessayer ?`)) nouvellePartie()
|
if (confirm(`Perdu ! Le mot à trouver était : ${motATrouver.toUpperCase()}.\nRéessayer ?`)) nouvellePartie()
|
||||||
else nbEssais = 0
|
else nbEssais = 0
|
||||||
}
|
}
|
||||||
|
if (volumeOn) play(sonPerdu)
|
||||||
|
else sonPerdu.onended()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function onfocus() {
|
function onfocus() {
|
||||||
@ -123,6 +126,10 @@ function play(son) {
|
|||||||
son.play()
|
son.play()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sonMotTrouve.onended = function(event) {
|
||||||
|
if (confirm("Bien joué !\nUne nouvelle partie ?")) nouvellePartie()
|
||||||
|
}
|
||||||
|
|
||||||
function onsubmit(event) {
|
function onsubmit(event) {
|
||||||
if (this.checkValidity()) {
|
if (this.checkValidity()) {
|
||||||
if (motsAutorises.includes(Array.from(form.children).map((input) => input.value).join(""))) {
|
if (motsAutorises.includes(Array.from(form.children).map((input) => input.value).join(""))) {
|
||||||
@ -157,8 +164,8 @@ function onsubmit(event) {
|
|||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (nbLettresBienPlacees == nbLettres) {
|
if (nbLettresBienPlacees == nbLettres) {
|
||||||
play(sonMotTrouve)
|
if (volumeOn) play(sonMotTrouve)
|
||||||
if (confirm("Bien joué !\nUne nouvelle partie ?")) nouvellePartie()
|
else sonMotTrouve.onended()
|
||||||
} else nouvelEssai()
|
} else nouvelEssai()
|
||||||
}, listeATrouver.length * periode)
|
}, listeATrouver.length * periode)
|
||||||
|
|
||||||
@ -172,3 +179,4 @@ function onsubmit(event) {
|
|||||||
this.reportValidity()
|
this.reportValidity()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user