// ============================================ // CORE - Initialisierung und Rendering // Gutachter Symbolbibliothek v2.0 // ============================================ // ========== GLOBALE VARIABLEN ========== let currentFilter = 'all'; let currentSearch = ''; let selectedSymbols = new Set(); let legendItems = []; // ========== INITIALISIERUNG ========== document.addEventListener('DOMContentLoaded', function() { renderSymbols(); setupEventListeners(); loadLegendFromStorage(); }); // ========== EVENT LISTENERS ========== function setupEventListeners() { // Suche document.getElementById('searchInput').addEventListener('input', function(e) { currentSearch = e.target.value.toLowerCase(); renderSymbols(); }); // Filter Pills document.querySelectorAll('.filter-pill').forEach(pill => { pill.addEventListener('click', function() { document.querySelectorAll('.filter-pill').forEach(p => p.classList.remove('active')); this.classList.add('active'); currentFilter = this.dataset.filter; renderSymbols(); }); }); // Modal schließen document.getElementById('legendModal').addEventListener('click', function(e) { if (e.target === this) { closeLegendModal(); } }); // Escape-Taste zum Schließen document.addEventListener('keydown', function(e) { if (e.key === 'Escape') { closeLegendModal(); } }); } // ========== SYMBOLE RENDERN ========== function renderSymbols() { const container = document.getElementById('symbolGrid'); container.innerHTML = ''; let hasResults = false; Object.keys(SYMBOLS).forEach(categoryKey => { const category = SYMBOLS[categoryKey]; // Filter nach Kategorie if (currentFilter !== 'all' && currentFilter !== categoryKey) { return; } const filteredItems = category.items.filter(item => { if (!currentSearch) return true; return item.name.toLowerCase().includes(currentSearch) || item.tags.some(tag => tag.toLowerCase().includes(currentSearch)); }); if (filteredItems.length === 0) return; hasResults = true; // Kategorie-Header const categoryHeader = document.createElement('div'); categoryHeader.className = 'category-header'; categoryHeader.innerHTML = `${category.icon} ${category.name}${filteredItems.length} Symbole`; container.appendChild(categoryHeader); // Symbol-Grid für diese Kategorie const categoryGrid = document.createElement('div'); categoryGrid.className = 'category-grid'; filteredItems.forEach(item => { const card = createSymbolCard(item, categoryKey); categoryGrid.appendChild(card); }); container.appendChild(categoryGrid); }); if (!hasResults) { container.innerHTML = '