From 1fd66641daa0dbbf872a10b727e0de21e4a11bf1 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 09:40:12 +0200 Subject: [PATCH] Add files via upload --- kontakt/contact-scrape.go | 13 ++++--------- kontakt/index.html | 40 +++++++++++++++++++-------------------- 2 files changed, 24 insertions(+), 29 deletions(-) diff --git a/kontakt/contact-scrape.go b/kontakt/contact-scrape.go index 4805f88..119e293 100644 --- a/kontakt/contact-scrape.go +++ b/kontakt/contact-scrape.go @@ -192,18 +192,13 @@ func parseExcelFile(filename string) ([]Contact, error) { } sheetName := sheets[0] - var contacts []Contact - - // Parse first table (A-D columns) - contacts = append(contacts, parseTable(f, sheetName, "A", "D", 1)...) - - // Parse second table (F-H columns) - contacts = append(contacts, parseTable(f, sheetName, "F", "H", 2)...) - + + // Parse the single table (columns A-E) + contacts := parseTable(f, sheetName, "A", "E") return contacts, nil } -func parseTable(f *excelize.File, sheetName, startCol, endCol string, tableNum int) []Contact { +func parseTable(f *excelize.File, sheetName, startCol, endCol string) []Contact { var contacts []Contact var currentContact *Contact diff --git a/kontakt/index.html b/kontakt/index.html index 63b3dec..2e2895c 100644 --- a/kontakt/index.html +++ b/kontakt/index.html @@ -230,9 +230,17 @@ function filterContacts() { const query = document.getElementById('searchInput').value.toLowerCase().trim(); + const activeTab = document.querySelector('.switcher-btn.active').dataset.type; + + // Get contacts based on active tab + let contacts = []; + if (activeTab === 'main') { + contacts = [...allContacts.filter(c => !c.internal)]; + } else if (activeTab === 'internal') { + contacts = [...allContacts.filter(c => c.internal)]; + } // Apply table filter - let contacts = allContacts; if (currentTableFilter !== 'all') { contacts = contacts.filter(contact => contact.table == currentTableFilter); } @@ -315,26 +323,18 @@ } function showContacts(type) { - const mainDiv = document.getElementById('contacts'); - const internalDiv = document.getElementById('internal-contacts'); - const mainBtn = document.getElementById('showMainContacts'); - const internalBtn = document.getElementById('showInternalContacts'); + // Update switcher buttons + document.querySelectorAll('.switcher-btn').forEach(btn => { + btn.classList.remove('active', 'bg-blue-600', 'text-white'); + btn.classList.add('bg-gray-100', 'text-gray-700'); + if (btn.dataset.type === type) { + btn.classList.add('active', 'bg-blue-600', 'text-white'); + btn.classList.remove('bg-gray-100', 'text-gray-700'); + } + }); - if (type === 'main') { - mainDiv.classList.remove('hidden'); - internalDiv.classList.add('hidden'); - mainBtn.classList.add('bg-blue-600', 'text-white'); - mainBtn.classList.remove('bg-gray-100', 'text-gray-700'); - internalBtn.classList.remove('bg-blue-600', 'text-white'); - internalBtn.classList.add('bg-gray-100', 'text-gray-700'); - } else { - mainDiv.classList.add('hidden'); - internalDiv.classList.remove('hidden'); - mainBtn.classList.remove('bg-blue-600', 'text-white'); - mainBtn.classList.add('bg-gray-100', 'text-gray-700'); - internalBtn.classList.add('bg-blue-600', 'text-white'); - internalBtn.classList.remove('bg-gray-100', 'text-gray-700'); - } + // Filter contacts for the selected type + filterContacts(); } async function reloadContacts() {