summaryrefslogtreecommitdiff
path: root/rannak/kaart/js/kaart.js
blob: 518364353ff572710473d11eaf793b4cc904bd46 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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;

    if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|BB|PlayBook|IEMobile|Windows Phone|Kindle|Silk|Opera Mini/i.test(navigator.userAgent)) {
        btn.onclick = () => location.href = "../noMobiles";
    }
    else 
        btn.onclick = () => location.href = "../rolliValik";
}