From 00c3d853b17ed03af4bf1ae22a60f339adf413d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Dvo=C5=99=C3=A1k?= <150935816+Dvorinka@users.noreply.github.com> Date: Fri, 23 May 2025 10:25:08 +0200 Subject: [PATCH] Add files via upload --- kontakt/index.html | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/kontakt/index.html b/kontakt/index.html index e498649..83330d8 100644 --- a/kontakt/index.html +++ b/kontakt/index.html @@ -201,23 +201,24 @@ function filterContacts() { const query = document.getElementById('searchInput').value.toLowerCase().trim(); - const activeTab = document.querySelector('.switcher-btn.active')?.dataset.type || 'main'; - // Get contacts for active tab - const contacts = activeTab === 'main' ? - (currentData?.Contacts || []) : - (currentData?.InternalContacts || []); - - // Apply search filter - const filteredContacts = query ? - contacts.filter(c => - (c.name && c.name.toLowerCase().includes(query)) || - (c.position && c.position.toLowerCase().includes(query)) || - (c.phone && c.phone.includes(query)) || - (c.service_phone && c.service_phone.includes(query)) - ) : contacts; - - displayContacts(filteredContacts, query); + // Always show all contacts when searching + if (query) { + const allContacts = [...(currentData?.Contacts || []), ...(currentData?.InternalContacts || [])]; + const filteredContacts = allContacts.filter(contact => + (contact.name && contact.name.toLowerCase().includes(query)) || + (contact.position && contact.position.toLowerCase().includes(query)) || + (contact.phone && contact.phone.includes(query)) || + (contact.service_phone && contact.service_phone.includes(query)) + ); + displayContacts(filteredContacts, query); + } + // Show only active tab's contacts when no search + else { + const activeTab = document.querySelector('.switcher-btn.active')?.dataset.type || 'main'; + const contacts = activeTab === 'main' ? currentData?.Contacts : currentData?.InternalContacts; + displayContacts(contacts || [], ''); + } } function showError(message) {