/** * Réduit le contenu des cellules td des tableaux */ const BREAKPOINT_SM = 1000; (() => { // Récupère les cellules td (premier d'un tr) à traiter const getTargetCells = () => { const tbodyRows = Array.from(document.querySelectorAll("tbody tr")); let cells = tbodyRows.map((row) => row.querySelector("td")).filter(Boolean); if (cells.length === 0) { const allRows = Array.from(document.querySelectorAll("tr")); cells = allRows.map((row) => row.querySelector("td")).filter(Boolean); } return cells; }; const tdElts = getTargetCells(); tdElts.forEach((td) => { if (!td.dataset.fullText) { td.dataset.fullText = td.textContent.trim(); } }); const applyTruncation = () => { const narrow = window.innerWidth < BREAKPOINT_SM; tdElts.forEach((td) => { const full = td.dataset.fullText ?? td.textContent; const text = (full || "").trim(); if (narrow) { td.textContent = text.length > 40 ? text.slice(0, 40) + '...': text; } else { td.textContent = full; } }); }; applyTruncation(); window.addEventListener("resize", applyTruncation); })();