-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
27 lines (25 loc) · 970 Bytes
/
script.js
File metadata and controls
27 lines (25 loc) · 970 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
function logicalTableStyle(table) {
const rows = table.querySelectorAll("tr");
let logicalIndex = 0;
let spanGroupColor = null;
let remainingSpan = 0;
for (let i = 0; i < rows.length; i++) {
const row = rows[i];
if (remainingSpan > 0) {
row.style.backgroundColor = spanGroupColor;
remainingSpan--;
} else {
const firstCell = row.querySelector("td[rowspan]");
if (firstCell) {
const span = parseInt(firstCell.getAttribute("rowspan"), 10);
remainingSpan = span - 1;
spanGroupColor = logicalIndex % 2 === 0 ? "rgba(240, 243, 248, 0.7)" : "white";
row.style.backgroundColor = spanGroupColor;
logicalIndex++;
} else {
row.style.backgroundColor = logicalIndex % 2 === 0 ? "rgba(240, 243, 248, 0.7)" : "white";
logicalIndex++;
}
}
}
}