// AI-powered image search functionality // Initialize search form function initializeSearchForm() { const form = document.getElementById('searchForm'); const thresholdSlider = document.getElementById('similarityThreshold'); const thresholdValue = document.getElementById('thresholdValue'); // Update threshold display thresholdSlider.addEventListener('input', (e) => { thresholdValue.textContent = e.target.value; }); // Handle form submission form.addEventListener('submit', (e) => { e.preventDefault(); performSearch(); }); } // Perform search async function performSearch() { if (!config.isConfigured()) { showAlert('Please configure your API settings first.', 'warning'); return; } const query = document.getElementById('searchQuery').value.trim(); const threshold = parseFloat(document.getElementById('similarityThreshold').value); const maxResults = parseInt(document.getElementById('maxResults').value); if (!query) { showAlert('Please enter a search query', 'danger'); return; } const resultsContainer = document.getElementById('searchResults'); resultsContainer.innerHTML = `
Searching for "${escapeHtml(query)}"...
Try adjusting your search query or similarity threshold
Found ${results.length} images matching "${escapeHtml(query)}"
${formatDate(result.image.upload_date)}
${result.image.tags && result.image.tags.length > 0 ? `Popular tags in these results: