diff --git a/src/main/webapp/public/club-maps.js b/src/main/webapp/public/club-maps.js index bec2e5a..427a37e 100644 --- a/src/main/webapp/public/club-maps.js +++ b/src/main/webapp/public/club-maps.js @@ -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'; }