From a2d95dd6823e1533283416cb51e669fa0cc86e03 Mon Sep 17 00:00:00 2001 From: Yacine31 Date: Wed, 16 Apr 2025 20:44:14 +0200 Subject: [PATCH] maj style html --- summary/00_header.html | 9 +++++++++ summary/99_footer.html | 25 +++++++++++++++++++++++-- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/summary/00_header.html b/summary/00_header.html index 665ff46..b05b003 100644 --- a/summary/00_header.html +++ b/summary/00_header.html @@ -51,6 +51,15 @@ th.desc::after { content: " 🔽"; } + + /* Style pour les couleurs conditionnelles */ + .orange { + background-color: #ff9800; + } + + .red { + background-color: #f44336; + } diff --git a/summary/99_footer.html b/summary/99_footer.html index 1ab7f60..85526a7 100644 --- a/summary/99_footer.html +++ b/summary/99_footer.html @@ -10,7 +10,7 @@ }); }); */ - + // Permet de sélectionner une ligne en cliquant dessus document.addEventListener('DOMContentLoaded', () => { const getCellValue = (tr, idx) => tr.children[idx].innerText || tr.children[idx].textContent; @@ -20,7 +20,25 @@ const v2 = getCellValue(asc ? b : a, idx); 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(); });