diff options
author | Rasmus Luha <rasmus.luha@gmail.com> | 2022-09-24 19:56:37 +0300 |
---|---|---|
committer | Rasmus Luha <rasmus.luha@gmail.com> | 2022-09-24 19:56:37 +0300 |
commit | 03f99c33287e99e4db9e4cb4d3877fcf4114b877 (patch) | |
tree | e013ef265ccba7a310567370b926bd656ae164c6 /rannak/mangud/perenaine/ristsona/script.js | |
parent | cc12746da2f264ed0d485867a757d96bae620a64 (diff) |
ristsõna numbrid ja enter
Diffstat (limited to 'rannak/mangud/perenaine/ristsona/script.js')
-rw-r--r-- | rannak/mangud/perenaine/ristsona/script.js | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/rannak/mangud/perenaine/ristsona/script.js b/rannak/mangud/perenaine/ristsona/script.js index 121bfab..cacda18 100644 --- a/rannak/mangud/perenaine/ristsona/script.js +++ b/rannak/mangud/perenaine/ristsona/script.js @@ -12,13 +12,9 @@ function message(msg, color){ function õigeVastus(nr, vastus){ message("Õige!", "green"); - console.log(nr); let tähed = document.querySelectorAll("."+vastus); for (let i = 0; i < tähed.length; i++) { - if (i == 0) - tähed[i].childNodes[1].style.display = "inline"; - else tähed[i].childNodes[0].style.display = "inline"; } @@ -26,8 +22,6 @@ function õigeVastus(nr, vastus){ õiged.push(nr); counter++; } - console.log(counter); - console.log(õiged); if (counter >= 12) moveOnEnable(); } @@ -37,23 +31,18 @@ function valeVastus(tähed, nr, vastus){ message("Vale pakumine, proovi uuesti", "red"); for (let i = 0; i < tähed.length; i++) { - if (i == 0) - tähed[i].childNodes[1].style.display = "none"; - else tähed[i].childNodes[0].style.display = "none"; } if (õiged.includes(nr)) { delete õiged[õiged.indexOf(nr)]; counter--; - console.log(counter) } } function kontrolliVastus(nr, vastus){ nr += ''; // dont know, andis errorit - console.log(nr); switch (nr) { case "1": @@ -167,9 +156,6 @@ function kontrolliVastus(nr, vastus){ - - - function getInputValue() { // Selecting the input element and get its value let inputVal = document.getElementById("inputId").value; @@ -185,7 +171,19 @@ function getInputValue() { -// Button func +// Button funcs + +function enterSubmit(){ + document.getElementById('inputId') + .addEventListener('keyup', event => { + if (event.code === 'Enter') + { + event.preventDefault(); + getInputValue(); + } + }); +} +enterSubmit() function moveOnEnable(){ const btn = document.querySelector(".moveOn"); |