paint cp list on route edit page
This commit is contained in:
parent
4de91e933f
commit
facd974814
26
main.js
26
main.js
@ -84,6 +84,8 @@
|
||||
const ZOOM = 17
|
||||
const METERS = 510
|
||||
|
||||
const stageColors = ["#ff8080", "#ffc680", "#ffff80", "#80ff80", "#80ffff", "#8080ff", "#ff80ff"]
|
||||
|
||||
let removedFilesLinks = []
|
||||
|
||||
class Tag {
|
||||
@ -2307,9 +2309,13 @@
|
||||
showUnknownPoints()
|
||||
}
|
||||
|
||||
function getCpNumberFromOption(option) {
|
||||
return option.textContent.match(/(?<=^\s*#)\d+/g)?.[0]
|
||||
}
|
||||
|
||||
function matchNumberFromSelect(select) {
|
||||
return [...document.querySelector(select).options].reduce(
|
||||
(res, el) => ({ ...res, [el.textContent.match(/(?<=^\s*#)\d+/g)?.[0]]: el.value }),
|
||||
(res, el) => ({ ...res, [getCpNumberFromOption(el)]: el.value }),
|
||||
{}
|
||||
)
|
||||
}
|
||||
@ -2434,9 +2440,27 @@
|
||||
document.querySelectorAll(`table tr:is(:nth-child(3), :nth-child(4), :nth-child(5))`).forEach(el => el.classList.add("hidden"))
|
||||
}
|
||||
|
||||
function paintCpList() {
|
||||
let options = [...document.querySelectorAll(`#cps_in option`)]
|
||||
|
||||
;(async () => {
|
||||
let points = await getPointsByField("number", options.map(option => getCpNumberFromOption(option)))
|
||||
let catId = urlParams().get("cat_id")
|
||||
|
||||
for (const option of options) {
|
||||
let category = points[getCpNumberFromOption(option)].categories.find(category => category.cat_id === catId)
|
||||
if (category && category.pivot.bonus_time == "0") {
|
||||
let stage = parseInt(category.pivot.stage)
|
||||
option.style['background-color'] = stageColors[stage % stageColors.length]
|
||||
}
|
||||
}
|
||||
})()
|
||||
}
|
||||
|
||||
makeTextareasOneRow()
|
||||
hideRedundantRows()
|
||||
createPointsInpit()
|
||||
paintCpList()
|
||||
}
|
||||
|
||||
function toggleStagePageRows(rows) {
|
||||
|
Loading…
Reference in New Issue
Block a user