diff --git a/www/assets/js/channelsettings.js b/www/assets/js/channelsettings.js index ee3263ef..5a179e9a 100644 --- a/www/assets/js/channelsettings.js +++ b/www/assets/js/channelsettings.js @@ -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(); })(); diff --git a/www/assets/js/util.js b/www/assets/js/util.js index 39f0a669..c3fa0a21 100644 --- a/www/assets/js/util.js +++ b/www/assets/js/util.js @@ -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")); }