add count for points

This commit is contained in:
Zhora Shalyapin 2025-03-20 14:37:19 +00:00
parent 3958a610f9
commit 8e0b2d874c

49
main.js
View File

@ -1907,10 +1907,55 @@
finishRow.querySelector(`td`).colSpan = 4
}
function makeStatsSpan(text) {
let statsSpan = document.createElement("span")
statsSpan.textContent = text
statsSpan.classList.add("stats")
return statsSpan
}
function countCp() {
let rows = getRows()
let fullCount = 0
let stageCount = 0
let stageRow = null
for (const [i, row] of rows.entries()) {
if (i < 2) continue
let isFinish = row.querySelector(".attention") !== null
if (isFinish || row.querySelector(`th`)) {
if (stageRow) {
stageRow.querySelector("th").append(makeStatsSpan(`КП в этапе: ${stageCount}`))
}
if (isFinish) break
stageRow = row
stageCount = 0
continue
}
fullCount++
stageCount++
}
document.querySelector("table tr:nth-child(2) th").append(makeStatsSpan(`Всего КП: ${fullCount}`))
addStylesToHead(`
.stats {
color: red;
margin-left: .5em;
}
`)
}
changeColumnWidth()
hideDescription()
hideStartRow()
useColspanForFinishWarning()
countCp()
}
function matchNumberFromSelect(select) {
@ -2025,11 +2070,11 @@
el.rows = 1
})
}
function hideRedundantRows() {
document.querySelectorAll(`table tr:is(:nth-child(3), :nth-child(4), :nth-child(5))`).forEach(el => el.classList.add("hidden"))
}
makeTextareasOneRow()
hideRedundantRows()
createPointsInpit()