From 1c973624785b77e97791be8c917c4c13b7418be0 Mon Sep 17 00:00:00 2001 From: Rasmus Luha Date: Sat, 5 Nov 2022 23:13:57 +0200 Subject: actual restructure, previuos commit premature --- rannak/kaart/js/kaart.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 rannak/kaart/js/kaart.js (limited to 'rannak/kaart/js/kaart.js') 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"; +} -- cgit v1.2.3