This commit is contained in:
a-ill 2023-07-22 13:27:43 +03:00
parent 2c80026aba
commit 19a1b8d080
2 changed files with 28 additions and 5 deletions

View File

@ -4,11 +4,11 @@
// Import statements // Import statements
import { onMount } from 'svelte' import { onMount } from 'svelte'
import { writable } from 'svelte/store'; import { writable } from 'svelte/store';
import { addMarkersGroups, groupsMarkersLayer } from '/js/groups.js' import { addMarkersGroups, groupsMarkersLayer, translate } from '/js/groups.js'
import { addMarkersCoops, coopsMarkersLayer } from '/js/coops.js' import { addMarkersCoops, coopsMarkersLayer } from '/js/coops.js'
import { addMarkersCommunes, communesMarkersLayer } from '/js/communes.js' import { addMarkersCommunes, communesMarkersLayer } from '/js/communes.js'
import { addMarkersParties, partiesMarkersLayer } from '/js/parties.js' import { addMarkersParties, partiesMarkersLayer } from '/js/parties.js'
import { loadLocaleContent } from "/js/libraries/serverTools.js" import { loadLocaleContent, getData } from "/js/libraries/serverTools.js"
// Import components // Import components
import "/js/components/map-component.js" import "/js/components/map-component.js"
@ -18,6 +18,8 @@
let gridWidth let gridWidth
let loaded = writable(0) let loaded = writable(0)
let content = writable({}) let content = writable({})
let groups
let groupsByCountry
function changeWidth(locale) { function changeWidth(locale) {
if (locale=="ru") { if (locale=="ru") {
@ -28,6 +30,27 @@
} }
} }
let callback = (response) => {
groups = JSON.parse(response)
groupsByCountry = {}
for (let g of groups) {
let country = g.country
if (g.contact==null) {
g.contact = "https://discord.gg/Qk8KUk787z"
}
if (country in groupsByCountry) {
groupsByCountry[country].push(g)
}
else {
groupsByCountry[country] = [g]
}
}
loaded.update((val) => {
return val + 1
})
}
getData("/assets/groups.json",callback)
loadLocaleContent(content,"groups-component",loaded) loadLocaleContent(content,"groups-component",loaded)
loadLocaleContent(content,"communes-component",loaded) loadLocaleContent(content,"communes-component",loaded)
loadLocaleContent(content,"cooperatives-component",loaded) loadLocaleContent(content,"cooperatives-component",loaded)
@ -38,7 +61,7 @@
function mapCallback(createMap,content,locale) { function mapCallback(createMap,content,locale) {
let map = createMap([22, 0],2) let map = createMap([22, 0],2)
addMarkersGroups(map,content,locale) addMarkersGroups(groups,groupsByCountry,map,content,locale)
addMarkersCommunes(map,content,locale) addMarkersCommunes(map,content,locale)
addMarkersCoops(map,content,locale) addMarkersCoops(map,content,locale)
addMarkersParties(map,content,locale) addMarkersParties(map,content,locale)
@ -58,7 +81,7 @@
</script> </script>
{#key $loaded} {#key $loaded}
{#if $loaded==6} {#if $loaded==7}
<div id="container"> <div id="container">
<picture> <picture>
<source srcset="/img/crowd.webp"> <source srcset="/img/crowd.webp">

File diff suppressed because one or more lines are too long