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