Adjust ban script to work when unbanning

This commit is contained in:
Karina Kwiatek 2021-12-30 21:56:03 +01:00
parent 374da66cd1
commit b196cbdd1c
1 changed files with 15 additions and 14 deletions

View File

@ -6,18 +6,19 @@ load = ->
banCheckbox = modalForm.querySelector('[name="ban"][type="checkbox"]') banCheckbox = modalForm.querySelector('[name="ban"][type="checkbox"]')
permabanCheckbox = modalForm.querySelector('[name="permaban"][type="checkbox"]') permabanCheckbox = modalForm.querySelector('[name="permaban"][type="checkbox"]')
banCheckbox.addEventListener "change", (event) -> if banCheckbox
$t = $ this banCheckbox.addEventListener "change", (event) ->
if $t.is(":checked") $t = $ this
$("#ban-controls").show() if $t.is(":checked")
else $("#ban-controls").show()
$("#ban-controls").hide() else
permabanCheckbox.addEventListener "change", (event) -> $("#ban-controls").hide()
$t = $ this permabanCheckbox.addEventListener "change", (event) ->
if $t.is(":checked") $t = $ this
$("#ban-controls-time").hide() if $t.is(":checked")
else $("#ban-controls-time").hide()
$("#ban-controls-time").show() else
$("#ban-controls-time").show()
modalForm.addEventListener "submit", (event) -> modalForm.addEventListener "submit", (event) ->
event.preventDefault(); event.preventDefault();
@ -29,11 +30,11 @@ load = ->
"0" "0"
data = { data = {
ban: checktostr banCheckbox ban: banCheckbox ? checktostr banCheckbox : false
user: modalForm.elements["user"].value user: modalForm.elements["user"].value
} }
if banCheckbox.checked if banCheckbox && banCheckbox.checked
data.reason = modalForm.elements["reason"].value.trim() data.reason = modalForm.elements["reason"].value.trim()
unless permabanCheckbox.checked unless permabanCheckbox.checked
data.duration = modalForm.elements["duration"].value.trim() data.duration = modalForm.elements["duration"].value.trim()