// Función para cargar datos CSV async function loadCSVData() { try { const response = await fetch('data/options.csv'); const csvData = await response.text(); const lines = csvData.split('\n'); const headers = lines[0].split(','); // Crear objeto con arrays para cada columna const data = {}; headers.forEach(header => { data[header.trim()] = []; }); // Llenar los arrays con los datos for (let i = 1; i < lines.length; i++) { const values = lines[i].split(','); headers.forEach((header, index) => { if (values[index]) { data[header.trim()].push(values[index].trim()); } }); } // Llenar los selects con los datos correspondientes Object.keys(data).forEach(key => { const select = document.querySelector(`select[name="${key}"]`); if (select) { data[key].forEach(value => { if (value) { const option = document.createElement('option'); option.value = value; option.textContent = value; select.appendChild(option); } }); } }); } catch (error) { console.error('Error al cargar el archivo CSV:', error); } } // Función para inicializar componentes document.addEventListener('DOMContentLoaded', function() { // Cargar datos del CSV loadCSVData(); // Inicializar tooltips const tooltipTriggers = document.querySelectorAll('[data-tooltip]'); tooltipTriggers.forEach(trigger => { trigger.addEventListener('mouseenter', function() { const tooltip = document.createElement('div'); tooltip.className = 'tooltip'; tooltip.textContent = this.getAttribute('data-tooltip'); const rect = this.getBoundingClientRect(); tooltip.style.position = 'absolute'; tooltip.style.left = `${rect.left + rect.width/2}px`; tooltip.style.top = `${rect.top - 40}px`; tooltip.style.transform = 'translateX(-50%)'; document.body.appendChild(tooltip); this.addEventListener('mouseleave', function() { tooltip.remove(); }); }); }); // Validación de formulario adicional const form = document.getElementById('flightForm'); if (form) { form.addEventListener('submit', function(e) { // Validación adicional puede ir aquí }); } // Cargar feather icons if (window.feather) { feather.replace(); } });