/** * AgentMemory Landing Page - App JavaScript */ document.addEventListener('DOMContentLoaded', () => { // Initialize Lucide icons lucide.createIcons(); // Initialize highlight.js hljs.highlightAll(); // Initialize memory network animation initMemoryNetwork(); // Initialize navbar scroll behavior initNavbar(); // Initialize scroll animations initScrollAnimations(); // Initialize copy buttons initCopyButtons(); }); /** * Memory Network Animation * Creates an animated network visualization using CSS */ function initMemoryNetwork() { const container = document.getElementById('memoryNetwork'); if (!container) return; // Create nodes const nodesContainer = document.createElement('div'); nodesContainer.className = 'network-nodes'; for (let i = 0; i < 10; i++) { const node = document.createElement('div'); node.className = 'node'; nodesContainer.appendChild(node); } // Create connection lines const linesContainer = document.createElement('div'); linesContainer.className = 'network-lines'; for (let i = 0; i < 6; i++) { const line = document.createElement('div'); line.className = 'connection-line'; linesContainer.appendChild(line); } container.appendChild(nodesContainer); container.appendChild(linesContainer); } /** * Navbar scroll behavior * Adds shadow and background blur on scroll */ function initNavbar() { const navbar = document.querySelector('.navbar'); if (!navbar) return; let lastScrollY = window.scrollY; window.addEventListener('scroll', () => { const scrollY = window.scrollY; if (scrollY > 10) { navbar.classList.add('scrolled'); } else { navbar.classList.remove('scrolled'); } lastScrollY = scrollY; }, { passive: true }); } /** * Scroll reveal animations using Intersection Observer */ function initScrollAnimations() { const reveals = document.querySelectorAll('.problem-card, .capability-card, .arch-node'); if (!reveals.length) return; const observer = new IntersectionObserver((entries) => { entries.forEach(entry => { if (entry.isIntersecting) { entry.target.classList.add('visible'); } }); }, { threshold: 0.1, rootMargin: '0px 0px -50px 0px' }); reveals.forEach(el => observer.observe(el)); } /** * Copy button functionality with feedback */ function initCopyButtons() { const copyBtns = document.querySelectorAll('.copy-btn'); copyBtns.forEach(btn => { btn.addEventListener('click', async () => { const targetId = btn.dataset.copy; const codeEl = document.getElementById(targetId); if (!codeEl) return; try { await navigator.clipboard.writeText(codeEl.textContent); btn.classList.add('copied'); btn.querySelector('span').textContent = 'Copied!'; setTimeout(() => { btn.classList.remove('copied'); btn.querySelector('span').textContent = 'Copy'; }, 2000); } catch (err) { console.error('Failed to copy:', err); } }); }); }