PageSourceSearch

https://www.fiatlux.org.pe/wp-content/themes/spectra-child-theme/assets/script.js?v=2

js fiatlux.org.pe collected 2026-10-08 22:39:39 UTC 20,247 bytes, 464 lines download raw bytes

1document.addEventListener("DOMContentLoaded", function() {
2    //console.log("Script cargado y DOM listo");
3
4    // Seleccionamos tanto inputs como textareas
5    const inputs = document.querySelectorAll('.forminator-input, .forminator-textarea');
6    //console.log(inputs); // Verifica que se seleccionen correctamente
7
8    if (inputs.length > 0) {
9        inputs.forEach(input => {
10            // Chequear si el campo ya tiene texto al cargar la página
11            toggleLabel(input);
12
13            // Cuando el input está en foco
14            input.addEventListener('focus', () => {
15                input.parentNode.querySelector('label').classList.add('active');
16            });
17
18            // Cuando se pierde el foco, verificar si hay texto
19            input.addEventListener('blur', () => {
20                toggleLabel(input);
21            });
22
23            // Si el usuario escribe en el input o textarea
24            input.addEventListener('input', () => {
25                toggleLabel(input);
26            });
27        });
28    } else {
29        console.log('No se encontraron elementos con la clase .forminator-input o .forminator-textarea');
30    }
31
32    function toggleLabel(input) {
33        const label = input.parentNode.querySelector('label');
34        if (label) {
35            if (input.value.trim() !== "") {
36                label.classList.add('active');
37            } else {
38                label.classList.remove('active');
39            }
40        } else {
41            console.log('No se encontró el label para el input');
42        }
43    }
44});
45
46document.addEventListener("DOMContentLoaded", function() {
47    // Seleccionar el contenedor que tiene la lista de categorías
48    const listaCategorias = document.querySelector('.lista-categorias .uagb-heading-text');
49
50    if (listaCategorias) {
51        // Obtener el texto original y dividirlo por comas
52        let originalText = listaCategorias.innerText;
53        let categorias = originalText.split(',').map(categoria => categoria.trim());
54
55        // Crear los spans para cada categoría y eliminar las comas
56        let newText = categorias.map(categoria => {
57            return `<span class="categoria">${categoria}</span>`;
58        }).join(' '); // Unir con espacios
59
60        // Actualizar el contenido del elemento con los spans
61        listaCategorias.innerHTML = newText;
62    }
63});
64
65document.addEventListener("DOMContentLoaded", function() {
66    // Función para animar el contador
67    function animateCounter(counterElement) {
68        const numberElement = counterElement.querySelector('.uagb-heading-text');
69        if (numberElement) {
70            let targetNumber = parseFloat(numberElement.innerText.replace(',', '.')); // Obtener el número y manejar decimales
71            let currentNumber = 0;
72            let duration = 2000; // Duración de la animación en milisegundos
73            let increment = targetNumber / (duration / 16); // Calcular el incremento por frame (~16ms por frame)
74
75            function updateCounter() {
76                currentNumber += increment;
77                if (currentNumber >= targetNumber) {
78                    currentNumber = targetNumber; // Asegurarnos de que no sobrepase el valor objetivo
79                    numberElement.innerText = targetNumber.toFixed(1).replace('.', ','); // Mostrar el número final con formato
80                    return;
81                }
82                numberElement.innerText = currentNumber.toFixed(1).replace('.', ','); // Actualizar el número con formato de coma
83                requestAnimationFrame(updateCounter); // Continuar con la animación
84            }
85
86            // Iniciar el contador
87            updateCounter();
88        }
89    }
90
91    // Configuración del Intersection Observer
92    let options = {
93        root: null, // Usamos el viewport del navegador
94        rootMargin: '0px', // Sin margen extra
95        threshold: 0.5 // 50% visible para activar el contador
96    };
97
98    let observer = new IntersectionObserver(function(entries, observer) {
99        entries.forEach(entry => {
100            if (entry.isIntersecting) {
101                // El elemento está visible en el viewport, iniciamos la animación
102                animateCounter(entry.target);
103                observer.unobserve(entry.target); // Detenemos la observación una vez que se haya animado
104            }
105        });
106    }, options);
107
108    // Seleccionamos todos los elementos con la clase 'number-counter' para observarlos
109    const counters = document.querySelectorAll('.number-counter');
110    counters.forEach(counter => {
111        observer.observe(counter); // Iniciar la observación de cada contador
112    });
113});
114
115document.addEventListener('DOMContentLoaded', function() {
116    var buttons = document.querySelectorAll('.ver-mas-miembro');
117    var popupMiembro = document.getElementById('popup-miembro');
118    var cerrarPopup = document.getElementById('cerrar-popup');
119    var body = document.body;
120
121    var popupTitulo = document.getElementById('popup-titulo');
122    var popupCargo = document.getElementById('popup-cargo');
123    var popupDescripcion = document.getElementById('popup-descripcion');
124    var popupFrase = document.getElementById('popup-frase');
125    var popupImagen = document.getElementById('popup-imagen');
126
127    buttons.forEach(function(button) {
128        button.addEventListener('click', function() {
129            var miembroElement = this.closest('.miembro');
130            var titulo = this.getAttribute('data-titulo');
131            var cargo = this.getAttribute('data-cargo');
132            var frase = this.getAttribute('data-frase');
133            var imagen = this.getAttribute('data-imagen');
134
135            // Obtener la descripción desde el elemento oculto
136            var descripcion = miembroElement.querySelector('.descripcion-miembro').innerHTML;
137
138            popupTitulo.textContent = titulo;
139            popupCargo.textContent = cargo;
140            popupDescripcion.innerHTML = descripcion;
141            popupFrase.textContent = frase;
142            popupImagen.setAttribute('src', imagen);
143            popupImagen.setAttribute('alt', titulo);
144
145            // Mostrar el popup con efecto
146            popupMiembro.classList.add('abierto');
147            // Deshabilitar el scroll del body
148            body.style.overflow = 'hidden';
149        });
150    });
151
152    function closePopup() {
153        // Ocultar el popup
154        popupMiembro.classList.remove('abierto');
155        // Habilitar el scroll del body
156        body.style.overflow = '';
157    }
158
159    // Solo asignar el evento si cerrarPopup existe
160    if (cerrarPopup) {
161        cerrarPopup.addEventListener('click', closePopup);
162    }
163	
164	if (popupMiembro) {
165		// Cerrar el popup al hacer clic fuera del contenido
166		popupMiembro.addEventListener('click', function(e) {
167			if (!e.target.closest('.contenido-popup')) {
168				closePopup();
169			}
170		});
171	}
172});
173
174document.addEventListener("DOMContentLoaded", function() {
175  // List of form IDs and their respective name fields to validate
176  const forms = [
177    {
178      id: "forminator-module-1012",
179      fields: ["name-1", "name-2"]
180    },
181    {
182      id: "forminator-module-1342",
183      fields: ["name-11"]
184    },
185    {
186      id: "forminator-module-1479",
187      fields: ["name-11"]
188    },
189    {
190      id: "forminator-module-1470",
191      fields: ["name-11"]
192    },
193    {
194      id: "forminator-module-1471",
195      fields: ["name-23", "name-25"] // name-23 for letters, name-25 for numbers
196    }
197  ];
198
199  // Function to allow only letters, trim whitespace, and limit spaces
200  function allowOnlyLetters(event) {
201    // Remove leading spaces
202    event.target.value = event.target.value.trimStart();
203    // Allow only letters, accented characters, ñ, and a maximum of two consecutive spaces
204    const regex = /[^a-zA-ZáéíóúÁÉÍÓÚüÜñÑ\s]/g;
205    event.target.value = event.target.value.replace(regex, ""); // Remove invalid characters
206    // Replace more than two consecutive spaces with a single space
207    event.target.value = event.target.value.replace(/\s{3,}/g, "  "); // Restrict to max 2 spaces
208  }
209
210  // Function to allow only numbers
211  function allowOnlyNumbers(event) {
212    const regex = /[^0-9]/g; // Match anything that is not a number
213    event.target.value = event.target.value.replace(regex, ""); // Remove non-numeric characters
214  }
215
216  // Loop through each form configuration
217  forms.forEach(formConfig => {
218    const form = document.getElementById(formConfig.id);
219
220    if (form) {
221      // Attach input event listeners to each specified field
222      formConfig.fields.forEach(fieldName => {
223        const field = form.querySelector(`input[name='${fieldName}']`);
224        if (field) {
225          // Apply appropriate validation function
226          if (fieldName === "name-25") {
227            // For name-25, apply only numbers validation
228            field.addEventListener("input", allowOnlyNumbers);
229          } else {
230            // For other fields, apply letters validation
231            field.addEventListener("input", allowOnlyLetters);
232          }
233        }
234      });
235
236      // Trim spaces on form submission
237      form.addEventListener("submit", function() {
238        formConfig.fields.forEach(fieldName => {
239          const field = form.querySelector(`input[name='${fieldName}']`);
240          if (field) {
241            // Remove trailing spaces for text fields (numbers don't need this)
242            if (fieldName !== "name-25") {
243              field.value = field.value.trim();
244            }
245          }
246        });
247      });
248    }
249  });
250});
251
252document.addEventListener("DOMContentLoaded", () => {
253    // Selecciona el contenedor deplegable
254    const deplegable = document.querySelector(".contenido-a-desplegar .deplegable");
255    
256    // Crea el botón
257    const boton = document.createElement("button");
258    boton.textContent = "Mostrar más";
259    boton.classList.add("toggle-button");
260    
261    // Inserta el botón como hermano del contenedor deplegable
262    deplegable.parentNode.insertBefore(boton, deplegable.nextSibling);
263
264    // Agrega el evento al botón
265    boton.addEventListener("click", () => {
266        if (deplegable.style.maxHeight) {
267            // Contraer el contenido
268            deplegable.style.maxHeight = null;
269            boton.textContent = "Mostrar más";
270            boton.classList.remove("abierto");
271            
272            // Desplazarse al principio del contenedor
273            deplegable.scrollIntoView({ behavior: "smooth", block: "start" });
274        } else {
275            // Expandir el contenido al tamaño completo
276            deplegable.style.maxHeight = `${deplegable.scrollHeight}px`;
277            boton.textContent = "Mostrar menos";
278            boton.classList.add("abierto");
279        }
280    });
281});
282
283document.addEventListener("DOMContentLoaded", () => {
284    // Función para limpiar el contenido del label
285    function cleanUpLabel(divId, expectedTexts) {
286        // Seleccionar el div con el ID proporcionado
287        const fieldDiv = document.querySelector(`div#${divId}`);
288        
289        if (fieldDiv) {
290            // Buscar el label dentro del div
291            const label = fieldDiv.querySelector("label.forminator-label");
292            
293            if (label) {
294                // Obtener el contenido original del label
295                const originalContent = label.innerHTML;
296        
297                // Verificar si el label contiene exactamente las palabras en inglés
298                const labelText = label.textContent;
299
300                let containsExpectedText = expectedTexts.some(text => labelText.includes(text));
301
302                if (!containsExpectedText) {
303                    // Si no contiene los textos esperados en inglés, no hacemos nada
304                    return;
305                }
306
307                // Crear un elemento temporal para manipular el HTML
308                const tempElement = document.createElement('div');
309                tempElement.innerHTML = originalContent;
310        
311                // Variables para almacenar si ya hemos encontrado el texto esperado y el asterisco
312                let hasText = false;
313                let hasAsterisk = false;
314        
315                // Nuevo contenido para el label
316                let newContent = '';
317        
318                // Iterar sobre los nodos hijos del label
319                tempElement.childNodes.forEach(node => {
320                    if (node.nodeType === Node.TEXT_NODE) {
321                        // Es un nodo de texto
322                        const text = node.textContent.trim();
323                        if (expectedTexts.includes(text) && !hasText) {
324                            newContent += `${expectedTexts[0]} `;
325                            hasText = true;
326                        }
327                    } else if (node.nodeType === Node.ELEMENT_NODE) {
328                        // Es un elemento (por ejemplo, el span)
329                        if (node.matches('span.forminator-required') && !hasAsterisk) {
330                            newContent += '<span class="forminator-required">*</span>';
331                            hasAsterisk = true;
332                        }
333                    }
334                });
335        
336                // Actualizar el contenido del label solo si encontramos el texto esperado
337                if (hasText) {
338                    label.innerHTML = newContent.trim();
339                }
340            }
341        }
342    }
343
344    // Limpiar labels para los campos especificados solo si están en inglés
345    cleanUpLabel('name-1', ['Names']);
346    cleanUpLabel('name-2', ['Last name']);
347    cleanUpLabel('email-1', ['Email', 'E-mail']);
348});
349
350
351document.addEventListener("DOMContentLoaded", function () {
352    const links = document.querySelectorAll(".wp-block-navigation-item a");
353    
354    links.forEach((link) => {
355        if (link.href === window.location.href) {
356            link.parentElement.classList.add("active");
357
358            // Busca el elemento padre y agrégale la clase "active" si existe
359            let parent = link.closest(".wp-block-navigation-item").parentElement.closest(".wp-block-navigation-item");
360            if (parent) {
361                parent.classList.add("active");
362            }
363        }
364    });
365});
366
367
368document.addEventListener("DOMContentLoaded", () => {
369    const storageForm = sessionStorage.getItem('datosFormulario')
370    let formData = null
371    if(storageForm){
372        formData = JSON.parse(storageForm)
373    }
374    if(formData){
375        document.querySelector('input[name="hidden-2"]').value = formData?.tipo_pago
376        if(formData?.tipo_donante == 'Persona Natural'){
377            document.querySelector('input[name="radio-1"][value="one"]').checked = true
378            document.querySelector('input[name="name-11"]').value = formData?.nombres_completos
379            document.querySelector('input[name="email-1"]').value = formData?.correo
380            document.querySelector('input[name="hidden-1"]').value = formData?.pais
381            document.querySelector('select[name="select-2"]').value = formData?.pais
382            document.querySelector('select[name="select-1"]').value = formData?.pais_residencia || formData?.estado_residencia
383            if(formData?.monto_seleccionado){
384                const amountRadio = `input[name="radio-3"][value="${formData?.monto_seleccionado}"]`
385                document.querySelector(amountRadio).checked = true
386            }
387            if(formData?.desea_figurar_natural && formData?.desea_figurar_natural.includes('Sí')){
388                document.querySelector('input[name="radio-5"][value="one"]').checked = true
389            }else{
390                document.querySelector('input[name="radio-5"][value="two"]').checked = true
391            }
392            if(formData?.desea_figurar_juridico && formData?.desea_figurar_juridico.includes('Sí')){
393                document.querySelector('input[name="radio-6"][value="one"]').checked = true
394            }else{
395                document.querySelector('input[name="radio-6"][value="two"]').checked = true
396            }
397            if(formData?.dedicacion && formData?.dedicacion.includes('Sí')){
398                document.querySelector('input[name="radio-7"][value="one"]').checked = true
399            }else{
400                document.querySelector('input[name="radio-7"][value="two"]').checked = true
401            }
402            if(formData?.tipo_homenaje && formData?.tipo_homenaje.includes('En honor a')){
403                document.querySelector('input[name="radio-8"][value="one"]').checked = true
404            }else{
405                document.querySelector('input[name="radio-8"][value="two"]').checked = true
406            }
407            if(formData?.mensajeAlumni && formData?.mensajeAlumni == "Dejar un mensaje para los futuros Alumni PUCP"){
408                document.querySelector('input[name="radio-9"]').checked = true
409            }
410            document.querySelector('input[name="name-8"]').value = formData?.nombre_homenajeado
411            if(formData?.mensaje_homenajeado){
412                document.querySelector('textarea[name="textarea-1"]').value = formData?.mensaje_homenajeado
413            }
414            document.querySelector('textarea[name="textarea-2"]').value = formData?.mensaje_futuro_alumni
415
416            if(formData?.vinculacion_pucp){
417                const vinculacionRadio = `input[name="radio-10"][value="${formData?.vinculacion_pucp}"]`
418                document.querySelector(vinculacionRadio).checked = true
419            }
420
421        }else{
422            document.querySelector('input[name="radio-1"][value="two"]').checked = true
423            document.querySelector('input[name="email-2"]').value = formData?.correo
424            document.querySelector('input[name="name-22"]').value = formData?.domicilio_fiscal
425            document.querySelector('input[name="name-20"]').value = formData?.representante_legal
426            document.querySelector('input[name="hidden-1"]').value = formData?.pais
427            document.querySelector('select[name="select-2"]').value = formData?.estado_operacion || formData?.pais
428            document.querySelector('input[name="name-21"]').value = formData?.razon_social
429            if(formData?.monto_seleccionado){
430                const amountRadio = `input[name="radio-4"][value="${formData?.monto_seleccionado}"]`
431                document.querySelector(amountRadio).checked = true
432            }
433            if(formData?.desea_figurar_natural && formData?.desea_figurar_natural.includes('Sí')){
434                document.querySelector('input[name="radio-5"][value="one"]').checked = true
435            }else{
436                document.querySelector('input[name="radio-5"][value="two"]').checked = true
437            }
438            if(formData?.desea_figurar_juridico && formData?.desea_figurar_juridico.includes('Sí')){
439                document.querySelector('input[name="radio-6"][value="one"]').checked = true
440            }else{
441                document.querySelector('input[name="radio-6"][value="two"]').checked = true
442            }
443            if(formData?.mensajeAlumni && formData?.mensajeAlumni == "Dejar un mensaje para los futuros Alumni PUCP"){
444                document.querySelector('input[name="radio-9"]').checked = true
445            }
446            if(formData?.dedicacion && formData?.dedicacion.includes('Sí')){
447                document.querySelector('input[name="radio-7"][value="one"]').checked = true
448            }else{
449                document.querySelector('input[name="radio-7"][value="two"]').checked = true
450            }
451            if(formData?.mensajeAlumni && formData?.mensajeAlumni == "Dejar un mensaje para los futuros Alumni PUCP"){
452                document.querySelector('input[name="radio-9"]').checked = true
453            }
454            if(formData?.tipo_homenaje && formData?.tipo_homenaje.includes('En honor a')){
455                document.querySelector('input[name="radio-8"][value="one"]').checked = true
456            }else{
457                document.querySelector('input[name="radio-8"][value="two"]').checked = true
458            }
459            document.querySelector('input[name="name-8"]').value = formData?.nombre_homenajeado
460            document.querySelector('textarea[name="textarea-1"]').value = formData?.mensaje_homenajeado
461            document.querySelector('textarea[name="textarea-2"]').value = formData?.mensaje_futuro_alumni
462        }
463    }
464})

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.