If a user has spammed a lot of posts and made a mess of the board, this will allow us to delete all posts by the offending user from the same IP. Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
127 lines
3.9 KiB
JavaScript
127 lines
3.9 KiB
JavaScript
////////////////////////////////////////////////////////////////////////////////
|
|
// Constants
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// HACK: this should be a const, but it will cause an error if included twice in
|
|
// the same page (like an iframe).
|
|
if (typeof window.banWindowName === "undefined") {
|
|
window.banWindowName = "ban-window";
|
|
window.modifyWindowName = "modify-window";
|
|
window.wipeWindowName = "wipe-window";
|
|
}
|
|
|
|
if (typeof window.menuItemFactories !== "undefined") {
|
|
window.menuItemFactories.push(
|
|
(postElement) => $("<a>")
|
|
.text("Ban")
|
|
.attr("href", "#")
|
|
.on("click", (e) => {
|
|
e.preventDefault();
|
|
openBanWindow($(postElement).attr("data-ban-url"));
|
|
})
|
|
);
|
|
window.menuItemFactories.push(
|
|
(postElement) => $("<a>")
|
|
.text("Modify post")
|
|
.attr("href", "#")
|
|
.on("click", (e) => {
|
|
e.preventDefault();
|
|
openModifyWindow($(postElement).attr("data-modify-url"));
|
|
})
|
|
);
|
|
window.menuItemFactories.push(
|
|
(postElement) => $("<a>")
|
|
.text("Wipe user posts")
|
|
.attr("href", "#")
|
|
.on("click", (e) => {
|
|
e.preventDefault();
|
|
openWipeWindow($(postElement).attr("data-wipe-url"));
|
|
})
|
|
);
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
// Ban window
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
function getBanWindow() {
|
|
return window.top.jsFrame.getWindowByName(banWindowName);
|
|
}
|
|
|
|
function openBanWindow(banUrl) {
|
|
if (window.top.jsFrame.containsWindowName(banWindowName)) {
|
|
getBanWindow().closeFrame();
|
|
}
|
|
let banWindow = window.top.jsFrame.create({
|
|
title: "New Ban",
|
|
name: banWindowName,
|
|
width: 475,
|
|
url: banUrl,
|
|
});
|
|
$(banWindow.iframe, "iframe").on("load", () => {
|
|
fitWindowToContent(banWindow);
|
|
banWindow.setResizable(false);
|
|
});
|
|
banWindow.setPosition(
|
|
window.innerWidth,
|
|
window.innerHeight / 2,
|
|
"RIGHT_CENTER"
|
|
);
|
|
$(banWindow.iframe, "iframe").on("load", () => {
|
|
banWindow.iframe.contentWindow.thisWindow = banWindow;
|
|
});
|
|
banWindow.show();
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
// Modify window
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
function getModifyWindow() {
|
|
return window.top.jsFrame.getWindowByName(modifyWindowName);
|
|
}
|
|
|
|
function openModifyWindow(modifyUrl) {
|
|
if (window.top.jsFrame.containsWindowName(modifyWindowName)) {
|
|
getModifyWindow().closeFrame();
|
|
}
|
|
|
|
let modifyWindow = window.top.jsFrame.create({
|
|
title: "Modifying post",
|
|
name: modifyWindowName,
|
|
width: 475,
|
|
url: modifyUrl,
|
|
});
|
|
$(modifyWindow.iframe, "iframe").on("load", () => {
|
|
fitWindowToContent(modifyWindow);
|
|
modifyWindow.setResizable(false);
|
|
modifyWindow.iframe.contentWindow.thisWindow = modifyWindow;
|
|
});
|
|
modifyWindow.show();
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
// Wipe window
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
function getWipeWindow() {
|
|
return window.top.jsFrame.getWindowByName(wipeWindowName);
|
|
}
|
|
|
|
function openWipeWindow(wipeUrl) {
|
|
if (window.top.jsFrame.containsWindowName(wipeWindowName)) {
|
|
getWipeWindow().closeFrame();
|
|
}
|
|
|
|
let wipeWindow = window.top.jsFrame.create({
|
|
title: "Wipe post",
|
|
name: wipeWindowName,
|
|
width: 475,
|
|
url: wipeUrl,
|
|
});
|
|
$(wipeWindow.iframe, "iframe").on("load", () => {
|
|
fitWindowToContent(wipeWindow);
|
|
wipeWindow.setResizable(false);
|
|
wipeWindow.iframe.contentWindow.thisWindow = wipeWindow;
|
|
});
|
|
wipeWindow.show();
|
|
} |