diff --git a/js/upload.js b/js/upload.js index a364f49..fe1c042 100644 --- a/js/upload.js +++ b/js/upload.js @@ -99,9 +99,32 @@ async function beginCheck() { const quickMode = document.getElementById('quickMode').checked; if (quickMode) addLog('Quick mode enabled — skipping expensive checks', 'info'); + // Animate progress while Cloud Run processes synchronously (can take 2-5 min) + const progressStages = [ + { pct: 35, msg: 'Loading PDF structure...', log: 'Reading PDF metadata and tagging' }, + { pct: 45, msg: 'Checking document structure...', log: 'Validating PDF tags and structure tree' }, + { pct: 55, msg: 'Analyzing images with AI...', log: 'Running AI vision analysis on images' }, + { pct: 65, msg: 'Checking color contrast...', log: 'Calculating WCAG contrast ratios' }, + { pct: 72, msg: 'Analyzing readability...', log: 'Computing Flesch reading scores' }, + { pct: 80, msg: 'Checking headings & links...', log: 'Heading hierarchy, tab order, role mapping' }, + { pct: 88, msg: 'Running PDF/UA validation...', log: 'veraPDF structure validation' }, + { pct: 94, msg: 'Compiling results...', log: 'Generating accessibility report' }, + ]; + let stageIdx = 0; + const progressTimer = setInterval(() => { + if (stageIdx < progressStages.length) { + const s = progressStages[stageIdx++]; + updateProgress(s.pct, s.msg); + addLog(s.log, 'info'); + } + }, 18000); // advance every 18s → covers ~2.5 min of processing + + updateProgress(30, 'Analyzing PDF (this may take a few minutes)...'); + addLog('Sent to Cloud Run for processing...', 'info'); + try { - updateProgress(30, 'Analyzing PDF (this may take a few minutes)...'); const result = await startCheck(currentJobId, quickMode); + clearInterval(progressTimer); if (result.success) { if (result.data && result.data.status === 'completed') { @@ -121,6 +144,7 @@ async function beginCheck() { document.getElementById('progressContainer').style.display = 'none'; } } catch (error) { + clearInterval(progressTimer); addLog('Check error: ' + error.message, 'error'); alert('Check failed: ' + error.message); document.getElementById('progressContainer').style.display = 'none';