chaque définition pointe vers le début du mot

This commit is contained in:
2025-12-05 17:40:16 +01:00
parent 8f1e323c8a
commit 459c0e9ed2
2 changed files with 35 additions and 21 deletions

View File

@@ -64,6 +64,18 @@ function mot_courant($mots, $position) {
} }
return []; return [];
} }
function debuts($definitions) {
$debut = 0;
$retour = [];
foreach ($definitions as $fin => $definition) {
if ($fin - $debut > 1) {
$retour[$debut] = $definition;
}
$debut = $fin + 1;
}
return $retour;
}
?> ?>
<!DOCTYPE HTML> <!DOCTYPE HTML>
<html lang="fr-FR" dir="ltr" prefix="og: https://ogp.me/ns#"> <html lang="fr-FR" dir="ltr" prefix="og: https://ogp.me/ns#">
@@ -166,26 +178,25 @@ function mot_courant($mots, $position) {
<ol type="1"> <ol type="1">
<?php <?php
foreach ($grille->definitions["horizontales"] as $y => $definitions): foreach ($grille->definitions["horizontales"] as $y => $definitions):
$definitions = array_filter( $definitions = debuts($definitions);
$definitions, function($definition) {
return isset($definition[0]);
});
?> ?>
<label for="A<?=$y + 1?>"><li> <li>
<?php if (count($definitions)): ?> <?php if (count($definitions)): ?>
<?php if (count($definitions) == 1): ?> <?php if (count($definitions) == 1): ?>
<label for="A<?=$y + 1?>">
<?= formatter_definition(reset($definitions)) ?> <?= formatter_definition(reset($definitions)) ?>
</label>
<?php else: ?> <?php else: ?>
<ol> <ol>
<?php foreach ($definitions as $definition) : ?> <?php foreach ($definitions as $debut => $definition) : ?>
<?php if (isset($definition[0])): ?> <label for="<?=chr($debut + 0x41)?><?=$y + 1?>">
<li><?= formatter_definition($definition) ?></li> <li><?= formatter_definition($definition) ?></li>
<?php endif ?> </label>
<?php endforeach ?> <?php endforeach ?>
</ol> </ol>
<?php endif ?> <?php endif ?>
<?php endif ?> <?php endif ?>
</li></label> </li>
<?php endforeach; ?> <?php endforeach; ?>
</ol> </ol>
</div> </div>
@@ -194,26 +205,25 @@ function mot_courant($mots, $position) {
<ol type="A"> <ol type="A">
<?php <?php
foreach ($grille->definitions["verticales"] as $x => $definitions): foreach ($grille->definitions["verticales"] as $x => $definitions):
$definitions = array_filter( $definitions = debuts($definitions);
$definitions, function($definition) {
return isset($definition[0]);
});
?> ?>
<label for="<?=chr($x + 0x41)?>1"><li> <li>
<?php if (count($definitions)): ?> <?php if (count($definitions)): ?>
<?php if (count($definitions) == 1): ?> <?php if (count($definitions) == 1): ?>
<?= formatter_definition(reset($definitions)) ?> <label for="<?=chr($x + 0x41)?>1">
<?= formatter_definition(reset($definitions)) ?>
</label>
<?php else: ?> <?php else: ?>
<ol> <ol>
<?php foreach ($definitions as $definition) : ?> <?php foreach ($definitions as $debut => $definition) : ?>
<?php if (isset($definition[0])): ?> <label for="<?=chr($x + 0x41)?><?=$debut + 1?>">
<li><?= formatter_definition($definition) ?></li> <li><?= formatter_definition($definition) ?></li>
<?php endif ?> </label>
<?php endforeach ?> <?php endforeach ?>
</ol> </ol>
<?php endif ?> <?php endif ?>
<?php endif ?> <?php endif ?>
</li></label> </li>
<?php endforeach; ?> <?php endforeach; ?>
</ol> </ol>
</div> </div>

View File

@@ -177,6 +177,10 @@ h2 {
opacity: 30%; opacity: 30%;
} }
.definitions label {
cursor: pointer;
}
.erreur { .erreur {
text-align: center; text-align: center;
} }