MarseyWorld/files/assets/js/admin/punish_modal.js

36 lines
1.0 KiB
JavaScript
Raw Normal View History

function punishModal(t, kind, link, name, fullname) {
const kind_title = kind.charAt(0).toUpperCase() + kind.slice(1)
2023-05-05 21:45:25 +00:00
document.getElementById(`${kind}ModalTitle`).innerHTML = `${kind_title} @${name}`;
document.getElementById(`${kind}_reason`).value = link;
const btn = document.getElementById(`${kind}UserButton`)
btn.innerHTML = `${kind_title} @${name}`;
btn.onclick = () => {
const values = {
"days": document.getElementById(`${kind}_days`).value,
"reason": document.getElementById(`${kind}_reason`).value
}
2023-05-05 21:45:25 +00:00
if (kind == "ban") {
2024-02-14 16:01:05 +00:00
values["alts"] = document.getElementById('ban_alts').value;
}
else {
values["chud_phrase"] = document.getElementById('chud_phrase_modal').value;
}
postToast(t, `/${kind}_user/${fullname}`,
values,
() => {
document.getElementById(`un${kind}-${fullname}`).classList.remove("d-none");
document.getElementById(`un${kind}2-${fullname}`).classList.remove("d-none");
const days = document.getElementById(`${kind}_days`).value
if (!days) {
t.classList.add("d-none")
}
}
);
}
}