// Timeout dla automatycznej minimizacji po odpowiedzi z 🤖 let autoMinimizeTimeout = null; // Wyślij wiadomość po naciśnięciu Enter w polu #msg document.getElementById('msg').addEventListener('keydown', function (e) { if (e.key === 'Enter') { e.preventDefault(); send(); } }); // Start zminimalizowany i auto-rozszerzenie po 15 sekundach document.addEventListener('DOMContentLoaded', function () { const body = document.getElementById('chatbotBody'); const toggle = document.getElementById('chatbotToggle'); // Ustaw startowo na zminimalizowany body.classList.add('minimized'); toggle.textContent = '+'; toggle.setAttribute('aria-label', 'Otwórz czat'); // Zaplanuj automatyczne rozszerzenie po 15s let autoExpandTimeout = setTimeout(function () { if (body.classList.contains('minimized')) { body.classList.remove('minimized'); toggle.textContent = '−'; toggle.setAttribute('aria-label', 'Minimalizuj czat'); } }, 15000); // Obsługa kliknięcia — jeśli użytkownik otworzy ręcznie, anuluj automatyczne rozszerzenie toggle.addEventListener('click', function () { const isMin = body.classList.toggle('minimized'); this.textContent = isMin ? '+' : '−'; this.setAttribute('aria-label', isMin ? 'Otwórz czat' : 'Minimalizuj czat'); if (!isMin) { clearTimeout(autoExpandTimeout); } }); }); // JSON z listą plików galerii const galleryData = { "title": "Realizacje Olvik", "images": [ { "id": 1, "name": "Projekt 1", "thumbnail": "img/realizacje/1.jpg", "fullsize": "img/realizacje/1.jpg", "description": "Szafa na wymiar" }, { "id": 2, "name": "Projekt 2", "thumbnail": "img/realizacje/2.jpg", "fullsize": "img/realizacje/2.jpg", "description": "Kuchnia nowoczesna" } ] }; // Inicjalizacja zmiennych let currentImageIndex = 0; const images = galleryData.images; const mainImage = document.getElementById('mainImage'); const thumbnailsContainer = document.getElementById('thumbnailsContainer'); const prevBtn = document.getElementById('prevBtn'); const nextBtn = document.getElementById('nextBtn'); const imageCounter = document.getElementById('imageCounter'); const totalImages = document.getElementById('totalImages'); // Funkcja inicjalizacyjna function initGallery() { totalImages.textContent = images.length; renderThumbnails(); updateMainImage(); updateNavigationButtons(); } // Renderowanie miniaturek function renderThumbnails() { thumbnailsContainer.innerHTML = ''; images.forEach((image, index) => { const thumbnail = document.createElement('div'); thumbnail.className = 'thumbnail' + (index === currentImageIndex ? ' active' : ''); thumbnail.innerHTML = `${image.name}`; thumbnail.addEventListener('click', () => { currentImageIndex = index; updateMainImage(); updateNavigationButtons(); }); thumbnailsContainer.appendChild(thumbnail); }); } // Aktualizacja głównego obrazu function updateMainImage() { const currentImage = images[currentImageIndex]; mainImage.src = currentImage.fullsize; mainImage.alt = currentImage.description; imageCounter.textContent = currentImageIndex + 1; // Zaktualizuj miniaturki document.querySelectorAll('.thumbnail').forEach((thumb, index) => { thumb.classList.toggle('active', index === currentImageIndex); }); } // Aktualizacja przycisków nawigacji function updateNavigationButtons() { prevBtn.disabled = currentImageIndex === 0; nextBtn.disabled = currentImageIndex === images.length - 1; } // Event listenery dla przycisków prevBtn.addEventListener('click', () => { if (currentImageIndex > 0) { currentImageIndex--; updateMainImage(); updateNavigationButtons(); } }); nextBtn.addEventListener('click', () => { if (currentImageIndex < images.length - 1) { currentImageIndex++; updateMainImage(); updateNavigationButtons(); } }); // Obsługa klawiatury (strzałki) document.addEventListener('keydown', (e) => { if (e.key === 'ArrowLeft' && currentImageIndex > 0) { currentImageIndex--; updateMainImage(); updateNavigationButtons(); } else if (e.key === 'ArrowRight' && currentImageIndex < images.length - 1) { currentImageIndex++; updateMainImage(); updateNavigationButtons(); } }); // Inicjalizacja galerii po załadowaniu strony initGallery();