Added a data entry system at /groups-add

This commit is contained in:
a-ill
2023-07-20 00:15:12 +03:00
parent 4fd0a23b8f
commit 1afca45d4b
55 changed files with 10348 additions and 228 deletions

View File

@@ -310,7 +310,7 @@ input[type="text"],input[type="email"],input[type="password"],input[type="number
border-color: black;
border: black solid 0.063rem;
padding-left: 0.5rem;
font: 1.3rem var(--serif, serif);
font: 1.15rem var(--serif, serif);
}
input[type="text"] {

View File

@@ -39,7 +39,7 @@ for (let c of communes) {
export let communesMarkersLayer = L.layerGroup()
export function addMarkersCommunes(map,content) {
export function addMarkersCommunes(map,content,locale) {
for (let g of communes) {
let coordinates
let text = "<b>"+content["Commune"]+"</b><br>"
@@ -50,7 +50,14 @@ export function addMarkersCommunes(map,content) {
}
else if (field=="location") {
let location = g[field][0]
let locationString = location.map(x => content[x]).join(", ")
let locationString
if (locale=="en") {
locationString = location.map(x => x).join(", ")
}
else {
locationString = location.map(x => content[x]).join(", ")
}
text += fieldText + locationString + "<br>"
coordinates = g[field][1]
}

View File

@@ -2,7 +2,7 @@ export let coops = [
{
logo: "chiron_logo",
name: "Chiron Health",
location: [["Estonia","KohtlaJarve"],[59.41038769769602, 27.287802936242034]],
location: [["Estonia","Kohtla-Järve"],[59.41038769769602, 27.287802936242034]],
market: "wellnessAndHealth",
workers: 2,
status: "inDevelopment",
@@ -13,7 +13,7 @@ export let coops = [
{
logo: "kuusk_logo",
name: "Kuusk",
location: [["Estonia","KohtlaJarve"],[59.399947051803004, 27.277159931677055]],
location: [["Estonia","Kohtla-Järve"],[59.399947051803004, 27.277159931677055]],
market: "herbalTeas",
workers: 1,
status: "inDevelopment",
@@ -36,7 +36,7 @@ for (let g of coops) {
export let coopsMarkersLayer = L.layerGroup()
export function addMarkersCoops(map,content) {
export function addMarkersCoops(map,content,locale) {
for (let g of coops) {
let coordinates
let text = "<b>"+content["Cooperative"]+"</b><br>"
@@ -56,7 +56,13 @@ export function addMarkersCoops(map,content) {
}
else if (field=="location") {
let location = g[field][0]
let locationString = location.map(x => content[x]).join(", ")
let locationString
if (locale=="en") {
locationString = location.map(x => x).join(", ")
}
else {
locationString = location.map(x => content[x]).join(", ")
}
text += fieldText + locationString + "<br>"
coordinates = g[field][1]
}

View File

@@ -25,7 +25,7 @@ export let groups = [
contact: ["https://discord.gg/Qk8KUk787z","DiscordInviteLink"]
},
{
location: [["Estonia","KohtlaJarve"], [59.40629447076191, 27.280605339416322]],
location: [["Estonia","Kohtla-Järve"], [59.40629447076191, 27.280605339416322]],
members: 3,
contact: ["https://discord.gg/Qk8KUk787z","DiscordInviteLink"]
},
@@ -93,7 +93,7 @@ let groupsMarkersLayerIn = L.layerGroup()
let contactGeneral =["https://discord.gg/4BUau4AZre","DiscordInviteLink"]
function addMarkersToLayer(g,layer,content) {
function addMarkersToLayer(g,layer,content,locale) {
let coordinates
let text = "<b>"+content["Group"]+"</b><br>"
for (let field in g) {
@@ -103,7 +103,13 @@ function addMarkersToLayer(g,layer,content) {
}
else if (field=="location") {
let location = g[field][0]
let locationString = location.map(x => content[x]).join(", ")
let locationString
if (locale=="en") {
locationString = location.map(x => x).join(", ")
}
else {
locationString = location.map(x => content[x]).join(", ")
}
text += fieldText + locationString + "<br>"
coordinates = g[field][1]
}
@@ -123,15 +129,15 @@ function addMarkersToLayer(g,layer,content) {
marker.addTo(layer).bindPopup(text)
}
export function addMarkersGroups(map,content) {
export function addMarkersGroups(map,content,locale) {
for (let g of groups) {
addMarkersToLayer(g,groupsMarkersLayerIn,content)
addMarkersToLayer(g,groupsMarkersLayerIn,content,locale)
}
for (let gs of Object.values(groupsByCountry)) {
if (gs.length==1) {
let g = {...gs[0]}
g.location[0] = [g.location[0][0]]
addMarkersToLayer(g,groupsMarkersLayerOut,content)
addMarkersToLayer(g,groupsMarkersLayerOut,content,locale)
}
else {
let locationName = [gs[0].location[0][0]]
@@ -153,7 +159,7 @@ export function addMarkersGroups(map,content) {
members: members,
contact: contact
}
addMarkersToLayer(gNew,groupsMarkersLayerOut,content)
addMarkersToLayer(gNew,groupsMarkersLayerOut,content,locale)
}
}
groupsMarkersLayerOut.addTo(groupsMarkersLayer)
@@ -172,37 +178,5 @@ function onZoomEnd(map) {
groupsMarkersLayerIn.addTo(groupsMarkersLayer)
}
}
/*
function reverseGeocode(latitude, longitude) {
let url = `https://nominatim.openstreetmap.org/reverse?format=jsonv2&lat=${latitude}&lon=${longitude}`;
// Create a new XMLHttpRequest object
let xhr = new XMLHttpRequest();
// Set up the AJAX request
xhr.open('GET', url, true);
// Define the onload function
xhr.onload = function() {
if (xhr.status === 200) {
// Parse the response JSON
let response = JSON.parse(xhr.responseText);
// Extract the address information from the response
let address = response.address;
let city = address.city || address.town || address.village || address.hamlet;
let country = address.country;
let fullAddress = city + ', ' + country;
// Do something with the address
console.log(fullAddress);
}
};
// Send the AJAX request
xhr.send();
}
let latitude = 123.456; // Replace with your latitude
let longitude = 78.901; // Replace with your longitude
reverseGeocode(latitude, longitude);*/

View File

@@ -1,17 +1,17 @@
// Get data from server
export function getData(path,callback) {
var xhr = new XMLHttpRequest();
xhr.overrideMimeType("application/json");
xhr.open('GET', path, true);
let xhr = new XMLHttpRequest();
xhr.overrideMimeType("application/json")
xhr.open('GET', path, true)
xhr.onreadystatechange = function () {
if (xhr.readyState == 4 && xhr.status == "200") {
if (xhr.readyState == 4 && xhr.status == "200") {
if (callback !== undefined) {
callback(xhr.responseText);
callback(xhr.responseText)
}
}
}
};
xhr.send(null);
xhr.send()
}
// Parse JSON from given path into a given variable under a given key
@@ -35,6 +35,7 @@ export function sendData(route,data,callback) {
callback(xhr.responseText)
}
} else {
console.log("Request gave an error")
// Oh no! There has been an error with the request!
}
}

View File

@@ -22,7 +22,7 @@ for (let g of parties) {
export let partiesMarkersLayer = L.layerGroup()
export function addMarkersParties(map,content) {
export function addMarkersParties(map,content,locale) {
for (let g of parties) {
let coordinates
let text = "<b>"+content["Party"]+"</b><br>"
@@ -42,7 +42,13 @@ export function addMarkersParties(map,content) {
}
else if (field=="location") {
let location = g[field][0]
let locationString = location
let locationString
if (locale=="en") {
locationString = location
}
else {
locationString = content[location]
}
text += fieldText + locationString + "<br>"
coordinates = g[field][1]
}

View File

@@ -1,29 +1,3 @@
{
"map-prompt": "Want to appear on our map? Contact us!",
"Online": "Online",
"Denmark": "Denmark",
"Estonia": "Estonia",
"Greece": "Greece",
"Latvia": "Latvia",
"Canada": "Canada",
"Germany": "Germany",
"Copenhagen": "Copenhagen",
"Ireland": "Ireland",
"USA": "USA",
"Bulgaria": "Bulgaria",
"Colorado": "Colorado",
"Georgia": "Georgia",
"Ohio": "Ohio",
"Montreal": "Montreal",
"Kolding": "Kolding",
"KohtlaJarve": "Kohtla-Järve",
"Athens": "Athens",
"Riga": "Riga",
"Halifax": "Halifax",
"Wiesbaden": "Wiesbaden",
"Florida": "Florida",
"Tallinn": "Tallinn",
"Varna": "Varna",
"Louisville": "Louisville",
"Toronto": "Toronto"
"map-prompt": "Want to appear on our map? Contact us!"
}

View File

@@ -15,7 +15,7 @@
"Ohio": "Огайо",
"Copenhagen": "Копенгаген",
"Kolding": "Колдинг",
"KohtlaJarve": "Кохтла-Ярве",
"Kohtla-Järve": "Кохтла-Ярве",
"Athens": "Афины",
"Riga": "Рига",
"Halifax": "Галифакс",