Revert optimisations sidebar/fetch qui causaient des blocages navigateur
Retour a l'etat 408ab76. Les tentatives d'optimisation du nombre
de fetch (sidebar unique, config partagee, sequencement) causaient
des blocages sur Chrome/Firefox. On garde les features (forget wifi,
hotspot badge, UI wifi) mais on revient au chargement d'origine.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -181,6 +181,15 @@
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
console.log("DOMContentLoaded");
|
||||
|
||||
const elementsToLoad = [
|
||||
{ id: 'topbar', file: 'topbar.html' },
|
||||
{ id: 'sidebar', file: 'sidebar.html' },
|
||||
{ id: 'sidebar_mobile', file: 'sidebar.html' }
|
||||
];
|
||||
|
||||
let loadedCount = 0;
|
||||
const totalElements = elementsToLoad.length;
|
||||
|
||||
function applyTranslationsWhenReady() {
|
||||
if (typeof i18n !== 'undefined' && i18n.translations && Object.keys(i18n.translations).length > 0) {
|
||||
console.log("Applying translations to dynamically loaded content");
|
||||
@@ -191,28 +200,23 @@
|
||||
}
|
||||
}
|
||||
|
||||
let loadedCount = 0;
|
||||
elementsToLoad.forEach(({ id, file }) => {
|
||||
fetch(file)
|
||||
.then(response => response.text())
|
||||
.then(data => {
|
||||
const element = document.getElementById(id);
|
||||
if (element) {
|
||||
element.innerHTML = data;
|
||||
}
|
||||
loadedCount++;
|
||||
|
||||
// Load topbar
|
||||
fetch('topbar.html')
|
||||
.then(r => r.text())
|
||||
.then(data => {
|
||||
document.getElementById('topbar').innerHTML = data;
|
||||
loadedCount++;
|
||||
if (loadedCount === 2) applyTranslationsWhenReady();
|
||||
})
|
||||
.catch(e => console.error('Error loading topbar:', e));
|
||||
|
||||
// Load sidebar once, reuse for desktop + mobile
|
||||
fetch('sidebar.html')
|
||||
.then(r => r.text())
|
||||
.then(data => {
|
||||
document.getElementById('sidebar').innerHTML = data;
|
||||
document.getElementById('sidebar_mobile').innerHTML = data;
|
||||
loadedCount++;
|
||||
if (loadedCount === 2) applyTranslationsWhenReady();
|
||||
})
|
||||
.catch(e => console.error('Error loading sidebar:', e));
|
||||
// Re-apply translations after all dynamic content is loaded
|
||||
if (loadedCount === totalElements) {
|
||||
applyTranslationsWhenReady();
|
||||
}
|
||||
})
|
||||
.catch(error => console.error(`Error loading ${file}:`, error));
|
||||
});
|
||||
|
||||
// Also listen for language change events to re-apply translations
|
||||
document.addEventListener('languageChanged', function() {
|
||||
|
||||
Reference in New Issue
Block a user