df8211c8ac
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
64 lines
2.6 KiB
HTML
64 lines
2.6 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="fr">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<title>⚡ Sandbox - Découverte de Table</title>
|
|
<style>
|
|
body { font-family: sans-serif; background: #333; padding: 50px; color: white; }
|
|
.modal { background: white; padding: 20px; border-radius: 12px; width: 400px; margin: 0 auto; color: black; }
|
|
.debug-panel { margin-top: 20px; padding: 15px; background: #222; border-radius: 8px; font-family: monospace; }
|
|
.btn { padding: 10px 20px; border-radius: 8px; border: none; cursor: pointer; margin: 5px; background: #1976d2; color: white; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
|
|
<div class="modal">
|
|
<h3>Découverte automatique</h3>
|
|
<button class="btn" onclick="discoverCategories()">Lancer la lecture de la table</button>
|
|
<div id="result-area"></div>
|
|
</div>
|
|
|
|
<div class="debug-panel">
|
|
<strong>Table des catégories trouvées :</strong>
|
|
<pre id="table-display">En attente...</pre>
|
|
</div>
|
|
|
|
<script>
|
|
async function discoverCategories() {
|
|
try {
|
|
// On lit le fichier source directement depuis le serveur
|
|
const response = await fetch('/assets/js/app.js');
|
|
const text = await response.text();
|
|
|
|
// On cherche la définition de CATEGORY_LABELS par regex
|
|
const match = text.match(/const CATEGORY_LABELS = ({[\s\S]*?});/);
|
|
|
|
if (match) {
|
|
// On transforme le bloc trouvé en objet JS
|
|
const categoryObject = eval('(' + match[1] + ')');
|
|
|
|
// Affichage dans le panneau de debug
|
|
document.getElementById('table-display').innerText = JSON.stringify(categoryObject, null, 2);
|
|
|
|
// Génération du menu déroulant
|
|
renderDropdown(categoryObject);
|
|
} else {
|
|
document.getElementById('table-display').innerText = "Erreur : Table CATEGORY_LABELS introuvable dans app.js.";
|
|
}
|
|
} catch (e) {
|
|
document.getElementById('table-display').innerText = "Erreur de lecture : " + e.message;
|
|
}
|
|
}
|
|
|
|
function renderDropdown(data) {
|
|
const area = document.getElementById('result-area');
|
|
const options = Object.entries(data).map(([k, v]) => `<option value="${k}">${v}</option>`).join('');
|
|
area.innerHTML = `
|
|
<select style="width:100%; padding:10px; margin-top:10px;">
|
|
${options}
|
|
</select>
|
|
`;
|
|
}
|
|
</script>
|
|
</body>
|
|
</html> |