From c09d51555d65505694a314ece2b959653bf3fc65 Mon Sep 17 00:00:00 2001 From: adrien Date: Fri, 13 Nov 2020 02:12:58 +0100 Subject: [PATCH] automatically insert only candidate on click --- sudoku.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/sudoku.js b/sudoku.js index a98540e..a905ece 100644 --- a/sudoku.js +++ b/sudoku.js @@ -110,11 +110,19 @@ function onfocus() { } function onclick() { - if (inkPenRadio.checked) { + if (this.value == "" && this.candidates.size == 1) { + valueToInsert = this.candidates.values().next().value + document.getElementById("insertRadio" + valueToInsert).checked = true this.value = valueToInsert + } else if (inkPenRadio.checked) { + if (valueToInsert) + this.value = valueToInsert + else + this.select() } else if (pencilRadio.checked) { - this.value += valueToInsert - } else { + if (valueToInsert) + this.value += valueToInsert + } else if (eraserRadio.checked) { this.value = "" this.placeholder = "" }