show number of candidates in tooltip

This commit is contained in:
Adrien MALINGREY 2020-10-26 00:07:22 +01:00
parent 661a25638e
commit 0c79b4fd53
2 changed files with 15 additions and 8 deletions

5
app.js
View File

@ -38,8 +38,9 @@ window.onload = function() {
box.neighbourhood = new Set(rows[box.rowId].concat(columns[box.columnId]).concat(regions[box.regionId])) box.neighbourhood = new Set(rows[box.rowId].concat(columns[box.columnId]).concat(regions[box.regionId]))
box.neighbourhood.delete(box) box.neighbourhood.delete(box)
box.neighbourhood = Array.from(box.neighbourhood) box.neighbourhood = Array.from(box.neighbourhood)
searchCandidatesOf(box)
}) })
boxes.forEach(searchCandidatesOf)
enableButtons() enableButtons()
highlightAndTab() highlightAndTab()
@ -58,6 +59,8 @@ window.onload = function() {
function searchCandidatesOf(box) { function searchCandidatesOf(box) {
box.candidates = new Set(VALUES) box.candidates = new Set(VALUES)
box.neighbourhood.forEach(neighbour => box.candidates.delete(neighbour.value)) box.neighbourhood.forEach(neighbour => box.candidates.delete(neighbour.value))
if (!box.disabled)
box.title = box.candidates.size + (box.candidates.size <= 1 ? " possibilité [Clic-droit]" : " possibilités [Clic-droit]")
} }
function onfocus() { function onfocus() {

View File

@ -33,15 +33,19 @@
<?php <?php
for ($column = 0; $column < 9; $column++) { for ($column = 0; $column < 9; $column++) {
$value = $gridStr[9*$row+$column]; $value = $gridStr[9*$row+$column];
if ($value == UNKNOWN) {
$value = "";
$disabled = "";
} else {
$disabled = "disabled";
}
?> ?>
<td> <td>
<input type='number' min='1' max='9' step='1' value='<?=$value?>' title='Valeurs possibles [Clic-droit]' <?=$disabled?>/> <?php
if ($value == UNKNOWN) {
?>
<input type='number' min='1' max='9' step='1' value='' title='Valeurs possibles [Clic-droit]'/>
<?php
} else {
?>
<input type='number' min='1' max='9' step='1' value='<?=$value?>' disabled/>
<?php
}
?>
</td> </td>
<?php <?php
} }