make function local
This commit is contained in:
parent
cf7a722429
commit
3958a610f9
304
main.js
304
main.js
@ -1859,53 +1859,57 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function changeColumnWidthForRouteBuildPage() {
|
|
||||||
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)
|
|
||||||
}
|
|
||||||
|
|
||||||
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 useColspanForFinishWarning() {
|
|
||||||
let rows = [...document.querySelectorAll(`#content > form > table > tbody > tr:nth-child(3) tr`)]
|
|
||||||
let finishRow = rows.find(el => el.querySelector(`td`)?.textContent.trim() == "Финиш маршрута")
|
|
||||||
|
|
||||||
finishRow.querySelectorAll(`td:not(:nth-child(2))`).forEach(el => el.remove())
|
|
||||||
finishRow.querySelector(`td`).colSpan = 4
|
|
||||||
}
|
|
||||||
|
|
||||||
function prettifyRouteBuildPage() {
|
function prettifyRouteBuildPage() {
|
||||||
changeColumnWidthForRouteBuildPage()
|
function changeColumnWidth() {
|
||||||
hideDescriptionFromRouteBuildPage()
|
let styles = `
|
||||||
hideStartRowFromRouteBuildPage()
|
#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)
|
||||||
|
}
|
||||||
|
|
||||||
|
function hideDescription() {
|
||||||
|
document.querySelectorAll(`#content > form > table > tbody > tr:is(:nth-child(3), :nth-child(6)) `).forEach(el => el.remove())
|
||||||
|
}
|
||||||
|
|
||||||
|
function hideStartRow() {
|
||||||
|
document.querySelector(`#content table table tr:nth-child(2) `).remove()
|
||||||
|
}
|
||||||
|
|
||||||
|
function getRows() {
|
||||||
|
return [...document.querySelectorAll(`#content > form > table > tbody > tr:nth-child(3) tr`)]
|
||||||
|
}
|
||||||
|
|
||||||
|
function useColspanForFinishWarning() {
|
||||||
|
let rows = getRows()
|
||||||
|
let finishRow = rows.find(el => el.querySelector(`td`)?.textContent.trim() == "Финиш маршрута")
|
||||||
|
|
||||||
|
finishRow.querySelectorAll(`td:not(:nth-child(2))`).forEach(el => el.remove())
|
||||||
|
finishRow.querySelector(`td`).colSpan = 4
|
||||||
|
}
|
||||||
|
|
||||||
|
changeColumnWidth()
|
||||||
|
hideDescription()
|
||||||
|
hideStartRow()
|
||||||
useColspanForFinishWarning()
|
useColspanForFinishWarning()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1924,111 +1928,111 @@
|
|||||||
document.querySelector(`${select} option:last-child`).scrollIntoView()
|
document.querySelector(`${select} option:last-child`).scrollIntoView()
|
||||||
}
|
}
|
||||||
|
|
||||||
function createPointsInpitForRouteEditPage() {
|
|
||||||
let addPointsContainer = document.createElement("div")
|
|
||||||
|
|
||||||
let pointInput = document.createElement("input")
|
|
||||||
pointInput.id = "add-point"
|
|
||||||
pointInput.type = "text"
|
|
||||||
pointInput.addEventListener("focus", () => {
|
|
||||||
pointInput.classList.remove("success", "error")
|
|
||||||
})
|
|
||||||
|
|
||||||
let addButton = document.createElement("button")
|
|
||||||
addButton.type = "button"
|
|
||||||
addButton.textContent = "Добавить"
|
|
||||||
addButton.id = "add-button"
|
|
||||||
addButton.addEventListener("click", () => {
|
|
||||||
let point = pointInput.value
|
|
||||||
if (point == "") return
|
|
||||||
|
|
||||||
let availablePoints = matchNumberFromSelect("#cps_avail")
|
|
||||||
let addedPoints = matchNumberFromSelect("#cps_in")
|
|
||||||
|
|
||||||
if (point in addedPoints) {
|
|
||||||
alert("Точка уже добавлена")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(point in availablePoints)) {
|
|
||||||
alert("Точка не найдена")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
unselectAll("#cps_avail")
|
|
||||||
let option = document.querySelector(`#cps_avail option[value="${availablePoints[point]}"]`)
|
|
||||||
option.selected = true
|
|
||||||
document.querySelector(`#cps_add`).click()
|
|
||||||
pointInput.classList.add("success")
|
|
||||||
pointInput.value = ""
|
|
||||||
option.selected = false
|
|
||||||
scrollSelectToBottom("#cps_in")
|
|
||||||
})
|
|
||||||
|
|
||||||
let removeButton = document.createElement("button")
|
|
||||||
removeButton.type = "button"
|
|
||||||
removeButton.textContent = "Убрать"
|
|
||||||
removeButton.addEventListener("click", () => {
|
|
||||||
let point = pointInput.value
|
|
||||||
if (point == "") return
|
|
||||||
|
|
||||||
let addedPoints = matchNumberFromSelect("#cps_in")
|
|
||||||
|
|
||||||
if (!(point in addedPoints)) return
|
|
||||||
|
|
||||||
unselectAll("#cps_in")
|
|
||||||
let option = document.querySelector(`#cps_in option[value="${addedPoints[point]}"]`)
|
|
||||||
option.selected = true
|
|
||||||
document.querySelector(`#cps_delete`).click()
|
|
||||||
pointInput.classList.add("error")
|
|
||||||
pointInput.value = ""
|
|
||||||
option.selected = false
|
|
||||||
scrollSelectToBottom("#cps_in")
|
|
||||||
})
|
|
||||||
|
|
||||||
addPointsContainer.append(addButton)
|
|
||||||
addPointsContainer.append(pointInput)
|
|
||||||
addPointsContainer.append(removeButton)
|
|
||||||
|
|
||||||
document.querySelector("table tr:nth-child(16) td").prepend(addPointsContainer)
|
|
||||||
|
|
||||||
addStylesToHead(`
|
|
||||||
#cps_in, #cps_avail {
|
|
||||||
height: 15em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.success {
|
|
||||||
border-color: green;
|
|
||||||
}
|
|
||||||
|
|
||||||
.error {
|
|
||||||
border-color: red;
|
|
||||||
}
|
|
||||||
|
|
||||||
#add-point {
|
|
||||||
width: 5em;
|
|
||||||
}
|
|
||||||
|
|
||||||
#add-button {
|
|
||||||
margin-left: 420px;
|
|
||||||
}
|
|
||||||
`)
|
|
||||||
}
|
|
||||||
|
|
||||||
function makeTextareasOneRowInRouteEditPage() {
|
|
||||||
document.querySelectorAll(`textarea:is([name="track[comment_int]"], [name="track[comment_ext]"])`).forEach(el => {
|
|
||||||
el.rows = 1
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
function hideRedundantRowsInRouteEditPage() {
|
|
||||||
document.querySelectorAll(`table tr:is(:nth-child(3), :nth-child(4), :nth-child(5))`).forEach(el => el.classList.add("hidden"))
|
|
||||||
}
|
|
||||||
|
|
||||||
function prettifyRouteEditPage() {
|
function prettifyRouteEditPage() {
|
||||||
makeTextareasOneRowInRouteEditPage()
|
function createPointsInpit() {
|
||||||
hideRedundantRowsInRouteEditPage()
|
let addPointsContainer = document.createElement("div")
|
||||||
createPointsInpitForRouteEditPage()
|
|
||||||
|
let pointInput = document.createElement("input")
|
||||||
|
pointInput.id = "add-point"
|
||||||
|
pointInput.type = "text"
|
||||||
|
pointInput.addEventListener("focus", () => {
|
||||||
|
pointInput.classList.remove("success", "error")
|
||||||
|
})
|
||||||
|
|
||||||
|
let addButton = document.createElement("button")
|
||||||
|
addButton.type = "button"
|
||||||
|
addButton.textContent = "Добавить"
|
||||||
|
addButton.id = "add-button"
|
||||||
|
addButton.addEventListener("click", () => {
|
||||||
|
let point = pointInput.value
|
||||||
|
if (point == "") return
|
||||||
|
|
||||||
|
let availablePoints = matchNumberFromSelect("#cps_avail")
|
||||||
|
let addedPoints = matchNumberFromSelect("#cps_in")
|
||||||
|
|
||||||
|
if (point in addedPoints) {
|
||||||
|
alert("Точка уже добавлена")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(point in availablePoints)) {
|
||||||
|
alert("Точка не найдена")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
unselectAll("#cps_avail")
|
||||||
|
let option = document.querySelector(`#cps_avail option[value="${availablePoints[point]}"]`)
|
||||||
|
option.selected = true
|
||||||
|
document.querySelector(`#cps_add`).click()
|
||||||
|
pointInput.classList.add("success")
|
||||||
|
pointInput.value = ""
|
||||||
|
option.selected = false
|
||||||
|
scrollSelectToBottom("#cps_in")
|
||||||
|
})
|
||||||
|
|
||||||
|
let removeButton = document.createElement("button")
|
||||||
|
removeButton.type = "button"
|
||||||
|
removeButton.textContent = "Убрать"
|
||||||
|
removeButton.addEventListener("click", () => {
|
||||||
|
let point = pointInput.value
|
||||||
|
if (point == "") return
|
||||||
|
|
||||||
|
let addedPoints = matchNumberFromSelect("#cps_in")
|
||||||
|
|
||||||
|
if (!(point in addedPoints)) return
|
||||||
|
|
||||||
|
unselectAll("#cps_in")
|
||||||
|
let option = document.querySelector(`#cps_in option[value="${addedPoints[point]}"]`)
|
||||||
|
option.selected = true
|
||||||
|
document.querySelector(`#cps_delete`).click()
|
||||||
|
pointInput.classList.add("error")
|
||||||
|
pointInput.value = ""
|
||||||
|
option.selected = false
|
||||||
|
scrollSelectToBottom("#cps_in")
|
||||||
|
})
|
||||||
|
|
||||||
|
addPointsContainer.append(addButton)
|
||||||
|
addPointsContainer.append(pointInput)
|
||||||
|
addPointsContainer.append(removeButton)
|
||||||
|
|
||||||
|
document.querySelector("table tr:nth-child(16) td").prepend(addPointsContainer)
|
||||||
|
|
||||||
|
addStylesToHead(`
|
||||||
|
#cps_in, #cps_avail {
|
||||||
|
height: 15em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.success {
|
||||||
|
border-color: green;
|
||||||
|
}
|
||||||
|
|
||||||
|
.error {
|
||||||
|
border-color: red;
|
||||||
|
}
|
||||||
|
|
||||||
|
#add-point {
|
||||||
|
width: 5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
#add-button {
|
||||||
|
margin-left: 420px;
|
||||||
|
}
|
||||||
|
`)
|
||||||
|
}
|
||||||
|
|
||||||
|
function makeTextareasOneRow() {
|
||||||
|
document.querySelectorAll(`textarea:is([name="track[comment_int]"], [name="track[comment_ext]"])`).forEach(el => {
|
||||||
|
el.rows = 1
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function hideRedundantRows() {
|
||||||
|
document.querySelectorAll(`table tr:is(:nth-child(3), :nth-child(4), :nth-child(5))`).forEach(el => el.classList.add("hidden"))
|
||||||
|
}
|
||||||
|
|
||||||
|
makeTextareasOneRow()
|
||||||
|
hideRedundantRows()
|
||||||
|
createPointsInpit()
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleStagePageRows(rows) {
|
function toggleStagePageRows(rows) {
|
||||||
|
Loading…
Reference in New Issue
Block a user