CI / Build & Test (push) Failing after 28s
Split monolithic dashboard.js (2753 lines) into 18 focused modules
under dashboard/{core,data,ui,pages}/ with refresh.js and events.js
as orchestrators. Extracted ~900-line inline <style> into dashboard.css
and moved dashboard.html to dashboard/dashboard.html.
Split background.js (609 lines) into background/{logs,state,proxy,
native-messaging,tab-lifecycle,message-router}.js with a thin entry
point using importScripts().
Deleted dead files: wrong-domain.js (duplicate of inline script).
Updated manifest.json web_accessible_resources for new paths.
Updated docs/ARCHITECTURE.md to reflect the new file structure.
No functionality changed. No build step introduced.
33 lines
1.0 KiB
JavaScript
33 lines
1.0 KiB
JavaScript
function $(id) { return document.getElementById(id); }
|
|
function log(...args) { console.log('[Holesail-dashboard]', ...args); }
|
|
|
|
function timeAgo(timestamp) {
|
|
const seconds = Math.floor((Date.now() - timestamp) / 1000);
|
|
if (seconds < 60) return seconds + 's ago';
|
|
const minutes = Math.floor(seconds / 60);
|
|
if (minutes < 60) return minutes + 'm ago';
|
|
const hours = Math.floor(minutes / 60);
|
|
if (hours < 24) return hours + 'h ago';
|
|
return Math.floor(hours / 24) + 'd ago';
|
|
}
|
|
|
|
function formatUptime(ms) {
|
|
const seconds = Math.floor(ms / 1000);
|
|
if (seconds < 60) return seconds + 's';
|
|
const minutes = Math.floor(seconds / 60);
|
|
if (minutes < 60) return minutes + 'm ' + (seconds % 60) + 's';
|
|
const hours = Math.floor(minutes / 60);
|
|
return hours + 'h ' + (minutes % 60) + 'm';
|
|
}
|
|
|
|
function truncate(str, len = 20) {
|
|
if (!str) return '';
|
|
return str.length > len ? str.slice(0, len) + '…' : str;
|
|
}
|
|
|
|
function escapeHtml(str) {
|
|
const div = document.createElement('div');
|
|
div.textContent = str;
|
|
return div.innerHTML;
|
|
}
|