summaryrefslogtreecommitdiff
path: root/rannak/algus/kaart/js
diff options
context:
space:
mode:
authorRasmus Luha <rasmus.luha@gmail.com>2022-09-17 00:17:34 +0300
committerRasmus Luha <rasmus.luha@gmail.com>2022-09-17 00:17:34 +0300
commit2863a49dd0cdae245a741f533c8861c1c8b97fd6 (patch)
treeade3d224162790ed3844f601c7802ee7065683cb /rannak/algus/kaart/js
init commit
Diffstat (limited to 'rannak/algus/kaart/js')
-rw-r--r--rannak/algus/kaart/js/kaart.js33
1 files changed, 33 insertions, 0 deletions
diff --git a/rannak/algus/kaart/js/kaart.js b/rannak/algus/kaart/js/kaart.js
new file mode 100644
index 0000000..5d1a1a3
--- /dev/null
+++ b/rannak/algus/kaart/js/kaart.js
@@ -0,0 +1,33 @@
+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 button = document.querySelector(".btn");
+ button.classList.remove('disabled');
+ button.setAttribute('aria-disabled', false);
+ console.log("done");
+
+ counter = 0;
+}