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

67 lines
2.4 KiB
JavaScript
Raw Normal View History

2023-07-13 01:25:28 +07:00
export let parties = [
{
logo: "roots",
name: "Roots",
2023-07-13 18:32:49 +07:00
location: ["Ireland",[52.98479517270413, -7.649233227534782]],
2023-07-13 02:52:14 +07:00
//members: 6,
2023-07-13 01:25:28 +07:00
link: "https://discord.gg/pSTMacJZsK",
description: "descriptionRoots"
}
]
2023-07-13 18:32:49 +07:00
export let partiesByCountry = {}
for (let g of parties) {
let country = g.location[0]
if (country in partiesByCountry) {
partiesByCountry[country].push(g)
}
else {
partiesByCountry[country] = [g]
}
}
2023-07-15 02:27:11 +07:00
export let partiesMarkersLayer = L.layerGroup()
2023-07-13 01:25:28 +07:00
export function addMarkersParties(map,content) {
for (let g of parties) {
let coordinates
2023-07-16 18:22:48 +07:00
let text = "<b>"+content["Party"]+"</b><br>"
2023-07-13 01:25:28 +07:00
for (let field in g) {
let fieldText
if (field!="logo") {
fieldText = content[field] + ": "
}
if (field=="logo") {
text += "<picture><source srcset=" + "/img/parties/" + g.logo + ".webp><source srcset='/img/parties/" + g.logo + ".png'><img alt='logo' style='position: relative; max-height: 5rem; max-width: 100%; margin: auto;'></picture>" + "<br>"
}
else if (field=="link") {
text += fieldText + "<a href='" + g.link + "' target='_blank' rel=noreferrer>" + g.link + "</a>" + "<br>"
}
else if (field=="website") {
text += fieldText + "<a href='" + g.website + "' target='_blank' rel=noreferrer>" + g.website + "</a>" + "<br>"
}
else if (field=="location") {
2023-07-16 20:56:28 +07:00
let locationString = location.map(x => content[x]).join(", ")
text += fieldText + locationString + "<br>"
2023-07-13 01:25:28 +07:00
coordinates = g[field][1]
}
else if (field=="description") {
text += fieldText + content[g[field]] + "<br>"
}
else {
text += fieldText + g[field] + "<br>"
}
}
var markerIcon = new L.Icon({
iconUrl: 'https://www.libsoc.org/img/common/markers/marker-gold.png',
shadowUrl: 'https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.7/images/marker-shadow.png',
iconSize: [25, 41],
iconAnchor: [12, 41],
popupAnchor: [1, -34],
shadowSize: [41, 41]
});
let marker = L.marker(coordinates, {icon: markerIcon})
2023-07-15 02:27:11 +07:00
marker.addTo(partiesMarkersLayer).bindPopup(text)
2023-07-13 01:25:28 +07:00
}
2023-07-15 02:27:11 +07:00
partiesMarkersLayer.addTo(map)
2023-07-13 01:25:28 +07:00
}