📧

Newsletter Coming Soon

AI-powered daily summaries of market news and insights delivered to your inbox

🚀 What's Coming

Daily Market Summaries

Condensed insights from top financial newsletters

AI Analysis

Key takeaways and sentiment analysis

Custom Sources

Choose your favorite newsletters to follow

// unified-search.js - Integrate search functionality across all pages // Add this script to every HTML page (function() { const API_BASE = 'https://financial-terminal-api.vercel.app/api'; const searchInput = document.getElementById('search-input'); const searchResults = document.getElementById('search-results'); if (!searchInput || !searchResults) { console.log('Search elements not found on this page'); return; } let searchTimeout; // Handle input searchInput.addEventListener('input', (e) => { const query = e.target.value.trim(); clearTimeout(searchTimeout); if (query.length < 2) { searchResults.style.display = 'none'; return; } searchTimeout = setTimeout(() => performSearch(query), 300); }); // Show results on focus if they exist searchInput.addEventListener('focus', () => { if (searchResults.children.length > 0) { searchResults.style.display = 'block'; } }); // Hide results when clicking outside document.addEventListener('click', (e) => { if (!searchInput.contains(e.target) && !searchResults.contains(e.target)) { searchResults.style.display = 'none'; } }); // Perform search async function performSearch(query) { try { const response = await fetch(`${API_BASE}/search?q=${encodeURIComponent(query)}`, { signal: AbortSignal.timeout(5000) }); if (!response.ok) throw new Error('Search failed'); const data = await response.json(); if (data.success && data.results && data.results.length > 0) { renderSearchResults(data.results); } else { renderNoResults(); } } catch (error) { console.error('Search error:', error); renderNoResults(); } } // Render search results function renderSearchResults(results) { searchResults.innerHTML = results.map(result => `
${result.symbol}
${result.shortname || result.longname || 'N/A'}
${result.type || 'EQUITY'} ${result.exchange ? `• ${result.exchange}` : ''}
`).join(''); searchResults.style.display = 'block'; } // Render no results function renderNoResults() { searchResults.innerHTML = '
No results found
'; searchResults.style.display = 'block'; } // Global navigation function window.navigateToAsset = function(tvSymbol, yhSymbol) { window.location.href = `details.html?symbol=${encodeURIComponent(tvSymbol)}&yahoo=${encodeURIComponent(yhSymbol)}`; }; })();