diff --git a/www/assets/js/callbacks.js b/www/assets/js/callbacks.js index e12cc405..c0f61ed0 100644 --- a/www/assets/js/callbacks.js +++ b/www/assets/js/callbacks.js @@ -553,7 +553,9 @@ Callbacks = { return; if(data.success) { + log.data("log", data.data); log.text(data.data); + filterChannelLog(); } else { log.text("Error reading channel log"); } diff --git a/www/assets/js/channelsettings.js b/www/assets/js/channelsettings.js index ee3263ef..23a2fcbc 100644 --- a/www/assets/js/channelsettings.js +++ b/www/assets/js/channelsettings.js @@ -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(); })(); diff --git a/www/assets/js/util.js b/www/assets/js/util.js index 78c42bf7..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) @@ -1840,3 +1840,86 @@ function showMOTDEditor() { $("#editmotd").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")); +} diff --git a/www/channeloptions.html b/www/channeloptions.html index c6fb237b..699dc9fe 100644 --- a/www/channeloptions.html +++ b/www/channeloptions.html @@ -228,5 +228,31 @@