diff --git a/html/assets/js/topbar-logo.js b/html/assets/js/topbar-logo.js index 5ea5ccc..6b924a2 100644 --- a/html/assets/js/topbar-logo.js +++ b/html/assets/js/topbar-logo.js @@ -9,12 +9,15 @@ document.addEventListener('DOMContentLoaded', () => { let config = null; - // Fetch config once + // Fetch config once and share globally fetch('launcher.php?type=get_config_sqlite') .then(response => response.json()) .then(data => { config = data; - applyConfig(); // Apply immediately if elements are ready + 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)); diff --git a/html/wifi.html b/html/wifi.html index 26e4e1a..9707a87 100755 --- a/html/wifi.html +++ b/html/wifi.html @@ -560,14 +560,11 @@ function get_internet(){ - window.onload = function() { - $.ajax({ - url: 'launcher.php?type=get_config_sqlite', - dataType: 'json', - method: 'GET', - success: function(data) { - console.log("Getting SQLite config table (wifi page):"); - console.log(data); + // 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):"); + console.log(data); // WiFi connection status — toggle cards const WIFI_statusElement = document.getElementById("wifi-status"); @@ -580,7 +577,7 @@ function get_internet(){ 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 + // Auto-load connection details (includes ethernet info) get_internet(); } else if (data.WIFI_status === "hotspot") { WIFI_statusElement.textContent = "Hotspot"; @@ -599,29 +596,8 @@ function get_internet(){ document.getElementById('card-hotspot-info').style.display = 'none'; document.getElementById('card-wifi-scan').style.display = ''; } - - // Always load ethernet info - load_ethernet_info(); - }, - error: function(xhr, status, error) { - console.error('AJAX request failed:', status, error); } - }); - - // Load RTC time - $.ajax({ - url: 'launcher.php?type=RTC_time', - dataType: 'text', - method: 'GET', - success: function(response) { - const RTC_Element = document.getElementById("RTC_time"); - if (RTC_Element) RTC_Element.textContent = response; - }, - error: function(xhr, status, error) { - console.error('AJAX request failed:', status, error); - } - }); - } + });