update menu
This commit is contained in:
parent
64f55efca8
commit
0f8af9b014
99
main.js
99
main.js
@ -18,8 +18,14 @@
|
|||||||
const links = {
|
const links = {
|
||||||
"Волонтеры": "suv_comp",
|
"Волонтеры": "suv_comp",
|
||||||
"Контрольные пункты": "cp_mgmt",
|
"Контрольные пункты": "cp_mgmt",
|
||||||
"Добавить новый КП": "cp_mgmt/?action=edit",
|
"+ КП": "cp_mgmt/?action=edit",
|
||||||
"Маршруты": "route_mgmt",
|
"Маршруты": "route_mgmt",
|
||||||
|
"Тесты": "route_mgmt?test=1",
|
||||||
|
"+ Тест": "suv_comp?action=test_online",
|
||||||
|
"Склеить": "suv_comp?action=test_merge",
|
||||||
|
"Прохождение": "callcenter?action=online_log",
|
||||||
|
"КП в трассах": "route_mgmt?action=cp_list",
|
||||||
|
// "Связанные КП": "#",
|
||||||
}
|
}
|
||||||
|
|
||||||
const catLinks = {
|
const catLinks = {
|
||||||
@ -979,29 +985,16 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function addStickyMenu() {
|
function createMenuFromLinks(links, blanks = []) {
|
||||||
let competition = getCompetition()
|
|
||||||
if (!competition) return
|
|
||||||
|
|
||||||
let menuContainer = document.createElement("nav")
|
|
||||||
menuContainer.classList.add("sticky-menu")
|
|
||||||
let menu = document.createElement("menu")
|
let menu = document.createElement("menu")
|
||||||
menuContainer.appendChild(menu)
|
|
||||||
|
|
||||||
let catId = urlParams().get("cat_id")
|
|
||||||
if (catId !== null) {
|
|
||||||
for (const [label, href] of Object.entries(catLinks)) {
|
|
||||||
links[label] = href(catId)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const [label, href] of Object.entries(links)) {
|
for (const [label, href] of Object.entries(links)) {
|
||||||
let menuItem = document.createElement("li")
|
let menuItem = document.createElement("li")
|
||||||
let link = document.createElement("a")
|
let link = document.createElement("a")
|
||||||
link.href = `/${competition}/${href}`
|
link.href = href
|
||||||
link.innerText = label
|
link.innerText = label
|
||||||
|
|
||||||
if (label === "Легенда") {
|
if (blanks.includes(label)) {
|
||||||
link.setAttribute("target", "_blank")
|
link.setAttribute("target", "_blank")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1009,7 +1002,57 @@
|
|||||||
menu.appendChild(menuItem)
|
menu.appendChild(menuItem)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return menu
|
||||||
|
}
|
||||||
|
|
||||||
|
function addStickyMenu() {
|
||||||
|
let competition = getCompetition()
|
||||||
|
if (!competition) return
|
||||||
|
|
||||||
|
let menuContainer = document.createElement("nav")
|
||||||
|
menuContainer.classList.add("sticky-menu")
|
||||||
|
|
||||||
|
let mainLinksFormatted = {}
|
||||||
|
for (const [label, href] of Object.entries(links)) {
|
||||||
|
mainLinksFormatted[label] = `/${competition}/${href}`
|
||||||
|
}
|
||||||
|
menuContainer.append(createMenuFromLinks(mainLinksFormatted, ["Легенда"]))
|
||||||
|
|
||||||
|
let catId = urlParams().get("cat_id")
|
||||||
|
if (catId !== null) {
|
||||||
|
let catLinksFormatted = {}
|
||||||
|
for (const [label, href] of Object.entries(catLinks)) {
|
||||||
|
catLinksFormatted[label] = href(catId)
|
||||||
|
}
|
||||||
|
|
||||||
|
menuContainer.append(createMenuFromLinks(catLinksFormatted))
|
||||||
|
}
|
||||||
|
|
||||||
document.querySelector("#header").after(menuContainer)
|
document.querySelector("#header").after(menuContainer)
|
||||||
|
|
||||||
|
addStylesToHead(`
|
||||||
|
.sticky-menu {
|
||||||
|
position: sticky;
|
||||||
|
top: 0;
|
||||||
|
z-index: 9999;
|
||||||
|
|
||||||
|
menu {
|
||||||
|
display: flex;
|
||||||
|
gap: .3rem;
|
||||||
|
background: white;
|
||||||
|
font-size: 1.2rem;
|
||||||
|
padding-left: 10px;
|
||||||
|
|
||||||
|
li {
|
||||||
|
list-style-type: none;
|
||||||
|
|
||||||
|
&:not(:last-child)::after {
|
||||||
|
content: " | "
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`)
|
||||||
}
|
}
|
||||||
|
|
||||||
function addClearBoth() {
|
function addClearBoth() {
|
||||||
@ -1996,28 +2039,6 @@
|
|||||||
|
|
||||||
function addCommonStyles() {
|
function addCommonStyles() {
|
||||||
addStylesToHead(`
|
addStylesToHead(`
|
||||||
.sticky-menu {
|
|
||||||
position: sticky;
|
|
||||||
top: 0;
|
|
||||||
z-index: 9999;
|
|
||||||
|
|
||||||
menu {
|
|
||||||
display: flex;
|
|
||||||
gap: .3rem;
|
|
||||||
background: white;
|
|
||||||
font-size: 1.2rem;
|
|
||||||
padding-left: 10px;
|
|
||||||
|
|
||||||
li {
|
|
||||||
list-style-type: none;
|
|
||||||
|
|
||||||
&:not(:last-child)::after {
|
|
||||||
content: " | "
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#content h1 {
|
#content h1 {
|
||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user