Implement log filtering

This commit is contained in:
calzoneman 2013-11-15 23:44:53 -06:00
parent ca4090c533
commit a008c923b7
2 changed files with 102 additions and 2 deletions

View File

@ -205,4 +205,25 @@
});
}
});
var logfilters = [
"#filter_chat",
"#filter_polls",
"#filter_queue",
"#filter_bans",
"#filter_channelsettings",
"#filter_joinquit"
];
$("#filter_all").change(function () {
var checked = $("#filter_all").prop("checked");
logfilters.forEach(function (f) {
$(f).attr("disabled", checked);
});
});
logfilters.unshift("#filter_all");
logfilters.forEach(function (f) {
$(f).change(filterChannelLog);
});
logfilters.shift();
})();

View File

@ -294,7 +294,7 @@ function calcUserBreakdown() {
var data = {
rank: $(item).data("rank")
};
if(data.rank >= 255)
breakdown["Site Admins"]++;
else if(data.rank >= 3)
@ -1842,5 +1842,84 @@ function showMOTDEditor() {
}
function filterChannelLog() {
var cc = $("#chanlog_contents");
if (!cc.data("log")) {
cc.data("log", cc.text());
}
var all = $("#filter_all").prop("checked");
var chat = $("#filter_chat").prop("checked");
var polls = $("#filter_polls").prop("checked");
var queue = $("#filter_queue").prop("checked");
var bans = $("#filter_bans").prop("checked");
var channelsettings = $("#filter_channelsettings").prop("checked");
var joinquit = $("#filter_joinquit").prop("checked");
var lines = cc.data("log").split("\n");
var include = [];
lines.forEach(function (line) {
if (line.trim() === "") {
return;
}
if (all) {
include.push(line);
return;
}
var pre = line.split(" ")[5];
if (pre === undefined) {
return;
}
if (chat && pre.match(/<[\w-]+\.>/)) {
include.push(line);
return;
}
if (polls && pre === "***" && (line.indexOf("Opened Poll") >= 0 ||
line.indexOf("closed the active poll") >= 0)) {
include.push(line);
return;
}
if (queue && pre === "###") {
include.push(line);
return;
}
if (channelsettings && pre === "%%%") {
include.push(line);
return;
}
if (joinquit) {
if (pre === "+++" || pre === "---") {
include.push(line);
return;
}
if (pre.match(/(\d{1,3}\.){3}\d{1,3}/) &&
line.indexOf("logged in as") >= 0) {
include.push(line);
return;
}
}
if (bans && pre === "***" && line.indexOf("banned") >= 0) {
include.push(line);
return;
}
if (channelsettings && pre === "***") {
if (line.indexOf("Loading") >= 0 ||
line.indexOf("Loaded") >= 0 ||
line.indexOf("unloading") >= 0 ||
line.indexOf("rank") >= 0) {
include.push(line);
return;
}
return;
}
});
$("#chanlog_contents").text(include.join("\n"));
}