From 9aea68272393fd848150500cd25bf33761911713 Mon Sep 17 00:00:00 2001 From: adrien Date: Fri, 26 Apr 2024 21:22:34 +0200 Subject: [PATCH] =?UTF-8?q?r=C3=A8gles=20du=20jeu?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 39 +++++++++++++++++++++++++-------------- script.js | 26 ++++++++++++-------------- style.css | 16 +++++++++++----- 3 files changed, 48 insertions(+), 33 deletions(-) diff --git a/index.html b/index.html index 2d672cc..86c5e76 100644 --- a/index.html +++ b/index.html @@ -19,29 +19,40 @@
-

LOTUS

+

LOTUS

-
-
diff --git a/script.js b/script.js index 10bdc85..e9f8a52 100644 --- a/script.js +++ b/script.js @@ -13,19 +13,16 @@ optionsButton.onclick = function(event) { optionsDialog.showModal(); } -cancelOptionsButton.onclick = function(event) { - volumeCheckbox.checked = volumeOn - minLettresInput.value = minLettres - maxLettresInput.value = maxLettres - optionsDialog.close() -} - confirmOptionsButton.onclick = function(event) { - volumeOn = volumeCheckbox.checked - minLettres = Math.min(minLettresInput.value, maxLettresInput.value) - maxLettres = Math.max(minLettresInput.value, maxLettresInput.value) - optionsDialog.close() - if (!nbEssais) nouvellePartie() + if (optionsForm.checkValidity()) { + volumeOn = volumeCheckbox.checked + minLettres = Math.min(minLettresInput.value, maxLettresInput.value) + maxLettres = Math.max(minLettresInput.value, maxLettresInput.value) + optionsDialog.close() + if (!nbEssais) nouvellePartie() + } else { + optionsForm.reportValidity() + } } var motATrouver @@ -68,6 +65,7 @@ function nouvelEssai() { input.size = 1 input.pattern = "[a-z]" input.placeholder = "." + input.classList.add("lettre") input.onfocus = onfocus input.onkeydown = onkeydown input.oninput = oninput @@ -132,7 +130,7 @@ function onsubmit(event) { delete(inputsNonValides[indice]) nbLettresBienPlacees++ setTimeout(() => { - input.className = "lettre-bien-placee" + input.classList.add("bien-placee") if (volumeOn) sonLettreBienPlacee.play() }, periode * indice) } @@ -144,7 +142,7 @@ function onsubmit(event) { if (index >= 0) { delete(lettresATrouver[index]) setTimeout(() => { - input.className = "lettre-mal-placee" + input.classList.add("mal-placee") if (volumeOn) sonLettreMalPlacee.play() }, periode * indice) } else { diff --git a/style.css b/style.css index 7beafbb..89c4679 100644 --- a/style.css +++ b/style.css @@ -12,7 +12,7 @@ h1 { } h1 img, -h3 img { +h2 img { background-color: var(--pico-h1-color); border-radius: 100%; background-origin: content-box; @@ -21,12 +21,18 @@ h3 img { vertical-align: baseline; } +label.option { + display: flex; + align-items: baseline; + gap: 1em; +} + #grille { width: fit-content; margin: auto; } -#grille input[type=text] { +input.lettre { font-size: 1.5em; text-transform: capitalize; width: 1.3em; @@ -37,15 +43,15 @@ h3 img { vertical-align: text-top; } -.lettre-bien-placee { +input.bien-placee { background-color: #D93526D0; } -.lettre-mal-placee { +input.mal-placee { background-image: radial-gradient(ellipse at center, #FFBF00A0 70%, transparent 70%); background-repeat: no-repeat; } -#grille input[type=text]:disabled { +input.lettre:disabled { opacity: 100%; } \ No newline at end of file