diff options
Diffstat (limited to 'rannak/kaart/js')
-rw-r--r-- | rannak/kaart/js/kaart.js | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/rannak/kaart/js/kaart.js b/rannak/kaart/js/kaart.js new file mode 100644 index 0000000..4bb0afe --- /dev/null +++ b/rannak/kaart/js/kaart.js @@ -0,0 +1,30 @@ +const riigid = document.querySelectorAll("svg path") + +// Praegu Eesti, Portugal, Holland +const leitavad = ["EE", "PT", "NL"] +let leitud = []; + +// Add click listener +for (let i = 0; i < riigid.length; i++){ + if (leitavad.includes(riigid[i].id)){ + riigid[i].addEventListener("click", e => { + e.target.style.fill = "#00FF00"; + if (!leitud.includes(e.target.id)) + leitud.push(riigid[i].id); + + if (leitavad.length == leitud.length) + moveOnEnable(); + }) + } + else{ + riigid[i].addEventListener("click", e => { + e.target.style.fill = "#FF0000"; + }) + } +} + +function moveOnEnable(){ + const btn = document.querySelector(".moveOn"); + btn.disabled = false; + btn.onclick = () => location.href = "../rolliValik"; +} |