diff --git a/scripts/pi-hole/js/taillog-FTL.js b/scripts/pi-hole/js/taillog-FTL.js new file mode 100644 index 00000000..cbe709b5 --- /dev/null +++ b/scripts/pi-hole/js/taillog-FTL.js @@ -0,0 +1,46 @@ +/* Pi-hole: A black hole for Internet advertisements +* (c) 2017 Pi-hole, LLC (https://pi-hole.net) +* Network-wide ad blocking via your own hardware. +* +* This file is copyright under the latest version of the EUPL. +* Please see LICENSE file for your rights under this license. */ +var offset, timer, pre, scrolling = true; + +// Check every 200msec for fresh data +var interval = 200; + +// Function that asks the API for new data +function reloadData(){ + clearTimeout(timer); + $.getJSON("scripts/pi-hole/php/tailLog.php?FTL&offset="+offset, function (data) + { + offset = data["offset"]; + pre.append(data["lines"]); + }); + + if(scrolling) + { + window.scrollTo(0,document.body.scrollHeight); + } + timer = setTimeout(reloadData, interval); +} + +$(function(){ + // Get offset at first loading of page + $.getJSON("scripts/pi-hole/php/tailLog.php?FTL", function (data) + { + offset = data["offset"]; + }); + pre = $("#output"); + // Trigger function that looks for new data + reloadData(); +}); + +$("#chk1").click(function() { + $("#chk2").prop("checked",this.checked); + scrolling = this.checked; +}); +$("#chk2").click(function() { + $("#chk1").prop("checked",this.checked); + scrolling = this.checked; +}); diff --git a/scripts/pi-hole/php/header.php b/scripts/pi-hole/php/header.php index e08de235..c92c26b5 100644 --- a/scripts/pi-hole/php/header.php +++ b/scripts/pi-hole/php/header.php @@ -469,6 +469,12 @@ Tail pihole.log + +