site-libsoc/Server/app/svelte/public/js/coops.js

79 lines
2.9 KiB
JavaScript
Raw Normal View History

2023-06-24 20:44:16 +07:00
export let coops = [
{
logo: "chiron_logo",
name: "Chiron Health",
location: [["Estonia","Kohtla-Järve"],[59.41038769769602, 27.287802936242034]],
2023-07-09 19:25:09 +07:00
market: "wellnessAndHealth",
2023-06-24 20:44:16 +07:00
workers: 2,
2023-07-09 19:25:09 +07:00
status: "inDevelopment",
2023-07-19 01:02:08 +07:00
website: ["https://www.chrn.health/", "chrn.health"],
2023-07-15 18:29:26 +07:00
contact: ["https://discord.gg/Qk8KUk787z","DiscordInviteLink"],
2023-07-09 19:25:09 +07:00
description: "descriptionChironHealth"
2023-06-24 20:44:16 +07:00
},
{
logo: "kuusk_logo",
name: "Kuusk",
location: [["Estonia","Kohtla-Järve"],[59.399947051803004, 27.277159931677055]],
2023-07-09 19:25:09 +07:00
market: "herbalTeas",
2023-06-24 20:44:16 +07:00
workers: 1,
2023-07-09 19:25:09 +07:00
status: "inDevelopment",
2023-07-19 01:02:08 +07:00
website: ["-","-"],
2023-07-15 18:29:26 +07:00
contact: ["https://discord.gg/Qk8KUk787z","DiscordInviteLink"],
2023-07-09 19:25:09 +07:00
description: "kuuskDescription"
2023-06-24 20:44:16 +07:00
}
]
2023-07-13 18:32:49 +07:00
export let coopsByCountry = {}
for (let g of coops) {
let country = g.location[0][0]
if (country in coopsByCountry) {
coopsByCountry[country].push(g)
}
else {
coopsByCountry[country] = [g]
}
}
2023-07-15 02:27:11 +07:00
export let coopsMarkersLayer = L.layerGroup()
export function addMarkersCoops(map,content,locale) {
2023-06-24 20:44:16 +07:00
for (let g of coops) {
let coordinates
2023-07-16 18:22:48 +07:00
let text = "<b>"+content["Cooperative"]+"</b><br>"
2023-06-24 20:44:16 +07:00
for (let field in g) {
2023-07-03 03:07:45 +07:00
let fieldText
if (field!="logo") {
fieldText = content[field] + ": "
}
2023-06-24 20:44:16 +07:00
if (field=="logo") {
text += "<picture><source srcset=" + "/img/coops/" + g.logo + ".webp><source srcset='/img/coops/" + g.logo + ".png'><img alt='logo' style='position: relative; max-height: 5rem; max-width: 100%; margin: auto;'></picture>" + "<br>"
}
else if (field=="contact") {
2023-07-09 19:25:09 +07:00
text += fieldText + "<a href='https://www." + g.contact[0] + "' target='_blank' rel=noreferrer>" + content[g.contact[1]] + "</a>" + "<br>"
2023-06-24 20:44:16 +07:00
}
else if (field=="website") {
2023-07-16 04:25:01 +07:00
text += fieldText + "<a href='" + g.website[0] + "' target='_blank' rel=noreferrer>" + g.website[1] + "</a>" + "<br>"
2023-06-24 20:44:16 +07:00
}
else if (field=="location") {
2023-07-13 18:32:49 +07:00
let location = g[field][0]
let locationString
if (locale=="en") {
locationString = location.map(x => x).join(", ")
}
else {
locationString = location.map(x => content[x]).join(", ")
}
2023-07-16 20:56:28 +07:00
text += fieldText + locationString + "<br>"
2023-06-24 20:44:16 +07:00
coordinates = g[field][1]
}
2023-07-03 03:07:45 +07:00
else if (field=="market" || field=="status" || field=="description") {
2023-07-09 19:25:09 +07:00
text += fieldText + content[g[field]] + "<br>"
2023-07-03 03:07:45 +07:00
}
2023-06-24 20:44:16 +07:00
else {
text += fieldText + g[field] + "<br>"
}
}
2023-07-15 02:27:11 +07:00
L.marker(coordinates).addTo(coopsMarkersLayer).bindPopup(text)
2023-06-24 20:44:16 +07:00
}
2023-07-15 02:27:11 +07:00
coopsMarkersLayer.addTo(map)
2023-06-24 20:44:16 +07:00
}