efactor(extension): modularize dashboard, background, and docs
CI / Build & Test (push) Failing after 28s
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.
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
// Global event wiring — toggle switches, settings buttons, and per-page setup calls.
|
||||
// Depends on: all page modules
|
||||
|
||||
function setupEvents() {
|
||||
// Toggle switches
|
||||
document.querySelectorAll('.toggle').forEach(toggle => {
|
||||
toggle.addEventListener('click', () => toggle.classList.toggle('active'));
|
||||
});
|
||||
|
||||
// Save settings
|
||||
$('btnSaveSettings')?.addEventListener('click', saveSettings);
|
||||
|
||||
// Reset settings to defaults
|
||||
$('btnResetSettings')?.addEventListener('click', () => {
|
||||
settings = { ...SETTINGS_DEFAULTS };
|
||||
chrome.runtime.sendMessage(
|
||||
{ target: 'holesail-native', action: 'send', payload: { type: 'updateSettings', payload: { ...settings } } },
|
||||
(response) => {
|
||||
if (response && response.settings) settings = { ...SETTINGS_DEFAULTS, ...response.settings };
|
||||
updateSettingsUI();
|
||||
showToast('Settings reset to defaults', 'success');
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
setupVirtualHostEvents();
|
||||
setupServerEvents();
|
||||
setupServiceTunnelEvents();
|
||||
setupLogsEvents();
|
||||
}
|
||||
Reference in New Issue
Block a user