refactor
This commit is contained in:
parent
0f8af9b014
commit
e963a3e179
63
main.js
63
main.js
@ -308,7 +308,7 @@
|
||||
return ref
|
||||
}
|
||||
|
||||
let makeCoordinatesLinks = (function() {
|
||||
let makeCoordinatesLinks = (function () {
|
||||
var executed = false
|
||||
return function () {
|
||||
if (executed) return
|
||||
@ -443,7 +443,7 @@
|
||||
while (n--) {
|
||||
u8arr[n] = bstr.charCodeAt(n)
|
||||
}
|
||||
return new File([u8arr], filename, {type:mime})
|
||||
return new File([u8arr], filename, { type: mime })
|
||||
}
|
||||
|
||||
function getHtmlElementByFileType(file) {
|
||||
@ -481,7 +481,7 @@
|
||||
function makeHandleFilesFunc() {
|
||||
let storedFiles = []
|
||||
|
||||
return function() {
|
||||
return function () {
|
||||
let dt = new DataTransfer()
|
||||
|
||||
if (storedFiles.length) {
|
||||
@ -556,7 +556,7 @@
|
||||
displayedFile.src = e.target.result
|
||||
downloadLink.setAttribute("href", displayedFile.src)
|
||||
|
||||
storedFiles.push({data: displayedFile.src, name: file.name})
|
||||
storedFiles.push({ data: displayedFile.src, name: file.name })
|
||||
}
|
||||
reader.readAsDataURL(file)
|
||||
}
|
||||
@ -565,9 +565,9 @@
|
||||
}
|
||||
}
|
||||
|
||||
let prettifyFiles = (function() {
|
||||
let prettifyFiles = (function () {
|
||||
var executed = false
|
||||
return function(insertedFileRows) {
|
||||
return function (insertedFileRows) {
|
||||
if (executed) return
|
||||
executed = true
|
||||
|
||||
@ -666,7 +666,7 @@
|
||||
}
|
||||
|
||||
function moveNewFilesOnVariantChange() {
|
||||
document.querySelectorAll(`input[name^="new_file_type"]`).forEach(el => el.addEventListener("change", function() {
|
||||
document.querySelectorAll(`input[name^="new_file_type"]`).forEach(el => el.addEventListener("change", function () {
|
||||
let attachmentIndex = getAttachmentIndex(this)
|
||||
|
||||
let [from, to] = getContainersByVariant(this.value, attachmentIndex)
|
||||
@ -720,7 +720,7 @@
|
||||
alwaysPrettifyCheckbox.type = "checkbox"
|
||||
alwaysPrettifyCheckbox.id = "always-prettify-" + index
|
||||
alwaysPrettifyCheckbox.name = "always-prettify-" + index
|
||||
alwaysPrettifyCheckbox.addEventListener("change", function() {
|
||||
alwaysPrettifyCheckbox.addEventListener("change", function () {
|
||||
let otherCheckboxes = document.querySelectorAll(`input[name^="always-prettify-"]`)
|
||||
for (let checkbox of otherCheckboxes) {
|
||||
if (checkbox.id !== this.id) {
|
||||
@ -816,16 +816,16 @@
|
||||
}
|
||||
|
||||
function bindArrowsForGallery(leftButtonQuery, rightButtonQuery) {
|
||||
document.addEventListener("keydown", function(e) {
|
||||
document.addEventListener("keydown", function (e) {
|
||||
if (!document.querySelector("dialog").open) return
|
||||
switch(e.key) {
|
||||
switch (e.key) {
|
||||
case "ArrowLeft":
|
||||
$(leftButtonQuery).click()
|
||||
break
|
||||
break
|
||||
|
||||
case "ArrowRight":
|
||||
$(rightButtonQuery).click()
|
||||
break
|
||||
break
|
||||
|
||||
default: return
|
||||
}
|
||||
@ -1835,7 +1835,7 @@
|
||||
}
|
||||
|
||||
function isAllPointsSouthOfLat(lat) {
|
||||
map.eachLayer(function(layer) {
|
||||
map.eachLayer(function (layer) {
|
||||
if (layer instanceof L.Marker) {
|
||||
let latLng = layer.getLatLng()
|
||||
if (latLng.lat > lat) {
|
||||
@ -1859,7 +1859,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
function prettifyRouteBuildPage() {
|
||||
function changeColumnWidthForRouteBuildPage() {
|
||||
let styles = `
|
||||
#content table table {
|
||||
td:nth-child(2) {
|
||||
@ -1884,11 +1884,22 @@
|
||||
}
|
||||
`
|
||||
addStylesToHead(styles)
|
||||
}
|
||||
|
||||
function hideDescriptionFromRouteBuildPage() {
|
||||
document.querySelectorAll(`#content > form > table > tbody > tr:is(:nth-child(3), :nth-child(6)) `).forEach(el => el.remove())
|
||||
}
|
||||
|
||||
function hideStartRowFromRouteBuildPage() {
|
||||
document.querySelector(`#content table table tr:nth-child(2) `).remove()
|
||||
}
|
||||
|
||||
function prettifyRouteBuildPage() {
|
||||
changeColumnWidthForRouteBuildPage()
|
||||
hideDescriptionFromRouteBuildPage()
|
||||
hideStartRowFromRouteBuildPage()
|
||||
}
|
||||
|
||||
function matchNumberFromSelect(select) {
|
||||
return [...document.querySelector(select).options].reduce(
|
||||
(res, el) => ({ ...res, [el.textContent.match(/(?<=^\s*#)\d+/g)?.[0]]: el.value }),
|
||||
@ -1904,13 +1915,7 @@
|
||||
document.querySelector(`${select} option:last-child`).scrollIntoView()
|
||||
}
|
||||
|
||||
function prettifyRouteEditPage() {
|
||||
document.querySelectorAll(`textarea:is([name="track[comment_int]"], [name="track[comment_ext]"])`).forEach(el => {
|
||||
el.rows = 1
|
||||
})
|
||||
|
||||
document.querySelectorAll(`table tr:is(:nth-child(3), :nth-child(4), :nth-child(5))`).forEach(el => el.classList.add("hidden"))
|
||||
|
||||
function createPointsInpitForRouteEditPage() {
|
||||
let addPointsContainer = document.createElement("div")
|
||||
|
||||
let pointInput = document.createElement("input")
|
||||
@ -2001,6 +2006,16 @@
|
||||
`)
|
||||
}
|
||||
|
||||
function prettifyRouteEditPage() {
|
||||
document.querySelectorAll(`textarea:is([name="track[comment_int]"], [name="track[comment_ext]"])`).forEach(el => {
|
||||
el.rows = 1
|
||||
})
|
||||
|
||||
document.querySelectorAll(`table tr:is(:nth-child(3), :nth-child(4), :nth-child(5))`).forEach(el => el.classList.add("hidden"))
|
||||
|
||||
createPointsInpitForRouteEditPage()
|
||||
}
|
||||
|
||||
function toggleStagePageRows(rows) {
|
||||
let showIndex = [0, 3]
|
||||
let to = rows.findIndex(el => el.querySelector("th")?.textContent.trim() == "Бонусы")
|
||||
@ -2011,7 +2026,7 @@
|
||||
toggleRows(rows, to, rows.length, 1, [])
|
||||
}
|
||||
|
||||
function prettifyRouteStagesPage() {
|
||||
function hideUselessRowsFromRouteStagesPage() {
|
||||
let styles = `
|
||||
tr.collapsed {
|
||||
display: block;
|
||||
@ -2143,7 +2158,7 @@
|
||||
alwaysEnableCheckbox.type = "checkbox"
|
||||
alwaysEnableCheckbox.id = "always-enable"
|
||||
alwaysEnableCheckbox.name = "always-enable"
|
||||
alwaysEnableCheckbox.addEventListener("change", function() {
|
||||
alwaysEnableCheckbox.addEventListener("change", function () {
|
||||
if (this.checked)
|
||||
removeDisabledPage()
|
||||
else
|
||||
@ -2190,7 +2205,7 @@
|
||||
}
|
||||
|
||||
if (isRouteStagesPage()) {
|
||||
prettifyRouteStagesPage()
|
||||
hideUselessRowsFromRouteStagesPage()
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user