summaryrefslogtreecommitdiff
path: root/rannak/mangud/partorg/plakat/script.js
blob: 4d4ee365912a3da46884f304b8ef768935dcd84f (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
document.addEventListener('DOMContentLoaded', () => {
    let btn = document.querySelector('.modalButton');
    btn.click();
});









// FROM HERE TODO


// Init Setup - to access later
let dingDong = document.querySelector(".addedText");
dingDong.style.top = "50%";
dingDong.style.left = "50%";


// Position
const ules = document.querySelectorAll(".ules");
const alla = document.querySelectorAll(".alla");
const vasak = document.querySelectorAll(".vasak");
const parem = document.querySelectorAll(".parem");

ules.forEach(el => {
    el.addEventListener("click" , e => {
        let theText = e.target.parentElement.parentElement.parentElement.childNodes[1].childNodes[1];
        let curTop = theText.style["top"];
        curTop = curTop.substring(0, curTop.length-1)
        
        if (Number(curTop) >= 5)
            theText.style["top"] = Number(curTop)-5+"%";
    });
})

alla.forEach(el => {
    el.addEventListener("click" , e => {
        let theText = e.target.parentElement.parentElement.parentElement.childNodes[1].childNodes[1];
        let curTop = theText.style["top"];
        curTop = curTop.substring(0, curTop.length-1)
        
        if (Number(curTop) <= 85)
            theText.style["top"] = Number(curTop)+5+"%";
    });
})

vasak.forEach(el => {
    el.addEventListener("click", e => {
        let theText = e.target.parentElement.parentElement.parentElement.childNodes[1].childNodes[1];
        let curLeft = theText.style["left"];
        curLeft = curLeft.substring(0, curLeft.length-1)

        console.log("Vasak");
        console.log(theText.innerHTML);
        
        if (Number(curLeft) >= 5)
            theText.style["left"] = Number(curLeft)-5+"%";
    });
})

parem.forEach(el => {
    el.addEventListener("click", e => {
        let theText = e.target.parentElement.parentElement.parentElement.childNodes[1].childNodes[1];
        let curLeft = theText.style["left"];
        curLeft = curLeft.substring(0, curLeft.length-1)
        
        if (Number(curLeft) >= 5)
            theText.style["left"] = Number(curLeft)+5+"%";
    });
})




// Muuda Text button

const muudaBtn = document.querySelector(".muuda");

muudaBtn.addEventListener("click", e => {
    console.log(e);
});











function checkIfAllGood(){
	let rightDone = [];

	for (let j=0; j < lists.length; j++){
		const list = lists[j];
		if (list.className.includes("startBasket"))
			continue;
		else if (list.children.length == 1){
			if (list.id == list.children[0].id){
				if (!rightDone.includes(list.id))
					rightDone.push(list.id);
			}
		}
	}  // For loop end

	if (rightDone.length == 6) {
        const btn = document.querySelector(".moveOn");
        btn.disabled = false;
        btn.onclick = () => location.href = "";
	}
}