// ========================================== // CAROUSEL COMPONENT // ========================================== // Active session carousel with detailed task info and smooth transitions let carouselIndex = 0; let carouselSessions = []; let carouselInterval = null; let carouselPaused = false; const CAROUSEL_INTERVAL_MS = 5000; // 5 seconds function initCarousel() { const prevBtn = document.getElementById('carouselPrev'); const nextBtn = document.getElementById('carouselNext'); const pauseBtn = document.getElementById('carouselPause'); if (prevBtn) { prevBtn.addEventListener('click', () => { carouselPrev(); resetCarouselInterval(); }); } if (nextBtn) { nextBtn.addEventListener('click', () => { carouselNext(); resetCarouselInterval(); }); } if (pauseBtn) { pauseBtn.addEventListener('click', toggleCarouselPause); } } function updateCarousel() { // Get active sessions from workflowData const previousSessions = carouselSessions; const previousIndex = carouselIndex; const previousSessionId = previousSessions[previousIndex]?.session_id; carouselSessions = workflowData.activeSessions || []; // Try to preserve current position if (previousSessionId && carouselSessions.length > 0) { // Find if the same session still exists const newIndex = carouselSessions.findIndex(s => s.session_id === previousSessionId); if (newIndex !== -1) { carouselIndex = newIndex; } else if (previousIndex < carouselSessions.length) { // Keep same index if valid carouselIndex = previousIndex; } else { // Reset to last valid index carouselIndex = Math.max(0, carouselSessions.length - 1); } } else { carouselIndex = 0; } renderCarouselDots(); renderCarouselSlide('none'); startCarouselInterval(); } function renderCarouselDots() { const dotsContainer = document.getElementById('carouselDots'); if (!dotsContainer) return; if (carouselSessions.length === 0) { dotsContainer.innerHTML = ''; return; } dotsContainer.innerHTML = carouselSessions.map((_, index) => ` `).join(''); } function updateActiveDot() { const dots = document.querySelectorAll('.carousel-dot'); dots.forEach((dot, index) => { if (index === carouselIndex) { dot.classList.remove('bg-muted-foreground/40', 'hover:bg-muted-foreground/60', 'w-2'); dot.classList.add('bg-primary', 'w-4'); } else { dot.classList.remove('bg-primary', 'w-4'); dot.classList.add('bg-muted-foreground/40', 'hover:bg-muted-foreground/60', 'w-2'); } }); } function carouselGoToIndex(index) { if (index < 0 || index >= carouselSessions.length) return; const direction = index > carouselIndex ? 'left' : (index < carouselIndex ? 'right' : 'none'); carouselIndex = index; renderCarouselSlide(direction); updateActiveDot(); resetCarouselInterval(); } function renderCarouselSlide(direction = 'none') { const container = document.getElementById('carouselContent'); if (!container) return; if (carouselSessions.length === 0) { container.innerHTML = `
${t('carousel.noActiveSessions')}