gogo2/test_js_debug.html
2025-05-26 16:02:40 +03:00

86 lines
2.9 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<title>JavaScript Debug Test</title>
<script>
// Test the same debugging code we injected
window.dashDebug = {
callbackCount: 0,
lastUpdate: null,
errors: [],
log: function(message, data) {
const timestamp = new Date().toISOString();
console.log(`[DASH DEBUG ${timestamp}] ${message}`, data || '');
// Store in window for inspection
if (!window.dashLogs) window.dashLogs = [];
window.dashLogs.push({timestamp, message, data});
// Keep only last 100 logs
if (window.dashLogs.length > 100) {
window.dashLogs = window.dashLogs.slice(-100);
}
}
};
// Test fetch override
const originalFetch = window.fetch;
window.fetch = function(...args) {
const url = args[0];
if (typeof url === 'string' && url.includes('_dash-update-component')) {
window.dashDebug.log('FETCH REQUEST to _dash-update-component', {
url: url,
method: (args[1] || {}).method || 'GET'
});
}
return originalFetch.apply(this, args);
};
// Helper functions
window.getDashDebugInfo = function() {
return {
callbackCount: window.dashDebug.callbackCount,
lastUpdate: window.dashDebug.lastUpdate,
errors: window.dashDebug.errors,
logs: window.dashLogs || []
};
};
window.clearDashLogs = function() {
window.dashLogs = [];
window.dashDebug.errors = [];
window.dashDebug.callbackCount = 0;
console.log('Dash debug logs cleared');
};
// Test the logging
document.addEventListener('DOMContentLoaded', function() {
window.dashDebug.log('TEST: DOM LOADED');
// Test logging every 2 seconds
setInterval(() => {
window.dashDebug.log('TEST: Periodic log', {
timestamp: new Date(),
test: 'data'
});
}, 2000);
});
</script>
</head>
<body>
<h1>JavaScript Debug Test</h1>
<p>Open browser console and check for debug logs.</p>
<p>Use these commands in console:</p>
<ul>
<li><code>getDashDebugInfo()</code> - Get debug info</li>
<li><code>clearDashLogs()</code> - Clear logs</li>
<li><code>window.dashLogs</code> - View all logs</li>
</ul>
<button onclick="window.dashDebug.log('TEST: Button clicked')">Test Log</button>
<button onclick="fetch('/_dash-update-component')">Test Fetch</button>
</body>
</html>