diff --git a/Grille.php b/Grille.php index 9b1d750..6a45b5a 100644 --- a/Grille.php +++ b/Grille.php @@ -3,7 +3,7 @@ include_once "dico.php"; -const MIN_LETTRES = 0; +const MIN_LETTRES = 1; class Grille { @@ -42,7 +42,6 @@ class Grille { } public function get_ligne($l, $longueur = 100) { - $longueur = min($longueur, $this->largeur); $ligne = ""; for ($i = 0; $i < $longueur; $i++) { $ligne .= $this->grille[$l][$i]; @@ -57,7 +56,6 @@ class Grille { } public function get_colonne($c, $longueur = 100) { - $longueur = min($longueur, $this->hauteur); $colonne = ""; for ($i = 0; $i < $longueur; $i++) { $colonne .= $this->grille[$i][$c]; diff --git a/dico.php b/dico.php index bee659c..e9dcf08 100644 --- a/dico.php +++ b/dico.php @@ -24,7 +24,7 @@ foreach ($dico as $mot => $definition) { function fisherYatesShuffle(&$items, $seed) { - @mt_srand($seed); + mt_srand($seed); for ($i = count($items) - 1; $i > 0; $i--) { $j = @mt_rand(0, $i); @@ -32,6 +32,7 @@ function fisherYatesShuffle(&$items, $seed) $items[$i] = $items[$j]; $items[$j] = $tmp; } + mt_srand(); } function mots_espaces($max, $min=0, $seed=0) { diff --git a/index.php b/index.php index 7e1a9a8..2aa32ab 100644 --- a/index.php +++ b/index.php @@ -3,6 +3,10 @@ const HAUTEUR_PAR_DEFAUT = 6; const LARGEUR_PAR_DEFAUT = 6; +echo "\n"; + $id = filter_input(INPUT_GET, 'grille', FILTER_VALIDATE_REGEXP, [ "options" => [ @@ -11,7 +15,7 @@ $id = filter_input(INPUT_GET, 'grille', FILTER_VALIDATE_REGEXP, [ ]); if (!$id) { $_GET["grille"] = uniqid(); - header("Location: " . $_SERVER['PHP_SELF'] . "?" . http_build_query($_GET)); + header("Location: " . $_SERVER['REQUEST_URI'] . "?" . http_build_query($_GET)); exit; } diff --git a/script.js b/script.js index 72c1475..3123f0e 100644 --- a/script.js +++ b/script.js @@ -19,20 +19,26 @@ inputs.forEach(input => { }; input.onkeydown = function (event) { + next_input = null; switch (event.key) { case 'ArrowUp': - inputs[(input.index - largeur + nb_cases) % nb_cases].focus(); + next_input = inputs[(input.index - largeur + nb_cases) % nb_cases]; break; case 'ArrowDown': - inputs[(input.index + largeur) % nb_cases].focus(); + next_input = inputs[(input.index + largeur) % nb_cases]; break; case 'ArrowLeft': - inputs[(input.index - 1 + nb_cases) % nb_cases].focus(); + next_input = inputs[(input.index - 1 + nb_cases) % nb_cases]; break; case 'ArrowRight': - inputs[(input.index + 1) % nb_cases].focus(); + next_input = inputs[(input.index + 1) % nb_cases]; break; } + if (next_input) { + next_input.focus(); + next_input.select(); + event.preventDefault(); + } }; input.oninput = function (event) {