summaryrefslogtreecommitdiff
path: root/rannak/mangud/arimees/pood.bak/script.js
blob: 3b3e67b78e78e5d3f4899c17dd503c156c379cb9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
document.addEventListener('DOMContentLoaded', () => {
    let btn = document.querySelector('.modalButton');
    btn.click();
});



const kurss = 15.6;
doneCounter = 0;


const kontrollBtns = document.querySelectorAll(".kontrolliKaarti");
for (let nupp of kontrollBtns){
    nupp.addEventListener("click", (e) => {
        let rublaHind = e.target.previousElementSibling.children[0].children[1].innerHTML;
        let pakkumine = e.target.previousElementSibling.children[1].children[1].value;

        if (pakkumine*kurss == rublaHind){

            //Change color
            e.target.offsetParent.style.background = "#288654";
            e.target.previousElementSibling.children[0].style.borderRight = ".5rem solid #288654";
            e.target.previousElementSibling.children[1].style.borderLeft = ".5rem solid #288654";

            //Change Element

            (e.target.previousElementSibling.children[1].children[1]).remove();
            const newEl = document.createElement("span");
            newEl.classList.add("symbol");
            newEl.innerHTML = pakkumine + " M";
            e.target.previousElementSibling.children[1].appendChild(newEl);

            e.target.remove(); 
            doneCounter++;


            // InfoTxt
            let infoTxt = document.querySelector(".infoTxt")
            infoTxt.innerHTML = "";

            if (doneCounter >= 6){
                enableAllGood();
            }
        }


        else{
            // Inputvalue Reset
            e.target.previousElementSibling.children[1].children[1].value = "";

            // InfoTxt
            let infoTxt = document.querySelector(".infoTxt")
            infoTxt.style.color = "red";
            infoTxt.innerHTML = "Proovi Uuesti!";

        }



    })
}



function enableAllGood(){
    const btn = document.querySelector(".moveOn");
    btn.disabled = false;
    btn.onclick = () => location.href = "";
}