afficher la définition du mot courant

This commit is contained in:
2025-12-06 16:51:38 +01:00
parent b1704dce72
commit 976498e8be
2 changed files with 42 additions and 40 deletions

View File

@@ -170,8 +170,8 @@ function definition_courante($definitions, $position) {
?> ?>
<input id="case-<?= chr($x + 65) . ($y + 1) ?>" type="text" maxlength="1" size="1" <input id="case-<?= chr($x + 65) . ($y + 1) ?>" type="text" maxlength="1" size="1"
pattern="[A-Z]" title="<?= $title ?>" pattern="[A-Z]" title="<?= $title ?>"
data-iddh="<?= isset($definition_horizontale["definition"])? "dh-$y.$iddh" : "" ?>" data-iddh="<?= isset($definition_horizontale["definition"])? "dh-$y-$iddh" : "" ?>"
data-iddv="<?= isset($definition_verticale["definition"])? "dv-$x.$iddv" : "" ?>" data-iddv="<?= isset($definition_verticale["definition"])? "dv-$x-$iddv" : "" ?>"
/> />
</td> </td>
<?php endif; ?> <?php endif; ?>
@@ -188,25 +188,23 @@ function definition_courante($definitions, $position) {
return isset($definition["definition"]); return isset($definition["definition"]);
}); });
?> ?>
<li>
<?php if (count($definitions)): ?> <?php if (count($definitions)): ?>
<?php if (count($definitions) == 1): ?> <?php if (count($definitions) == 1): ?>
<?php foreach ($definitions as $id => $definition): ?> <?php foreach ($definitions as $id => $definition): ?>
<label id="<?= "dh-$y.$id" ?>" for="case-1<?= $y + 1 ?>"> <li id="<?= "dh-$y-$id" ?>"><label for="case-A<?= $y + 1 ?>"><?= formatter_definition($definition) ?></label></li>
<?= formatter_definition($definition) ?>
</label>
<?php endforeach ?> <?php endforeach ?>
<?php else: ?> <?php else: ?>
<li>
<ol> <ol>
<?php foreach ($definitions as $id => $definition): ?> <?php foreach ($definitions as $id => $definition): ?>
<label id="<?= "dh-$y.$id" ?>" for="case-<?= chr($definition["debut"] + 0x41) ?><?= $y + 1 ?>"> <li id="<?= "dh-$y-$id" ?>">
<li><?= formatter_definition($definition) ?></li> <label for="case-<?= chr($definition["debut"] + 0x41) ?><?= $y + 1 ?>"><?= formatter_definition($definition) ?></label>
</label> </li>
<?php endforeach ?> <?php endforeach ?>
</ol> </ol>
</li>
<?php endif ?> <?php endif ?>
<?php endif ?> <?php endif ?>
</li>
<?php endforeach ?> <?php endforeach ?>
</ol> </ol>
</div> </div>
@@ -218,25 +216,23 @@ function definition_courante($definitions, $position) {
return isset($definition["definition"]); return isset($definition["definition"]);
}); });
?> ?>
<li>
<?php if (count($definitions)): ?> <?php if (count($definitions)): ?>
<?php if (count($definitions) == 1): ?> <?php if (count($definitions) == 1): ?>
<?php foreach ($definitions as $id => $definition): ?> <?php foreach ($definitions as $id => $definition): ?>
<label id="<?= "dv-$x.$id" ?>" for="case-<?= chr($x + 0x41) ?>1"> <li id="<?= "dv-$x-$id" ?>"><label for="case-<?= chr($x + 0x41) ?>1"><?= formatter_definition($definition) ?></label></li>
<?= formatter_definition($definition) ?>
</label>
<?php endforeach ?> <?php endforeach ?>
<?php else: ?> <?php else: ?>
<li>
<ol> <ol>
<?php foreach ($definitions as $id => $definition): ?> <?php foreach ($definitions as $id => $definition): ?>
<label id="<?= "dv-$x.$id" ?>" for="case-<?= chr($x + 0x41) ?><?= $definition["debut"] + 1 ?>"> <li id="<?= "dv-$x-$id" ?>">
<li><?= formatter_definition($definition) ?></li> <label for="case-<?= chr($x + 0x41) ?><?= $definition["debut"] + 1 ?>"><?= formatter_definition($definition) ?></label>
</label> </li>
<?php endforeach ?> <?php endforeach ?>
</ol> </ol>
</li>
<?php endif ?> <?php endif ?>
<?php endif ?> <?php endif ?>
</li>
<?php endforeach ?> <?php endforeach ?>
</ol> </ol>
</div> </div>
@@ -251,11 +247,9 @@ function definition_courante($definitions, $position) {
<img src="favicons/favicon.svg" width="16" height="16"> <img src="favicons/favicon.svg" width="16" height="16">
<button type="submit">Nouvelle grille</button> <button type="submit">Nouvelle grille</button>
de de
<input type="number" id="lignes" <?= isset($_GET["lignes"]) ? ' name="lignes"' : "" ?> <input type="number" id="lignes" <?= isset($_GET["lignes"]) ? ' name="lignes"' : "" ?> value="<?= $hauteur ?>" min="<?= HAUTEUR_MIN ?>" max="<?= HAUTEUR_MAX ?>" />
value="<?= $hauteur ?>" min="<?= HAUTEUR_MIN ?>" max="<?= HAUTEUR_MAX ?>" />
lignes et lignes et
<input type="number" id="colonnes" <?= isset($_GET["colonnes"]) ? ' name="colonnes"' : "" ?> <input type="number" id="colonnes" <?= isset($_GET["colonnes"]) ? ' name="colonnes"' : "" ?> value="<?= $largeur ?>" min="<?= LARGEUR_MIN ?>" max="<?= LARGEUR_MAX ?>" />
value="<?= $largeur ?>" min="<?= LARGEUR_MIN ?>" max="<?= LARGEUR_MAX ?>" />
colonnes colonnes
</div> </div>
</form> </form>

View File

@@ -17,19 +17,37 @@ for (let input of inputs) {
input.onfocus = function (event) { input.onfocus = function (event) {
for (li of document.querySelectorAll( for (li of document.querySelectorAll(
`.definitions.horizontales > ol > li:nth-child(${ `.definitions.horizontales > ol > li:nth-child(${input.y + 1}), .definitions.verticales > ol > li:nth-child(${input.x + 1})`
input.y + 1
}), .definitions.verticales > ol > li:nth-child(${input.x + 1})`
)) { )) {
li.classList.add("selectionee"); li.classList.add("selectionee");
} }
for (li of document.querySelectorAll( for (li of document.querySelectorAll(
`.definitions.horizontales > ol > li:not(:nth-child(${ `.definitions.horizontales > ol > li:not(:nth-child(${input.y + 1})), .definitions.verticales > ol > li:not(:nth-child(${input.x + 1}))`
input.y + 1
})), .definitions.verticales > ol > li:not(:nth-child(${input.x + 1}))`
)) { )) {
li.classList.add("non-selectionee"); li.classList.add("non-selectionee");
} }
if (input.dataset.iddh) {
for (li of document.querySelectorAll(`.definitions.horizontales ol li ol #${input.dataset.iddh}`)) {
for (liVoisin of li.parentElement.querySelectorAll("li")) {
if (liVoisin == li) {
liVoisin.classList.add("selectionee");
} else {
liVoisin.classList.add("non-selectionee");
}
}
}
}
if (input.dataset.iddv) {
for (li of document.querySelectorAll(`.definitions.verticales ol li ol #${input.dataset.iddv}`)) {
for (liVoisin of li.parentElement.querySelectorAll("li")) {
if (liVoisin == li) {
liVoisin.classList.add("selectionee");
} else {
liVoisin.classList.add("non-selectionee");
}
}
}
}
input.select(); input.select();
}; };
@@ -79,21 +97,11 @@ for (let input of inputs) {
}; };
input.onblur = function (event) { input.onblur = function (event) {
for (li of document.querySelectorAll( for (li of document.querySelectorAll(".definitions li")) {
`.definitions.horizontales > ol > li:nth-child(${
input.y + 1
}), .definitions.verticales > ol > li:nth-child(${input.x + 1})`
)) {
li.classList.remove("selectionee"); li.classList.remove("selectionee");
}
for (li of document.querySelectorAll(
`.definitions.horizontales > ol > li:not(:nth-child(${
input.y + 1
})), .definitions.verticales > ol > li:not(:nth-child(${input.x + 1}))`
)) {
li.classList.remove("non-selectionee"); li.classList.remove("non-selectionee");
} }
}; }
} }
for (let input of grilleForm.querySelectorAll(".nouvelle-grille input")) { for (let input of grilleForm.querySelectorAll(".nouvelle-grille input")) {