input for going to cp
This commit is contained in:
parent
08cf3333a8
commit
358d7659b8
51
main.js
51
main.js
@ -280,6 +280,10 @@
|
|||||||
return isRouteManagement() && getAction() === "map"
|
return isRouteManagement() && getAction() === "map"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function cpLink(cpId) {
|
||||||
|
return `/${getCompetition()}/cp_mgmt/?action=edit&cp_id=${cpId}`
|
||||||
|
}
|
||||||
|
|
||||||
async function updatePoint(formData) {
|
async function updatePoint(formData) {
|
||||||
return await fetch(`https://runcity.geo.rictum.ru/api/competitions/${getCompetition()}/update`, {
|
return await fetch(`https://runcity.geo.rictum.ru/api/competitions/${getCompetition()}/update`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
@ -293,6 +297,12 @@
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function getPointIdByNumber(number) {
|
||||||
|
return await fetch(`https://runcity.geo.rictum.ru/api/competitions/${getCompetition()}/${number}`, {
|
||||||
|
method: 'GET'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
function copyCoordinates() {
|
function copyCoordinates() {
|
||||||
let copyButton = document.createElement("button")
|
let copyButton = document.createElement("button")
|
||||||
copyButton.addEventListener("click", async event => {
|
copyButton.addEventListener("click", async event => {
|
||||||
@ -1057,6 +1067,36 @@
|
|||||||
}
|
}
|
||||||
menuContainer.append(createMenuFromLinks(mainLinksFormatted, ["Легенда"]))
|
menuContainer.append(createMenuFromLinks(mainLinksFormatted, ["Легенда"]))
|
||||||
|
|
||||||
|
let goToContainer = Tag.make("li", {
|
||||||
|
classes: "go-to-container",
|
||||||
|
children: [
|
||||||
|
Tag.input({
|
||||||
|
type: "text",
|
||||||
|
id: "go-to-cp"
|
||||||
|
}),
|
||||||
|
Tag.span({
|
||||||
|
textContent: "✏️ КП",
|
||||||
|
on: {
|
||||||
|
click: async function() {
|
||||||
|
let number = document.querySelector("#go-to-cp").value
|
||||||
|
let response = await getPointIdByNumber(number)
|
||||||
|
let json = await response.json()
|
||||||
|
let id = json.id
|
||||||
|
|
||||||
|
if (id == null) {
|
||||||
|
alert("Нет КП с таким номером")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
location.href = cpLink(id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
]
|
||||||
|
})
|
||||||
|
|
||||||
|
;[...menuContainer.querySelectorAll(`li`)].find(el => el.querySelector(`a`).textContent.trim() == "Контрольные пункты")?.after(goToContainer)
|
||||||
|
|
||||||
let catId = urlParams().get("cat_id")
|
let catId = urlParams().get("cat_id")
|
||||||
if (catId !== null) {
|
if (catId !== null) {
|
||||||
let catLinksFormatted = {}
|
let catLinksFormatted = {}
|
||||||
@ -1090,6 +1130,17 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.go-to-container {
|
||||||
|
input {
|
||||||
|
width: 5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
span {
|
||||||
|
margin-left: .5em;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
`)
|
`)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user