Clean up JS

* remove unused variables/functions
* use the dot notation
* use explicit coercion
* remove unneeded else
* use `textContent` instead of `innerHTML`
* cache a few `getElementById` calls
* fix a couple of undefined variables
* various assorted lint tweaks

Signed-off-by: XhmikosR <xhmikosr@gmail.com>
This commit is contained in:
XhmikosR
2019-12-10 10:15:20 +02:00
parent b198467bfc
commit 9c1846885a
17 changed files with 199 additions and 244 deletions

View File

@@ -4,6 +4,7 @@
*
* 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
@@ -14,13 +15,13 @@ function reloadData(){
clearTimeout(timer);
$.getJSON("scripts/pi-hole/php/tailLog.php?offset="+offset, function (data)
{
pre.append(data["lines"]);
pre.append(data.lines);
if(scrolling && offset !== data["offset"]) {
if(scrolling && offset !== data.offset) {
pre.scrollTop(pre[0].scrollHeight);
}
offset = data["offset"];
offset = data.offset;
});
timer = setTimeout(reloadData, interval);
@@ -30,7 +31,7 @@ $(function(){
// Get offset at first loading of page
$.getJSON("scripts/pi-hole/php/tailLog.php", function (data)
{
offset = data["offset"];
offset = data.offset;
});
pre = $("#output");
// Trigger function that looks for new data