MarseyWorld/files/assets/js/comments_admin.js

88 lines
2.7 KiB
JavaScript
Raw Normal View History

2022-07-16 21:00:02 +00:00
function removeComment(post_id,button1,button2) {
url="/remove_comment/"+post_id
2022-07-16 21:00:02 +00:00
post(url)
try {
document.getElementById("comment-"+post_id+"-only").classList.add("banned");
} catch(e) {
document.getElementById("context").classList.add("banned");
}
var button=document.getElementById("remove-"+post_id);
button.onclick=function(){approveComment(post_id)};
button.innerHTML='<i class="fas fa-clipboard-check"></i>Approve'
if (typeof button1 !== 'undefined') {
document.getElementById(button1).classList.toggle("d-md-block");
document.getElementById(button2).classList.toggle("d-md-block");
}
};
function approveComment(post_id,button1,button2) {
url="/approve_comment/"+post_id
2022-07-16 21:00:02 +00:00
post(url)
try {
document.getElementById("comment-"+post_id+"-only").classList.remove("banned");
} catch(e) {
document.getElementById("context").classList.remove("banned");
}
var button=document.getElementById("remove-"+post_id);
button.onclick=function(){removeComment(post_id)};
button.innerHTML='<i class="fas fa-trash-alt"></i>Remove'
if (typeof button1 !== 'undefined') {
document.getElementById(button1).classList.toggle("d-md-block");
document.getElementById(button2).classList.toggle("d-md-block");
}
}
function removeComment2(post_id,button1,button2) {
url="/remove_comment/"+post_id
2022-07-16 21:00:02 +00:00
post(url)
document.getElementById("comment-"+post_id+"-only").classList.add("banned");
var button=document.getElementById("remove-"+post_id);
button.onclick=function(){approveComment(post_id)};
button.innerHTML='<i class="fas fa-clipboard-check"></i>Approve'
if (typeof button1 !== 'undefined') {
document.getElementById(button1).classList.toggle("d-none");
document.getElementById(button2).classList.toggle("d-none");
}
};
function approveComment2(post_id,button1,button2) {
url="/approve_comment/"+post_id
2022-07-16 21:00:02 +00:00
post(url)
document.getElementById("comment-"+post_id+"-only").classList.remove("banned");
var button=document.getElementById("remove-"+post_id);
button.onclick=function(){removeComment(post_id)};
button.innerHTML='<i class="fas fa-trash-alt"></i>Remove'
if (typeof button1 !== 'undefined') {
document.getElementById(button1).classList.toggle("d-none");
document.getElementById(button2).classList.toggle("d-none");
}
}
function adminMuteUser(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.add("d-none");
}