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
36
37
async function setIntervals() {
    try {
        const birth_intervals = await getIntervalJson();
        for (const country in birth_intervals) {
            setInterval(() => {
                const countryElement = document.getElementById(country);
                if (countryElement) {
                    countryElement.style.animation = 'none';
                    setTimeout(() => {
                        countryElement.style.animation = `flashColor 1s`;
                    }, 0);
                } else {
                    console.log("setInterval failed: " + country);
                }
            }, birth_intervals[country]);
        }
    } catch (error) {
        console.error("Failed to set intervals:", error);
    }
}

function getIntervalJson() {
    console.log("Fetching birth_intervals.json");
    return fetch('birth-map/birth_intervals.json')
        .then(response => {
            if (!response.ok) {
                throw new Error("Bad network response.");
            }
            return response.json();
        })
        .catch(error => {
            console.error("Failed to load birth rates:", error);
            throw error;
        });
}

setIntervals();