forked from rDrama/rDrama
1
0
Fork 0
rDrama/files/assets/js/comments_admin.js

78 lines
2.2 KiB
JavaScript
Raw Normal View History

2022-11-03 15:43:00 +00:00
function removeComment(t,comment_id,button1,button2,cls) {
url="/remove_comment/"+comment_id
2022-07-16 21:00:02 +00:00
2022-11-03 15:43:00 +00:00
t.disabled = true;
t.classList.add("disabled");
2022-11-03 16:11:04 +00:00
postToastCallback(url,
2022-11-03 15:43:00 +00:00
{
},
(xhr) => {
if (xhr.status >= 200 && xhr.status < 300) {
if (window.location.pathname == '/admin/reported/comments')
{
document.getElementById("post-info-"+comment_id).remove()
document.getElementById("comment-"+comment_id).remove()
}
else
{
try {
document.getElementById("comment-"+comment_id+"-only").classList.add("banned");
} catch(e) {
document.getElementById("context").classList.add("banned");
}
document.getElementById(button1).classList.toggle(cls);
document.getElementById(button2).classList.toggle(cls);
}
}
t.disabled = false;
t.classList.remove("disabled");
}
2022-11-03 15:43:00 +00:00
);
}
2022-07-16 21:00:02 +00:00
2022-11-03 15:43:00 +00:00
function approveComment(t,comment_id,button1,button2,cls) {
url="/approve_comment/"+comment_id
2022-07-16 21:00:02 +00:00
2022-11-03 15:43:00 +00:00
t.disabled = true;
t.classList.add("disabled");
2022-11-03 16:11:04 +00:00
postToastCallback(url,
2022-11-03 15:43:00 +00:00
{
},
(xhr) => {
if (xhr.status >= 200 && xhr.status < 300) {
if (window.location.pathname == '/admin/reported/comments')
{
document.getElementById("post-info-"+comment_id).remove()
document.getElementById("comment-"+comment_id).remove()
}
else
{
try {
document.getElementById("comment-"+comment_id+"-only").classList.remove("banned");
} catch(e) {
document.getElementById("context").classList.remove("banned");
}
document.getElementById(button1).classList.toggle(cls);
document.getElementById(button2).classList.toggle(cls);
}
}
t.disabled = false;
t.classList.remove("disabled");
}
2022-11-03 15:43:00 +00:00
);
}
function adminToggleMute(userId, muteStatus, buttonId) {
const xhr = createXhrWithFormKey(`/mute_user/${userId}/${muteStatus}`);
xhr[0].onload = function() {
let data
try {data = JSON.parse(xhr[0].response)}
catch(e) {console.log(e)}
success = xhr[0].status >= 200 && xhr[0].status < 300;
showToast(success, getMessageFromJsonData(success, data));
};
xhr[0].send(xhr[1]);
document.getElementById('mute-user-' + buttonId).classList.toggle("d-none");
document.getElementById('unmute-user-' + buttonId).classList.toggle("d-none");
}