add unban function
This commit is contained in:
parent
d2001461c9
commit
6b4b455a12
@ -21,6 +21,7 @@ function get_longhash(str) {
|
|||||||
// handle ban command
|
// handle ban command
|
||||||
function nntpchan_ban() {
|
function nntpchan_ban() {
|
||||||
nntpchan_mod({
|
nntpchan_mod({
|
||||||
|
parser: get_longhash,
|
||||||
name: "ban",
|
name: "ban",
|
||||||
handle: function(j) {
|
handle: function(j) {
|
||||||
if (j.banned) {
|
if (j.banned) {
|
||||||
@ -30,10 +31,21 @@ function nntpchan_ban() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function nntpchan_unban() {
|
||||||
|
nntpchan_mod({
|
||||||
|
name: "unban",
|
||||||
|
handle: function(j) {
|
||||||
|
if (j.result) {
|
||||||
|
return document.createTextNode(j.result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// handle delete command
|
// handle delete command
|
||||||
function nntpchan_delete() {
|
function nntpchan_delete() {
|
||||||
nntpchan_mod({
|
nntpchan_mod({
|
||||||
|
parser: get_longhash,
|
||||||
name: "del",
|
name: "del",
|
||||||
handle: function(j) {
|
handle: function(j) {
|
||||||
var elem = document.createElement("div");
|
var elem = document.createElement("div");
|
||||||
@ -65,8 +77,10 @@ function nntpchan_mod(mod_action) {
|
|||||||
|
|
||||||
// get the element
|
// get the element
|
||||||
var input = document.getElementById("nntpchan_mod_target");
|
var input = document.getElementById("nntpchan_mod_target");
|
||||||
// get the long hash
|
var target = input.value;
|
||||||
var longhash = get_longhash(input.value);
|
if (mod_action.parser) {
|
||||||
|
target = mod_action.parser(target);
|
||||||
|
}
|
||||||
|
|
||||||
var elem = document.getElementById("nntpchan_mod_result");
|
var elem = document.getElementById("nntpchan_mod_result");
|
||||||
// clear old results
|
// clear old results
|
||||||
@ -112,7 +126,7 @@ function nntpchan_mod(mod_action) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (mod_action.name) {
|
if (mod_action.name) {
|
||||||
var url = mod_action.name + "/" + longhash;
|
var url = mod_action.name + "/" + target;
|
||||||
ajax.open("GET", url);
|
ajax.open("GET", url);
|
||||||
ajax.send();
|
ajax.send();
|
||||||
} else {
|
} else {
|
||||||
|
@ -16,11 +16,14 @@
|
|||||||
<div> post actions </div>
|
<div> post actions </div>
|
||||||
<hr />
|
<hr />
|
||||||
<div>
|
<div>
|
||||||
<label for="nntpchan_mod_target">url</label>
|
<label for="nntpchan_mod_target">target</label>
|
||||||
<input id="nntpchan_mod_target" type="text" />
|
<input id="nntpchan_mod_target" type="text" />
|
||||||
</div>
|
</div>
|
||||||
<button onclick="nntpchan_ban()">ban</button>
|
<div>
|
||||||
<button onclick="nntpchan_delete()">delete</button>
|
<button onclick="nntpchan_ban()">ban (url)</button>
|
||||||
|
<button onclick="nntpchan_delete()">delete (url)</button>
|
||||||
|
<button onclock="nntpchan_unban()">unban (ip)</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="nntpchan_mod_result"></div>
|
<div id="nntpchan_mod_result"></div>
|
||||||
<noscript>
|
<noscript>
|
||||||
|
Reference in New Issue
Block a user