| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>Eye Demo - Debug Test</title>
- <style>
- body { background: #111; color: #0f0; font-family: monospace; padding: 20px; white-space: pre-wrap; font-size: 13px; }
- .err { color: #f44; }
- .ok { color: #0f0; }
- .warn { color: #fa0; }
- </style>
- </head>
- <body>
- <h2>Eye Tracking Debug Test</h2>
- <div id="output"></div>
- <script>
- // Extract and test the JS from index.html
- fetch('/eye-demo/index.html')
- .then(r => r.text())
- .then(html => {
- const out = document.getElementById('output');
- function log(msg, cls) {
- const div = document.createElement('div');
- div.className = cls || '';
- div.textContent = msg;
- out.appendChild(div);
- }
- // 1. Extract main script
- const match = html.match(/<script>\(function \(\) \{([\s\S]+)\}\)\(\);<\/script>/);
- if (!match) {
- log('ERROR: Could not extract main IIFE script', 'err');
- return;
- }
- log('Script extracted OK (' + match[1].length + ' chars)', 'ok');
- // 2. Syntax check
- try {
- new Function(match[1]);
- log('JS SYNTAX: VALID', 'ok');
- } catch(e) {
- log('JS SYNTAX ERROR: ' + e.message, 'err');
- // Try to find the error location
- log('Error stack: ' + e.stack, 'err');
- }
- // 3. Check DOM element IDs referenced in JS
- const script = match[1];
- const ids = script.match(/getElementById\(['"]([^'"]+)['"]\)/g) || [];
- log('\n--- DOM ID Check (' + ids.length + ' refs) ---');
- let missingCount = 0;
- ids.forEach(ref => {
- const id = ref.match(/getElementById\(['"]([^'"]+)['"]\)/)[1];
- const exists = html.indexOf('id="' + id + '"') !== -1;
- if (!exists) {
- log(' MISSING ID: "' + id + '" (JS looks for it but HTML has no such id)', 'err');
- missingCount++;
- }
- });
- if (missingCount === 0) log(' All DOM IDs found in HTML', 'ok');
- // 4. Key logic flow check
- log('\n--- Logic Flow ---');
- // Check that calibration flow doesn't have issues
- const hasCalStart = script.indexOf('startCalibration()') !== -1;
- const hasCalFinish = script.indexOf('finishCalibration()') !== -1;
- const hasOnResults = script.indexOf('function onResults') !== -1;
- const hasApplyRegression = script.indexOf('applyRegression') !== -1;
- const hasFrameSkip = script.indexOf('frameCount % 2') !== -1;
- log(' startCalibration: ' + (hasCalStart ? 'found' : 'MISSING'), hasCalStart ? 'ok' : 'err');
- log(' finishCalibration: ' + (hasCalFinish ? 'found' : 'MISSING'), hasCalFinish ? 'ok' : 'err');
- log(' onResults: ' + (hasOnResults ? 'found' : 'MISSING'), hasOnResults ? 'ok' : 'err');
- log(' applyRegression: ' + (hasApplyRegression ? 'found' : 'MISSING'), hasApplyRegression ? 'ok' : 'err');
- log(' frameSkip: ' + (hasFrameSkip ? 'found' : 'MISSING'), hasFrameSkip ? 'ok' : 'err');
- // 5. Check right eye fix
- const hasRFlip = script.indexOf('r_inner.x - r_outer.x') !== -1;
- log('\n Right eye flip fix: ' + (hasRFlip ? 'PRESENT' : 'MISSING'), hasRFlip ? 'ok' : 'err');
- // 6. Check that old Kalman is removed
- const hasKalman = script.indexOf('SimpleKalman') !== -1;
- log(' Kalman removed: ' + (!hasKalman ? 'YES' : 'STILL PRESENT'), !hasKalman ? 'ok' : 'warn');
- // 7. Check that head pose is removed
- const hasHeadPose = script.indexOf('nose') !== -1 && script.indexOf('headOffY') !== -1;
- log(' Head pose removed: ' + (!hasHeadPose ? 'YES' : 'STILL PRESENT'), !hasHeadPose ? 'ok' : 'warn');
- // 8. Check EMA
- const hasEMA = script.indexOf('EMA_ALPHA') !== -1;
- log(' EMA smoothing: ' + (hasEMA ? 'PRESENT' : 'MISSING'), hasEMA ? 'ok' : 'err');
- // 9. Check localStorage
- const hasStorage = script.indexOf('localStorage') !== -1;
- log(' localStorage: ' + (hasStorage ? 'PRESENT' : 'MISSING'), hasStorage ? 'ok' : 'err');
- // 10. Check if there's an unused eyeData function inside computeIrisGaze
- const computeGazeSection = script.match(/function computeIrisGaze[\s\S]*?function eyeData[\s\S]*?\n \}/);
- if (computeGazeSection) {
- log('\n WARNING: Unused nested eyeData() inside computeIrisGaze (dead code, harmless)', 'warn');
- }
- log('\n--- DONE ---');
- })
- .catch(e => {
- document.getElementById('output').textContent = 'Fetch error: ' + e.message;
- });
- </script>
- </body>
- </html>
|