1document.addEventListener('DOMContentLoaded', function() { 2 3 const mapContainer = document.querySelector('.modulo-mappa-africa'); 4 5 // 2. Se non c'è la mappa in questa pagina, interrompo subito l'esecuzione 6 if (!mapContainer) return; 7 8 // Elementi mappa e card 9 const pathPaesi = document.querySelectorAll('svg g[id]'); 10 const cardContainer = document.getElementById('card-paese'); 11 const cardTitolo = document.getElementById('card-titolo'); 12 const cardListaDati = document.getElementById('card-lista-dati'); 13 const cardLink = document.getElementById('card-link'); 14 15 // Elementi Custom Dropdown Paesi 16 const selectedPaeseBtn = document.getElementById('selected-paese'); 17 const optionsPaeseList = document.getElementById('options-paese'); 18 const itemsPaese = optionsPaeseList.querySelectorAll('li'); 19 20 // Elementi Custom Dropdown Ambiti 21 const selectedAmbitoBtn = document.getElementById('selected-ambito'); 22 const optionsAmbitoList = document.getElementById('options-ambito'); 23 const itemsAmbito = optionsAmbitoList.querySelectorAll('li'); 24 25 // Dati JSON 26 const jsonDataElement = document.getElementById('dati-mappa-json'); 27 if (!jsonDataElement) return; 28 const datiMappa = JSON.parse(jsonDataElement.textContent); 29 30 // ========================================== 31 // FUNZIONE HELPER PER PULIRE L'ID DELL'SVG 32 // Trasforma "Maurizio_x7C_Mauritius_x7C_Maurice_x7C_MaurÃcia_x7C_Mauricia_x0A_" 33 // in un array: ["maurizio", "mauritius", "maurice", "maurÃcia", "mauricia"] 34 // ========================================== 35 function parseSvgId(rawId) { 36 if (!rawId) return []; 37 // Rimuovi ritorni a capo sporchi di Illustrator 38 let cleaned = rawId.replace(/_x0A_/g, ''); 39 // Sostituisci _x7C_ (pipe) con il pipe vero 40 cleaned = cleaned.replace(/_x7C_/g, '|'); 41 // Trasforma in minuscolo e dividi per il pipe 42 return cleaned.toLowerCase().split('|').map(s => s.trim()); 43 } 44 45 46 // ========================================== 47 // AGGIUNTA: CLASSE 'HAS-DATA' PER L'HOVER CSS 48 // ========================================== 49 // Scorriamo TUTTI i tag <g> dell'SVG e verifichiamo se almeno una delle parole nel loro ID 50 // corrisponde a una chiave del nostro JSON 51 pathPaesi.forEach(function(path) { 52 const rawId = path.getAttribute('id'); 53 const possibleNames = parseSvgId(rawId); 54 55 let foundMatch = false; 56 57 for (const possibleName of possibleNames) { 58 // Normalizziamo anche per sicurezza (es. togliendo gli spazi o apostrofi come fai dopo) 59 const normalizedName = possibleName.replace(/[\s'â]/g, '_'); 60 61 if (datiMappa[normalizedName]) { 62 foundMatch = true; 63 // Assegniamo al path un attributo "data-slug-json" per facilitare la vita dopo! 64 path.setAttribute('data-slug-json', normalizedName); 65 break; // Ne basta uno, usciamo dal ciclo 66 } 67 } 68 69 if (foundMatch) { 70 path.classList.add('has-data'); 71 } 72 }); 73 74 // ========================================== 75 // GESTIONE DROPDOWN PAESI 76 // ========================================== 77 selectedPaeseBtn.addEventListener('click', function(e) { 78 e.stopImmediatePropagation(); 79 80 // Chiudi l'altro 81 optionsAmbitoList.classList.remove('open'); 82 const frecciaAmbito = selectedAmbitoBtn.querySelector('.icon-chevron-down'); 83 if (frecciaAmbito) frecciaAmbito.classList.remove('rotate'); 84 85 optionsPaeseList.classList.toggle('open'); 86 this.querySelector('.icon-chevron-down').classList.toggle('rotate'); 87 }); 88 89 itemsPaese.forEach(item => { 90 item.addEventListener('click', function() { 91 itemsPaese.forEach(i => i.classList.remove('selected')); 92 this.classList.add('selected'); 93 94 const slug = this.getAttribute('data-value'); 95 const nomeTesto = this.textContent.trim(); 96 97 const spanTesto = selectedPaeseBtn.querySelector('.value-paese'); 98 if (spanTesto) spanTesto.innerHTML = nomeTesto; 99 100 optionsPaeseList.classList.remove('open'); 101 selectedPaeseBtn.querySelector('.icon-chevron-down').classList.remove('rotate'); 102 103 impostaPaese(slug); 104 105 selectedPaeseBtn.classList.add('has-selection'); 106 107 // RESET AMBITI (visivo + logico) 108 selectedAmbitoBtn.classList.remove('has-selection'); 109 110 const spanTestoAmbito = selectedAmbitoBtn.querySelector('.value-ambito'); 111 if (spanTestoAmbito) { 112 spanTestoAmbito.textContent = window.mappaTranslations.selezionaAmbito; 113 } 114 115 itemsAmbito.forEach(i => i.classList.remove('selected')); 116 }); 117 });
118 119 120 // ========================================== 121 // GESTIONE DROPDOWN AMBITI D'INTERVENTO (MULTI-SELECT) 122 // ========================================== 123 selectedAmbitoBtn.addEventListener('click', function(e) { 124 e.stopPropagation(); 125 126 // Chiudi l'altro (Paesi) 127 optionsPaeseList.classList.remove('open'); 128 const iconaFrecciaPaese = selectedPaeseBtn.querySelector('.icon-chevron-down'); 129 if (iconaFrecciaPaese) iconaFrecciaPaese.classList.remove('rotate'); 130 131 optionsAmbitoList.classList.toggle('open'); 132 this.querySelector('.icon-chevron-down').classList.toggle('rotate'); 133 }); 134 135 itemsAmbito.forEach(item => { 136 item.addEventListener('click', function(e) { 137 e.stopImmediatePropagation(); 138 139 // RESET PAESE (visivo + logico) 140 selectedPaeseBtn.classList.remove('has-selection'); 141 142 const spanTestoPaese = selectedPaeseBtn.querySelector('.value-paese'); 143 if (spanTestoPaese) { 144 spanTestoPaese.textContent = window.mappaTranslations.selezionaPaese; 145 } 146 147 itemsPaese.forEach(i => i.classList.remove('selected')); 148 149 const slugAmbito = this.getAttribute('data-value'); 150 151 // Se clicco su "Seleziona l'ambito" (data-value vuoto), resetto tutto 152 if (!slugAmbito) { 153 itemsAmbito.forEach(i => i.classList.remove('selected')); 154 this.classList.add('selected'); 155 } else { 156 // Aggiungo/rimuovo la selezione da questa voce 157 this.classList.toggle('selected'); 158 } 159 160 // Raccolgo tutti gli ambiti attualmente selezionati 161 let ambitiSelezionati = []; 162 let nomiSelezionati = []; 163 164 itemsAmbito.forEach(i => { 165 if (i.classList.contains('selected') && i.getAttribute('data-value')) { 166 ambitiSelezionati.push(i.getAttribute('data-value')); 167 nomiSelezionati.push(i.textContent.trim()); 168 } 169 }); 170 171 // Aggiorno il testo del bottone 172 const spanTesto = selectedAmbitoBtn.querySelector('.value-ambito'); 173 174 if (ambitiSelezionati.length === 0) { 175 spanTesto.innerHTML = window.mappaTranslations.selezionaAmbito; 176 } else if (ambitiSelezionati.length === 1) { 177 spanTesto.innerHTML = nomiSelezionati[0]; // Se è uno solo, metto il suo nome 178 } else { 179 spanTesto.innerHTML = ambitiSelezionati.length + " " + window.mappaTranslations.selezionati; 180 } 181 182 if (ambitiSelezionati.length > 0) { 183 selectedAmbitoBtn.classList.add('has-selection'); 184 } else { 185 selectedAmbitoBtn.classList.remove('has-selection'); 186 } 187 188 // Chiamo la nuova funzione passandogli l'array degli ambiti 189 filtraMappaPerAmbitiMultipli(ambitiSelezionati); 190 }); 191 }); 192 193 194 // ========================================== 195 // CHIUSURA GLOBALE DEI DROPDOWN E RESET AL CLICK FUORI 196 // ========================================== 197 document.addEventListener('click', function(e) { 198 // 1. Logica originale: Chiudi le tendine 199 optionsPaeseList.classList.remove('open'); 200 const iconaFrecciaPaese = selectedPaeseBtn.querySelector('.icon-chevron-down'); 201 if (iconaFrecciaPaese) iconaFrecciaPaese.classList.remove('rotate'); 202 203 optionsAmbitoList.classList.remove('open'); 204 const iconaFrecciaAmbito = selectedAmbitoBtn.querySelector('.icon-chevron-down'); 205 if (iconaFrecciaAmbito) iconaFrecciaAmbito.classList.remove('rotate'); 206 207 // 2. NUOVA LOGICA: Controllo dove ha cliccato l'utente
208 // Verifichiamo se il click è avvenuto su un elemento interattivo della mappa/filtri 209 const clickSuFiltri = e.target.closest('#selected-paese') || e.target.closest('#options-paese') || e.target.closest('#selected-ambito') || e.target.closest('#options-ambito'); 210 const clickSuMappa = e.target.closest('svg g[id].has-data'); // Clic su un paese specifico della mappa 211 const clickSuCard = e.target.closest('#card-paese'); // Clic sulla card/tooltip popup 212 const clickSuInterventi = e.target.closest('#interventi-paese-section'); // Clicca sullo slider in basso 213 214 // Se l'utente clicca fuori da tutto (es. sfondo bianco del sito o spazio vuoto dell'SVG) 215 if (!clickSuFiltri && !clickSuMappa && !clickSuCard && !clickSuInterventi) { 216 resetMappaGenerale(); 217 } 218 }); 219 220 221 // ========================================== 222 // FUNZIONE HELPER: COSTRUISCI E MOSTRA CARD 223 // ========================================== 224 function mostraCard(slug) { 225 const dati = datiMappa[slug]; 226 if (!dati) return; 227 228 // Invece di cercare l'ID letterale, usiamo il data-attribute che abbiamo iniettato all'inizio! 229 const pathAttivo = document.querySelector(`svg [data-slug-json="${slug}" i]`); 230 231 // Se non lo trovo, nascondo la card ed esco 232 if (!pathAttivo) { 233 cardContainer.style.display = 'none'; 234 return; 235 } 236 237 // Popola i dati 238 cardTitolo.innerHTML = dati.titolo; 239 cardLink.href = dati.link; 240 cardListaDati.innerHTML = ''; 241 242 if (dati.statistiche && dati.statistiche.length > 0) { 243 dati.statistiche.forEach(function(stat) { 244 const li = document.createElement('li'); 245 li.innerHTML = `<strong>${stat.numero}</strong> ${stat.testo}`; 246 cardListaDati.appendChild(li); 247 }); 248 } 249 250 // Mostra la card per poterla misurare 251 cardContainer.style.display = 'block'; 252 253 const mapContainer = document.querySelector('.modulo-mappa-africa'); 254 255 if (window.innerWidth <= 768) { 256 cardContainer.style.left = '50%'; 257 cardContainer.style.transform = 'translateX(-50%)'; 258 cardContainer.style.width = 'calc(100% - 40px)'; 259 cardContainer.style.maxWidth = '286px'; 260 cardContainer.style.bottom = 'auto'; 261 } else { 262 cardContainer.style.transform = 'none'; 263 cardContainer.style.bottom = 'auto'; 264 cardContainer.style.width = 'auto'; 265 cardContainer.style.maxWidth = 'none'; 266 } 267 268 const containerRect = mapContainer.getBoundingClientRect(); 269 const svgContainer = document.querySelector('.svg-container'); 270 const svgRect = svgContainer.getBoundingClientRect(); 271 const pathRect = pathAttivo.getBoundingClientRect(); 272 273 // Calcolo l'altezza dei filtri per la "zona di sicurezza" 274 const filtriContainer = document.querySelector('.filtri-mappa'); 275 const filtriHeight = filtriContainer ? filtriContainer.offsetHeight : 0; 276 277 const cardRect = cardContainer.getBoundingClientRect(); 278 const gap = 20; 279 280 let posLeft, posTop; 281 282 // CONTROLLO RESPONSIVE: Mobile o Desktop? 283 if (window.innerWidth <= 768) { 284 // --- LOGICA MOBILE DINAMICA --- 285 const svgCenterY = svgRect.top + (svgRect.height / 2); 286 const pathCenterY = pathRect.top + (pathRect.height / 2); 287 288 if (pathCenterY < svgCenterY) { 289 // NORD (Sopra la metà ): La card appare SOTTO il paese (Es. Etiopia) 290 posTop = (pathRect.bottom - containerRect.top) + gap; 291 } else { 292 // SUD (Sotto la metà ): La card appare SOPRA il paese (Es. Angola, Mozambico) 293 posTop = (pathRect.top - containerRect.top) - cardRect.height - gap; 294 } 295 296 // --- PROTEZIONI ANTI-OVERLAP --- 297 // A. Evita che la card salga troppo e copra i menu a tendina 298 const minSafeTop = filtriHeight + 10; 299 if (posTop < minSafeTop) { 300 posTop = minSafeTop; 301 } 302 303 // B. Evita che la card sbrodoli fuori dal fondo del container 304 const maxSafeTop = containerRect.height - cardRect.height - 10; 305 if (posTop > maxSafeTop) { 306 posTop = maxSafeTop; 307 } 308 309 cardContainer.style.top = `${posTop}
309px`; 310 311 } else { 312 // --- LOGICA DESKTOP (Insegue la nazione a Sinistra o Destra) --- 313 let posLeft = (pathRect.left - containerRect.left) - cardRect.width - gap; 314 if (posLeft < 10) { 315 posLeft = (pathRect.right - containerRect.left) + gap; 316 } 317 318 let posTop = (pathRect.top - containerRect.top) + (pathRect.height / 2) - (cardRect.height / 2); 319 320 cardContainer.style.left = `${posLeft}px`; 321 cardContainer.style.top = `${posTop}px`; 322 } 323 } 324 325 326 // ========================================== 327 // LOGICA MAPPA: SINGOLO PAESE 328 // ========================================== 329 function impostaPaese(valore) { 330 pathPaesi.forEach(path => path.classList.remove('attivo')); 331 332 const interventiSection = document.getElementById('interventi-paese-section'); 333 const interventiWrapper = document.getElementById('interventi-paese-wrapper'); 334 335 // Resetta la tendina ambiti 336 const spanTestoAmbito = selectedAmbitoBtn.querySelector('.value-ambito'); 337 if (spanTestoAmbito) { 338 spanTestoAmbito.textContent = window.mappaTranslations.selezionaAmbito; 339 itemsAmbito.forEach(i => i.classList.remove('selected')); 340 } 341 342 if (!valore) { 343 cardContainer.style.display = 'none'; 344 345 if (interventiSection) { 346 interventiSection.style.display = 'none'; 347 interventiSection.classList.remove("active"); 348 } 349 350 selectedPaeseBtn.classList.remove('has-selection'); 351 352 return; 353 } 354 355 const slug = valore.replace(/[\s'â]/g, '_').toLowerCase(); 356 357 if (datiMappa[slug]) { 358 const dati = datiMappa[slug]; 359 360 // Illumina mappa usando il nostro comodo data-attribute 361 const pathAttivo = document.querySelector(`[data-slug-json="${slug}" i]`); 362 if (pathAttivo) pathAttivo.classList.add('attivo'); 363 364 // Sincronizza il testo del bottone 365 const spanTesto = selectedPaeseBtn.querySelector('.value-paese'); 366 if (spanTesto) spanTesto.innerHTML = dati.titolo; 367 368 // Richiama la funzione helper per mostrare la card 369 mostraCard(slug); 370 371 // --- GESTIONE SLIDER INTERVENTI --- 372 if (interventiSection && interventiWrapper) { 373 if (dati.interventi_html && dati.interventi_html.trim() !== '') { 374 // Inserisce l'html 375 interventiWrapper.innerHTML = dati.interventi_html; 376 interventiSection.style.display = 'block'; 377 interventiSection.classList.add("active"); 378 379 // GESTIONE VISIBILITÃ HEADER SLIDER (Frecce e pallini) 380 const sliderHeader = document.querySelector('.interventi-slider-header'); 381 if (sliderHeader) { 382 const limit = window.innerWidth <= 992 ? 1 : 3; 383 if (dati.interventi_count <= limit) { 384 sliderHeader.style.display = 'none'; 385 interventiSection.classList.add('no-slider-nav'); 386 } else { 387 sliderHeader.style.display = 'flex'; 388 interventiSection.classList.remove('no-slider-nav'); 389 } 390 } 391 392 // Inizializza o aggiorna lo slider 393 if (window.mapInterventiSwiper) { 394 window.mapInterventiSwiper.update(); 395 window.mapInterventiSwiper.slideTo(0); 396 } else { 397 window.mapInterventiSwiper = new Swiper('.js-interventi-paese-swiper', { 398 slidesPerView: 3, 399 spaceBetween: 20, 400 observer: true, 401 observeParents: true, 402 watchOverflow: true, 403 pagination: { 404 el: '.interventi-slider-pagination', 405 clickable: true, 406 renderBullet: function (index, className) { 407 let num = index + 1; 408 return '<span class="' + className + '">' + (num < 10 ? '0' + num : num) + '.</span>'; 409 }, 410 }, 411 navigation: { 412 nextEl: '.int-nav-next', 413 prevEl: '.int-nav-prev', 414 }, 415 breakpoints: { 416 0: { slidesPerView: 1.1 }, 417 993: { slidesPerView: 3 } 418 } 419 }); 420 } 421 } else { 422 interventiSection.style.display = 'none'; 423 interventiSection.classList.remove("active"); 424 } 425 } 426 } else { 427 cardContainer.style.display = 'none'; 428 if (interventiSection) { 429 interventiSection.style.display = 'none'; 430 interventiSection.classList.remove("active"); 431 } 432 } 433 } 434 435 // ========================================== 436 // FUNZIONE DI RESET GLOBALE DELLA MAPPA 437 // ========================================== 438 function resetMappaGenerale() { 439 // 1. Spegni la mappa (rimuove la classe 'attivo' da tutti i paesi) 440 pathPaesi.forEach(path => path.classList.remove('attivo')); 441 442 // 2. Nascondi la card / tooltip galleggiante 443 if (cardContainer) cardContainer.style.display = 'none'; 444 445 // 3. Nascondi lo slider degli interventi in basso 446 const interventiSection = document.getElementById('interventi-paese
446-section'); 447 if (interventiSection) { 448 interventiSection.style.display = 'none'; 449 interventiSection.classList.remove("active"); 450 } 451 452 // 4. Azzera il selettore dei Paesi 453 selectedPaeseBtn.classList.remove('has-selection'); 454 const spanTestoPaese = selectedPaeseBtn.querySelector('.value-paese'); 455 if (spanTestoPaese) spanTestoPaese.textContent = window.mappaTranslations.selezionaPaese; 456 itemsPaese.forEach(i => i.classList.remove('selected')); 457 458 // 5. Azzera il selettore degli Ambiti 459 selectedAmbitoBtn.classList.remove('has-selection'); 460 const spanTestoAmbito = selectedAmbitoBtn.querySelector('.value-ambito'); 461 if (spanTestoAmbito) spanTestoAmbito.textContent = window.mappaTranslations.selezionaAmbito; 462 itemsAmbito.forEach(i => i.classList.remove('selected')); 463 } 464 465 466 // ========================================== 467 // LOGICA MAPPA: FILTRO PER AMBITI MULTIPLI (Logica AND) 468 // ========================================== 469 function filtraMappaPerAmbitiMultipli(arrayAmbiti) { 470 pathPaesi.forEach(path => path.classList.remove('attivo')); 471 cardContainer.style.display = 'none'; 472 473 const interventiSection = document.getElementById('interventi-paese-section'); 474 const interventiWrapper = document.getElementById('interventi-paese-wrapper'); 475 476 // Resetta la tendina paesi 477 const spanTestoPaese = selectedPaeseBtn.querySelector('.value-paese'); 478 if (spanTestoPaese) { 479 spanTestoPaese.textContent = window.mappaTranslations.selezionaPaese; 480 itemsPaese.forEach(i => i.classList.remove('selected')); 481 } 482 483 if (!arrayAmbiti || arrayAmbiti.length === 0) { 484 if (interventiSection) { 485 interventiSection.style.display = 'none'; 486 interventiSection.classList.remove("active"); 487 } 488 return; 489 } 490 491 let paesiTrovati = []; 492 let htmlInterventiCombinato = ""; 493 let conteggioInterventiCombinato = 0; 494 let idAggiunti = new Set(); 495 496 for (const [id_json, dati] of Object.entries(datiMappa)) { 497 if (dati.ambiti && dati.ambiti.length > 0) { 498 499 const hasMatch = arrayAmbiti.every(ambito => dati.ambiti.includes(ambito)); 500 501 if (hasMatch) { 502 paesiTrovati.push(id_json); 503 504 const pathAttivo = document.querySelector(`[data-slug-json="${id_json}" i]`); 505 if (pathAttivo) { 506 pathAttivo.classList.add('attivo'); 507 } 508 509 if (dati.interventi_html && dati.interventi_html.trim() !== '') { 510 511 const tempContainer = document.createElement('div'); 512 tempContainer.innerHTML = dati.interventi_html; 513 const slides = tempContainer.querySelectorAll('.swiper-slide'); 514
515 slides.forEach(slide => { 516 const slideTopics = slide.getAttribute('data-topics'); 517 if (slideTopics) { 518 const topicArray = slideTopics.split(','); 519 const cardHasAllTopics = arrayAmbiti.every(ambito => topicArray.includes(ambito)); 520 521 if (cardHasAllTopics) { 522 const postId = slide.getAttribute('data-post-id'); 523 524 if (!idAggiunti.has(postId)) { 525 idAggiunti.add(postId); 526 527 const topicLabels = slide.querySelectorAll('.single-topic-item'); 528 topicLabels.forEach(label => { 529 const labelSlug = label.getAttribute('data-topic-slug'); 530 if (!arrayAmbiti.includes(labelSlug)) { 531 label.style.display = 'none'; 532 } 533 }); 534 535 htmlInterventiCombinato += slide.outerHTML; 536 conteggioInterventiCombinato++; 537 } 538 } 539 } 540 }); 541 } 542 } 543 } 544 } 545 546 if (paesiTrovati.length === 1) { 547 mostraCard(paesiTrovati[0]); 548 } 549 550 // GESTIONE SLIDER 551 if (interventiSection && interventiWrapper) { 552 if (htmlInterventiCombinato.trim() !== '') { 553 interventiWrapper.innerHTML = htmlInterventiCombinato; 554 interventiSection.style.display = 'block'; 555 interventiSection.classList.add("active"); 556 557 const sliderHeader = document.querySelector('.interventi-slider-header'); 558 if (sliderHeader) { 559 const limit = window.innerWidth <= 992 ? 1 : 3; 560 561 if (conteggioInterventiCombinato <= limit) { 562 sliderHeader.style.display = 'none'; 563 interventiSection.classList.add('no-slider-nav'); 564 } else { 565 sliderHeader.style.display = 'flex'; 566 interventiSection.classList.remove('no-slider-nav'); 567 } 568 } 569 570 if (window.mapInterventiSwiper) { 571 window.mapInterventiSwiper.update(); 572 window.mapInterventiSwiper.slideTo(0); 573 } else { 574 window.mapInterventiSwiper = new Swiper('.js-interventi-paese-swiper', { 575 slidesPerView: 3, 576 spaceBetween: 20, 577 observer: true, 578 observeParents: true, 579 watchOverflow: true, 580 pagination: { 581 el: '.interventi-slider-pagination', 582 clickable: true, 583 renderBullet: function (index, className) { 584 let num = index + 1; 585 return '<span class="' + className + '">' + (num < 10 ? '0' + num : num) + '.</span>'; 586 }, 587 }, 588 navigation: { 589 nextEl: '.int-nav-next', 590 prevEl: '.int-nav-prev', 591 }, 592 breakpoints: { 593 0: { slidesPerView: 1.1 }, 594 993: { slidesPerView: 3 } 595 } 596 }); 597 } 598 } else { 599 interventiSection.style.display = 'none'; 600 interventiSection.classList.remove("active"); 601 } 602 } 603 } 604 605 606 // ========================================== 607 // CLICK DIRETTO SULL'SVG DELLA MAPPA 608 // ========================================== 609 pathPaesi.forEach(path => { 610 path.addEventListener('click', function(e) { 611 612 // Se l'elemento cliccato NON ha la classe 'has-data', fermati 613 if (!this.classList.contains('has-data')) { 614 return; 615 } 616 617 // Invece di prendere l'ID sporco dell'SVG, usiamo lo slug pulito che abbiamo 618 // iniettato durante la fase di avvio (riga 50 circa) 619 const slugCliccato = this.getAttribute('data-slug-json'); 620 621 if (!slugCliccato) return; 622 623 // Riproduce il click come se fosse stato fatto dal menu dropdown dei paesi 624 itemsPaese.forEach(i => i.classList.remove('selected')); 625 626 const optionCorrispondente = optionsPaeseList.querySelector(`li[data-value="${slugCliccato}"]`); 627 628 if (optionCorrispondente) { 629 optionCorrispondente.classList.add('selected'); 630 } 631 632 selectedPaeseBtn.classList.add('has-selection'); 633 634 // Passo lo slug direttamente (è già pulito!) 635 impostaPaese(slugCliccato); 636 }); 637 });
638 639});
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.