This commit is contained in:
a-ill 2023-07-21 17:38:02 +03:00
parent 41998a13be
commit 909416fbe3
12 changed files with 121 additions and 19 deletions

View File

@ -212,10 +212,34 @@ function political_compass()
end
function groups_add_post()
data = collect(JSON3.read(rawpayload()))
push!(data,1)
dict = Dict(zip(["country","state","town","latitude","longitude","contact","members"],data))
insert_into_table("groups",dict)
data = jsonpayload()
insert_into_table("groups",data)
end
#=
function compile_groups()
function table_to_json(name,t)
ar = []
for df_row in eachrow(t)
df_row = first(eachrow(df))
id = :town
location = String[]
for id in [:country,:state,:town]
if !isempty(df_row[id])
push!(location,df_row[id])
end
end
df = select_from_table(["groups" => ["*"]])
dict = Dict(
"location" => [location,[df_row[:latitude],df_row[:longitude]]],
"members" => df_row[:members],
"contact" => df_row[:contact]
)
end
return ar
end
df = select_from_table(["groups" => ["*"]])
end
=#
end

View File

@ -73,6 +73,16 @@ export let groups = [
location: [["USA","Ohio"], [40.18243610076637, -83.07800532738788]],
members: 1,
contact: ["https://discord.gg/Qk8KUk787z","DiscordInviteLink"]
},
{
location: [["Thailand","Chiang Mai"], [18.788343253574393, 98.99423221087719]],
members: 1,
contact: ["https://discord.gg/Qk8KUk787z","DiscordInviteLink"]
},
{
location: [["Switzerland","Cham"], [47.18298143153399, 8.460076421717238]],
members: 1,
contact: ["https://discord.gg/Qk8KUk787z","DiscordInviteLink"]
}
]
@ -93,6 +103,18 @@ let groupsMarkersLayerIn = L.layerGroup()
let contactGeneral =["https://discord.gg/4BUau4AZre","DiscordInviteLink"]
export function translate(content, x) {
let out = content[x]
if (out==undefined) {
return x
}
else {
return out
}
}
function addMarkersToLayer(g,layer,content,locale) {
let coordinates
let text = "<b>"+content["Group"]+"</b><br>"
@ -108,7 +130,7 @@ function addMarkersToLayer(g,layer,content,locale) {
locationString = location.map(x => x).join(", ")
}
else {
locationString = location.map(x => content[x]).join(", ")
locationString = location.map(x => translate(content, x)).join(", ")
}
text += fieldText + locationString + "<br>"
coordinates = g[field][1]

View File

@ -35,6 +35,7 @@ export function sendData(route,data,callback) {
callback(xhr.responseText)
}
} else {
callback(false)
console.log("Request gave an error")
// Oh no! There has been an error with the request!
}
@ -57,6 +58,7 @@ export function sendText(route,data,callback) {
}
} else {
callback(false)
console.log("Request gave an error")
// Oh no! There has been an error with the request!
}
}

View File

@ -10,6 +10,7 @@
"Germany": "Германия",
"USA": "CША",
"Bulgaria": "Болгария",
"Thailand": "Тайланд",
"Colorado": "Колорадо",
"Georgia": "Джорджия",
"Ohio": "Огайо",

View File

@ -5,7 +5,7 @@
import { onMount } from 'svelte'
import { writable } from 'svelte/store';
import { groupsByCountry, addMarkersGroups } from '/js/groups.js'
import { loadLocaleContent, getData, sendText } from "/js/libraries/serverTools.js"
import { loadLocaleContent, getData, sendData } from "/js/libraries/serverTools.js"
// Import components
import "/js/components/map-component.js"
@ -105,9 +105,27 @@
function submitLocation() {
if (addressVec!=undefined) {
let data = [...addressVec,userPinLat,userPinLng,contactInput.value]
let data = {
country: addressVec[0],
state: addressVec[1],
town: addressVec[2],
latitude: userPinLat,
longitude: userPinLng,
contact: contactInput.value,
members: 1
}
if (data.state=="") {
data.state = null
}
if (data.town=="") {
data.town = null
}
if (data.contact=="") {
data.contact = null
}
let url = "/" + locale + "/groups-add-post/"
sendText(url,JSON.stringify(data),updateConfirmationMsg)
sendData(url,data,updateConfirmationMsg)
}
}

