Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0

Fix JS for torrent/user deletion that would delete even if you refused to confirm (#1711)

* Update torrentlist.jet.html

* Update index_admin.jet.html
Cette révision appartient à :
kilo 2017-11-04 07:23:10 +01:00 révisé par GitHub
Parent 357012932b
révision cc4e0fe5c0
Aucune clé n'a été trouvée pour cette signature dans la base de données
ID de la clé GPG: 4AEE18F83AFDEB23
2 fichiers modifiés avec 36 ajouts et 23 suppressions

Voir le fichier

@ -91,22 +91,29 @@
var deleteButtons = document.querySelectorAll("button.form-input.btn-red")
for(var i = 0; i < deleteButtons.length; i++) {
var needConfirmation = (deleteButtons[i].onclick != null)
deleteButtons[i].onclick = null
deleteButtons[i].addEventListener("click", function (e) {
e.preventDefault()
var form = this.parentNode
var formInputs = form.querySelectorAll('input')
var query = ""
if(needConfirmation && !confirm("Are you sure?")) {
return
} else if(!needConfirmation) {
var form = this.parentNode
var formInputs = form.querySelectorAll('input')
var query = ""
for(var x = 0; x < formInputs.length; x ++) {
if(query != "") query = query + "&"
query = query + formInputs[x].name + "=" + formInputs[x].value
}
for(var x = 0; x < formInputs.length; x ++) {
if(query != "") query = query + "&"
query = query + formInputs[x].name + "=" + formInputs[x].value
}
Query.Post(form.action, query, function(data) {})
Query.Post(form.action, query, function(data) {})
this.parentNode.parentNode.parentNode.className = this.parentNode.parentNode.className + " hidden"
this.innerText = "Deleted"
this.disabled = true
this.parentNode.parentNode.parentNode.className = this.parentNode.parentNode.className + " hidden"
this.innerText = "Deleted"
this.disabled = true
}
})
}

Voir le fichier

@ -23,24 +23,30 @@
{{block footer_js()}}
<script type="text/javascript">
var deleteButtons = document.querySelectorAll("button.form-input.btn-red")
for(var i = 0; i < deleteButtons.length; i++) {
var needConfirmation = (deleteButtons[i].onclick != null)
deleteButtons[i].onclick = null
deleteButtons[i].addEventListener("click", function (e) {
e.preventDefault()
var form = this.parentNode
var formInputs = form.querySelectorAll('input')
var query = ""
if(needConfirmation && !confirm("Are you sure?")) {
return
} else if(!needConfirmation) {
var form = this.parentNode
var formInputs = form.querySelectorAll('input')
var query = ""
for(var x = 0; x < formInputs.length; x ++) {
if(query != "") query = query + "&"
query = query + formInputs[x].name + "=" + formInputs[x].value
}
for(var x = 0; x < formInputs.length; x ++) {
if(query != "") query = query + "&"
query = query + formInputs[x].name + "=" + formInputs[x].value
}
Query.Post(form.action, query, function(data) {})
Query.Post(form.action, query, function(data) {})
this.parentNode.parentNode.parentNode.className = this.parentNode.parentNode.className + " hidden"
this.innerText = "Deleted"
this.disabled = true
this.parentNode.parentNode.parentNode.className = this.parentNode.parentNode.className + " hidden"
this.innerText = "Deleted"
this.disabled = true
}
})
}
</script>