Wedstrijdarchief

Bekijk de resultaten van eerder gehouden wedstrijden

Resultaten laden...

`); printWindow.document.close(); } // Setup filters function setupFilters() { const yearFilter = document.getElementById('filterYear'); const typeFilter = document.getElementById('filterType'); const searchInput = document.getElementById('filterSearch'); [yearFilter, typeFilter, searchInput].forEach(el => { el.addEventListener('change', applyFilters); el.addEventListener('input', applyFilters); }); } // Apply filters function applyFilters() { const year = document.getElementById('filterYear').value; const type = document.getElementById('filterType').value; const search = document.getElementById('filterSearch').value.toLowerCase(); const filtered = allCompetitions.filter(comp => { const [d, m, y] = comp.competition_date.split('-'); const compYear = y; const compType = comp.competition_type.toLowerCase(); const yearMatch = !year || compYear === year; const typeMatch = !type || compType.includes(type.toLowerCase()); const searchMatch = !search || compType.includes(search) || comp.competition_date.includes(search); return yearMatch && typeMatch && searchMatch; }); // Update display const container = document.getElementById('competitionCards'); if (filtered.length === 0) { container.innerHTML = `

Geen resultaten gevonden

`; } else { allCompetitions = filtered; renderCompetitions(); } } // Populate year filter function populateYearFilter() { const years = new Set(allCompetitions.map(c => c.competition_date.split('-')[2])); const yearFilter = document.getElementById('filterYear'); Array.from(years).sort().reverse().forEach(year => { const option = document.createElement('option'); option.value = year; option.textContent = year; yearFilter.appendChild(option); }); } // HTML escape — decodes any HTML entities first (handles names stored as & in DB) function escapeHtml(text) { const ta = document.createElement('textarea'); ta.innerHTML = text; const decoded = ta.value; const div = document.createElement('div'); div.textContent = decoded; return div.innerHTML; } // Close modal on background click document.addEventListener('DOMContentLoaded', () => { document.getElementById('competitionModal').addEventListener('click', function(e) { if (e.target === this) { closeModal(); } }); });