// Browser compatibility test
function testCompatibility() {
const requiredFeatures = {
'Promise': window.Promise,
'fetch': window.fetch,
'Web Components': window.customElements,
'Shadow DOM': 'attachShadow' in Element.prototype,
'ES6 Modules': 'noModule' in HTMLScriptElement.prototype,
'CSS Variables': window.CSS && CSS.supports('color', 'var(--test)')
};
const missingFeatures = Object.entries(requiredFeatures)
.filter(([_, supported]) => !supported)
.map(([name]) => name);
if (missingFeatures.length > 0) {
const warning = document.createElement('div');
warning.className = 'compatibility-warning';
warning.innerHTML = `
⚠️ Compatibility Warning
Your browser is missing these required features:
${missingFeatures.map(f => `- ${f}
`).join('')}
Please update your browser or use a modern alternative like Chrome, Firefox, or Edge.
`;
document.body.prepend(warning);
return false;
}
return true;
}
// Database tables with more complete default data
const dbTables = [
{
table_name: 'documents',
table_schema: 'Stores document metadata including OCR processing info',
row_count: 50430,
columns: [
'id', 'doc_id', 'file_path', 'file_type', 'content',
'file_hash', 'processing_time_seconds', 'file_size_bytes',
'ocr_date'
]
},
{
table_name: 'users',
table_schema: 'Contains user account information and permissions',
row_count: 15
},
{
table_name: 'sessions',
table_schema: 'Tracks active user sessions and login history',
row_count: 28
}
];
// Function to fetch tables with better error handling
async function fetchTables() {
try {
// First try local fallback
const localResponse = await fetch('/api/tables.json');
if (localResponse.ok) {
const data = await localResponse.json();
return data.tables || dbTables;
}
// If local fails, use default data
console.warn('Using default table data - local API not available');
return dbTables;
} catch (error) {
console.error('Table fetch error:', error);
showError('Using default table data - could not connect to API');
return dbTables;
}
}
// Function to display tables in UI
function displayTables(tables) {
const tablesContainer = document.querySelector('.divide-y');
if (!tablesContainer) return;
tablesContainer.innerHTML = '';
tables.forEach(table => {
const tableElement = document.createElement('div');
tableElement.className = 'p-6 hover:bg-gray-50 transition cursor-pointer group';
tableElement.innerHTML = `