33e552373c
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
65 lines
2.6 KiB
HTML
65 lines
2.6 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="fr">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<title>⚡ Sandbox - Test Récupération ID</title>
|
|
<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; }
|
|
|
|
/* 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-success { background-color: #2e7d32; color: white; }
|
|
.btn-danger { background-color: #d32f2f; color: white; }
|
|
.btn-purple { background-color: #7b1fa2; color: white; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
|
|
<h2 style="text-align: center;">Test de Capture d'attribut HTML</h2>
|
|
|
|
<div class="modal-preview">
|
|
<h3>Jus ananas</h3>
|
|
<p>Emplacement : 🍷 Cave</p>
|
|
|
|
<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(() => {
|
|
const greenBtn = document.querySelector('.btn-success');
|
|
|
|
if (greenBtn && !greenBtn.parentNode.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);
|
|
} else {
|
|
alert("Aïe ! Le bouton vert n'a pas d'attribut 'data-id'.");
|
|
}
|
|
};
|
|
|
|
container.insertBefore(blueBtn, greenBtn);
|
|
}
|
|
}, 1000);
|
|
</script>
|
|
|
|
</body>
|
|
</html> |