diff --git a/index.php b/index.php index b94b91f..66562a6 100644 --- a/index.php +++ b/index.php @@ -170,8 +170,8 @@ function definition_courante($definitions, $position) { ?> " - data-iddv="" + data-iddh="" + data-iddv="" /> @@ -188,25 +188,23 @@ function definition_courante($definitions, $position) { return isset($definition["definition"]); }); ?> -
  • $definition): ?> - +
  • ">
  • +
    1. $definition): ?> - +
    2. "> + +
    +
  • - @@ -218,25 +216,23 @@ function definition_courante($definitions, $position) { return isset($definition["definition"]); }); ?> -
  • $definition): ?> - +
  • ">
  • +
    1. $definition): ?> - +
    2. "> + +
    +
  • - @@ -251,11 +247,9 @@ function definition_courante($definitions, $position) { de - - value="" min="" max="" /> + value="" min="" max="" /> lignes et - - value="" min="" max="" /> + value="" min="" max="" /> colonnes diff --git a/script.js b/script.js index ce1ff9c..c660983 100644 --- a/script.js +++ b/script.js @@ -17,19 +17,37 @@ for (let input of inputs) { input.onfocus = function (event) { for (li of document.querySelectorAll( - `.definitions.horizontales > ol > li:nth-child(${ - input.y + 1 - }), .definitions.verticales > ol > li:nth-child(${input.x + 1})` + `.definitions.horizontales > ol > li:nth-child(${input.y + 1}), .definitions.verticales > ol > li:nth-child(${input.x + 1})` )) { li.classList.add("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}))` + `.definitions.horizontales > ol > li:not(:nth-child(${input.y + 1})), .definitions.verticales > ol > li:not(:nth-child(${input.x + 1}))` )) { 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(); }; @@ -79,21 +97,11 @@ for (let input of inputs) { }; input.onblur = function (event) { - for (li of document.querySelectorAll( - `.definitions.horizontales > ol > li:nth-child(${ - input.y + 1 - }), .definitions.verticales > ol > li:nth-child(${input.x + 1})` - )) { + for (li of document.querySelectorAll(".definitions li")) { 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"); } - }; + } } for (let input of grilleForm.querySelectorAll(".nouvelle-grille input")) {