summaryrefslogtreecommitdiff
path: root/rannak/mangud/perenaine/ristsona/script.js
diff options
context:
space:
mode:
Diffstat (limited to 'rannak/mangud/perenaine/ristsona/script.js')
-rw-r--r--rannak/mangud/perenaine/ristsona/script.js28
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");