Merge pull request #308 from calzoneman/logfilter

Logfilter
This commit is contained in:
Calvin Montgomery 2013-11-16 10:59:36 -08:00
commit b200d6cc2c
4 changed files with 132 additions and 1 deletions

View file

@ -553,7 +553,9 @@ Callbacks = {
return; return;
if(data.success) { if(data.success) {
log.data("log", data.data);
log.text(data.data); log.text(data.data);
filterChannelLog();
} else { } else {
log.text("Error reading channel log"); log.text("Error reading channel log");
} }

View file

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

View file

@ -294,7 +294,7 @@ function calcUserBreakdown() {
var data = { var data = {
rank: $(item).data("rank") rank: $(item).data("rank")
}; };
if(data.rank >= 255) if(data.rank >= 255)
breakdown["Site Admins"]++; breakdown["Site Admins"]++;
else if(data.rank >= 3) else if(data.rank >= 3)
@ -1840,3 +1840,86 @@ function showMOTDEditor() {
$("#editmotd").hide(); $("#editmotd").hide();
$("#togglemotd").hide(); $("#togglemotd").hide();
} }
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"));
}

View file

@ -228,5 +228,31 @@
</div> </div>
<div id="chanlog" class="span12"> <div id="chanlog" class="span12">
<button class="btn" id="chanlog_refresh">Refresh</button> <button class="btn" id="chanlog_refresh">Refresh</button>
<br>
<br>
<strong>Filter Log:</strong>
<form class="form-inline" action="javascript:void(0)">
<label class="checkbox" for="filter_all">Everything
<input type="checkbox" id="filter_all" checked="checked">
</label>
<label class="checkbox" for="filter_chat">Chat
<input type="checkbox" id="filter_chat">
</label>
<label class="checkbox" for="filter_polls">Polls
<input type="checkbox" id="filter_polls">
</label>
<label class="checkbox" for="filter_queue">Playlist actions
<input type="checkbox" id="filter_queue">
</label>
<label class="checkbox" for="filter_bans">Bans
<input type="checkbox" id="filter_bans">
</label>
<label class="checkbox" for="filter_channelsettings">Channel settings
<input type="checkbox" id="filter_channelsettings">
</label>
<label class="checkbox" for="filter_joinquit">Join/Quit Messages
<input type="checkbox" id="filter_joinquit">
</label>
</form>
<pre id="chanlog_contents" style="max-height: 400px; overflow-y: scroll"></pre> <pre id="chanlog_contents" style="max-height: 400px; overflow-y: scroll"></pre>
</div> </div>