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) <noreply@anthropic.com>
This commit is contained in:
@@ -564,13 +564,18 @@ function get_internet(){
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Listen for config loaded by topbar-logo.js (avoids duplicate fetch)
|
// Use window.onload to wait for all initial resources to finish loading
|
||||||
document.addEventListener('nebuleair-config-ready', function(e) {
|
// This frees up HTTP connection slots before making AJAX calls
|
||||||
const data = e.detail;
|
window.onload = function() {
|
||||||
console.log("Config received (wifi page):");
|
// 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);
|
console.log(data);
|
||||||
|
|
||||||
// WiFi connection status — toggle cards
|
|
||||||
const WIFI_statusElement = document.getElementById("wifi-status");
|
const WIFI_statusElement = document.getElementById("wifi-status");
|
||||||
console.log("WIFI is: " + data.WIFI_status);
|
console.log("WIFI is: " + data.WIFI_status);
|
||||||
|
|
||||||
@@ -581,7 +586,6 @@ function get_internet(){
|
|||||||
document.getElementById('card-connection-info').style.display = '';
|
document.getElementById('card-connection-info').style.display = '';
|
||||||
document.getElementById('card-hotspot-info').style.display = 'none';
|
document.getElementById('card-hotspot-info').style.display = 'none';
|
||||||
document.getElementById('card-wifi-scan').style.display = 'none';
|
document.getElementById('card-wifi-scan').style.display = 'none';
|
||||||
// Auto-load connection details (includes ethernet info)
|
|
||||||
get_internet();
|
get_internet();
|
||||||
} else if (data.WIFI_status === "hotspot") {
|
} else if (data.WIFI_status === "hotspot") {
|
||||||
WIFI_statusElement.textContent = "Hotspot";
|
WIFI_statusElement.textContent = "Hotspot";
|
||||||
@@ -590,7 +594,6 @@ function get_internet(){
|
|||||||
document.getElementById('card-connection-info').style.display = 'none';
|
document.getElementById('card-connection-info').style.display = 'none';
|
||||||
document.getElementById('card-hotspot-info').style.display = '';
|
document.getElementById('card-hotspot-info').style.display = '';
|
||||||
document.getElementById('card-wifi-scan').style.display = '';
|
document.getElementById('card-wifi-scan').style.display = '';
|
||||||
// Auto-load cached scan results in hotspot mode
|
|
||||||
wifi_scan();
|
wifi_scan();
|
||||||
} else {
|
} else {
|
||||||
WIFI_statusElement.textContent = "Unknown";
|
WIFI_statusElement.textContent = "Unknown";
|
||||||
@@ -600,7 +603,7 @@ function get_internet(){
|
|||||||
document.getElementById('card-hotspot-info').style.display = 'none';
|
document.getElementById('card-hotspot-info').style.display = 'none';
|
||||||
document.getElementById('card-wifi-scan').style.display = '';
|
document.getElementById('card-wifi-scan').style.display = '';
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user