summaryrefslogtreecommitdiff
path: root/rannak/mangud/direktor/loosung/script.js
blob: aaf62412c989be2d0b55f87cb8db603806249aa1 (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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
document.addEventListener('DOMContentLoaded', () => {
    let btn = document.querySelector('.modalButton');
    btn.click();
});


// To Know when to move on
changedArr = new Array();




// Loosung Font
let fontPick = document.querySelector("#fontPick");
fontPick.addEventListener("change", () => {

    let loosung = document.querySelector("#loosung");
    let val = fontPick.value; 
    loosung.style.fontFamily = val;

    if (!changedArr.includes("font"))
        changedArr.push("font");
    
    CheckIfAllGood();

});



// Loosung Size
let fontSize = document.querySelector("#fontSize");
fontSize.addEventListener("change", () => {


    let loosung = document.querySelector("#loosung");
    let val = fontSize.value; 
    let newSize = parseInt(val)/10; 
     

    if (val > 50)
        loosung.style.fontSize="5rem";
    
    else if (val < 10)
        loosung.style.fontSize="1rem";
    
    else
        loosung.style.fontSize = newSize+"rem";
    

    if (!changedArr.includes("size"))
        changedArr.push("size");
    
    CheckIfAllGood();

});




// Loosung Color
let fontColor = document.querySelector("#fontColor");
fontColor.addEventListener("change", () => {

    let loosung = document.querySelector("#loosung");
    let val = fontColor.value; 
    loosung.style.color = val;


    if (!changedArr.includes("color"))
        changedArr.push("color");
    
    CheckIfAllGood();

});




// Reset BTN
let resetBtn = document.querySelector("#resetBtn");
resetBtn.addEventListener("click", () => {

    let loosung = document.querySelector("#loosung");
    loosung.style.color= "#fff";
    loosung.style.fontSize= "2rem";
    loosung.style.fontFamily= "inherit";

    fontPick.value = "tavaline";
    fontColor.value = "#ffffff";
    fontSize.value = 20;

    let moveOnBtn = document.querySelector(".moveOn");
    moveOnBtn.disabled = true;

    loosung.innerHTML = "Muuda Loosung enda omaks!";
    changedArr = new Array();

});


document.querySelector("#loosung").addEventListener("input", () => {CheckIfAllGood()})



// BulletPoints eventListener
bulletBtns = document.querySelectorAll("#sundmus");
bulletBtns.forEach(element => {
   element.addEventListener('change', () => CheckIfAllGood());
});













// Other Funcs //

function CheckIfAllGood(){
    //let radioBtn = document.querySelector("input[name='sundmuseValik']:checked");
    let loosung = document.querySelector("#loosung");

    if (document.querySelector("input[name='sundmuseValik']:checked") != null &&
    changedArr.length >= 3 && loosung.innerHTML != "Muuda loosung enda omaks!"){
        moveOnEnable();
    }

    return false
}


// If Done
function moveOnEnable(){
    const btn = document.querySelector(".moveOn");
    btn.disabled = false;
    btn.onclick = () => location.href = "../kone";
}