remove global variable
This commit is contained in:
parent
49a3d4d493
commit
34780a741a
35
main.js
35
main.js
@ -86,8 +86,6 @@
|
||||
|
||||
const stageColors = ["#ff8080", "#ffc680", "#ffff80", "#80ff80", "#80ffff", "#8080ff", "#ff80ff"]
|
||||
|
||||
let removedFilesLinks = []
|
||||
|
||||
class Tag {
|
||||
static make(name, params = {}) {
|
||||
let element = document.createElement(name)
|
||||
@ -500,7 +498,7 @@
|
||||
return Object.keys(fileInpitVariants).find(key => fileInpitVariants[key] === parsePurpose(cell))
|
||||
}
|
||||
|
||||
function addDisplayedFile(inputName, type, file, preview, removeLink, variant = null) {
|
||||
function addDisplayedFile(inputName, type, file, preview, removeLink, removedFilesLinks, variant = null) {
|
||||
if (!inputName || !file || !removeLink) return
|
||||
|
||||
let fileListContainer
|
||||
@ -726,7 +724,7 @@
|
||||
|
||||
let prettifyFiles = (function () {
|
||||
let executed = false
|
||||
return function (insertedFileRows) {
|
||||
return function (insertedFileRows, removedFilesLinks) {
|
||||
if (executed) return
|
||||
executed = true
|
||||
|
||||
@ -746,7 +744,7 @@
|
||||
element.addEventListener("change", makeHandleFilesFunc(), false)
|
||||
})
|
||||
|
||||
moveFileInputValues(insertedFileRows)
|
||||
moveFileInputValues(insertedFileRows, removedFilesLinks)
|
||||
}
|
||||
})()
|
||||
|
||||
@ -780,7 +778,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
function moveFileInputValues(insertedFileRows) {
|
||||
function moveFileInputValues(insertedFileRows, removedFilesLinks) {
|
||||
for (const [inputRowIndex, rows] of insertedFileRows) {
|
||||
for (const row of rows) {
|
||||
let fileInput = null, type = null, fileUrl = null, deleteUrl = null, preview = null
|
||||
@ -818,7 +816,7 @@
|
||||
|
||||
let variant = parsefileInputVariant(row)
|
||||
|
||||
addDisplayedFile(fileInput, type, fileUrl, preview, deleteUrl, variant)
|
||||
addDisplayedFile(fileInput, type, fileUrl, preview, deleteUrl, removedFilesLinks, variant)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -848,21 +846,21 @@
|
||||
createSendButtons()
|
||||
}
|
||||
|
||||
function prettifyEditCpForm(form, was, became, insertedFileRows) {
|
||||
function prettifyEditCpForm(form, was, became, insertedFileRows, removedFilesLinks) {
|
||||
moveInputValues(form, was, became)
|
||||
prettifyFiles(insertedFileRows)
|
||||
prettifyFiles(insertedFileRows, removedFilesLinks)
|
||||
|
||||
moveNewFilesOnVariantChange()
|
||||
$("#cps_main").select2()
|
||||
makeCoordinatesLinks()
|
||||
}
|
||||
|
||||
function uglifyEditCpForm(form, was, became) {
|
||||
function uglifyEditCpForm(form, was, became, removedFilesLinks) {
|
||||
moveInputValues(form, was, became)
|
||||
for (const removedFileLink of removedFilesLinks) {
|
||||
removeDeletedFilesFromUglyVersion(removedFileLink)
|
||||
}
|
||||
removedFilesLinks = []
|
||||
removedFilesLinks.length = 0
|
||||
}
|
||||
|
||||
function createAlwaysPrettifyInput(index) {
|
||||
@ -1374,7 +1372,7 @@
|
||||
createPseudoButton(document.querySelector(`input[name="delete_go"]`), deletePoint)
|
||||
}
|
||||
|
||||
function makeTopAndBottomButtons(rows, form, oldTable, container, insertedFileRows) {
|
||||
function makeTopAndBottomButtons(rows, form, oldTable, container, insertedFileRows, removedFilesLinks) {
|
||||
let topButtonsContainer = createFrom(rows, "buttons", [
|
||||
{ index: 0 }
|
||||
])
|
||||
@ -1395,7 +1393,7 @@
|
||||
textContent: "Сделать красиво",
|
||||
on: {
|
||||
click: () => {
|
||||
prettifyEditCpForm(form, oldTable, container, insertedFileRows)
|
||||
prettifyEditCpForm(form, oldTable, container, insertedFileRows, removedFilesLinks)
|
||||
}
|
||||
}
|
||||
})
|
||||
@ -1412,7 +1410,7 @@
|
||||
textContent: "Сделать как было",
|
||||
on: {
|
||||
"click": () => {
|
||||
uglifyEditCpForm(form, container, oldTable)
|
||||
uglifyEditCpForm(form, container, oldTable, removedFilesLinks)
|
||||
}
|
||||
}
|
||||
})
|
||||
@ -1698,10 +1696,10 @@
|
||||
})()
|
||||
}
|
||||
|
||||
function checkIfAlwaysPrettify(form, oldTable, container, insertedFileRows) {
|
||||
function checkIfAlwaysPrettify(form, oldTable, container, insertedFileRows, removedFilesLinks) {
|
||||
if (localStorage.getItem(localStorageItems.NOT_PRETTIFY_EDIT_CP) === null) {
|
||||
document.querySelector(`input[name^="always-prettify-0"]`).click()
|
||||
prettifyEditCpForm(form, oldTable, container, insertedFileRows)
|
||||
prettifyEditCpForm(form, oldTable, container, insertedFileRows, removedFilesLinks)
|
||||
}
|
||||
}
|
||||
|
||||
@ -2051,6 +2049,7 @@
|
||||
let form = document.querySelector('form')
|
||||
let rows = getRows()
|
||||
let insertedFileRows = getInsertedFileRows(rows)
|
||||
let removedFilesLinks = []
|
||||
|
||||
let container = makeContainer()
|
||||
let oldTable = document.querySelector("#props")
|
||||
@ -2061,7 +2060,7 @@
|
||||
|
||||
/* TOP BUTTONS */
|
||||
|
||||
let [topButtonsContainer, bottomButtonsContainer] = makeTopAndBottomButtons(rows, form, oldTable, container, insertedFileRows)
|
||||
let [topButtonsContainer, bottomButtonsContainer] = makeTopAndBottomButtons(rows, form, oldTable, container, insertedFileRows, removedFilesLinks)
|
||||
|
||||
addUglyDeleteListener()
|
||||
createSendButtons()
|
||||
@ -2093,7 +2092,7 @@
|
||||
|
||||
/* PRETTIFY CHECKBOX */
|
||||
|
||||
checkIfAlwaysPrettify(form, oldTable, container, insertedFileRows)
|
||||
checkIfAlwaysPrettify(form, oldTable, container, insertedFileRows, removedFilesLinks)
|
||||
}
|
||||
|
||||
function isAllPointsSouthOfLat(lat) {
|
||||
|
Loading…
Reference in New Issue
Block a user