forked from rDrama/rDrama
make post approval and removal effects only happen when response code is between 200 and 300
parent
07a12380de
commit
32f079ed20
|
@ -1,8 +1,13 @@
|
||||||
function removePost(t,post_id,button1,button2,cls) {
|
function removePost(t,post_id,button1,button2,cls) {
|
||||||
url="/remove_post/"+post_id
|
url="/remove_post/"+post_id
|
||||||
|
|
||||||
postToast(t,url,button1,button2,cls)
|
t.disabled = true;
|
||||||
|
t.classList.add("disabled");
|
||||||
|
postToast_callback(url,
|
||||||
|
{
|
||||||
|
},
|
||||||
|
(xhr) => {
|
||||||
|
if (xhr.status >= 200 && xhr.status < 300) {
|
||||||
if (window.location.pathname == '/admin/reported/posts')
|
if (window.location.pathname == '/admin/reported/posts')
|
||||||
{
|
{
|
||||||
document.getElementById("flaggers-"+post_id).remove()
|
document.getElementById("flaggers-"+post_id).remove()
|
||||||
|
@ -11,14 +16,27 @@ function removePost(t,post_id,button1,button2,cls) {
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
document.getElementById("post-"+post_id).classList.add("banned");
|
document.getElementById("post-"+post_id).classList.add("banned");
|
||||||
|
document.getElementById(button1).classList.toggle(cls);
|
||||||
|
document.getElementById(button2).classList.toggle(cls);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
t.disabled = false;
|
||||||
|
t.classList.remove("disabled");
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function approvePost(t,post_id,button1,button2,cls) {
|
function approvePost(t,post_id,button1,button2,cls) {
|
||||||
url="/approve_post/"+post_id
|
url="/approve_post/"+post_id
|
||||||
|
|
||||||
postToast(t,url,button1,button2,cls)
|
t.disabled = true;
|
||||||
|
t.classList.add("disabled");
|
||||||
|
postToast_callback(url,
|
||||||
|
{
|
||||||
|
},
|
||||||
|
(xhr) => {
|
||||||
|
if (xhr.status >= 200 && xhr.status < 300) {
|
||||||
if (window.location.pathname == '/admin/reported/posts')
|
if (window.location.pathname == '/admin/reported/posts')
|
||||||
{
|
{
|
||||||
document.getElementById("flaggers-"+post_id).remove()
|
document.getElementById("flaggers-"+post_id).remove()
|
||||||
|
@ -27,5 +45,12 @@ function approvePost(t,post_id,button1,button2,cls) {
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
document.getElementById("post-"+post_id).classList.remove("banned");
|
document.getElementById("post-"+post_id).classList.remove("banned");
|
||||||
|
document.getElementById(button1).classList.toggle(cls);
|
||||||
|
document.getElementById(button2).classList.toggle(cls);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
t.disabled = false;
|
||||||
|
t.classList.remove("disabled");
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue