// static/js/dashboard.js v7 async function initDashboard() { refreshDashboardFiles(); simulateSystemStatus(); } async function refreshDashboardFiles() { if (!currentToken) return; var list = document.getElementById('dash-recent-files'); if (!list) return; try { var res = await fetch('/api/files', { method: 'POST', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({token: currentToken}) }); var data = await res.json(); list.innerHTML = ''; if (data.files && data.files.length) { data.files.slice(0, 4).forEach(function(f) { var ext = f.split('.').pop(); var icons = { py: 'fa-brands fa-python', js: 'fa-brands fa-js', html: 'fa-brands fa-html5', css: 'fa-brands fa-css3-alt' }; var colors = { py: '#4B8BBE', js: '#F7DF1E', html: '#E34F26', css: '#1572B6' }; var html = '
' + '
' + '

' + f + '

Workspace file

'; list.insertAdjacentHTML('beforeend', html); }); } else { list.innerHTML = '
No files yet
'; } } catch (e) { console.error(e); } } function openFileFromDash(f) { switchView('editor-view', document.querySelector('.nav-item[data-view=editor-view]')); if (typeof openFile === 'function') openFile(f); } function simulateSystemStatus() { setInterval(function() { var cpu = document.getElementById('stat-cpu'), cpuBar = document.getElementById('bar-cpu'); if (cpu && cpuBar) { var v = Math.floor(Math.random() * 20 + 5); cpu.textContent = v + '%'; cpuBar.style.width = v + '%'; } var ram = document.getElementById('stat-ram'), ramBar = document.getElementById('bar-ram'); if (ram && ramBar) { var v = Math.floor(Math.random() * 15 + 30); ram.textContent = v + '%'; ramBar.style.width = v + '%'; } }, 3000); }