maj style html
This commit is contained in:
@@ -51,6 +51,15 @@
|
||||
th.desc::after {
|
||||
content: " 🔽";
|
||||
}
|
||||
|
||||
/* Style pour les couleurs conditionnelles */
|
||||
.orange {
|
||||
background-color: #ff9800;
|
||||
}
|
||||
|
||||
.red {
|
||||
background-color: #f44336;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@@ -21,6 +21,24 @@
|
||||
return !isNaN(v1) && !isNaN(v2) ? v1 - v2 : v1.localeCompare(v2);
|
||||
};
|
||||
|
||||
// Sélection de la colonne (par exemple la 3ème colonne, index 2)
|
||||
const colorColumnIndex = 9;
|
||||
|
||||
const colorizeCells = () => {
|
||||
const rows = document.querySelectorAll('table tr:nth-child(n+2)'); // Ignore l'en-tête
|
||||
rows.forEach(row => {
|
||||
const cell = row.children[colorColumnIndex];
|
||||
const value = parseFloat(cell.innerText);
|
||||
if (!isNaN(value)) {
|
||||
if (value > 90) {
|
||||
cell.classList.add('red');
|
||||
} else if (value >= 80 && value <= 90) {
|
||||
cell.classList.add('orange');
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// permet de trier le tableau
|
||||
document.querySelectorAll('table th').forEach(th => {
|
||||
th.addEventListener('click', () => {
|
||||
@@ -35,6 +53,9 @@
|
||||
rows.sort(comparer(index, asc)).forEach(row => tbody.appendChild(row));
|
||||
});
|
||||
});
|
||||
|
||||
// Appliquer la colorisation après chargement du tableau
|
||||
colorizeCells();
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user