| 139 | const SATURATION = '80%' |
| 140 | const LIGHTNESS = '88%' |
| 141 | function applyGradientToColumn(table, column) { |
| 142 | const rowCount = table.rows.length |
| 143 | Array.from(table.rows).forEach((row, index) => { |
| 144 | const cell = row.cells[column] |
| 145 | if (!cell) return |
| 146 | // Calculate a hue based on the row index (no need to rely on cell content) |
| 147 | const hue = (index / (rowCount - 1)) * HUE_RANGE |
| 148 | // Apply the gradient color to the cell |
| 149 | cell.style.backgroundColor = `hsl(${HUE_RANGE - hue}, ${SATURATION}, ${LIGHTNESS})` |
| 150 | }) |
| 151 | } |
| 152 | function initializeTable(table) { |
| 153 | if (table.hasAttribute('data-gradient-initialized')) return |
| 154 | table.setAttribute('data-gradient-initialized', 'true') |