diff options
author | Rasmus <rasmus.luha@gmail.com> | 2023-04-01 16:15:52 +0300 |
---|---|---|
committer | Rasmus <rasmus.luha@gmail.com> | 2023-04-01 16:15:52 +0300 |
commit | ba837f70632519d58ae0f3f95bfad0dbb8051fc0 (patch) | |
tree | 3fc7d6b8715d4e7818d197d8408c791af28da608 /rannak/mangud/direktor/loosung/script.js | |
parent | 760e8fff4d4fd71350ddc9b17e85e95a17d4ce8e (diff) |
Loosung ja Baltikett
Diffstat (limited to 'rannak/mangud/direktor/loosung/script.js')
-rw-r--r-- | rannak/mangud/direktor/loosung/script.js | 124 |
1 files changed, 124 insertions, 0 deletions
diff --git a/rannak/mangud/direktor/loosung/script.js b/rannak/mangud/direktor/loosung/script.js new file mode 100644 index 0000000..191d743 --- /dev/null +++ b/rannak/mangud/direktor/loosung/script.js @@ -0,0 +1,124 @@ +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; + + loosung.innerHTML = "Muuda Loosung enda omaks!"; + changedArr = new Array(); +}); + + +document.querySelector("#loosung").addEventListener("input", () => {CheckIfAllGood()}) + + + + +// 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 = ""; +} + |