choisir directement le nombre de lettre
This commit is contained in:
parent
d7e3fe8906
commit
369ca341e2
20
index.html
20
index.html
@ -16,22 +16,16 @@
|
||||
|
||||
<body>
|
||||
|
||||
<dialog id="optionsDialog">
|
||||
<dialog id="optionsDialog" open>
|
||||
<article>
|
||||
<header>
|
||||
<h2>L<img src="icones/lotus.svg" alt="O">TUS</h2>
|
||||
</header>
|
||||
<form id="optionsForm" action="#" method="dialog">
|
||||
<fieldset class="grid">
|
||||
<legend>
|
||||
Trouvez des mot comprenant entre
|
||||
</legend>
|
||||
<fieldset>
|
||||
<label class="option">
|
||||
<input type="number" id="minLettresInput" min="6" max="10" value="6" size="2" required/>
|
||||
et
|
||||
</label>
|
||||
<label class="option">
|
||||
<input type="number" id="maxLettresInput" min="6" max="10" value="10" size="2" required/>
|
||||
Trouvez des mot de
|
||||
<input type="number" id="nbLettresInput" min="6" max="10" value="8" size="2" step="1" required/>
|
||||
lettres.
|
||||
</label>
|
||||
</fieldset>
|
||||
@ -46,14 +40,16 @@
|
||||
</label>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<label for="volumeCheckbox" style="align-items: end;">
|
||||
<label for="volumeCheckbox" style="align-items: end;" class="option">
|
||||
<input id="volumeCheckbox" type="checkbox" role="switch" checked/>
|
||||
Effets sonores
|
||||
</label>
|
||||
</fieldset>
|
||||
</form>
|
||||
<footer>
|
||||
<button id="confirmOptionsButton" type="submit" form="optionsForm">Jouer</button>
|
||||
<button id="confirmOptionsButton" type="submit" form="optionsForm" disabled>
|
||||
<div aria-busy="true"></div>
|
||||
</button>
|
||||
</footer>
|
||||
</article>
|
||||
</dialog>
|
||||
|
14
script.js
14
script.js
@ -1,23 +1,21 @@
|
||||
const NB_ESSAIS_MAX = 6
|
||||
const periode = 400 //ms
|
||||
|
||||
var volumeOn = true
|
||||
var minLettres = 6
|
||||
var maxLettres = 10
|
||||
|
||||
window.onload = function(event) {
|
||||
optionsDialog.showModal();
|
||||
confirmOptionsButton.innerHTML = "Jouer"
|
||||
confirmOptionsButton.disabled = false
|
||||
}
|
||||
|
||||
optionsButton.onclick = function(event) {
|
||||
optionsDialog.showModal();
|
||||
}
|
||||
|
||||
var volumeOn = true
|
||||
var nbLettres = 8
|
||||
optionsForm.onsubmit = function(event) {
|
||||
if (optionsForm.checkValidity()) {
|
||||
volumeOn = volumeCheckbox.checked
|
||||
minLettres = minLettresInput.valueAsNumber
|
||||
maxLettres = maxLettresInput.valueAsNumber
|
||||
nbLettres = nbLettresInput.valueAsNumber
|
||||
optionsDialog.close()
|
||||
if (!nbEssais) nouvellePartie()
|
||||
} else {
|
||||
@ -28,11 +26,9 @@ optionsForm.onsubmit = function(event) {
|
||||
var motATrouver
|
||||
var listeATrouver
|
||||
var lettresTrouvees
|
||||
var nbLettres
|
||||
var nbEssais = 0
|
||||
function nouvellePartie() {
|
||||
nbEssais = 0
|
||||
nbLettres = minLettres + Math.floor(Math.random() * (Math.abs(maxLettres - minLettres) + 1))
|
||||
motATrouver = motsATrouver[nbLettres][Math.floor(motsATrouver[nbLettres].length * Math.random())]
|
||||
motATrouver = motATrouver.normalize("NFD").replace(/\p{Diacritic}/gu, "")
|
||||
listeATrouver = Array.from(motATrouver)
|
||||
|
Loading…
x
Reference in New Issue
Block a user