un peu de style et de js
This commit is contained in:
parent
341ac43d86
commit
c5e13c277e
4
dico.php
4
dico.php
@ -36,9 +36,9 @@ function mots_espaces($max, $min=0) {
|
|||||||
foreach ($mots_de_n_lettres[$i] as $mot1) {
|
foreach ($mots_de_n_lettres[$i] as $mot1) {
|
||||||
foreach (mots_espaces($max - $i -1, $min) as $mot2) {
|
foreach (mots_espaces($max - $i -1, $min) as $mot2) {
|
||||||
if ($mot1 != $mot2) {
|
if ($mot1 != $mot2) {
|
||||||
$dico["$mot1 $mot2"] = $dico[$mot1] && $dico[$mot2] ? "{$dico[$mot1]}. {$dico[$mot2]}." : $dico[$mot1] . $dico[$mot2];
|
$dico["$mot1 $mot2"] = $dico[$mot1] && $dico[$mot2] ? "{$dico[$mot1]}<br/>{$dico[$mot2]}." : $dico[$mot1] . $dico[$mot2];
|
||||||
yield "$mot1 $mot2";
|
yield "$mot1 $mot2";
|
||||||
$dico["$mot2 $mot1"] = $dico[$mot2] && $dico[$mot1] ? "{$dico[$mot2]}. {$dico[$mot1]}." : $dico[$mot2] . $dico[$mot1];
|
$dico["$mot2 $mot1"] = $dico[$mot2] && $dico[$mot1] ? "{$dico[$mot2]}<br/>{$dico[$mot1]}." : $dico[$mot2] . $dico[$mot1];
|
||||||
yield "$mot2 $mot1";
|
yield "$mot2 $mot1";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
74
index.php
74
index.php
@ -37,36 +37,36 @@ $grille = new Grille($hauteur, $largeur);
|
|||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<div class="grille">
|
<form id="grilleForm" class="grille">
|
||||||
<table class="grille">
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<th></th>
|
<th></th>
|
||||||
<?php for ($c = 0; $c < $largeur; $c++): ?>
|
<?php for ($c = 0; $c < $largeur; $c++): ?>
|
||||||
<th><?= chr($c + 65) ?></th>
|
<th><?= chr($c + 65) ?></th>
|
||||||
<?php endfor; ?>
|
<?php endfor; ?>
|
||||||
</tr>
|
</tr>
|
||||||
<?php for ($l = 0; $l < $hauteur; $l++): ?>
|
<?php for ($l = 0; $l < $hauteur; $l++): ?>
|
||||||
<tr>
|
<tr>
|
||||||
<th><?= $l + 1 ?></th>
|
<th><?= $l + 1 ?></th>
|
||||||
<?php for ($c = 0; $c < $largeur; $c++): ?>
|
<?php for ($c = 0; $c < $largeur; $c++): ?>
|
||||||
<td class="case <?= $grille->grille[$l][$c]==" "?"noire": "blanche" ?>">
|
<td class="case <?= $grille->grille[$l][$c] == " " ? "noire" : "blanche" ?>">
|
||||||
<?php if ($grille->grille[$l][$c] == " "): ?>
|
<?php if ($grille->grille[$l][$c] == " "): ?>
|
||||||
<input type="text" maxlength="1" size="1" name="<?= $l . $c ?>" value=" " disabled/>
|
<input type="text" maxlength="1" size="1" name="<?= $l . $c ?>" value=" " disabled />
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<input type="text" maxlength="1" size="1" name="<?= $l . $c ?>" />
|
<input type="text" maxlength="1" size="1" name="<?= $l . $c ?>" required pattern="[A-Z]" />
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</td>
|
</td>
|
||||||
<?php endfor; ?>
|
<?php endfor; ?>
|
||||||
</tr>
|
</tr>
|
||||||
<?php endfor; ?>
|
<?php endfor; ?>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</form>
|
||||||
<div class="definitions">
|
<div class="definitions">
|
||||||
<div class="horizontales">
|
<div class="horizontales">
|
||||||
<h2>Horizontalement</h2>
|
<h2>Horizontalement</h2>
|
||||||
<ol>
|
<ol>
|
||||||
<?php for ($l = 0; $l < $hauteur; $l++): ?>
|
<?php for ($l = 0; $l < $hauteur; $l++): ?>
|
||||||
<li><?= $dico[$grille->get_ligne($l, $largeur)] ?></li>
|
<li><?= $dico[$grille->get_ligne($l, $largeur)] ?></li>
|
||||||
<?php endfor; ?>
|
<?php endfor; ?>
|
||||||
</ol>
|
</ol>
|
||||||
</div>
|
</div>
|
||||||
@ -74,10 +74,48 @@ $grille = new Grille($hauteur, $largeur);
|
|||||||
<h2>Verticalement</h2>
|
<h2>Verticalement</h2>
|
||||||
<ol type="A">
|
<ol type="A">
|
||||||
<?php for ($c = 0; $c < $largeur; $c++): ?>
|
<?php for ($c = 0; $c < $largeur; $c++): ?>
|
||||||
<li><?= $dico[$grille->get_colonne($c, $hauteur)] ?></li>
|
<li><?= $dico[$grille->get_colonne($c, $hauteur)] ?></li>
|
||||||
<?php endfor; ?>
|
<?php endfor; ?>
|
||||||
</ol>
|
</ol>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
const inputs = Array.from(grilleForm.querySelectorAll('input[type="text"]'))
|
||||||
|
let largeur = <?= $largeur ?>;
|
||||||
|
let nb_cases = inputs.length
|
||||||
|
let index = 0
|
||||||
|
inputs.forEach(input => {
|
||||||
|
input.index = index++
|
||||||
|
input.onfocus = function() {
|
||||||
|
this.select();
|
||||||
|
}
|
||||||
|
input.oninput = function() {
|
||||||
|
this.value = this.value.toUpperCase()
|
||||||
|
if (!input.checkValidity()) {
|
||||||
|
input.value = ""
|
||||||
|
}
|
||||||
|
if (grilleForm.checkValidity()) {
|
||||||
|
window.setTimeout(() => alert("Grille validée !"), 100)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
input.onkeydown = function(event) {
|
||||||
|
switch (event.key) {
|
||||||
|
case "ArrowUp":
|
||||||
|
inputs[(input.index - largeur + nb_cases) % nb_cases].focus()
|
||||||
|
break;
|
||||||
|
case "ArrowDown":
|
||||||
|
inputs[(input.index + largeur) % nb_cases].focus()
|
||||||
|
break;
|
||||||
|
case "ArrowLeft":
|
||||||
|
inputs[(input.index - 1 + nb_cases) % nb_cases].focus()
|
||||||
|
break;
|
||||||
|
case "ArrowRight":
|
||||||
|
inputs[(input.index + 1) % nb_cases].focus()
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
</html>
|
</html>
|
30
style.css
30
style.css
@ -4,7 +4,29 @@ body {
|
|||||||
|
|
||||||
.grille {
|
.grille {
|
||||||
margin: 2rem auto;
|
margin: 2rem auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.grille table {
|
||||||
border-collapse: collapse;
|
border-collapse: collapse;
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
tr:nth-of-type(2) td {
|
||||||
|
border-top: 3px solid black;
|
||||||
|
}
|
||||||
|
tr:last-of-type td {
|
||||||
|
border-bottom: 3px solid black;
|
||||||
|
}
|
||||||
|
td:first-of-type {
|
||||||
|
border-left: 3px solid black;
|
||||||
|
}
|
||||||
|
td:last-child {
|
||||||
|
border-right: 3px solid black;
|
||||||
|
}
|
||||||
|
|
||||||
|
td {
|
||||||
|
border: 1px solid black;
|
||||||
|
padding: 2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
th, td {
|
th, td {
|
||||||
@ -13,11 +35,6 @@ th, td {
|
|||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
td {
|
|
||||||
border: 1px solid black;
|
|
||||||
padding: 2px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.case.noire {
|
.case.noire {
|
||||||
background-color: black;
|
background-color: black;
|
||||||
}
|
}
|
||||||
@ -28,7 +45,7 @@ input {
|
|||||||
border: none;
|
border: none;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
font-size: 1em;
|
font-size: 1.2em;
|
||||||
}
|
}
|
||||||
|
|
||||||
input[disabled] {
|
input[disabled] {
|
||||||
@ -42,4 +59,5 @@ input[disabled] {
|
|||||||
|
|
||||||
.definitions h2 {
|
.definitions h2 {
|
||||||
font-variant-caps: petite-caps;
|
font-variant-caps: petite-caps;
|
||||||
|
text-align: center;
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user