Skip to content

Commit 5a9292c

Browse files
committed
Désactivation des boutons radios lorsque le jeu est fini.
1 parent 2fa9860 commit 5a9292c

File tree

2 files changed

+10
-19
lines changed

2 files changed

+10
-19
lines changed

scripts/main.js

+1-18
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,4 @@
44
*
55
*********************************************************************************/
66

7-
lancerJeu()
8-
9-
// J'ai mis ce code en commentaire, nous pourrons le récupérer lorsque nous en auront besoin :
10-
11-
// let inputEcriture = document.getElementById("inputEcriture")
12-
// console.log(inputEcriture)
13-
14-
// let btnValiderMot = document.getElementById("btnValiderMot")
15-
// console.log(btnValiderMot)
16-
17-
// let zoneProposition = document.querySelector(".zoneProposition")
18-
// console.log(zoneProposition)
19-
20-
// let spanScore = document.querySelector(".zoneScore span")
21-
// console.log(spanScore)
22-
23-
// let listeBtnRadio = document.querySelectorAll(".optionSource input")
24-
// console.log(listeBtnRadio)
7+
lancerJeu()

scripts/script.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,10 @@ function lancerJeu() {
121121
let listeProposition = listeMots
122122

123123
let btnValiderMot = document.getElementById("btnValiderMot")
124+
let listeBtnRadio = document.querySelectorAll(".optionSource input")
124125
let inputEcriture = document.getElementById("inputEcriture")
125126

127+
126128
afficherProposition(listeProposition[i])
127129

128130
// Gestion de l'événement click sur le bouton "valider"
@@ -135,14 +137,20 @@ function lancerJeu() {
135137
inputEcriture.value = ''
136138
if (listeProposition[i] === undefined) {
137139
afficherProposition("Le jeu est fini")
140+
// On désactive le bouton valider
138141
btnValiderMot.disabled = true
142+
// On désactive les boutons radios
143+
for (let indexBtnRadio = 0; indexBtnRadio < listeBtnRadio.length; indexBtnRadio++) {
144+
listeBtnRadio[indexBtnRadio].disabled = true
145+
}
146+
139147
} else {
140148
afficherProposition(listeProposition[i])
141149
}
142150
})
143151

144152
// Gestion de l'événement change sur les boutons radios.
145-
let listeBtnRadio = document.querySelectorAll(".optionSource input")
153+
146154
for (let index = 0; index < listeBtnRadio.length; index++) {
147155
listeBtnRadio[index].addEventListener("change", (event) => {
148156
// Si c'est le premier élément qui a été modifié, alors nous voulons

0 commit comments

Comments
 (0)