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

73 lines
2.7 KiB
JavaScript
Raw Normal View History

2023-06-24 20:44:16 +07:00
export let coops = [
{
logo: "chiron_logo",
name: "Chiron Health",
2023-07-13 18:32:49 +07:00
location: [["Estonia","KohtlaJarve"],[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-06-24 20:44:16 +07:00
website: "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",
2023-07-13 18:32:49 +07:00
location: [["Estonia","KohtlaJarve"],[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-06-24 20:44:16 +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()
2023-07-09 19:25:09 +07:00
export function addMarkersCoops(map,content) {
2023-06-24 20:44:16 +07:00
for (let g of coops) {
let coordinates
2023-07-15 02:27:11 +07:00
let text = "<b>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") {
text += fieldText + "<a href='" + g.website + "' target='_blank' rel=noreferrer>" + g.website + "</a>" + "<br>"
}
else if (field=="location") {
2023-07-13 18:32:49 +07:00
let location = g[field][0]
let town = location[1]=="" ? "" : ", " + content[location[1]]
text += fieldText + content[location[0]] + town + "<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
}