send data to laravel server
This commit is contained in:
parent
6d96ab38a9
commit
26f492b8f0
59
main.js
59
main.js
@ -444,10 +444,6 @@
|
|||||||
|
|
||||||
dialog.appendChild(swiperDiv)
|
dialog.appendChild(swiperDiv)
|
||||||
|
|
||||||
console.log(src)
|
|
||||||
console.log(files.map(it => it.src))
|
|
||||||
console.log(files.findIndex(el => el.dataset.origin && el.dataset.origin === src || el.src === src))
|
|
||||||
|
|
||||||
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),
|
||||||
|
|
||||||
@ -458,6 +454,52 @@
|
|||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function createSendButtons() {
|
||||||
|
let saveButtons = [...document.querySelectorAll("input[name=\"save_go\"]"), ...document.querySelectorAll("input[name=\"save_exit\"]")]
|
||||||
|
|
||||||
|
for (let saveButton of saveButtons) {
|
||||||
|
let pseudoSaveButton = document.createElement("button")
|
||||||
|
pseudoSaveButton.type = "button"
|
||||||
|
pseudoSaveButton.textContent = saveButton.value
|
||||||
|
pseudoSaveButton.classList.add("safe-action")
|
||||||
|
pseudoSaveButton.addEventListener("click", async () => {
|
||||||
|
let formData = new FormData(document.querySelector("form"))
|
||||||
|
|
||||||
|
let props = document.querySelectorAll("input[name^=\"prop_\"]");
|
||||||
|
for (let prop of props) {
|
||||||
|
let parent = prop.parentElement
|
||||||
|
let propName
|
||||||
|
|
||||||
|
if (parent.tagName === "DIV") {
|
||||||
|
propName = parent.parentElement.querySelector("label").textContent
|
||||||
|
}
|
||||||
|
else if (parent.tagName === "TD") {
|
||||||
|
propName = parent.parentElement.querySelector("td:first-child").textContent
|
||||||
|
}
|
||||||
|
|
||||||
|
formData.set(`propname[${prop.name}]`, propName)
|
||||||
|
}
|
||||||
|
|
||||||
|
let result = await fetch(`https://runcity.geo.rictum.ru/api/competitions/${window.location.pathname.split('/')[1]}/update`, {
|
||||||
|
method: 'POST',
|
||||||
|
body: formData
|
||||||
|
})
|
||||||
|
|
||||||
|
try {
|
||||||
|
console.log(result.ok)
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
console.log(e)
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
saveButton.click()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
saveButton.style.display = "none"
|
||||||
|
saveButton.parentElement.insertBefore(pseudoSaveButton, saveButton)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let styles = `
|
let styles = `
|
||||||
#content-wrapper {
|
#content-wrapper {
|
||||||
@ -813,8 +855,8 @@
|
|||||||
prettifyButton.addEventListener("click", () => {
|
prettifyButton.addEventListener("click", () => {
|
||||||
prettify(form, oldTable, container, insertedFileRows)
|
prettify(form, oldTable, container, insertedFileRows)
|
||||||
})
|
})
|
||||||
rowContentWrapper.appendChild(prettifyButton)
|
|
||||||
|
|
||||||
|
rowContentWrapper.appendChild(prettifyButton)
|
||||||
rowContentWrapper.appendChild(createAlwaysPrettifyInput(index))
|
rowContentWrapper.appendChild(createAlwaysPrettifyInput(index))
|
||||||
|
|
||||||
el.appendChild(rowContentWrapper)
|
el.appendChild(rowContentWrapper)
|
||||||
@ -827,11 +869,14 @@
|
|||||||
unglifyButton.addEventListener("click", () => {
|
unglifyButton.addEventListener("click", () => {
|
||||||
moveInputValues(form, container, oldTable)
|
moveInputValues(form, container, oldTable)
|
||||||
})
|
})
|
||||||
el.querySelector("div > div > div").appendChild(unglifyButton)
|
|
||||||
|
|
||||||
el.querySelector("div > div > div").appendChild(createAlwaysPrettifyInput(index))
|
let topRowContentWrapper = el.querySelector("div > div > div")
|
||||||
|
topRowContentWrapper.appendChild(unglifyButton)
|
||||||
|
topRowContentWrapper.appendChild(createAlwaysPrettifyInput(index))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
createSendButtons()
|
||||||
|
|
||||||
/* OPTIONS */
|
/* OPTIONS */
|
||||||
|
|
||||||
let firstContainer = createFrom(rows, "options", [
|
let firstContainer = createFrom(rows, "options", [
|
||||||
|
Loading…
Reference in New Issue
Block a user