use same request for receiving point by number
This commit is contained in:
parent
fbaff3bdf3
commit
a4ac19e516
33
main.js
33
main.js
@ -312,8 +312,12 @@
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getPointIdByNumber(number) {
|
async function getPointIdByNumber(numbers) {
|
||||||
let response = await fetch(`https://${adminSite}/api/competitions/${getCompetition()}/${number}`, {
|
let params = new URLSearchParams()
|
||||||
|
for (const number of numbers) {
|
||||||
|
params.append("number[]", number)
|
||||||
|
}
|
||||||
|
let response = await fetch(`https://${adminSite}/api/competitions/${getCompetition()}/points?${params.toString()}`, {
|
||||||
method: 'GET'
|
method: 'GET'
|
||||||
})
|
})
|
||||||
return await response.json()
|
return await response.json()
|
||||||
@ -1171,8 +1175,8 @@
|
|||||||
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 getPointIdByNumber(number)
|
let json = await getPointIdByNumber([number])
|
||||||
let id = json.id
|
let id = json[number].cp_id
|
||||||
|
|
||||||
if (id == null) {
|
if (id == null) {
|
||||||
alert("Нет КП с таким номером")
|
alert("Нет КП с таким номером")
|
||||||
@ -2192,21 +2196,28 @@
|
|||||||
|
|
||||||
function addLinksToCp() {
|
function addLinksToCp() {
|
||||||
let pointCells = [...document.querySelectorAll(`#props table td:first-child`)]
|
let pointCells = [...document.querySelectorAll(`#props table td:first-child`)]
|
||||||
for (const pointCell of pointCells) {
|
let pointNumbers = {}
|
||||||
let cellContent = pointCell.textContent
|
for (const [i, pointCell] of pointCells.entries()) {
|
||||||
let pointNumber = cellContent.trim().match(/^\d+/)
|
let pointNumber = pointCell.textContent.trim().match(/^\d+/)?.[0]
|
||||||
if (pointNumber == null) continue
|
if (pointNumber != null)
|
||||||
|
pointNumbers[i] = pointNumber
|
||||||
|
}
|
||||||
|
|
||||||
;(async () => {
|
;(async () => {
|
||||||
let cpId = (await getPointIdByNumber(pointNumber)).id
|
let cpIds = await getPointIdByNumber(Object.values(pointNumbers))
|
||||||
|
|
||||||
|
for (const [i, pointCell] of pointCells.entries()) {
|
||||||
|
if (pointNumbers[i] == null) continue
|
||||||
|
|
||||||
|
let cellContent = pointCell.textContent
|
||||||
pointCell.innerHTML = ''
|
pointCell.innerHTML = ''
|
||||||
pointCell.append(Tag.a({
|
pointCell.append(Tag.a({
|
||||||
href: cpLink(cpId),
|
href: cpLink(cpIds[pointNumbers[i]].cp_id),
|
||||||
target: "_blank",
|
target: "_blank",
|
||||||
textContent: cellContent
|
textContent: cellContent
|
||||||
}))
|
}))
|
||||||
})()
|
|
||||||
}
|
}
|
||||||
|
})()
|
||||||
}
|
}
|
||||||
|
|
||||||
function getRouteName() {
|
function getRouteName() {
|
||||||
|
Loading…
Reference in New Issue
Block a user