From e75e6b4bc16ac11e939b28653658acd4c93bf69f Mon Sep 17 00:00:00 2001 From: adrien Date: Sun, 11 Oct 2020 02:41:54 +0200 Subject: [PATCH] small enhancements --- game.php | 26 ++++++++++++++----------- style.css | 38 ++++++++++++++++++++++-------------- sudoku.js | 58 ++++++++++++++++++++++++++++++++++--------------------- 3 files changed, 75 insertions(+), 47 deletions(-) diff --git a/game.php b/game.php index 18802cc..8cfba39 100644 --- a/game.php +++ b/game.php @@ -35,9 +35,14 @@ $value = ""; $disabled = ""; } else { - $disabled = " disabled"; + $disabled = "disabled"; } - echo " \n"; +?> + + /> + + + @@ -57,8 +62,7 @@
- - +
@@ -77,10 +81,6 @@ - - - - @@ -89,16 +89,20 @@ + + + +
Raccourcis clavier
TabDéplacement
+ 1~9 Surligner + Z Annuler
Tab, Maj + TabDéplacement
-
+
+ un chiffre entre 1 et 9 pour les cases connues
  • un point pour les case vides
  • - Exemple :
    + Exemple :
    { + option = document.createElement('option') + option.value = candidate + box.list.appendChild(option) + }) + } } } @@ -69,9 +73,9 @@ function onfocus() { } function oninput() { - history.push({input: this, value: this.previousValue}) - undoButton.disabled = false - refresh(this) + history.push({input: this, value: this.previousValue}) + undoButton.disabled = false + refresh(this) } function refresh(box) { @@ -86,16 +90,22 @@ function refresh(box) { for (neighbour1 of box.neighbourhood) { neighbour1.setCustomValidity("") if (neighbour1.value.length) { - for (area of [ - {name: "région", neighbours: regions[neighbour1.regionId]}, - {name: "ligne", neighbours: rows[neighbour1.rowId]}, - {name: "colonne", neighbours: columns[neighbour1.columnId]}, - ]) - for (neighbour2 of area.neighbours) - if (neighbour2 != neighbour1 && neighbour2.value == neighbour1.value) { - neighbour1.setCustomValidity(`Il y a un autre ${neighbour1.value} dans cette ${area.name}.`) - neighbour2.setCustomValidity(`Il y a un autre ${neighbour1.value} dans cette ${area.name}.`) - } + if (neighbour1.candidates.size) { + for (area of [ + {name: "région", neighbours: regions[neighbour1.regionId]}, + {name: "ligne", neighbours: rows[neighbour1.rowId]}, + {name: "colonne", neighbours: columns[neighbour1.columnId]}, + ]) + for (neighbour2 of area.neighbours) + if (neighbour2 != neighbour1 && neighbour2.value == neighbour1.value) { + for (neighbour of [neighbour1, neughbour2]) { + neighbour.setCustomValidity(`Il y a un autre ${neighbour.value} dans cette ${area.name}.`) + } + } + } + } else if (neighbour1.candidates.size == 0) { + console.log("rezgzgzg") + neighbour1.setCustomValidity("Aucun value possible !") } } @@ -111,8 +121,8 @@ function refresh(box) { suggestionTimer = setTimeout(showSuggestion, 30000) } } else { // Errors on grid - box.select() box.reportValidity() + box.select() } } @@ -151,6 +161,10 @@ function highlight(value) { } else { highlightedValue = value } + for (button of buttons.getElementsByTagName("button")) { + if (button.textContent == highlightedValue) button.className = "same-value" + else button.className = "" + } highlightAndTab() boxes.filter(box => box.value == "" && box.tabIndex == 0)[0].focus() }