View File

@ -4,7 +4,7 @@
// Import statements
import { onMount } from 'svelte'
import { writable } from 'svelte/store';
import { groupsByCountry, addMarkersGroups } from '/js/groups.js'
import { groupsByCountry, addMarkersGroups, translate } from '/js/groups.js'
import { loadLocaleContent, getData, sendData } from "/js/libraries/serverTools.js"
// Import components
@ -22,12 +22,12 @@
addMarkersGroups(map,content,locale)
}
function getCountry(name) {
return locale=="en" ? name : $content[name]
function getCountry(x) {
return locale=="en" ? x : translate($content,x)
}
function getAddress(group) {
return group.location[0].map(x => locale=="en" ? x : $content[x]).join(", ")
return group.location[0].map(x => locale=="en" ? x : translate($content,x)).join(", ")
}
onMount(() => {

View File

@ -6,14 +6,24 @@ using DataFrames
export exist_in_table, insert_into_table, update_table, select_from_table, add_foreign_key
options = SearchLight.Configuration.read_db_connection_data("db/connection.yml")
conn = SearchLight.connect(options)
function format(x)
if (x isa String) || (x isa Symbol)
return string("'",x,"'")
elseif (isnothing(x))
return "NULL"
else
return x
end
end
function insert_into_table(table_name,dict_values)
names_string = join(keys(dict_values),", ")
vals_raw = values(dict_values)
vals = map(x -> (x isa String) || (x isa Symbol) ? string("'",x,"'") : x,vals_raw)
vals = map(x -> format(x),vals_raw)
vals_string = join(values(vals),", ")
query = "INSERT INTO $table_name ($names_string) VALUES ($vals_string)"
SearchLight.query(query)

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
import{S as t,i as o,a as n,b as e,s as r,e as i,n as m,d as a,c as s,o as c,f as l,t as p,g,h as u,j as d,k as h,l as f,m as b,p as j}from"./index-4348483d.js";import{w as x}from"./index-71440b21.js";import{addMarkersGroups as v,groupsByCountry as w}from"../../../../../../../../../js/groups.js";import{loadLocaleContent as y}from"../../../../../../../../../js/libraries/serverTools.js";import"../../../../../../../../../js/components/map-component.js";function k(t,o,n){const e=t.slice();return e[9]=o[n][0],e[10]=o[n][1],e}function z(t,o,n){const e=t.slice();return e[13]=o[n],e}function D(t){let o,n,r,i,m,s,c,x,v,y,z,D,E,O,R,T,A,C,H,L,M=t[0].groups+"",S=t[0].p1+"",_=t[0].subheading1+"",q=t[0]["map-prompt"]+"",B=Object.entries(w),F=[];for(let o=0;o<B.length;o+=1)F[o]=N(k(t,B,o));return{c(){o=l("div"),n=l("div"),r=l("h1"),i=p(M),m=g(),s=l("img"),x=g(),v=l("p"),y=p(S),z=g(),D=l("h3"),E=p(_),O=g(),R=l("map-component"),A=g(),C=l("p"),H=p(q),L=g();for(let t=0;t<F.length;t+=1)F[t].c();u(s,"id","groups-img"),d(s.src,c="/img/common/groups.svg")||u(s,"src","/img/common/groups.svg"),u(s,"alt","groups"),u(v,"class","description"),h(R,"id","map"),h(R,"callback",T=t[8]),u(C,"id","add-prompt"),u(n,"id","text-container"),u(o,"id","container")},m(t,a){e(t,o,a),f(o,n),f(n,r),f(r,i),f(n,m),f(n,s),f(n,x),f(n,v),f(v,y),f(n,z),f(n,D),f(D,E),f(n,O),f(n,R),f(n,A),f(n,C),f(C,H),f(n,L);for(let t=0;t<F.length;t+=1)F[t].m(n,null)},p(t,o){if(1&o&&M!==(M=t[0].groups+"")&&b(i,M),1&o&&S!==(S=t[0].p1+"")&&b(y,S),1&o&&_!==(_=t[0].subheading1+"")&&b(E,_),1&o&&T!==(T=t[8])&&h(R,"callback",T),1&o&&q!==(q=t[0]["map-prompt"]+"")&&b(H,q),193&o){let e;for(B=Object.entries(w),e=0;e<B.length;e+=1){const r=k(t,B,e);F[e]?F[e].p(r,o):(F[e]=N(r),F[e].c(),F[e].m(n,null))}for(;e<F.length;e+=1)F[e].d(1);F.length=B.length}},d(t){t&&a(o),j(F,t)}}}function E(t){let o,n,r,i,m,s,c,d,h,j,x,v,w,y,k,z,D,E,N,O=t[0].location+"",R=t[7](t[13])+"",T=t[0].members+"",A=t[13].members+"",C=t[0].contact+"",H=t[0][t[13].contact[1]]+"";return{c(){o=l("div"),n=l("p"),r=l("b"),i=p(O),m=p(": "),s=p(R),c=g(),d=l("p"),h=l("b"),j=p(T),x=p(": "),v=p(A),w=g(),y=l("p"),k=l("b"),z=p(C),D=p(": "),E=l("a"),N=p(H),u(E,"href",t[13].contact[0]),u(E,"target",";_blank;"),u(E,"rel","noreferrer"),u(o,"class","location-info")},m(t,a){e(t,o,a),f(o,n),f(n,r),f(r,i),f(r,m),f(n,s),f(o,c),f(o,d),f(d,h),f(h,j),f(h,x),f(d,v),f(o,w),f(o,y),f(y,k),f(k,z),f(k,D),f(y,E),f(E,N)},p(t,o){1&o&&O!==(O=t[0].location+"")&&b(i,O),1&o&&T!==(T=t[0].members+"")&&b(j,T),1&o&&C!==(C=t[0].contact+"")&&b(z,C),1&o&&H!==(H=t[0][t[13].contact[1]]+"")&&b(N,H)},d(t){t&&a(o)}}}function N(t){let o,n,r,i,m,s=t[6](t[9])+"",c=t[10],d=[];for(let o=0;o<c.length;o+=1)d[o]=E(z(t,c,o));return{c(){o=l("h4"),n=p(s),r=g(),i=l("div");for(let t=0;t<d.length;t+=1)d[t].c();m=g(),u(o,"class","country-name"),u(i,"class","country-block")},m(t,a){e(t,o,a),f(o,n),e(t,r,a),e(t,i,a);for(let t=0;t<d.length;t+=1)d[t].m(i,null);f(i,m)},p(t,o){if(129&o){let n;for(c=t[10],n=0;n<c.length;n+=1){const e=z(t,c,n);d[n]?d[n].p(e,o):(d[n]=E(e),d[n].c(),d[n].m(i,m))}for(;n<d.length;n+=1)d[n].d(1);d.length=c.length}},d(t){t&&a(o),t&&a(r),t&&a(i),j(d,t)}}}function O(t){let o,n=2==t[1]&&D(t);return{c(){n&&n.c(),o=i()},m(t,r){n&&n.m(t,r),e(t,o,r)},p(t,e){2==t[1]?n?n.p(t,e):(n=D(t),n.c(),n.m(o.parentNode,o)):n&&(n.d(1),n=null)},d(t){n&&n.d(t),t&&a(o)}}}function R(t){let o,n=t[1],s=O(t);return{c(){s.c(),o=i(),this.c=m},m(t,n){s.m(t,n),e(t,o,n)},p(t,[e]){2&e&&r(n,n=t[1])?(s.d(1),s=O(t),s.c(),s.m(o.parentNode,o)):s.p(t,e)},i:m,o:m,d(t){t&&a(o),s.d(t)}}}function T(t,o,n){let e,r,i=x(0);s(t,i,(t=>n(1,r=t)));let m=x({});s(t,m,(t=>n(0,e=t)));let a=y(m,"groups-component",i);function l(t,o,n){let e=t([22,0],2);v(e,o,n)}y(m,"countries",i),c((()=>{}));return[e,r,i,m,a,l,function(t){return"en"==a?t:e[t]},function(t){return t.location[0].map((t=>"en"==a?t:e[t])).join(", ")},t=>l(t,e,a)]}class A extends t{constructor(t){super(),this.shadowRoot.innerHTML="<style>@import '/css/common.css';.description{margin-bottom:1rem}#add-prompt{margin-bottom:2rem}#groups-img{position:absolute;width:14rem;left:50%;transform:translate(-50%);z-index:0;opacity:0.2}#text-container>:nth-child(3){margin-top:8rem}.country-name{margin-bottom:0.5rem}.country-block{margin-bottom:2rem}.location-info{margin-bottom:0.75rem}.location-info p{margin-bottom:0}a{color:#DD1C1A}#map{--height:30rem;--width:100%;--margin-bottom:0.5rem}#text-container{position:relative;max-width:calc(100vw - 4rem);margin:auto}h1{margin-bottom:1rem;font-size:2.2rem;text-align:center}h3{margin-bottom:1rem}#container{margin:auto;max-width:800px;margin-top:1rem;margin-bottom:4rem}#container p{text-align:justify}</style>",o(this,{target:this.shadowRoot,props:n(this.attributes),customElement:!0},T,R,r,{},null),t&&t.target&&e(t.target,this,t.anchor)}}customElements.define("groups-component",A);export{A as default};
import{S as t,i as o,a as n,b as e,s as r,e as i,n as m,d as a,c as s,o as c,f as l,t as p,g,h as u,j as d,k as h,l as f,m as b,p as j}from"./index-4348483d.js";import{w as x}from"./index-71440b21.js";import{addMarkersGroups as v,translate as w,groupsByCountry as y}from"../../../../../../../../../js/groups.js";import{loadLocaleContent as k}from"../../../../../../../../../js/libraries/serverTools.js";import"../../../../../../../../../js/components/map-component.js";function z(t,o,n){const e=t.slice();return e[9]=o[n][0],e[10]=o[n][1],e}function D(t,o,n){const e=t.slice();return e[13]=o[n],e}function E(t){let o,n,r,i,m,s,c,x,v,w,k,D,E,N,R,T,A,C,H,L,M=t[0].groups+"",S=t[0].p1+"",_=t[0].subheading1+"",q=t[0]["map-prompt"]+"",B=Object.entries(y),F=[];for(let o=0;o<B.length;o+=1)F[o]=O(z(t,B,o));return{c(){o=l("div"),n=l("div"),r=l("h1"),i=p(M),m=g(),s=l("img"),x=g(),v=l("p"),w=p(S),k=g(),D=l("h3"),E=p(_),N=g(),R=l("map-component"),A=g(),C=l("p"),H=p(q),L=g();for(let t=0;t<F.length;t+=1)F[t].c();u(s,"id","groups-img"),d(s.src,c="/img/common/groups.svg")||u(s,"src","/img/common/groups.svg"),u(s,"alt","groups"),u(v,"class","description"),h(R,"id","map"),h(R,"callback",T=t[8]),u(C,"id","add-prompt"),u(n,"id","text-container"),u(o,"id","container")},m(t,a){e(t,o,a),f(o,n),f(n,r),f(r,i),f(n,m),f(n,s),f(n,x),f(n,v),f(v,w),f(n,k),f(n,D),f(D,E),f(n,N),f(n,R),f(n,A),f(n,C),f(C,H),f(n,L);for(let t=0;t<F.length;t+=1)F[t].m(n,null)},p(t,o){if(1&o&&M!==(M=t[0].groups+"")&&b(i,M),1&o&&S!==(S=t[0].p1+"")&&b(w,S),1&o&&_!==(_=t[0].subheading1+"")&&b(E,_),1&o&&T!==(T=t[8])&&h(R,"callback",T),1&o&&q!==(q=t[0]["map-prompt"]+"")&&b(H,q),193&o){let e;for(B=Object.entries(y),e=0;e<B.length;e+=1){const r=z(t,B,e);F[e]?F[e].p(r,o):(F[e]=O(r),F[e].c(),F[e].m(n,null))}for(;e<F.length;e+=1)F[e].d(1);F.length=B.length}},d(t){t&&a(o),j(F,t)}}}function N(t){let o,n,r,i,m,s,c,d,h,j,x,v,w,y,k,z,D,E,N,O=t[0].location+"",R=t[7](t[13])+"",T=t[0].members+"",A=t[13].members+"",C=t[0].contact+"",H=t[0][t[13].contact[1]]+"";return{c(){o=l("div"),n=l("p"),r=l("b"),i=p(O),m=p(": "),s=p(R),c=g(),d=l("p"),h=l("b"),j=p(T),x=p(": "),v=p(A),w=g(),y=l("p"),k=l("b"),z=p(C),D=p(": "),E=l("a"),N=p(H),u(E,"href",t[13].contact[0]),u(E,"target",";_blank;"),u(E,"rel","noreferrer"),u(o,"class","location-info")},m(t,a){e(t,o,a),f(o,n),f(n,r),f(r,i),f(r,m),f(n,s),f(o,c),f(o,d),f(d,h),f(h,j),f(h,x),f(d,v),f(o,w),f(o,y),f(y,k),f(k,z),f(k,D),f(y,E),f(E,N)},p(t,o){1&o&&O!==(O=t[0].location+"")&&b(i,O),1&o&&T!==(T=t[0].members+"")&&b(j,T),1&o&&C!==(C=t[0].contact+"")&&b(z,C),1&o&&H!==(H=t[0][t[13].contact[1]]+"")&&b(N,H)},d(t){t&&a(o)}}}function O(t){let o,n,r,i,m,s=t[6](t[9])+"",c=t[10],d=[];for(let o=0;o<c.length;o+=1)d[o]=N(D(t,c,o));return{c(){o=l("h4"),n=p(s),r=g(),i=l("div");for(let t=0;t<d.length;t+=1)d[t].c();m=g(),u(o,"class","country-name"),u(i,"class","country-block")},m(t,a){e(t,o,a),f(o,n),e(t,r,a),e(t,i,a);for(let t=0;t<d.length;t+=1)d[t].m(i,null);f(i,m)},p(t,o){if(129&o){let n;for(c=t[10],n=0;n<c.length;n+=1){const e=D(t,c,n);d[n]?d[n].p(e,o):(d[n]=N(e),d[n].c(),d[n].m(i,m))}for(;n<d.length;n+=1)d[n].d(1);d.length=c.length}},d(t){t&&a(o),t&&a(r),t&&a(i),j(d,t)}}}function R(t){let o,n=2==t[1]&&E(t);return{c(){n&&n.c(),o=i()},m(t,r){n&&n.m(t,r),e(t,o,r)},p(t,e){2==t[1]?n?n.p(t,e):(n=E(t),n.c(),n.m(o.parentNode,o)):n&&(n.d(1),n=null)},d(t){n&&n.d(t),t&&a(o)}}}function T(t){let o,n=t[1],s=R(t);return{c(){s.c(),o=i(),this.c=m},m(t,n){s.m(t,n),e(t,o,n)},p(t,[e]){2&e&&r(n,n=t[1])?(s.d(1),s=R(t),s.c(),s.m(o.parentNode,o)):s.p(t,e)},i:m,o:m,d(t){t&&a(o),s.d(t)}}}function A(t,o,n){let e,r,i=x(0);s(t,i,(t=>n(1,r=t)));let m=x({});s(t,m,(t=>n(0,e=t)));let a=k(m,"groups-component",i);function l(t,o,n){let e=t([22,0],2);v(e,o,n)}k(m,"countries",i),c((()=>{}));return[e,r,i,m,a,l,function(t){return"en"==a?t:w(e,t)},function(t){return t.location[0].map((t=>"en"==a?t:w(e,t))).join(", ")},t=>l(t,e,a)]}class C extends t{constructor(t){super(),this.shadowRoot.innerHTML="<style>@import '/css/common.css';.description{margin-bottom:1rem}#add-prompt{margin-bottom:2rem}#groups-img{position:absolute;width:14rem;left:50%;transform:translate(-50%);z-index:0;opacity:0.2}#text-container>:nth-child(3){margin-top:8rem}.country-name{margin-bottom:0.5rem}.country-block{margin-bottom:2rem}.location-info{margin-bottom:0.75rem}.location-info p{margin-bottom:0}a{color:#DD1C1A}#map{--height:30rem;--width:100%;--margin-bottom:0.5rem}#text-container{position:relative;max-width:calc(100vw - 4rem);margin:auto}h1{margin-bottom:1rem;font-size:2.2rem;text-align:center}h3{margin-bottom:1rem}#container{margin:auto;max-width:800px;margin-top:1rem;margin-bottom:4rem}#container p{text-align:justify}</style>",o(this,{target:this.shadowRoot,props:n(this.attributes),customElement:!0},A,T,r,{},null),t&&t.target&&e(t.target,this,t.anchor)}}customElements.define("groups-component",C);export{C as default};

View File

@ -73,6 +73,16 @@ export let groups = [
location: [["USA","Ohio"], [40.18243610076637, -83.07800532738788]],
members: 1,
contact: ["https://discord.gg/Qk8KUk787z","DiscordInviteLink"]
},
{
location: [["Thailand","Chiang Mai"], [18.788343253574393, 98.99423221087719]],
members: 1,
contact: ["https://discord.gg/Qk8KUk787z","DiscordInviteLink"]
},
{
location: [["Switzerland","Cham"], [47.18298143153399, 8.460076421717238]],
members: 1,
contact: ["https://discord.gg/Qk8KUk787z","DiscordInviteLink"]
}
]
@ -93,6 +103,18 @@ let groupsMarkersLayerIn = L.layerGroup()
let contactGeneral =["https://discord.gg/4BUau4AZre","DiscordInviteLink"]
export function translate(content, x) {
let out = content[x]
if (out==undefined) {
return x
}
else {
return out
}
}
function addMarkersToLayer(g,layer,content,locale) {
let coordinates
let text = "<b>"+content["Group"]+"</b><br>"
@ -108,7 +130,7 @@ function addMarkersToLayer(g,layer,content,locale) {
locationString = location.map(x => x).join(", ")
}
else {
locationString = location.map(x => content[x]).join(", ")
locationString = location.map(x => translate(content, x)).join(", ")
}
text += fieldText + locationString + "<br>"
coordinates = g[field][1]

View File

@ -35,6 +35,7 @@ export function sendData(route,data,callback) {
callback(xhr.responseText)
}
} else {
callback(false)
console.log("Request gave an error")
// Oh no! There has been an error with the request!
}
@ -57,6 +58,7 @@ export function sendText(route,data,callback) {
}
} else {
callback(false)
console.log("Request gave an error")
// Oh no! There has been an error with the request!
}
}

View File

@ -10,6 +10,7 @@
"Germany": "Германия",
"USA": "CША",
"Bulgaria": "Болгария",
"Thailand": "Тайланд",
"Colorado": "Колорадо",
"Georgia": "Джорджия",
"Ohio": "Огайо",