Enjambre Discografia Access
// elementos DOM const gridContainer = document.getElementById('discogGrid'); const searchInput = document.getElementById('searchInput'); const filterBtns = document.querySelectorAll('.filter-btn'); const statsSpan = document.getElementById('statsCounter');
// fondo de imagen con gradiente + ícono representativo const bgGradient = `linear-gradient(135deg, ${album.coverColor}dd, ${album.coverColor}aa)`; // lista de tracks (mostrar máximo 6 primeros) const trackListItems = album.tracks.slice(0, 8).map(track => `<li><i class="fas fa-music" style="font-size: 0.6rem; margin-right: 4px;"></i> ${escapeHtml(track)}</li>`).join(''); const moreTracks = album.tracks.length > 8 ? `<li style="background: none;">+${album.tracks.length - 8} más</li>` : ''; enjambre discografia
// pequeño helper para evitar XSS function escapeHtml(str) { return str.replace(/[&<>]/g, function(m) { if (m === '&') return '&'; if (m === '<') return '<'; if (m === '>') return '>'; return m; }).replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g, function(c) { return c; }); } // elementos DOM const gridContainer = document
// renderizar grid con animación sencilla function render() { const filteredData = filterDiscos(); const total = filteredData.length; statsSpan.innerHTML = `📀 ${total} ${total === 1 ? 'disco' : 'discos'}`; const searchInput = document.getElementById('searchInput')
// Helper: normalizar texto function normalizeText(txt) { return txt.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g, ""); }
// construcción de cards let html = ''; for (let album of filteredData) { // tipo legible let typeLabel = ''; let typeIcon = ''; if (album.type === 'estudio') { typeLabel = 'Álbum de estudio'; typeIcon = '🎙️'; } else if (album.type === 'ep') { typeLabel = 'EP / Extended Play'; typeIcon = '💿'; } else if (album.type === 'live') { typeLabel = 'En vivo / Concierto'; typeIcon = '🎤'; }
// evento búsqueda searchInput.addEventListener('input', onSearchInput);