Actualiser test.html
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
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
This commit is contained in:
@@ -2,51 +2,39 @@
|
|||||||
<html lang="fr">
|
<html lang="fr">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<title>⚡ Récupération Dynamique Totale</title>
|
<title>⚡ Récupération Directe</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h3>Catégories récupérées en temps réel :</h3>
|
<h3>Catégories récupérées depuis la mémoire :</h3>
|
||||||
<select id="dynamic-select" style="width:100%; padding:10px;"></select>
|
<select id="dynamic-select" style="width:100%; padding:10px;"></select>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
async function fetchRealCategories() {
|
// On crée une balise script qui pointe vers le fichier source d'EverShelf
|
||||||
try {
|
const script = document.createElement('script');
|
||||||
// 1. Récupération du fichier source
|
script.src = '/assets/js/app.js';
|
||||||
const response = await fetch('/assets/js/app.js');
|
|
||||||
const scriptText = await response.text();
|
|
||||||
|
|
||||||
// 2. Extraction du bloc CATEGORY_LABELS par expression régulière
|
script.onload = () => {
|
||||||
// On cible le bloc entre { et }
|
// Une fois le script chargé, la variable CATEGORY_LABELS est maintenant disponible dans la mémoire de cette page
|
||||||
const regex = /const CATEGORY_LABELS = ({[\s\S]*?});/;
|
const cats = window.CATEGORY_LABELS;
|
||||||
const match = scriptText.match(regex);
|
|
||||||
|
|
||||||
if (match) {
|
if (cats) {
|
||||||
// On nettoie le texte pour le rendre compatible JSON
|
|
||||||
// On supprime les appels t(...) et on transforme les backticks en guillemets
|
|
||||||
let cleanJson = match[1]
|
|
||||||
.replace(/'/g, '"')
|
|
||||||
.replace(/\s*:\s*`.*?\$\{t\('(.*?)'\)\}`/g, ': "$1"')
|
|
||||||
.replace(/,\s*}/g, '}');
|
|
||||||
|
|
||||||
const categories = JSON.parse(cleanJson);
|
|
||||||
|
|
||||||
// 3. Affichage
|
|
||||||
const select = document.getElementById('dynamic-select');
|
const select = document.getElementById('dynamic-select');
|
||||||
Object.entries(categories).forEach(([key, val]) => {
|
|
||||||
|
// On itère sur les clés de l'objet
|
||||||
|
Object.keys(cats).forEach(key => {
|
||||||
const opt = document.createElement('option');
|
const opt = document.createElement('option');
|
||||||
opt.value = key;
|
opt.value = key;
|
||||||
opt.textContent = val;
|
// On affiche le texte brut (en ignorant le résultat de la fonction t())
|
||||||
|
opt.textContent = key;
|
||||||
select.appendChild(opt);
|
select.appendChild(opt);
|
||||||
});
|
});
|
||||||
console.log("Catégories chargées avec succès :", categories);
|
console.log("Données récupérées :", cats);
|
||||||
}
|
} else {
|
||||||
} catch (err) {
|
console.error("Variable CATEGORY_LABELS non trouvée après chargement.");
|
||||||
console.error("Erreur de récupération :", err);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// Exécution automatique
|
document.head.appendChild(script);
|
||||||
fetchRealCategories();
|
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
Reference in New Issue
Block a user