diff --git a/html/assets/js/topbar-logo.js b/html/assets/js/topbar-logo.js
index 3f1bab8..5803700 100644
--- a/html/assets/js/topbar-logo.js
+++ b/html/assets/js/topbar-logo.js
@@ -5,29 +5,32 @@
* - Shows/Hides "Screen" sidebar tab based on device type
* - Updates sidebar device name
* - Shows hotspot badge in sidebar when in hotspot mode
+ *
+ * Fetches config at window.onload (not DOMContentLoaded) to avoid
+ * saturating the browser's 6-connection-per-domain limit.
*/
-document.addEventListener('DOMContentLoaded', () => {
+(function() {
let config = null;
- // Fetch config once and share globally
- fetch('launcher.php?type=get_config_sqlite')
- .then(response => response.json())
- .then(data => {
- config = data;
- window._nebuleairConfig = data;
- applyConfig();
- // Notify other scripts that config is ready
- document.dispatchEvent(new CustomEvent('nebuleair-config-ready', { detail: data }));
- })
- .catch(error => console.error('Error loading config:', error));
-
- // Observe DOM changes to handle dynamically loaded elements (sidebar, topbar)
+ // Observe DOM changes to apply config when sidebar/topbar are loaded
const observer = new MutationObserver(() => {
if (config) applyConfig();
});
-
observer.observe(document.body, { childList: true, subtree: true });
+ // Fetch config after all initial resources are loaded
+ window.addEventListener('load', () => {
+ fetch('launcher.php?type=get_config_sqlite')
+ .then(response => response.json())
+ .then(data => {
+ config = data;
+ window._nebuleairConfig = data;
+ applyConfig();
+ document.dispatchEvent(new CustomEvent('nebuleair-config-ready', { detail: data }));
+ })
+ .catch(error => console.error('Error loading config:', error));
+ });
+
function applyConfig() {
if (!config) return;
@@ -36,13 +39,12 @@ document.addEventListener('DOMContentLoaded', () => {
// 1. Topbar Logo Logic
const logo = document.getElementById('topbar-logo');
if (logo && isModuleAirPro) {
- // prevent unnecessary re-assignments
if (!logo.src.includes('logoModuleAir.png')) {
logo.src = 'assets/img/logoModuleAir.png';
}
}
- // 2. Sidebar Screen Tab Logic - Use class since ID might be duplicated (desktop/mobile)
+ // 2. Sidebar Screen Tab Logic
const navScreenElements = document.querySelectorAll('.nav-screen-item');
if (navScreenElements.length > 0) {
navScreenElements.forEach(navScreen => {
@@ -70,6 +72,5 @@ document.addEventListener('DOMContentLoaded', () => {
document.querySelectorAll('.sidebar-hotspot-badge').forEach(badge => {
badge.style.display = (config.WIFI_status === 'hotspot') ? '' : 'none';
});
-
}
-});
+})();
diff --git a/html/wifi.html b/html/wifi.html
index 450fa4d..e91b136 100755
--- a/html/wifi.html
+++ b/html/wifi.html
@@ -564,15 +564,9 @@ function get_internet(){
- // Use window.onload to wait for all initial resources to finish loading
- // This frees up HTTP connection slots before making AJAX calls
- window.onload = function() {
- // Reuse config already fetched by topbar-logo.js, or fetch if not ready
- const data = window._nebuleairConfig;
- if (!data) {
- console.warn("Config not ready yet, skipping wifi page init");
- return;
- }
+ // Wait for config loaded by topbar-logo.js (fires after window.onload)
+ document.addEventListener('nebuleair-config-ready', function(e) {
+ const data = e.detail;
console.log("Config loaded (wifi page):");
console.log(data);
@@ -603,7 +597,7 @@ function get_internet(){
document.getElementById('card-hotspot-info').style.display = 'none';
document.getElementById('card-wifi-scan').style.display = '';
}
- }
+ });