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 = ""; } }