eaf9ebc52e
CI / PHP Syntax Check (push) Has been cancelled
CI / JavaScript Lint (push) Has been cancelled
CI / Docker Build Test (push) Has been cancelled
CI / Validate Translation Files (push) Has been cancelled
CI / Auto-merge develop → main (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
50 lines
1.9 KiB
HTML
50 lines
1.9 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="fr">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<title>⚡ Récupération Dynamique Totale</title>
|
|
</head>
|
|
<body>
|
|
<h3>Catégories récupérées en temps réel :</h3>
|
|
<select id="dynamic-select" style="width:100%; padding:10px;"></select>
|
|
|
|
<script>
|
|
async function fetchRealCategories() {
|
|
// 1. On récupère le fichier app.js
|
|
const response = await fetch('/assets/js/app.js');
|
|
const scriptText = await response.text();
|
|
|
|
// 2. On crée un "bac à sable" (iframe) pour exécuter le code sans erreurs
|
|
const iframe = document.createElement('iframe');
|
|
iframe.style.display = 'none';
|
|
document.body.appendChild(iframe);
|
|
|
|
// 3. On définit un mock pour la fonction de traduction 't' qui bloquait tout
|
|
iframe.contentWindow.t = (key) => key.split('.').pop();
|
|
|
|
// 4. On injecte le code
|
|
const script = iframe.contentDocument.createElement('script');
|
|
script.textContent = scriptText;
|
|
iframe.contentDocument.body.appendChild(script);
|
|
|
|
// 5. On attend un instant que la variable soit déclarée et on la récupère
|
|
setTimeout(() => {
|
|
const cats = iframe.contentWindow.CATEGORY_LABELS;
|
|
if (cats) {
|
|
const select = document.getElementById('dynamic-select');
|
|
Object.entries(cats).forEach(([key, val]) => {
|
|
const opt = document.createElement('option');
|
|
opt.value = key;
|
|
opt.textContent = val;
|
|
select.appendChild(opt);
|
|
});
|
|
}
|
|
document.body.removeChild(iframe);
|
|
}, 500);
|
|
}
|
|
|
|
// On lance la découverte au chargement
|
|
fetchRealCategories();
|
|
</script>
|
|
</body>
|
|
</html> |