// LangMem Documentation JavaScript document.addEventListener('DOMContentLoaded', function() { // Initialize all components initializeNavigation(); initializeAnimations(); initializeDiagrams(); initializeCodeBlocks(); initializeSmoothScroll(); initializeProgressTracking(); }); // Navigation functionality function initializeNavigation() { const currentPath = window.location.pathname; const navLinks = document.querySelectorAll('.nav-links a'); navLinks.forEach(link => { if (link.getAttribute('href') === currentPath) { link.classList.add('active'); } }); } // Fade-in animations for cards function initializeAnimations() { const observerOptions = { threshold: 0.1, rootMargin: '0px 0px -100px 0px' }; const observer = new IntersectionObserver((entries) => { entries.forEach(entry => { if (entry.isIntersecting) { entry.target.classList.add('fade-in'); } }); }, observerOptions); document.querySelectorAll('.card, .phase-card, .diagram-container').forEach(el => { observer.observe(el); }); } // Initialize Mermaid diagrams function initializeDiagrams() { if (typeof mermaid !== 'undefined') { mermaid.initialize({ startOnLoad: true, theme: 'default', flowchart: { useMaxWidth: true, htmlLabels: true }, securityLevel: 'loose' }); } } // Code block enhancements function initializeCodeBlocks() { const codeBlocks = document.querySelectorAll('.code-block'); codeBlocks.forEach(block => { // Add copy button const copyBtn = document.createElement('button'); copyBtn.className = 'copy-btn'; copyBtn.innerHTML = '📋 Copy'; copyBtn.onclick = () => copyToClipboard(block.textContent, copyBtn); const container = document.createElement('div'); container.className = 'code-container'; container.appendChild(copyBtn); block.parentNode.insertBefore(container, block); container.appendChild(block); }); } // Copy to clipboard functionality function copyToClipboard(text, button) { navigator.clipboard.writeText(text).then(() => { const originalText = button.innerHTML; button.innerHTML = '✅ Copied!'; setTimeout(() => { button.innerHTML = originalText; }, 2000); }); } // Smooth scrolling for anchor links function initializeSmoothScroll() { document.querySelectorAll('a[href^="#"]').forEach(anchor => { anchor.addEventListener('click', function (e) { e.preventDefault(); const target = document.querySelector(this.getAttribute('href')); if (target) { target.scrollIntoView({ behavior: 'smooth', block: 'start' }); } }); }); } // Progress tracking for implementation phases function initializeProgressTracking() { const phaseCards = document.querySelectorAll('.phase-card'); const progressBar = document.querySelector('.progress-bar'); if (progressBar && phaseCards.length > 0) { updateProgressBar(); } } function updateProgressBar() { const totalPhases = document.querySelectorAll('.phase-card').length; const completedPhases = document.querySelectorAll('.status-completed').length; const progress = (completedPhases / totalPhases) * 100; const progressBar = document.querySelector('.progress-fill'); if (progressBar) { progressBar.style.width = `${progress}%`; } } // Architecture diagram interactions function showDiagramDetails(diagramId) { const modal = document.getElementById('diagram-modal'); const content = document.getElementById('diagram-details'); const diagramDetails = { 'system-overview': { title: 'System Architecture Overview', description: 'This diagram shows the high-level architecture of the LangMem system, including the main components and their relationships.', components: [ 'LangMem SDK - Core memory management layer', 'Supabase - Vector storage with pgvector', 'Neo4j - Graph database for relationships', 'Ollama - Local LLM and embedding models', 'Docker Network - Container orchestration' ] }, 'data-flow': { title: 'Data Flow Architecture', description: 'Shows how data flows through the system during ingestion and retrieval operations.', components: [ 'Input Processing - Text chunking and preprocessing', 'Embedding Generation - Vector creation via Ollama', 'Storage Layer - Dual storage in Supabase and Neo4j', 'Retrieval Engine - Hybrid search capabilities', 'Context Assembly - Final context preparation' ] } }; const details = diagramDetails[diagramId]; if (details && modal && content) { content.innerHTML = `
${details.description}
No results found
'; } else { searchResults.innerHTML = results.map(result => `