summaryrefslogtreecommitdiff
path: root/rannak/mangud/arimees/muusika/script.js
blob: 85d0292f1297b88eab327423ec9ed7d7f5e03bb4 (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
70
document.addEventListener('DOMContentLoaded', () => {
    let btn = document.querySelector('.modalButton');
    btn.click();
});


allPohjendatud = false;
allSelected = false;


// EventListenres
const selectors = document.querySelectorAll('select');
for(el of selectors){
    el.addEventListener('change', () => {

        let selected = new Array();
        for (el of selectors){
            if (!selected.includes(el.value) && el.value != 'Vali')
                selected.push(el.value);
        }

        if (selected.length == 6)
            allSelected = true;
        else
            allSelected = false;
        
        if (allPohjendatud && allSelected)
            moveOnEnable();
    });
}



const pohjendused = document.querySelectorAll('textarea');
for(el of pohjendused){
    el.addEventListener('input', () => {

        let pohjendatud = new Array();
        for (el of pohjendused){
            if (!pohjendatud.includes(el) && el.value != '')
                pohjendatud.push(el);
        }

        if (pohjendatud.length == 6)
            allPohjendatud = true;
        else
            allPohjendatud = false;

        if (allPohjendatud && allSelected)
            moveOnEnable();
        
    });
}








// If All Done

function moveOnEnable(){
    const btn = document.querySelector(".moveOn");
    btn.disabled = false;
    localStorage.setItem("roll", "Ärimehe");
    btn.onclick = () => location.href = "../../../endPage";
}