refactor
This commit is contained in:
parent
358d7659b8
commit
22db8f4575
458
main.js
458
main.js
@ -94,11 +94,14 @@
|
||||
}
|
||||
}
|
||||
else if (name == "classes") {
|
||||
element.classList.add(value.split(" "))
|
||||
element.classList.add(...value.split(" "))
|
||||
}
|
||||
else if (name == "children") {
|
||||
element.append(...value)
|
||||
}
|
||||
else if (name.startsWith("_")) {
|
||||
element.setAttribute(name.substring(1), value)
|
||||
}
|
||||
else
|
||||
element[name] = value
|
||||
}
|
||||
@ -182,7 +185,7 @@
|
||||
let prop = new Property()
|
||||
div = prop.toDiv(options.name)
|
||||
}
|
||||
container.appendChild(div)
|
||||
container.append(div)
|
||||
}
|
||||
|
||||
return container
|
||||
@ -202,19 +205,19 @@
|
||||
let css = document.createElement("link")
|
||||
css.href = link
|
||||
css.rel = "stylesheet"
|
||||
document.head.appendChild(css)
|
||||
document.head.append(css)
|
||||
}
|
||||
|
||||
function addJs(link) {
|
||||
let script = document.createElement("script")
|
||||
script.src = link
|
||||
document.head.appendChild(script)
|
||||
document.head.append(script)
|
||||
}
|
||||
|
||||
function addStylesToHead(styles) {
|
||||
let styleSheet = document.createElement("style")
|
||||
styleSheet.textContent = styles
|
||||
document.head.appendChild(styleSheet)
|
||||
document.head.append(styleSheet)
|
||||
}
|
||||
|
||||
const sleep = ms => new Promise(res => setTimeout(res, ms))
|
||||
@ -304,8 +307,10 @@
|
||||
}
|
||||
|
||||
function copyCoordinates() {
|
||||
let copyButton = document.createElement("button")
|
||||
copyButton.addEventListener("click", async event => {
|
||||
let copyButton = Tag.button({
|
||||
classes: "copy-button",
|
||||
on: {
|
||||
click: async event => {
|
||||
event.preventDefault()
|
||||
let lat = document.querySelector(`input[name="cp[lattitude]"]`).value
|
||||
let lon = document.querySelector(`input[name="cp[longitude]"]`).value
|
||||
@ -313,12 +318,13 @@
|
||||
const text = new Blob([`${lat}, ${lon}`], { type: "text/plain" })
|
||||
const data = new ClipboardItem({ "text/plain": text })
|
||||
await navigator.clipboard.write([data])
|
||||
}
|
||||
}
|
||||
})
|
||||
copyButton.classList.add("copy-button")
|
||||
|
||||
let copyImage = document.createElement("img")
|
||||
copyImage.src = "https://upload.wikimedia.org/wikipedia/commons/a/aa/Bw_copy_icon_320x320.svg"
|
||||
copyButton.appendChild(copyImage)
|
||||
copyButton.append(copyImage)
|
||||
|
||||
return copyButton
|
||||
}
|
||||
@ -352,7 +358,7 @@
|
||||
let icon = document.createElement("img")
|
||||
icon.src = iconSrc
|
||||
icon.classList.add("map-icon")
|
||||
ref.appendChild(icon)
|
||||
ref.append(icon)
|
||||
|
||||
return ref
|
||||
}
|
||||
@ -365,11 +371,11 @@
|
||||
|
||||
let linksContainer = document.createElement("div")
|
||||
|
||||
linksContainer.appendChild(copyCoordinates())
|
||||
linksContainer.appendChild(makeRef(yandexMaps, "https://upload.wikimedia.org/wikipedia/commons/7/72/Yandex_Maps_icon.svg", ZOOM))
|
||||
linksContainer.appendChild(makeRef(googleMaps, "https://upload.wikimedia.org/wikipedia/commons/a/aa/Google_Maps_icon_%282020%29.svg", METERS))
|
||||
linksContainer.appendChild(makeRef(pastvu, "https://pastvu.com/coast-icon.png", ZOOM))
|
||||
linksContainer.appendChild(makeRef(twoGis, "https://d-assets.2gis.ru/favicon.png", ZOOM))
|
||||
linksContainer.append(copyCoordinates())
|
||||
linksContainer.append(makeRef(yandexMaps, "https://upload.wikimedia.org/wikipedia/commons/7/72/Yandex_Maps_icon.svg", ZOOM))
|
||||
linksContainer.append(makeRef(googleMaps, "https://upload.wikimedia.org/wikipedia/commons/a/aa/Google_Maps_icon_%282020%29.svg", METERS))
|
||||
linksContainer.append(makeRef(pastvu, "https://pastvu.com/coast-icon.png", ZOOM))
|
||||
linksContainer.append(makeRef(twoGis, "https://d-assets.2gis.ru/favicon.png", ZOOM))
|
||||
|
||||
document.querySelector(`div:has(> div > input[name="cp[longitude]"])`).after(linksContainer)
|
||||
}
|
||||
@ -425,7 +431,7 @@
|
||||
if (fileListContainer == null) {
|
||||
fileListContainer = document.createElement("div")
|
||||
fileListContainer.classList.add("file-list-container")
|
||||
filesContainer.appendChild(fileListContainer)
|
||||
filesContainer.append(fileListContainer)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -460,13 +466,14 @@
|
||||
let fileButtonsContainer = document.createElement("div")
|
||||
fileButtonsContainer.classList.add("file-buttons-container")
|
||||
|
||||
fileButtonsContainer.appendChild(makeDownloadLink(/[^/]*$/.exec(new URL(file).pathname)[0], file))
|
||||
fileButtonsContainer.append(makeDownloadLink(/[^/]*$/.exec(new URL(file).pathname)[0], file))
|
||||
|
||||
let deleteButton = document.createElement("button")
|
||||
deleteButton.type = "button"
|
||||
deleteButton.classList.add("button-delete")
|
||||
deleteButton.textContent = "x"
|
||||
deleteButton.addEventListener("click", async e => {
|
||||
let deleteButton = Tag.button({
|
||||
type: "button",
|
||||
classes: "button-delete",
|
||||
textContent: "x",
|
||||
on: {
|
||||
click: async e => {
|
||||
if (!confirm("Точно?")) return
|
||||
|
||||
await fetch(removeLink)
|
||||
@ -474,13 +481,16 @@
|
||||
removedFilesLinks.push(removeLink)
|
||||
|
||||
fileListContainer.removeChild(fileContainer)
|
||||
}
|
||||
}
|
||||
})
|
||||
fileButtonsContainer.appendChild(deleteButton)
|
||||
|
||||
fileContainer.appendChild(displayedFile)
|
||||
fileContainer.appendChild(fileButtonsContainer)
|
||||
fileButtonsContainer.append(deleteButton)
|
||||
|
||||
fileListContainer.appendChild(fileContainer)
|
||||
fileContainer.append(displayedFile)
|
||||
fileContainer.append(fileButtonsContainer)
|
||||
|
||||
fileListContainer.append(fileContainer)
|
||||
}
|
||||
|
||||
function dataURLtoFile(dataurl, filename) {
|
||||
@ -571,13 +581,14 @@
|
||||
fileButtonsContainer.classList.add("file-buttons-container")
|
||||
|
||||
let downloadLink = makeDownloadLink(file.name)
|
||||
fileButtonsContainer.appendChild(downloadLink)
|
||||
fileButtonsContainer.append(downloadLink)
|
||||
|
||||
let deleteButton = document.createElement("button")
|
||||
deleteButton.classList.add("button-delete")
|
||||
deleteButton.textContent = "x"
|
||||
deleteButton.type = "button"
|
||||
deleteButton.addEventListener("click", e => {
|
||||
let deleteButton = Tag.button({
|
||||
classes: "button-delete",
|
||||
textContent: "x",
|
||||
type: "button",
|
||||
on: {
|
||||
click: e => {
|
||||
let index = [...fileContainer.parentElement.children].indexOf(fileContainer)
|
||||
|
||||
if (!confirm("Точно?")) return
|
||||
@ -592,13 +603,16 @@
|
||||
this.files = rdt.files
|
||||
|
||||
fileContainer.parentElement.removeChild(fileContainer)
|
||||
}
|
||||
}
|
||||
})
|
||||
fileButtonsContainer.appendChild(deleteButton)
|
||||
|
||||
fileContainer.appendChild(displayedFile)
|
||||
fileContainer.appendChild(fileButtonsContainer)
|
||||
fileButtonsContainer.append(deleteButton)
|
||||
|
||||
fileListContainer.appendChild(fileContainer)
|
||||
fileContainer.append(displayedFile)
|
||||
fileContainer.append(fileButtonsContainer)
|
||||
|
||||
fileListContainer.append(fileContainer)
|
||||
|
||||
const reader = new FileReader()
|
||||
reader.onload = (e) => {
|
||||
@ -624,15 +638,17 @@
|
||||
element.id = `input-file-${index}`
|
||||
element.setAttribute("multiple", "multiple")
|
||||
element.dataset.index = index
|
||||
let pseudoInput = document.createElement("label")
|
||||
pseudoInput.classList.add("custom-file-upload")
|
||||
pseudoInput.setAttribute("for", element.id)
|
||||
pseudoInput.textContent = "+"
|
||||
let pseudoInput = Tag.make("label", {
|
||||
classes: "custom-file-upload",
|
||||
_for: element.id,
|
||||
textContent: "+"
|
||||
})
|
||||
element.parentElement.insertBefore(pseudoInput, element)
|
||||
|
||||
let fileListContainer = document.createElement("div")
|
||||
fileListContainer.classList.add("file-list-container")
|
||||
element.parentElement.parentElement.appendChild(fileListContainer)
|
||||
let fileListContainer = Tag.div({
|
||||
classes: "file-list-container"
|
||||
})
|
||||
element.parentElement.parentElement.append(fileListContainer)
|
||||
|
||||
element.addEventListener("change", makeHandleFilesFunc(), false)
|
||||
})
|
||||
@ -721,7 +737,7 @@
|
||||
let [from, to] = getContainersByVariant(this.value, attachmentIndex)
|
||||
let newFiles = [...from.querySelectorAll(`.file-container-new`)]
|
||||
for (const newFile of newFiles) {
|
||||
to.querySelector(`.file-list-container`).appendChild(newFile)
|
||||
to.querySelector(`.file-list-container`).append(newFile)
|
||||
}
|
||||
}))
|
||||
}
|
||||
@ -734,7 +750,7 @@
|
||||
function moveInputValues(form, was, became) {
|
||||
let inputValues = saveInputValues(was)
|
||||
form.removeChild(was)
|
||||
form.appendChild(became)
|
||||
form.append(became)
|
||||
setInputValues(became, inputValues)
|
||||
createSendButtons()
|
||||
}
|
||||
@ -757,19 +773,23 @@
|
||||
}
|
||||
|
||||
function createAlwaysPrettifyInput(index) {
|
||||
let alwaysPrettify = document.createElement("div")
|
||||
alwaysPrettify.classList.add("always-prettify-container")
|
||||
let alwaysPrettify = Tag.div({
|
||||
classes: "always-prettify-container"
|
||||
})
|
||||
|
||||
let alwaysPrettifyLabel = document.createElement("label")
|
||||
alwaysPrettifyLabel.setAttribute("for", "always-prettify-" + index)
|
||||
alwaysPrettifyLabel.textContent = "Всегда"
|
||||
alwaysPrettify.appendChild(alwaysPrettifyLabel)
|
||||
let alwaysPrettifyLabel = Tag.make("label", {
|
||||
_for: "always-prettify-" + index,
|
||||
textContent: "Всегда"
|
||||
})
|
||||
|
||||
let alwaysPrettifyCheckbox = document.createElement("input")
|
||||
alwaysPrettifyCheckbox.type = "checkbox"
|
||||
alwaysPrettifyCheckbox.id = "always-prettify-" + index
|
||||
alwaysPrettifyCheckbox.name = "always-prettify-" + index
|
||||
alwaysPrettifyCheckbox.addEventListener("change", function () {
|
||||
alwaysPrettify.append(alwaysPrettifyLabel)
|
||||
|
||||
let alwaysPrettifyCheckbox = Tag.input({
|
||||
type: "checkbox",
|
||||
id: "always-prettify-" + index,
|
||||
name: "always-prettify-" + index,
|
||||
on: {
|
||||
change: function () {
|
||||
let otherCheckboxes = document.querySelectorAll(`input[name^="always-prettify-"]`)
|
||||
for (let checkbox of otherCheckboxes) {
|
||||
if (checkbox.id !== this.id) {
|
||||
@ -780,9 +800,11 @@
|
||||
localStorage.removeItem(localStorageItems.NOT_PRETTIFY_EDIT_CP)
|
||||
else
|
||||
localStorage.setItem(localStorageItems.NOT_PRETTIFY_EDIT_CP, "+")
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
alwaysPrettify.appendChild(alwaysPrettifyCheckbox)
|
||||
alwaysPrettify.append(alwaysPrettifyCheckbox)
|
||||
|
||||
return alwaysPrettify
|
||||
}
|
||||
@ -830,27 +852,27 @@
|
||||
downloadLink.href = file.dataset.origin
|
||||
downloadLink.text = "Скачать"
|
||||
downloadLink.setAttribute("target", "_blank")
|
||||
swiperSlide.appendChild(downloadLink)
|
||||
swiperSlide.append(downloadLink)
|
||||
|
||||
let swiperFile = file.cloneNode(true)
|
||||
if (swiperFile.dataset.origin)
|
||||
swiperFile.src = swiperFile.dataset.origin
|
||||
|
||||
swiperSlide.appendChild(swiperFile)
|
||||
swiperWrapper.appendChild(swiperSlide)
|
||||
swiperSlide.append(swiperFile)
|
||||
swiperWrapper.append(swiperSlide)
|
||||
}
|
||||
|
||||
swiperDiv.appendChild(swiperWrapper)
|
||||
swiperDiv.append(swiperWrapper)
|
||||
|
||||
let prevButton = document.createElement("div")
|
||||
prevButton.classList.add("swiper-button-prev")
|
||||
swiperDiv.appendChild(prevButton)
|
||||
swiperDiv.append(prevButton)
|
||||
|
||||
let nextButton = document.createElement("div")
|
||||
nextButton.classList.add("swiper-button-next")
|
||||
swiperDiv.appendChild(nextButton)
|
||||
swiperDiv.append(nextButton)
|
||||
|
||||
dialog.appendChild(swiperDiv)
|
||||
dialog.append(swiperDiv)
|
||||
|
||||
new Swiper('.swiper', {
|
||||
initialSlide: files.findIndex(el => el.dataset.origin && el.dataset.origin === src || el.src === src),
|
||||
@ -924,11 +946,12 @@
|
||||
}
|
||||
|
||||
function createSaveAndNewButton() {
|
||||
let saveAndNewButton = document.createElement("button")
|
||||
saveAndNewButton.textContent = "+"
|
||||
saveAndNewButton.type = "button"
|
||||
saveAndNewButton.classList.add("safe-action")
|
||||
saveAndNewButton.addEventListener("click", () => {
|
||||
let saveAndNewButton = Tag.button({
|
||||
textContent: "+",
|
||||
type: "button",
|
||||
classes: "safe-action",
|
||||
on: {
|
||||
click: () => {
|
||||
sendForm(() => {
|
||||
let cpNumber = document.querySelector(`input[name="cp[number]"]`).value
|
||||
let lattitude = document.querySelector(`input[name="cp[lattitude]"]`).value
|
||||
@ -940,6 +963,8 @@
|
||||
|
||||
document.querySelector(`input[name="save_go"]`).click()
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
return saveAndNewButton
|
||||
@ -953,11 +978,12 @@
|
||||
let saveButtons = [...saveAndStayButtons, ...saveAndExitButtons]
|
||||
|
||||
for (let saveButton of saveButtons) {
|
||||
let pseudoSaveButton = document.createElement("button")
|
||||
pseudoSaveButton.type = "button"
|
||||
pseudoSaveButton.textContent = saveButton.value
|
||||
pseudoSaveButton.classList.add("safe-action", "pseudo-save")
|
||||
pseudoSaveButton.addEventListener("click", async () => await sendForm(() => {
|
||||
let pseudoSaveButton = Tag.button({
|
||||
type: "button",
|
||||
textContent: saveButton.value,
|
||||
classes: "safe-action pseudo-save",
|
||||
on: {
|
||||
click: async () => await sendForm(() => {
|
||||
if (document.querySelector(`input[name="cp[id]"]`).value != '') {
|
||||
saveButton.click()
|
||||
return
|
||||
@ -968,7 +994,9 @@
|
||||
}
|
||||
|
||||
saveAndStayButtons[0].click()
|
||||
}))
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
saveButton.style.display = "none"
|
||||
saveButton.parentElement.insertBefore(pseudoSaveButton, saveButton)
|
||||
@ -1047,8 +1075,8 @@
|
||||
link.setAttribute("target", "_blank")
|
||||
}
|
||||
|
||||
menuItem.appendChild(link)
|
||||
menu.appendChild(menuItem)
|
||||
menuItem.append(link)
|
||||
menu.append(menuItem)
|
||||
}
|
||||
|
||||
return menu
|
||||
@ -1148,7 +1176,7 @@
|
||||
function addClearBoth() {
|
||||
let clearEl = document.createElement("div")
|
||||
clearEl.style.clear = "both"
|
||||
document.body.appendChild(clearEl)
|
||||
document.body.append(clearEl)
|
||||
}
|
||||
|
||||
function hasMap() {
|
||||
@ -1251,13 +1279,16 @@
|
||||
|
||||
function bindDeleteButton() {
|
||||
let deleteButton = document.querySelector(`input[name="delete_go"]`)
|
||||
let pseudoDeleteButton = document.createElement("button")
|
||||
pseudoDeleteButton.type = "button"
|
||||
pseudoDeleteButton.textContent = deleteButton.value
|
||||
pseudoDeleteButton.classList.add("unsafe-action", "pseudo-save")
|
||||
pseudoDeleteButton.addEventListener("click", async () => {
|
||||
let pseudoDeleteButton = Tag.button({
|
||||
type: "button",
|
||||
textContent: deleteButton.value,
|
||||
classes: "unsafe-action pseudo-save",
|
||||
on: {
|
||||
click: async () => {
|
||||
await deletePoint()
|
||||
deleteButton.click()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
deleteButton.style.display = "none"
|
||||
@ -1276,33 +1307,39 @@
|
||||
rowContentWrapper.classList.add("buttons-row__content-wrapper")
|
||||
while ([...el.children].length > 0) {
|
||||
let child = el.firstChild
|
||||
rowContentWrapper.appendChild(child)
|
||||
rowContentWrapper.append(child)
|
||||
}
|
||||
|
||||
let prettifyButton = document.createElement("button")
|
||||
prettifyButton.type = "button"
|
||||
prettifyButton.textContent = "Сделать красиво"
|
||||
prettifyButton.addEventListener("click", () => {
|
||||
let prettifyButton = Tag.button({
|
||||
type: "button",
|
||||
textContent: "Сделать красиво",
|
||||
on: {
|
||||
click: () => {
|
||||
prettifyEditCpForm(form, oldTable, container, insertedFileRows)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
rowContentWrapper.appendChild(prettifyButton)
|
||||
rowContentWrapper.appendChild(createAlwaysPrettifyInput(index))
|
||||
rowContentWrapper.append(prettifyButton)
|
||||
rowContentWrapper.append(createAlwaysPrettifyInput(index))
|
||||
|
||||
el.appendChild(rowContentWrapper)
|
||||
el.append(rowContentWrapper)
|
||||
})
|
||||
|
||||
;[topButtonsContainer, bottomButtonsContainer].forEach((el, index) => {
|
||||
let unglifyButton = document.createElement("button")
|
||||
unglifyButton.type = "button"
|
||||
unglifyButton.textContent = "Сделать как было"
|
||||
unglifyButton.addEventListener("click", () => {
|
||||
let unglifyButton = Tag.button({
|
||||
type: "button",
|
||||
textContent: "Сделать как было",
|
||||
on: {
|
||||
"click": () => {
|
||||
uglifyEditCpForm(form, container, oldTable)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
let topRowContentWrapper = el.querySelector("div > div > div")
|
||||
topRowContentWrapper.appendChild(unglifyButton)
|
||||
topRowContentWrapper.appendChild(createAlwaysPrettifyInput(index))
|
||||
topRowContentWrapper.append(unglifyButton)
|
||||
topRowContentWrapper.append(createAlwaysPrettifyInput(index))
|
||||
})
|
||||
|
||||
return [topButtonsContainer, bottomButtonsContainer]
|
||||
@ -1332,8 +1369,9 @@
|
||||
}
|
||||
|
||||
function makeLegend(rows) {
|
||||
let legendContainer = document.createElement("div")
|
||||
legendContainer.classList.add("legend-container")
|
||||
let legendContainer = Tag.div({
|
||||
classes: "legend-container"
|
||||
})
|
||||
|
||||
/* LEGEND DESC */
|
||||
|
||||
@ -1349,7 +1387,7 @@
|
||||
let legendLang = document.createElement("div")
|
||||
legendLang.classList.add("legend-desc__lang")
|
||||
legendLang.textContent = LEGEND_RU_LABEL
|
||||
legendDescHeader.appendChild(legendLang)
|
||||
legendDescHeader.append(legendLang)
|
||||
|
||||
let legendEnSwitchContainer = createFrom(rows, "legend-switch-container", [
|
||||
{ index: 48 }
|
||||
@ -1359,16 +1397,20 @@
|
||||
show([legendEnDescContainer, legendEnHiddenDescContainer, legendRuSwitchContainer])
|
||||
legendLang.textContent = LEGEND_EN_LABEL
|
||||
})
|
||||
legendDescHeader.appendChild(legendEnSwitchContainer)
|
||||
let copyDescButton = document.createElement("button")
|
||||
copyDescButton.type = "button"
|
||||
copyDescButton.textContent = "Копировать"
|
||||
copyDescButton.addEventListener("click", () => {
|
||||
legendDescHeader.append(legendEnSwitchContainer)
|
||||
|
||||
let copyDescButton = Tag.button({
|
||||
type: "button",
|
||||
textContent: "Копировать",
|
||||
on: {
|
||||
click: () => {
|
||||
let ruInputs = [...container.querySelectorAll(":is(input, textarea)[name^=\"cp_strings\[ru\]\"]")]
|
||||
let enInputs = [...container.querySelectorAll(":is(input, textarea)[name^=\"cp_strings\[en\]\"]")]
|
||||
for (const [i, enInput] of enInputs.entries()) {
|
||||
enInput.value = ruInputs[i].value
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
let legendRuSwitchContainer = createFrom(rows, "legend-switch-container hidden", [
|
||||
@ -1379,9 +1421,9 @@
|
||||
show([legendRuDescContainer, legendRuHiddenDescContainer, legendEnSwitchContainer])
|
||||
legendLang.textContent = LEGEND_RU_LABEL
|
||||
})
|
||||
legendDescHeader.appendChild(legendRuSwitchContainer)
|
||||
legendDescHeader.append(legendRuSwitchContainer)
|
||||
|
||||
legendDescHeader.appendChild(copyDescButton)
|
||||
legendDescHeader.append(copyDescButton)
|
||||
|
||||
let legendRuDescContainer = createFrom(rows, "legend-desc", [
|
||||
{ index: 40, desc: "" },
|
||||
@ -1412,24 +1454,28 @@
|
||||
])
|
||||
|
||||
let hider = document.createElement("div")
|
||||
let hiderButton = document.createElement("button")
|
||||
hiderButton.classList.add("collapse-button")
|
||||
hiderButton.setAttribute("type", "button")
|
||||
hiderButton.addEventListener("click", event => {
|
||||
let hiderButton = Tag.button({
|
||||
classes: "collapse-button",
|
||||
type: "button",
|
||||
on: {
|
||||
click: event => {
|
||||
let container = document.querySelector('.legend-container')
|
||||
container.querySelectorAll(".legend-desc.collapsible").forEach(element => {
|
||||
element.classList.toggle("collapsed")
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
hider.appendChild(hiderButton)
|
||||
|
||||
legendDescContainer.appendChild(legendDescHeader)
|
||||
legendDescContainer.appendChild(legendRuDescContainer)
|
||||
legendDescContainer.appendChild(legendRuHiddenDescContainer)
|
||||
legendDescContainer.appendChild(legendEnDescContainer)
|
||||
legendDescContainer.appendChild(legendEnHiddenDescContainer)
|
||||
legendDescContainer.appendChild(hider)
|
||||
legendContainer.appendChild(legendDescContainer)
|
||||
hider.append(hiderButton)
|
||||
|
||||
legendDescContainer.append(legendDescHeader)
|
||||
legendDescContainer.append(legendRuDescContainer)
|
||||
legendDescContainer.append(legendRuHiddenDescContainer)
|
||||
legendDescContainer.append(legendEnDescContainer)
|
||||
legendDescContainer.append(legendEnHiddenDescContainer)
|
||||
legendDescContainer.append(hider)
|
||||
legendContainer.append(legendDescContainer)
|
||||
|
||||
return legendContainer
|
||||
}
|
||||
@ -1446,22 +1492,22 @@
|
||||
let imagesForLegendContainer = createFrom(rows, "files-container legend-photo-container", [
|
||||
{ index: 23, name: "Фото в легенде" }
|
||||
])
|
||||
legendFilesContainer.appendChild(imagesForLegendContainer)
|
||||
legendFilesContainer.append(imagesForLegendContainer)
|
||||
|
||||
let imagesForHistoryContainer = createFrom(rows, "files-container history-photo-container", [
|
||||
{ name: "Фото для ИС" }
|
||||
])
|
||||
legendFilesContainer.appendChild(imagesForHistoryContainer)
|
||||
legendFilesContainer.append(imagesForHistoryContainer)
|
||||
|
||||
let audioForLegendContainer = createFrom(rows, "files-container legend-files-container", [
|
||||
{ index: 27, name: "Файлы в легенде" }
|
||||
])
|
||||
legendFilesContainer.appendChild(audioForLegendContainer)
|
||||
legendFilesContainer.append(audioForLegendContainer)
|
||||
|
||||
let audioForHistoryContainer = createFrom(rows, "files-container history-files-container", [
|
||||
{ name: "Файлы для ИС" }
|
||||
])
|
||||
legendFilesContainer.appendChild(audioForHistoryContainer)
|
||||
legendFilesContainer.append(audioForHistoryContainer)
|
||||
|
||||
return legendFilesContainer
|
||||
}
|
||||
@ -1473,12 +1519,12 @@
|
||||
let imagesForAdminContainer = createFrom(rows, "files-container admin-photo-container", [
|
||||
{ index: 31, name: "Фото в админке" }
|
||||
])
|
||||
adminFilesContainer.appendChild(imagesForAdminContainer)
|
||||
adminFilesContainer.append(imagesForAdminContainer)
|
||||
|
||||
let audioForAdminContainer = createFrom(rows, "files-container admin-files-container", [
|
||||
{ index: 35, name: "Файлы в админке" }
|
||||
])
|
||||
adminFilesContainer.appendChild(audioForAdminContainer)
|
||||
adminFilesContainer.append(audioForAdminContainer)
|
||||
|
||||
return adminFilesContainer
|
||||
}
|
||||
@ -1493,7 +1539,7 @@
|
||||
function makeDialog() {
|
||||
let dialog = document.createElement("dialog")
|
||||
dialog.id = "dialog"
|
||||
document.body.appendChild(dialog)
|
||||
document.body.append(dialog)
|
||||
|
||||
dialog.addEventListener("click", e => {
|
||||
if (e.target == dialog) {
|
||||
@ -1511,19 +1557,23 @@
|
||||
let content = document.querySelector("#content")
|
||||
let contentWrapper = document.createElement("div")
|
||||
contentWrapper.id = "content-wrapper"
|
||||
contentWrapper.appendChild(document.querySelector("form"))
|
||||
contentWrapper.appendChild(document.querySelector("#map-wrapper"))
|
||||
content.appendChild(contentWrapper)
|
||||
contentWrapper.append(document.querySelector("form"))
|
||||
contentWrapper.append(document.querySelector("#map-wrapper"))
|
||||
content.append(contentWrapper)
|
||||
|
||||
let panToCenter = document.createElement("button")
|
||||
panToCenter.type = "button"
|
||||
panToCenter.textContent = "В центр"
|
||||
panToCenter.addEventListener("click", () => {
|
||||
let panToCenter = Tag.button({
|
||||
type: "button",
|
||||
textContent: "В центр",
|
||||
on: {
|
||||
click: () => {
|
||||
let lat = document.querySelector("input[name=\"cp\[lattitude\]\"").value
|
||||
let lon = document.querySelector("input[name=\"cp\[longitude\]\"").value
|
||||
map.setView(new L.LatLng(parseFloat(lat), parseFloat(lon)), 16)
|
||||
}
|
||||
}
|
||||
})
|
||||
document.querySelector("#map_controls").appendChild(panToCenter)
|
||||
|
||||
document.querySelector("#map_controls").append(panToCenter)
|
||||
}
|
||||
}
|
||||
|
||||
@ -1898,18 +1948,18 @@
|
||||
/* LEGEND */
|
||||
|
||||
let legendContainer = makeLegend(rows)
|
||||
legendContainer.appendChild(makeLegendFiles(rows))
|
||||
legendContainer.append(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)
|
||||
container.append(topButtonsContainer)
|
||||
container.append(headerContainer)
|
||||
container.append(makeTopOptions(rows))
|
||||
container.append(makeComment(rows))
|
||||
container.append(legendContainer)
|
||||
container.append(makeAdminFiles(rows))
|
||||
container.append(makeBottomOptions(rows))
|
||||
container.append(bottomButtonsContainer)
|
||||
|
||||
/* MAP */
|
||||
|
||||
@ -1998,9 +2048,10 @@
|
||||
}
|
||||
|
||||
function makeStatsSpan(text) {
|
||||
let statsSpan = document.createElement("span")
|
||||
statsSpan.textContent = text
|
||||
statsSpan.classList.add("stats")
|
||||
let statsSpan = Tag.span({
|
||||
textContent: text,
|
||||
classes: "stats"
|
||||
})
|
||||
|
||||
return statsSpan
|
||||
}
|
||||
@ -2067,18 +2118,22 @@
|
||||
function createPointsInpit() {
|
||||
let addPointsContainer = document.createElement("div")
|
||||
|
||||
let pointInput = document.createElement("input")
|
||||
pointInput.id = "add-point"
|
||||
pointInput.type = "text"
|
||||
pointInput.addEventListener("focus", () => {
|
||||
let pointInput = Tag.input({
|
||||
id: "add-point",
|
||||
type: "text",
|
||||
on: {
|
||||
focus: () => {
|
||||
pointInput.classList.remove("success", "error")
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
let addButton = document.createElement("button")
|
||||
addButton.type = "button"
|
||||
addButton.textContent = "Добавить"
|
||||
addButton.id = "add-button"
|
||||
addButton.addEventListener("click", () => {
|
||||
let addButton = Tag.button({
|
||||
type: "button",
|
||||
textContent: "Добавить",
|
||||
id: "add-button",
|
||||
on: {
|
||||
click: () => {
|
||||
let point = pointInput.value
|
||||
if (point == "") return
|
||||
|
||||
@ -2103,12 +2158,15 @@
|
||||
pointInput.value = ""
|
||||
option.selected = false
|
||||
scrollSelectToBottom("#cps_in")
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
let removeButton = document.createElement("button")
|
||||
removeButton.type = "button"
|
||||
removeButton.textContent = "Убрать"
|
||||
removeButton.addEventListener("click", () => {
|
||||
let removeButton = Tag.button({
|
||||
type: "button",
|
||||
textContent: "Убрать",
|
||||
on: {
|
||||
click: () => {
|
||||
let point = pointInput.value
|
||||
if (point == "") return
|
||||
|
||||
@ -2124,6 +2182,8 @@
|
||||
pointInput.value = ""
|
||||
option.selected = false
|
||||
scrollSelectToBottom("#cps_in")
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
addPointsContainer.append(addButton)
|
||||
@ -2191,16 +2251,19 @@
|
||||
`
|
||||
|
||||
let rows = [...document.querySelectorAll(`#content tbody tr`)]
|
||||
let collapseButton = document.createElement("button")
|
||||
collapseButton.type = "button"
|
||||
collapseButton.textContent = "Показать"
|
||||
toggleStagePageRows(rows)
|
||||
|
||||
collapseButton.addEventListener("click", () => {
|
||||
let collapseButton = Tag.button({
|
||||
type: "button",
|
||||
textContent: "Показать",
|
||||
on: {
|
||||
click: () => {
|
||||
toggleStagePageRows(rows)
|
||||
collapseButton.textContent = toggleText(collapseButton.textContent, "Показать", "Скрыть")
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
toggleStagePageRows(rows)
|
||||
|
||||
document.querySelector(`table tr:first-child th`).append(collapseButton)
|
||||
|
||||
addStylesToHead(styles)
|
||||
@ -2252,20 +2315,24 @@
|
||||
}
|
||||
|
||||
function addEnableButtons() {
|
||||
let enableButton = document.createElement("button")
|
||||
enableButton.type = "button"
|
||||
enableButton.id = "enable-button"
|
||||
enableButton.textContent = "Сделать красиво"
|
||||
if (!isPageDisabled()) {
|
||||
hide([enableButton])
|
||||
}
|
||||
enableButton.addEventListener("click", () => {
|
||||
let enableButton = Tag.button({
|
||||
type: "button",
|
||||
id: "enable-button",
|
||||
textContent: "Сделать красиво",
|
||||
on: {
|
||||
click: () => {
|
||||
if (pretty) return
|
||||
|
||||
hide([enableButton])
|
||||
prettify()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
if (!isPageDisabled()) {
|
||||
hide([enableButton])
|
||||
}
|
||||
|
||||
let header = document.querySelector("#header")
|
||||
header.insertBefore(enableButton, header.querySelector("#globalmenu"))
|
||||
header.insertBefore(createAlwaysEnable(), header.querySelector("#globalmenu"))
|
||||
@ -2282,11 +2349,12 @@
|
||||
}
|
||||
|
||||
function addDisableButton() {
|
||||
let disableButton = document.createElement("button")
|
||||
disableButton.id = "disable-button"
|
||||
disableButton.type = "button"
|
||||
disableButton.textContent = "Сделать как было"
|
||||
disableButton.addEventListener("click", () => {
|
||||
let disableButton = Tag.button({
|
||||
id: "disable-button",
|
||||
type: "button",
|
||||
textContent: "Сделать как было",
|
||||
on: {
|
||||
click: () => {
|
||||
if (!pretty) return
|
||||
|
||||
if (!confirm("Это действие отключит скрипт на этой странице и удалит все несохраненные данные")) return
|
||||
@ -2294,36 +2362,44 @@
|
||||
addDisabledPage()
|
||||
pretty = false
|
||||
location.reload()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
header.querySelector("#enable-button").after(disableButton)
|
||||
}
|
||||
|
||||
function createAlwaysEnable() {
|
||||
let alwaysEnableContainer = document.createElement("div")
|
||||
alwaysEnableContainer.id = "always-enable-container"
|
||||
let alwaysEnableContainer = Tag.div({
|
||||
id: "always-enable-container",
|
||||
children: [
|
||||
Tag.make("label", {
|
||||
_for: "always-enable",
|
||||
textContent: "Всегда красиво"
|
||||
})
|
||||
]
|
||||
})
|
||||
|
||||
let alwaysEnableLabel = document.createElement("label")
|
||||
alwaysEnableLabel.setAttribute("for", "always-enable")
|
||||
alwaysEnableLabel.textContent = "Всегда красиво"
|
||||
alwaysEnableContainer.appendChild(alwaysEnableLabel)
|
||||
|
||||
let alwaysEnableCheckbox = document.createElement("input")
|
||||
alwaysEnableCheckbox.type = "checkbox"
|
||||
alwaysEnableCheckbox.id = "always-enable"
|
||||
alwaysEnableCheckbox.name = "always-enable"
|
||||
alwaysEnableCheckbox.addEventListener("change", function () {
|
||||
let alwaysEnableCheckbox = Tag.input({
|
||||
type: "checkbox",
|
||||
id: "always-enable",
|
||||
name: "always-enable",
|
||||
on: {
|
||||
change: function () {
|
||||
if (this.checked)
|
||||
removeDisabledPage()
|
||||
else
|
||||
addDisabledPage()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
if (!isPageDisabled()) {
|
||||
alwaysEnableCheckbox.checked = true
|
||||
}
|
||||
|
||||
alwaysEnableContainer.appendChild(alwaysEnableCheckbox)
|
||||
alwaysEnableContainer.append(alwaysEnableCheckbox)
|
||||
|
||||
return alwaysEnableContainer
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user