split styles

This commit is contained in:
Zhora Shalyapin 2025-03-18 10:11:44 +00:00
parent 06e1d9d14f
commit f83a2adf06

353
main.js
View File

@ -1383,178 +1383,8 @@
} }
} }
function prettifyEditCpPage() { function addPrettifyEditPageCss() {
addCss("https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css") addStylesToHead(`
addCss("https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.min.css")
/* NEW DEFALUT VALUES */
chooseLegendAsDefaultVariant()
/* CONTAINER */
let form = document.querySelector('form')
let rows = getRows()
let insertedFileRows = getInsertedFileRows(rows)
let container = makeContainer()
let oldTable = document.querySelector("#props")
/* HEADER */
let headerContainer = makeHeader(rows)
/* TOP BUTTONS */
let [topButtonsContainer, bottomButtonsContainer] = makeTopAndBottomButtons(rows, form, oldTable, container, insertedFileRows)
addUglyDeleteListener()
createSendButtons()
/* LEGEND */
let legendContainer = makeLegend(rows)
legendContainer.appendChild(makeLegendFiles(rows))
/* APPEND ALL */
container.appendChild(topButtonsContainer)
container.appendChild(headerContainer)
container.appendChild(makeTopOptions(rows))
container.appendChild(makeComment(rows))
container.appendChild(legendContainer)
container.appendChild(makeAdminFiles(rows))
container.appendChild(makeBottomOptions(rows))
container.appendChild(bottomButtonsContainer)
/* MAP */
formatMap()
/* DIALOG */
makeDialog()
/* PRETTIFY CHECKBOX */
checkIfAlwaysPrettify(form, oldTable, container, insertedFileRows)
}
function isAllPointsSouthOfLat(lat) {
map.eachLayer(function(layer) {
if (layer instanceof L.Marker) {
let latLng = layer.getLatLng()
if (latLng.lat > lat) {
return false
}
}
})
}
function centerMap() {
if (map !== undefined && L !== undefined) {
let coords = mapsCenterByCompetition[getCompetition()]
if (coords == null) return
if (isAllPointsSouthOfLat(lat)) {
map.setView(new L.LatLng(coords.ifSouthern.lat, coords.ifSouthern.lon), 13)
}
else {
map.setView(new L.LatLng(coords.ifEverywhere.lat, coords.ifEverywhere.lon), 12)
}
}
}
function prettifyRouteBuildPage() {
let styles = `
#content table table {
td:nth-child(2) {
width: 10%;
select {
width: 5em !important;
}
}
td:nth-child(3) {
width: 12%;
}
td:nth-child(4) {
width: 12%;
input {
width: 4em;
}
}
}
`
addStylesToHead(styles)
document.querySelectorAll(`#content > form > table > tbody > tr:is(:nth-child(3), :nth-child(6)) `).forEach(el => el.remove())
document.querySelector(`#content table table tr:nth-child(2) `).remove()
}
function toggleStagePageRows(rows) {
let showIndex = [0, 3]
let to = rows.findIndex(el => el.querySelector("th")?.textContent.trim() == "Бонусы")
toggleRows(rows, 3, to, 8, showIndex)
toggleRows(rows, to, rows.length, 1, [])
}
function prettifyRouteStagesPage() {
let styles = `
tr.collapsed {
display: block;
width: 0;
height: 0;
overflow: hidden;
}
`
let rows = [...document.querySelectorAll(`#content tbody tr`)]
let collapseButton = document.createElement("button")
collapseButton.type = "button"
collapseButton.textContent = "Показать"
toggleStagePageRows(rows)
collapseButton.addEventListener("click", () => {
toggleStagePageRows(rows)
collapseButton.textContent = toggleText(collapseButton.textContent, "Показать", "Скрыть")
})
document.querySelector(`table tr:first-child th`).append(collapseButton)
addStylesToHead(styles)
}
let styles = `
.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 {
margin-bottom: 0;
}
#content-wrapper { #content-wrapper {
display: flex; display: flex;
gap: 20px; gap: 20px;
@ -1882,7 +1712,184 @@
align-items: center; align-items: center;
gap: 5px; gap: 5px;
} }
`)
}
function prettifyEditCpPage() {
addCss("https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css")
addCss("https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.min.css")
addPrettifyEditPageCss()
/* NEW DEFALUT VALUES */
chooseLegendAsDefaultVariant()
/* CONTAINER */
let form = document.querySelector('form')
let rows = getRows()
let insertedFileRows = getInsertedFileRows(rows)
let container = makeContainer()
let oldTable = document.querySelector("#props")
/* HEADER */
let headerContainer = makeHeader(rows)
/* TOP BUTTONS */
let [topButtonsContainer, bottomButtonsContainer] = makeTopAndBottomButtons(rows, form, oldTable, container, insertedFileRows)
addUglyDeleteListener()
createSendButtons()
/* LEGEND */
let legendContainer = makeLegend(rows)
legendContainer.appendChild(makeLegendFiles(rows))
/* APPEND ALL */
container.appendChild(topButtonsContainer)
container.appendChild(headerContainer)
container.appendChild(makeTopOptions(rows))
container.appendChild(makeComment(rows))
container.appendChild(legendContainer)
container.appendChild(makeAdminFiles(rows))
container.appendChild(makeBottomOptions(rows))
container.appendChild(bottomButtonsContainer)
/* MAP */
formatMap()
/* DIALOG */
makeDialog()
/* PRETTIFY CHECKBOX */
checkIfAlwaysPrettify(form, oldTable, container, insertedFileRows)
}
function isAllPointsSouthOfLat(lat) {
map.eachLayer(function(layer) {
if (layer instanceof L.Marker) {
let latLng = layer.getLatLng()
if (latLng.lat > lat) {
return false
}
}
})
}
function centerMap() {
if (map !== undefined && L !== undefined) {
let coords = mapsCenterByCompetition[getCompetition()]
if (coords == null) return
if (isAllPointsSouthOfLat(lat)) {
map.setView(new L.LatLng(coords.ifSouthern.lat, coords.ifSouthern.lon), 13)
}
else {
map.setView(new L.LatLng(coords.ifEverywhere.lat, coords.ifEverywhere.lon), 12)
}
}
}
function prettifyRouteBuildPage() {
let styles = `
#content table table {
td:nth-child(2) {
width: 10%;
select {
width: 5em !important;
}
}
td:nth-child(3) {
width: 12%;
}
td:nth-child(4) {
width: 12%;
input {
width: 4em;
}
}
}
` `
addStylesToHead(styles)
document.querySelectorAll(`#content > form > table > tbody > tr:is(:nth-child(3), :nth-child(6)) `).forEach(el => el.remove())
document.querySelector(`#content table table tr:nth-child(2) `).remove()
}
function toggleStagePageRows(rows) {
let showIndex = [0, 3]
let to = rows.findIndex(el => el.querySelector("th")?.textContent.trim() == "Бонусы")
toggleRows(rows, 3, to, 8, showIndex)
toggleRows(rows, to, rows.length, 1, [])
}
function prettifyRouteStagesPage() {
let styles = `
tr.collapsed {
display: block;
width: 0;
height: 0;
overflow: hidden;
}
`
let rows = [...document.querySelectorAll(`#content tbody tr`)]
let collapseButton = document.createElement("button")
collapseButton.type = "button"
collapseButton.textContent = "Показать"
toggleStagePageRows(rows)
collapseButton.addEventListener("click", () => {
toggleStagePageRows(rows)
collapseButton.textContent = toggleText(collapseButton.textContent, "Показать", "Скрыть")
})
document.querySelector(`table tr:first-child th`).append(collapseButton)
addStylesToHead(styles)
}
function addCommonStyles() {
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 {
margin-bottom: 0;
}
`)
}
/* REDIRECTS */ /* REDIRECTS */
@ -1890,7 +1897,7 @@
/* HEAD */ /* HEAD */
addStylesToHead(styles) addCommonStyles()
/* SWITCH FOR DIFFERENT PAGES */ /* SWITCH FOR DIFFERENT PAGES */