// Memory Module Detection QA Interface JavaScript const API_BASE_URL = 'http://localhost:5001'; let uploadedFile = null; // Initialize the application document.addEventListener('DOMContentLoaded', function() { initializeApp(); setupEventListeners(); }); function initializeApp() { checkApiStatus(); loadApiInfo(); } function setupEventListeners() { // File input change document.getElementById('fileInput').addEventListener('change', handleFileSelect); // Drag and drop const uploadArea = document.getElementById('uploadArea'); uploadArea.addEventListener('dragover', handleDragOver); uploadArea.addEventListener('dragleave', handleDragLeave); uploadArea.addEventListener('drop', handleDrop); uploadArea.addEventListener('click', () => document.getElementById('fileInput').click()); // Confidence slider document.getElementById('confidenceSlider').addEventListener('input', function() { document.getElementById('confidenceValue').textContent = this.value; }); } async function checkApiStatus() { const statusElement = document.getElementById('apiStatus'); try { const response = await fetch(`${API_BASE_URL}/health`); if (response.ok) { const data = await response.json(); statusElement.className = 'status-indicator online'; statusElement.innerHTML = ' API Online'; } else { throw new Error('API not responding'); } } catch (error) { statusElement.className = 'status-indicator offline'; statusElement.innerHTML = ' API Offline'; } } async function loadApiInfo() { const apiInfoElement = document.getElementById('apiInfo'); try { const response = await fetch(`${API_BASE_URL}/api`); if (response.ok) { const data = await response.json(); displayApiInfo(data); } else { throw new Error('Failed to load API info'); } } catch (error) { apiInfoElement.innerHTML = '
${data.message}
${data.version}
${data.model_loaded ? 'Loaded ✅' : 'Not Loaded ❌'}
${data.supported_formats.join(', ')}
File selected: ${file.name}
Size: ${(file.size / 1024 / 1024).toFixed(2)} MB
${test.message}