2017-01-12 19:24:51 +05:00
|
|
|
/** censor tools */
|
|
|
|
|
|
|
|
|
|
|
|
function show_censortools() {
|
|
|
|
var e = document.getElementById("censor-tools");
|
|
|
|
if(e) e.checked = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
function nntpchan_report_thread(posthash) {
|
2017-01-12 19:38:48 +05:00
|
|
|
var thread = document.getElementById("thread_"+posthash);
|
2017-01-12 19:24:51 +05:00
|
|
|
if (!thread) return;
|
|
|
|
var posts = thread.getElementsByClassName("post");
|
|
|
|
for (var idx = 0; idx < posts.length; idx ++ ) {
|
|
|
|
var post = posts[idx];
|
|
|
|
nntpchan_report(post.dataset.msgid);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-12 19:37:23 +05:00
|
|
|
function nntpchan_report(msgid, msgid_hash, refid, refid_hash) {
|
2017-01-12 19:40:07 +05:00
|
|
|
var e = document.getElementById("nntpchan_censor_actions");
|
2017-01-12 19:24:51 +05:00
|
|
|
if (!e) return;
|
2017-01-12 19:37:23 +05:00
|
|
|
if(refid == msgid) {
|
2017-01-12 19:40:33 +05:00
|
|
|
nntpchan_report_thread(refid_hash);
|
2017-01-12 19:37:23 +05:00
|
|
|
} else {
|
|
|
|
e.value += "delete "+msgid+"\n";
|
|
|
|
}
|
2017-01-12 19:24:51 +05:00
|
|
|
show_censortools();
|
|
|
|
}
|
|
|
|
|
|
|
|
function nntpchan_submit_censor(form, regular_url) {
|
|
|
|
|
|
|
|
var result = document.getElementById("nntpchan_censor_result");
|
|
|
|
|
|
|
|
var show_result = function(msg) {
|
2017-01-16 20:35:44 +05:00
|
|
|
while(result.children.length > 0) {
|
|
|
|
result.children[0].remove();
|
|
|
|
}
|
|
|
|
result.appendChild(document.createTextNode(msg));
|
2017-01-12 19:24:51 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
var handle_result = function(j) {
|
|
|
|
var err = j.error;
|
|
|
|
if(err) {
|
|
|
|
show_result("error: "+err);
|
|
|
|
return;
|
|
|
|
}
|
2017-01-16 20:32:11 +05:00
|
|
|
var msgid = j.message_id;
|
2017-01-12 19:24:51 +05:00
|
|
|
if(msgid) {
|
|
|
|
show_result("submitted report as "+msgid);
|
2017-01-16 20:21:37 +05:00
|
|
|
} else {
|
|
|
|
show_result("post failed, bad captcha?");
|
2017-01-12 19:24:51 +05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// build url to ctl
|
|
|
|
var parts = regular_url.split('/');
|
|
|
|
parts[parts.length-1] = 'ctl';
|
|
|
|
var url = parts.join('/');
|
2017-01-16 20:31:18 +05:00
|
|
|
url += '/json';
|
2017-01-12 19:44:59 +05:00
|
|
|
console.log(url);
|
2017-01-12 19:24:51 +05:00
|
|
|
var captcha = form.captcha.value;
|
|
|
|
if(!captcha) {
|
|
|
|
show_result("no captcha solution provided");
|
|
|
|
return;
|
|
|
|
}
|
2017-01-12 19:49:30 +05:00
|
|
|
var secret = document.getElementById("nntp_censor_secret").value;
|
2017-01-12 19:24:51 +05:00
|
|
|
if(!secret) {
|
|
|
|
show_result("no mod key provided");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
var actions = document.getElementById("nntpchan_censor_actions").value;
|
|
|
|
if(!actions) {
|
|
|
|
show_result("no mod actions provided");
|
|
|
|
}
|
|
|
|
var msg = "";
|
|
|
|
var lines = actions.split("\n");
|
|
|
|
for (var idx = 0; idx < lines.length; idx ++ ) {
|
|
|
|
var line = lines[idx].trim();
|
|
|
|
if(!line) continue;
|
|
|
|
msg += line + "\n";
|
|
|
|
}
|
|
|
|
if(!msg) {
|
|
|
|
show_result("no mod actions given");
|
|
|
|
return;
|
|
|
|
}
|
2017-01-12 20:25:15 +05:00
|
|
|
msg = msg.trim() + "\n\n";
|
2017-01-12 19:24:51 +05:00
|
|
|
var formdata = new FormData();
|
|
|
|
formdata.append("name", "mod#"+secret);
|
|
|
|
formdata.append("subject", "censor");
|
|
|
|
formdata.append("message", msg);
|
|
|
|
formdata.append("captcha", captcha);
|
|
|
|
formdata.append("reference", "");
|
|
|
|
nntpchan_apicall(url, handle_result, null, "POST", formdata);
|
|
|
|
}
|
|
|
|
|
|
|
|
onready(function() {
|
|
|
|
|
|
|
|
});
|