Archived
1
0

more js crap

This commit is contained in:
Jeff Becker 2018-11-06 15:28:02 -05:00
parent cc4cee1322
commit 0e72397956
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05

View File

@ -28,32 +28,48 @@ var nntpchan_mod_commit_spam = function(elem) {
} }
} }
formdata.set("spam", spams.join(",")); formdata.set("spam", spams.join(","));
var ajax = new XMLHttpRequest(); var jax = new XMLHttpRequest();
ajax.onreadystatechange = function() { jax.onreadystatechange = function() {
if(ajax.readyState == 4) if(jax.readyState == 4)
{ {
if(ajax.status == 200) if(jax.status == 200)
{ {
// success (?)
var j = JSON.parse(ajax.responseText); var ajax = new XMLHttpRequest();
if(j.error) ajax.setRequestHeader("X-CSRF-Token", jax.getResponseHeader("X-CSRF-Token"));
{ ajax.onreadystatechange = function() {
elem.innerText = "could not mark as spam: " + j.error; if(ajax.readyState == 4)
} {
else if(ajax.status == 200)
{ {
elem.innerText = "OK: marked as spam"; // success (?)
} var j = JSON.parse(ajax.responseText);
if(j.error)
{
elem.innerText = "could not mark as spam: " + j.error;
}
else
{
elem.innerText = "OK: marked as spam";
}
}
else
{
elem.innerText = "post not marked as spam on server: "+ ajax.statusText;
}
}
};
ajax.open("POST", "/mod/spam")
ajax.send(formdata);
} }
else else
{ {
elem.innerText = "post not marked as spam on server: "+ ajax.statusText; elem.innerText = "failed to moderate, not logged in";
} }
} }
}; };
ajax.open("POST", "/mod/spam") jax.open("GET", "/mod/");
ajax.send(formdata); jax.send();
}; };
var nntpchan_mod_delete = function(longhash) { var nntpchan_mod_delete = function(longhash) {