cambiarMapaDinamico(".ver-en-mapa", '[id^="mapa-contenedor"]'); /** * Rota imágenes en los elementos con clase específica * @param {String} selector - Selector de las imágenes rotativas * @param {Number} intervalo - Tiempo de cambio en milisegundos */ function iniciarRotacionImagenes(selector = ".img-rotativa", intervalo = 3000) { const imagenesRotativas = document.querySelectorAll(selector); imagenesRotativas.forEach((img) => { const imagenes = JSON.parse(img.getAttribute("data-imagenes") || "[]"); let index = 0; if (imagenes.length > 1) { setInterval(() => { index = (index + 1) % imagenes.length; img.src = imagenes[index]; }, intervalo); } }); } function cambiarMapaDinamico(selectorEnlaces, contenedorMapaId) { // Verificar si existen los elementos para evitar errores const enlacesVerMapa = document.querySelectorAll(selectorEnlaces); if (enlacesVerMapa.length === 0) return; // Agregar el evento de click para cada enlace enlacesVerMapa.forEach(function (enlace) { enlace.addEventListener("click", function (e) { e.preventDefault(); // Obtener el iframe del data-iframe const nuevoIframe = this.getAttribute("data-iframe"); // Buscar el contenedor del mapa más cercano dentro de la ciudad const tabContent = this.closest(".tab-pane"); const mapaContenedor = tabContent.querySelector(contenedorMapaId); // Si existe el contenedor del mapa, se reemplaza el contenido if (mapaContenedor) { mapaContenedor.innerHTML = nuevoIframe; } }); }); } function searchFilter(inputId, itemsSelector, messageSelector) { const input = document.getElementById(inputId); const items = document.querySelectorAll(itemsSelector); const messageElement = document.querySelector(messageSelector); input.addEventListener("input", function () { const search = input.value .toLowerCase() .normalize("NFD") .replace(/[\u0300-\u036f]/g, ""); let matchesFound = false; items.forEach((item) => { const name = item.getAttribute("data-name"); if (name.includes(search)) { item.style.display = "block"; matchesFound = true; } else { item.style.display = "none"; } }); // Mostrar o ocultar el mensaje if (!matchesFound) { messageElement.style.display = "block"; } else { messageElement.style.display = "none"; } }); } (() => { 'use strict' const forms = document.querySelectorAll('.needs-validation') Array.from(forms).forEach(form => { form.addEventListener('submit', event => { if (!form.checkValidity()) { event.preventDefault() event.stopPropagation() } form.classList.add('was-validated') }, false) }) })()