add cp name to options on stages page
This commit is contained in:
parent
a5b62f30a2
commit
4b4990b123
33
main.js
33
main.js
@ -312,10 +312,10 @@
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getPointsByNumber(numbers) {
|
async function getPointsByField(field, values) {
|
||||||
let params = new URLSearchParams()
|
let params = new URLSearchParams()
|
||||||
for (const number of numbers) {
|
for (const value of values) {
|
||||||
params.append("number[]", number)
|
params.append(`${field}[]`, value)
|
||||||
}
|
}
|
||||||
let response = await fetch(`https://${adminSite}/api/competitions/${getCompetition()}/points?${params.toString()}`, {
|
let response = await fetch(`https://${adminSite}/api/competitions/${getCompetition()}/points?${params.toString()}`, {
|
||||||
method: 'GET'
|
method: 'GET'
|
||||||
@ -1164,7 +1164,7 @@
|
|||||||
on: {
|
on: {
|
||||||
click: async function () {
|
click: async function () {
|
||||||
let number = document.querySelector("#go-to-cp").value
|
let number = document.querySelector("#go-to-cp").value
|
||||||
let json = await getPointsByNumber([number])
|
let json = await getPointsByField("number", [number])
|
||||||
let id = json[number].cp_id
|
let id = json[number].cp_id
|
||||||
|
|
||||||
if (id == null) {
|
if (id == null) {
|
||||||
@ -2153,7 +2153,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function getPointsFromRows() {
|
async function getPointsFromRows() {
|
||||||
return await getPointsByNumber(Object.values(getPointNumbers()))
|
return await getPointsByField("number", Object.values(getPointNumbers()))
|
||||||
}
|
}
|
||||||
|
|
||||||
function countCp(points) {
|
function countCp(points) {
|
||||||
@ -2210,7 +2210,7 @@
|
|||||||
fullNeedHistoryCount++
|
fullNeedHistoryCount++
|
||||||
stageNeedHistoryCount++
|
stageNeedHistoryCount++
|
||||||
}
|
}
|
||||||
|
|
||||||
if (point.history_ru) {
|
if (point.history_ru) {
|
||||||
fullHistoryCount++
|
fullHistoryCount++
|
||||||
stageHistoryCount++
|
stageHistoryCount++
|
||||||
@ -2469,6 +2469,26 @@
|
|||||||
addStylesToHead(styles)
|
addStylesToHead(styles)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function addCpNameToOptions() {
|
||||||
|
let options = [...document.querySelectorAll(`option`)]
|
||||||
|
let cpIds = [...new Set(
|
||||||
|
options
|
||||||
|
.map($option => $option.value)
|
||||||
|
.filter($value => $value != null)
|
||||||
|
)
|
||||||
|
]
|
||||||
|
|
||||||
|
;(async () => {
|
||||||
|
let points = await getPointsByField("cp_id", cpIds)
|
||||||
|
|
||||||
|
for (const option of options) {
|
||||||
|
if (option.value != null && points[option.value] != null) {
|
||||||
|
option.innerText = option.innerText + " - " + points[option.value].name_int
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})()
|
||||||
|
}
|
||||||
|
|
||||||
function addCommonStyles() {
|
function addCommonStyles() {
|
||||||
addStylesToHead(`
|
addStylesToHead(`
|
||||||
#content h1 {
|
#content h1 {
|
||||||
@ -2636,6 +2656,7 @@
|
|||||||
|
|
||||||
if (isRouteStagesPage()) {
|
if (isRouteStagesPage()) {
|
||||||
hideUselessRowsFromRouteStagesPage()
|
hideUselessRowsFromRouteStagesPage()
|
||||||
|
addCpNameToOptions()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user