feat(maps): add link to contact
This commit is contained in:
parent
9e9e8525d6
commit
5d80f20999
@ -1,4 +1,5 @@
|
||||
const api_url = "https://intra.ffsaf.fr";
|
||||
//const api_url = "https://intra.ffsaf.fr";
|
||||
const api_url = "http://localhost:8080";
|
||||
|
||||
let map = L.map('map').setView([46.631196, 2.456000], 6);
|
||||
|
||||
@ -94,13 +95,45 @@ async function getData() {
|
||||
div_info.appendChild(document.createElement("br"));
|
||||
} else {
|
||||
for (const [key, value] of Object.entries(d.contact)) {
|
||||
div_info.appendChild(document.createTextNode(`${key.charAt(0).toUpperCase() + key.slice(1).toLowerCase()}: ${value}`));
|
||||
let str
|
||||
|
||||
if (key === "SITE") {
|
||||
str = document.createElement('a');
|
||||
str.appendChild(document.createTextNode(value))
|
||||
str.title = value
|
||||
str.href = (value.startsWith("http") ? "" : "https://") + value
|
||||
str.target = '_blank'
|
||||
} else if (key === "COURRIEL") {
|
||||
str = document.createElement('a');
|
||||
str.appendChild(document.createTextNode(value))
|
||||
str.title = value
|
||||
str.href = `mailto:${value}`
|
||||
str.target = '_blank'
|
||||
} else if (key === "INSTAGRAM") {
|
||||
let r = value.match(/^https?:\/\/www\.instagram\.com\/([a-zA-Z0-9_.\-]+)\/?$/)
|
||||
str = document.createElement('a');
|
||||
str.appendChild(document.createTextNode(r == null ? value : r[1]))
|
||||
str.title = value
|
||||
str.href = (value.startsWith("http") ? "" : "https://www.instagram.com/") + value
|
||||
str.target = '_blank'
|
||||
} else if (key === "FACEBOOK") {
|
||||
let r = value.match(/^https?:\/\/www\.facebook\.com\/([a-zA-Z0-9_.\-]+)\/?$/)
|
||||
str = document.createElement('a');
|
||||
str.appendChild(document.createTextNode(r == null ? value : r[1]))
|
||||
str.title = value
|
||||
str.href = (value.startsWith("http") ? "" : "https://www.facebook.com/") + value
|
||||
str.target = '_blank'
|
||||
} else {
|
||||
str = document.createTextNode(value)
|
||||
}
|
||||
div_info.appendChild(document.createTextNode(`${key.charAt(0).toUpperCase() + key.slice(1).toLowerCase()}: `));
|
||||
div_info.appendChild(str);
|
||||
div_info.appendChild(document.createElement("br"));
|
||||
}
|
||||
}
|
||||
marker.bindPopup(div_info.innerHTML);
|
||||
|
||||
if (icon !== null){
|
||||
if (icon !== null) {
|
||||
marker.valueOf()._icon.style.backgroundColor = '#FFFFFF';
|
||||
marker.valueOf()._icon.style.borderRadius = '10px';
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user