1// Contenu de l'info-bulle d'un site sur les cartes (contrôleur gmaps, public et 2// admin), construit en nÅuds DOM. 3// 4// Les champs du repère (name, typology_name, multilang_name, blockers) sont du 5// TEXTE BRUT saisi en back-office : ils ne passent que par textContent / title, 6// jamais par une chaîne HTML. Un toponyme contenant « < » ou « & » s'affiche 7// tel quel, et ne peut rien injecter dans la page. 8// 9// Styles posés par le CSSOM (element.style) : compatibles avec une CSP sans 10// 'unsafe-inline', à la différence d'attributs style="â¦" dans une chaîne HTML. 11 12const STYLES = { 13 wrapper: { padding: "16px 2px 2px 0", minWidth: "140px" }, 14 title: { fontSize: "14px", fontWeight: "500", color: "#202124", paddingRight: "22px", paddingBottom: "6px" }, 15 link: { color: "#202124", textDecoration: "none" }, 16 draft: { fontSize: "11px", fontWeight: "400", color: "#a05050" }, 17 warn: { color: "#a32d2d", fontWeight: "500", cursor: "help" }, 18 typology: { fontSize: "12px", color: "#70757a", marginTop: "3px" }, 19 multilang: { fontSize: "12px", color: "#70757a", marginTop: "2px" } 20} 21 22function element(tag, style, text) { 23 const node = document.createElement(tag) 24 Object.assign(node.style, style) 25 if (text != null) node.textContent = text 26 return node 27} 28 29// location : un repère du payload des cartes (cf. gmaps_location_hash et 30// FortressesController#locations). admin : lien vers la fiche admin (adressée 31// par identifier) plutôt que vers la fiche publique. 32export function buildSiteInfoContent(location, { admin = false } = {}) { 33 const wrapper = element("div", STYLES.wrapper) 34 const title = element("div", STYLES.title) 35 36 const link = element("a", STYLES.link, location.name || "") 37 link.href = admin 38 ? `/admin/fortresses/${encodeURIComponent(location.identifier)}` 39 : `/fortresses/${encodeURIComponent(location.id)}` 40 title.append(link) 41 42 // Brouillon = tout ce qui n'est pas strictement publié (status false ou NULL). 43 if (location.published !== true) { 44 title.append(" ", element("span", STYLES.draft, "(brouillon)")) 45 } 46 47 // Brouillon incomplet (non publiable) : « ! », le détail de ce qui manque est 48 // dans l'info-bulle native (title). 49 if (location.incomplete) { 50 const warn = element("span", STYLES.warn, "!") 51 warn.title = `Incomplet â manque : ${(location.blockers || []).join(", ")}` 52 title.append(" ", warn) 53 } 54 55 wrapper.append(title) 56 if (location.typology_name) wrapper.append(element("div", STYLES.typology, location.typology_name)) 57 if (location.multilang_name) wrapper.append(element("div", STYLES.multilang, location.multilang_name)) 58 59 return wrapper 60};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.