add links to stages
This commit is contained in:
parent
7ef9d55dc6
commit
815bc96234
69
main.js
69
main.js
@ -15,7 +15,22 @@
|
|||||||
(function () {
|
(function () {
|
||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
let fileInputs = {
|
const links = {
|
||||||
|
"Волонтеры": "suv_comp",
|
||||||
|
"Контрольные пункты": "cp_mgmt",
|
||||||
|
"Добавить новый КП": "cp_mgmt/?action=edit",
|
||||||
|
"Маршруты": "route_mgmt",
|
||||||
|
}
|
||||||
|
|
||||||
|
const catLinks = {
|
||||||
|
"Редактор маршрута": (catId) => `route_mgmt?action=edit&cat_id=${catId}`,
|
||||||
|
"Конструктор маршрута": (catId) => `route_mgmt/?action=build2&cat_id=${catId}`,
|
||||||
|
"Карта": (catId) => `route_mgmt?action=map&cat_id=${catId}`,
|
||||||
|
"Этапы": (catId) => `route_mgmt/?action=stages&cat_id=${catId}`,
|
||||||
|
"Легенда": (catId) => `route_mgmt?action=preview&cat_id=${catId}&locale_id=ru`,
|
||||||
|
}
|
||||||
|
|
||||||
|
const fileInputs = {
|
||||||
"attachment1": {
|
"attachment1": {
|
||||||
"l": "legend_photo",
|
"l": "legend_photo",
|
||||||
"h": "history_photo"
|
"h": "history_photo"
|
||||||
@ -28,12 +43,12 @@
|
|||||||
"attachment3": "admin_files"
|
"attachment3": "admin_files"
|
||||||
}
|
}
|
||||||
|
|
||||||
let fileInpitVariants = {
|
const fileInpitVariants = {
|
||||||
"l": "для легенды",
|
"l": "для легенды",
|
||||||
"h": "для ист. справки"
|
"h": "для ист. справки"
|
||||||
}
|
}
|
||||||
|
|
||||||
let mapsCenterByCompetition = {
|
const mapsCenterByCompetition = {
|
||||||
"msk2025": {
|
"msk2025": {
|
||||||
lat: 55.839808,
|
lat: 55.839808,
|
||||||
ifSouthern: {
|
ifSouthern: {
|
||||||
@ -187,10 +202,14 @@
|
|||||||
return getPageType() === "route_mgmt"
|
return getPageType() === "route_mgmt"
|
||||||
}
|
}
|
||||||
|
|
||||||
function isListCpPage() {
|
function isCpListPage() {
|
||||||
return isCpManagement() && getAction() === null
|
return isCpManagement() && getAction() === null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isRouteListPage() {
|
||||||
|
return isRouteManagement() && getAction() === null
|
||||||
|
}
|
||||||
|
|
||||||
function isRouteBuildPage() {
|
function isRouteBuildPage() {
|
||||||
return isRouteManagement() && getAction() === "build2"
|
return isRouteManagement() && getAction() === "build2"
|
||||||
}
|
}
|
||||||
@ -935,20 +954,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function addStickyMenu() {
|
function addStickyMenu() {
|
||||||
let links = {
|
|
||||||
"Волонтеры": "suv_comp",
|
|
||||||
"Контрольные пункты": "cp_mgmt",
|
|
||||||
"Добавить новый КП": "cp_mgmt/?action=edit",
|
|
||||||
"Маршруты": "route_mgmt",
|
|
||||||
}
|
|
||||||
let catLinks = {
|
|
||||||
"Редактор маршрута": (catId) => `route_mgmt?action=edit&cat_id=${catId}`,
|
|
||||||
"Конструктор маршрута": (catId) => `route_mgmt/?action=stages&cat_id=${catId}`,
|
|
||||||
"Карта": (catId) => `route_mgmt?action=map&cat_id=${catId}`,
|
|
||||||
"Этапы": (catId) => `route_mgmt/?action=stages&cat_id=${catId}`,
|
|
||||||
"Легенда": (catId) => `route_mgmt?action=preview&cat_id=${catId}&locale_id=ru`,
|
|
||||||
}
|
|
||||||
|
|
||||||
let menuContainer = document.createElement("nav")
|
let menuContainer = document.createElement("nav")
|
||||||
menuContainer.classList.add("sticky-menu")
|
menuContainer.classList.add("sticky-menu")
|
||||||
let menu = document.createElement("menu")
|
let menu = document.createElement("menu")
|
||||||
@ -996,6 +1001,24 @@
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function addStageLink() {
|
||||||
|
let linkCells = [...document.querySelectorAll("#content table td:nth-child(2)")]
|
||||||
|
for (const linkCell of linkCells) {
|
||||||
|
let href = linkCell.querySelector("a").href
|
||||||
|
let catId = new URLSearchParams(href).get("cat_id")
|
||||||
|
let constructorLink = linkCell.querySelector(`a[href="${catLinks["Конструктор маршрута"](catId).replace("route_mgmt/", "")}"]`)
|
||||||
|
|
||||||
|
if (constructorLink) {
|
||||||
|
let stagesLink = document.createElement("a")
|
||||||
|
stagesLink.innerText = "Этапы"
|
||||||
|
stagesLink.href = catLinks[stagesLink.innerText](catId)
|
||||||
|
|
||||||
|
constructorLink.after(stagesLink)
|
||||||
|
constructorLink.after(", ")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function getRows() {
|
function getRows() {
|
||||||
return [...document.querySelectorAll('#props > tbody > tr')]
|
return [...document.querySelectorAll('#props > tbody > tr')]
|
||||||
}
|
}
|
||||||
@ -1781,16 +1804,22 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
addClearBoth()
|
addClearBoth()
|
||||||
|
if (document.querySelector(".leaflet-container")) {
|
||||||
initMapbox()
|
initMapbox()
|
||||||
addFullscreenButton()
|
addFullscreenButton()
|
||||||
|
|
||||||
addStickyMenu()
|
|
||||||
|
|
||||||
if (isRouteBuildPage() || isRouteMapPage()) {
|
if (isRouteBuildPage() || isRouteMapPage()) {
|
||||||
centerMap()
|
centerMap()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
addStickyMenu()
|
||||||
|
|
||||||
if (isEditCpPage()) {
|
if (isEditCpPage()) {
|
||||||
prettifyEditCpPage()
|
prettifyEditCpPage()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isRouteListPage()) {
|
||||||
|
addStageLink()
|
||||||
|
}
|
||||||
})();
|
})();
|
Loading…
Reference in New Issue
Block a user