petites améliorations
This commit is contained in:
parent
e234dd0ff8
commit
65e31d71c6
@ -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];
|
||||
|
3
dico.php
3
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) {
|
||||
|
@ -3,6 +3,10 @@
|
||||
const HAUTEUR_PAR_DEFAUT = 6;
|
||||
const LARGEUR_PAR_DEFAUT = 6;
|
||||
|
||||
echo "<!--\n";
|
||||
var_dump($_SERVER);
|
||||
echo "\n-->\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;
|
||||
}
|
||||
|
||||
|
14
script.js
14
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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user