// Shared JavaScript across all pages // Initialize app document.addEventListener('DOMContentLoaded', function() { console.log('AutoDev Agent Orchestrator Pro loaded successfully! 🚀'); // Add loading states for better UX const links = document.querySelectorAll('a[href]'); links.forEach(link => { link.addEventListener('click', function(e) { if (this.getAttribute('href').startsWith('/') && this.getAttribute('href') !== window.location.pathname) { // Show loading state (could be enhanced with a proper loader component) document.body.style.opacity = '0.7'; setTimeout(() => { document.body.style.opacity = '1'; }, 500); } }); }); // Add intersection observer for scroll animations const observerOptions = { threshold: 0.1, rootMargin: '0px 0px -50px 0px' }; const observer = new IntersectionObserver((entries) => { entries.forEach(entry => { if (entry.isIntersecting) { entry.target.style.opacity = '1'; entry.target.style.transform = 'translateY(0)'; } }); }, observerOptions); // Observe all cards and sections for animation document.querySelectorAll('.grid > div, section').forEach(el => { el.style.opacity = '0'; el.style.transform = 'translateY(20px)'; el.style.transition = 'opacity 0.6s ease, transform 0.6s ease'; observer.observe(el); }); }); // API integration for agent status (placeholder) class AgentAPI { static async getAgentStatus(agentId) { // This would connect to your backend API try { const response = await fetch(`/api/agents/${agentId}/status`); return await response.json(); } catch (error) { console.error('Failed to fetch agent status:', error); return { status: 'unknown', lastActivity: new Date() }; } } static async startDevelopment(projectData) { try { const response = await fetch('/api/projects/start', { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify(projectData) }); return await response.json(); } catch (error) { console.error('Failed to start development:', error); return { success: false, projectId: null }; } } } // Utility functions const Utils = { // Format date for display formatDate: (date) => { return new Date(date).toLocaleDateString('en-US', { year: 'numeric', month: 'short', day: 'numeric' }); }, // Debounce function for search and filter inputs debounce: (func, wait) => { let timeout; return function executedFunction(...args) { const later = () => { clearTimeout(timeout); func(...args); }; clearTimeout(timeout); timeout = setTimeout(later, wait); }; }, // Generate random project ID generateProjectId: () => { return 'proj_' + Math.random().toString(36).substr(2, 9); } }; // Export for module usage if (typeof module !== 'undefined' && module.exports) { module.exports = { AgentAPI, Utils }; }