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:
@@ -6,13 +6,13 @@
|
||||
<style>
|
||||
body { font-family: sans-serif; background: #333; color: #fff; padding: 50px; }
|
||||
.modal-preview { background: #fff; color: #000; padding: 20px; border-radius: 12px; width: 500px; margin: 0 auto; box-shadow: 0 4px 15px rgba(0,0,0,0.5); }
|
||||
.button-container { display: flex; justify-content: space-between; align-items: center; margin-top: 20px; }
|
||||
.button-container { display: flex; justify-content: space-between; align-items: center; margin-top: 20px; gap: 8px; }
|
||||
|
||||
/* Les styles que tu as inspectés */
|
||||
.btn { padding: 12px; border-radius: 8px; border: none; font-weight: bold; cursor: pointer; flex: 1; margin: 0 5px; text-align: center; text-decoration: none; }
|
||||
.btn { padding: 12px; border-radius: 8px; border: none; font-weight: bold; cursor: pointer; flex: 1; text-align: center; text-decoration: none; }
|
||||
.btn-success { background-color: #2e7d32; color: white; }
|
||||
.btn-danger { background-color: #d32f2f; color: white; }
|
||||
.btn-purple { background-color: #7b1fa2; color: white; }
|
||||
.btn-catalog-shortcut { background-color: #1976d2; color: white; font-size: 11px; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
@@ -25,41 +25,46 @@
|
||||
|
||||
<div class="button-container">
|
||||
<button class="btn btn-danger">Utiliser</button>
|
||||
|
||||
<button class="btn btn-success" data-id="145">Modifier</button>
|
||||
|
||||
<button class="btn btn-purple">Recette</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
setInterval(() => {
|
||||
// Utilisation d'une fonction pour injecter proprement
|
||||
function injectShortcut() {
|
||||
const greenBtn = document.querySelector('.btn-success');
|
||||
|
||||
if (greenBtn && !greenBtn.parentNode.querySelector('.btn-catalog-shortcut')) {
|
||||
// Si le bouton existe ET qu'on n'a pas encore ajouté le bouton bleu
|
||||
if (greenBtn && !document.querySelector('.btn-catalog-shortcut')) {
|
||||
const container = greenBtn.parentNode;
|
||||
|
||||
// Extraction chirurgicale de l'attribut "data-id"
|
||||
let pId = greenBtn.getAttribute('data-id');
|
||||
|
||||
const blueBtn = document.createElement('button');
|
||||
blueBtn.type = 'button';
|
||||
blueBtn.className = 'btn btn-catalog-shortcut';
|
||||
blueBtn.style.cssText = 'background-color: #1976d2; color: white; font-size: 11px;';
|
||||
blueBtn.innerText = '✏️ Modifier la fiche';
|
||||
|
||||
blueBtn.onclick = function() {
|
||||
if (pId) {
|
||||
alert("ID extrait avec succès du bouton vert ! Valeur : " + pId);
|
||||
alert("Succès ! ID extrait : " + pId);
|
||||
// Ici tu mettras : window.location.href = '/catalogue?id=' + pId;
|
||||
} else {
|
||||
alert("Aïe ! Le bouton vert n'a pas d'attribut 'data-id'.");
|
||||
alert("ID introuvable.");
|
||||
}
|
||||
};
|
||||
|
||||
container.insertBefore(blueBtn, greenBtn);
|
||||
console.log("Injection réussie.");
|
||||
}
|
||||
}
|
||||
}, 1000);
|
||||
</script>
|
||||
|
||||
// On vérifie la présence du bouton une seule fois si la page est chargée,
|
||||
// ou via un intervalle léger pour s'adapter au rendu dynamique.
|
||||
const observer = setInterval(injectShortcut, 500);
|
||||
|
||||
// Optionnel : arrêter l'intervalle après 5 secondes pour économiser les ressources
|
||||
setTimeout(() => clearInterval(observer), 5000);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user