// Main Application Script document.addEventListener('DOMContentLoaded', function() { // Initialize Feather Icons if (typeof feather !== 'undefined') { feather.replace(); } // Mobile menu toggle for sidebar const setupMobileMenu = () => { const sidebarToggle = document.querySelector('[data-sidebar-toggle]'); const sidebar = document.querySelector('custom-sidebar'); const overlay = document.createElement('div'); if (sidebarToggle && sidebar) { // Create overlay for mobile overlay.className = 'fixed inset-0 bg-black bg-opacity-50 z-40 hidden'; document.body.appendChild(overlay); sidebarToggle.addEventListener('click', () => { sidebar.classList.toggle('-translate-x-full'); sidebar.classList.toggle('translate-x-0'); overlay.classList.toggle('hidden'); document.body.classList.toggle('overflow-hidden'); }); overlay.addEventListener('click', () => { sidebar.classList.add('-translate-x-full'); sidebar.classList.remove('translate-x-0'); overlay.classList.add('hidden'); document.body.classList.remove('overflow-hidden'); }); // Close sidebar when clicking on links (mobile) const sidebarLinks = sidebar.shadowRoot.querySelectorAll('a'); sidebarLinks.forEach(link => { link.addEventListener('click', () => { if (window.innerWidth < 768) { sidebar.classList.add('-translate-x-full'); sidebar.classList.remove('translate-x-0'); overlay.classList.add('hidden'); document.body.classList.remove('overflow-hidden'); } }); }); } }; // Setup AI code assistant functionality const setupAIAssistant = () => { const codeInput = document.querySelector('input[placeholder*="Ask DevinAI"]'); const sendButton = document.querySelector('button.bg-blue-600'); if (codeInput && sendButton) { sendButton.addEventListener('click', async () => { const query = codeInput.value.trim(); if (!query) return; // Show loading state const originalText = sendButton.innerHTML; sendButton.innerHTML = '
'; sendButton.disabled = true; // Simulate API call with timeout setTimeout(() => { // In a real app, this would be an API call to an AI service console.log('AI Query:', query); // Reset button sendButton.innerHTML = originalText; sendButton.disabled = false; codeInput.value = ''; // Show success message showNotification('AI is processing your request...', 'success'); }, 1500); }); // Allow Enter key to submit codeInput.addEventListener('keypress', (e) => { if (e.key === 'Enter') { sendButton.click(); } }); } }; // Notification system const showNotification = (message, type = 'info') => { const notification = document.createElement('div'); const colors = { success: 'bg-green-100 border-green-400 text-green-700', error: 'bg-red-100 border-red-400 text-red-700', info: 'bg-blue-100 border-blue-400 text-blue-700', warning: 'bg-yellow-100 border-yellow-400 text-yellow-700' }; notification.className = `fixed top-6 right-6 px-6 py-4 rounded-lg border ${colors[type]} shadow-lg z-50 transform transition-transform duration-300 translate-x-full`; notification.innerHTML = `