From 196176667f8f55ea933c83f0a12fdcd8a07e441b Mon Sep 17 00:00:00 2001 From: PaulVua Date: Tue, 17 Mar 2026 18:42:56 +0100 Subject: [PATCH] Fix: window.onload au lieu de event listener pour sequencer les requetes window.onload attend que les ressources initiales soient chargees, liberant les slots HTTP avant de lancer les AJAX (internet, scan). Reutilise la config deja fetched par topbar-logo.js via window global. Co-Authored-By: Claude Opus 4.6 (1M context) --- html/wifi.html | 71 ++++++++++++++++++++++++++------------------------ 1 file changed, 37 insertions(+), 34 deletions(-) diff --git a/html/wifi.html b/html/wifi.html index fe471f5..450fa4d 100755 --- a/html/wifi.html +++ b/html/wifi.html @@ -564,43 +564,46 @@ function get_internet(){ - // Listen for config loaded by topbar-logo.js (avoids duplicate fetch) - document.addEventListener('nebuleair-config-ready', function(e) { - const data = e.detail; - console.log("Config received (wifi page):"); + // 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; + } + console.log("Config loaded (wifi page):"); console.log(data); - // WiFi connection status — toggle cards - const WIFI_statusElement = document.getElementById("wifi-status"); - console.log("WIFI is: " + data.WIFI_status); + const WIFI_statusElement = document.getElementById("wifi-status"); + console.log("WIFI is: " + data.WIFI_status); - if (data.WIFI_status === "connected") { - WIFI_statusElement.textContent = "Connected"; - WIFI_statusElement.className = "badge text-bg-success"; - document.getElementById('btn-forget-wifi').style.display = 'inline-block'; - document.getElementById('card-connection-info').style.display = ''; - document.getElementById('card-hotspot-info').style.display = 'none'; - document.getElementById('card-wifi-scan').style.display = 'none'; - // Auto-load connection details (includes ethernet info) - get_internet(); - } else if (data.WIFI_status === "hotspot") { - WIFI_statusElement.textContent = "Hotspot"; - WIFI_statusElement.className = "badge text-bg-warning"; - document.getElementById('btn-forget-wifi').style.display = 'none'; - document.getElementById('card-connection-info').style.display = 'none'; - document.getElementById('card-hotspot-info').style.display = ''; - document.getElementById('card-wifi-scan').style.display = ''; - // Auto-load cached scan results in hotspot mode - wifi_scan(); - } else { - WIFI_statusElement.textContent = "Unknown"; - WIFI_statusElement.className = "badge text-bg-secondary"; - document.getElementById('btn-forget-wifi').style.display = 'none'; - document.getElementById('card-connection-info').style.display = 'none'; - document.getElementById('card-hotspot-info').style.display = 'none'; - document.getElementById('card-wifi-scan').style.display = ''; - } - }); + if (data.WIFI_status === "connected") { + WIFI_statusElement.textContent = "Connected"; + WIFI_statusElement.className = "badge text-bg-success"; + document.getElementById('btn-forget-wifi').style.display = 'inline-block'; + document.getElementById('card-connection-info').style.display = ''; + document.getElementById('card-hotspot-info').style.display = 'none'; + document.getElementById('card-wifi-scan').style.display = 'none'; + get_internet(); + } else if (data.WIFI_status === "hotspot") { + WIFI_statusElement.textContent = "Hotspot"; + WIFI_statusElement.className = "badge text-bg-warning"; + document.getElementById('btn-forget-wifi').style.display = 'none'; + document.getElementById('card-connection-info').style.display = 'none'; + document.getElementById('card-hotspot-info').style.display = ''; + document.getElementById('card-wifi-scan').style.display = ''; + wifi_scan(); + } else { + WIFI_statusElement.textContent = "Unknown"; + WIFI_statusElement.className = "badge text-bg-secondary"; + document.getElementById('btn-forget-wifi').style.display = 'none'; + document.getElementById('card-connection-info').style.display = 'none'; + document.getElementById('card-hotspot-info').style.display = 'none'; + document.getElementById('card-wifi-scan').style.display = ''; + } + }