'; }); html += ''; content.innerHTML = html; content.style.display = 'block'; document.querySelectorAll('.sym-item').forEach(function(el) { el.addEventListener('click', function() { var sym = el.dataset.sym; copyText(sym); el.style.background = '#e8f0fe'; el.style.borderColor = '#4a90e2'; setTimeout(function() { el.style.background = ''; el.style.borderColor = ''; }, 300); }); }); } function search(query) { query = query.trim().toLowerCase(); if (!query) { renderCategory(); return; } var html = ''; Object.keys(SYMBOLS).forEach(function(key) { var section = SYMBOLS[key]; // Also match by section label (category name), e.g. "数学" matches "数学符号" var labelMatched = section.label.toLowerCase().includes(query); var matched = section.items.filter(function(s) { return s.toLowerCase().includes(query); }); if (matched.length > 0 || labelMatched) { var items = labelMatched && matched.length === 0 ? section.items : matched; html += '

' + section.label + '

'; items.forEach(function(sym) { html += '
' + sym + '
'; }); html += '
'; } }); if (!html) html = '

未找到匹配的符号

'; content.innerHTML = html; document.querySelectorAll('.sym-item').forEach(function(el) { el.addEventListener('click', function() { var sym = el.dataset.sym; copyText(sym); }); }); } searchInput.addEventListener('input', function() { search(searchInput.value); }); renderNav(); renderCategory(); })();