From 274c196e42bdf83d98fd2b5e4047d9ab9bd12da4 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Mon, 26 Oct 2020 08:07:33 +0200 Subject: [PATCH] Lint. Signed-off-by: XhmikosR --- scripts/pi-hole/js/db_queries.js | 10 +++------- scripts/pi-hole/js/footer.js | 10 ++++------ scripts/pi-hole/js/index.js | 23 +++++++---------------- scripts/pi-hole/js/queries.js | 18 ++++-------------- 4 files changed, 18 insertions(+), 43 deletions(-) diff --git a/scripts/pi-hole/js/db_queries.js b/scripts/pi-hole/js/db_queries.js index 2f56fcd7..c0578594 100644 --- a/scripts/pi-hole/js/db_queries.js +++ b/scripts/pi-hole/js/db_queries.js @@ -239,13 +239,9 @@ function refreshTableData() { } $(function () { - var APIstring; - - if (instantquery) { - APIstring = "api_db.php?getAllQueries&from=" + from + "&until=" + until; - } else { - APIstring = "api_db.php?getAllQueries=empty"; - } + var APIstring = instantquery + ? "api_db.php?getAllQueries&from=" + from + "&until=" + until + : "api_db.php?getAllQueries=empty"; // Check if query type filtering is enabled var queryType = getQueryTypes(); diff --git a/scripts/pi-hole/js/footer.js b/scripts/pi-hole/js/footer.js index 38b093c7..32dbc84e 100644 --- a/scripts/pi-hole/js/footer.js +++ b/scripts/pi-hole/js/footer.js @@ -96,12 +96,10 @@ function piholeChange(action, duration) { function checkMessages() { $.getJSON("api_db.php?status", function (data) { if ("message_count" in data && data.message_count > 0) { - var title; - if (data.message_count > 1) { - title = "There are " + data.message_count + " warnings. Click for further details."; - } else { - title = "There is one warning. Click for further details."; - } + var title = + data.message_count > 1 + ? "There are " + data.message_count + " warnings. Click for further details." + : "There is one warning. Click for further details."; $("#pihole-diagnosis").prop("title", title); $("#pihole-diagnosis-count").text(data.message_count); diff --git a/scripts/pi-hole/js/index.js b/scripts/pi-hole/js/index.js index 83f49b02..9c1a31e0 100644 --- a/scripts/pi-hole/js/index.js +++ b/scripts/pi-hole/js/index.js @@ -251,15 +251,11 @@ function updateQueriesOverTime() { // Add data for each hour that is available for (var hour in data.ads_over_time[0]) { if (Object.prototype.hasOwnProperty.call(data.ads_over_time[0], hour)) { - var d, h; - h = parseInt(data.domains_over_time[0][hour], 10); - if (parseInt(data.ads_over_time[0][0], 10) < 1200) { - // Fallback - old style - d = new Date().setHours(Math.floor(h / 6), 10 * (h % 6), 0, 0); - } else { - // New style: Get Unix timestamps - d = new Date(1000 * h); - } + var h = parseInt(data.domains_over_time[0][hour], 10); + var d = + parseInt(data.ads_over_time[0][0], 10) < 1200 + ? new Date().setHours(Math.floor(h / 6), 10 * (h % 6), 0, 0) + : new Date(1000 * h); timeLineChart.data.labels.push(d); var blocked = data.ads_over_time[1][hour]; @@ -297,14 +293,9 @@ function updateQueryTypesPie() { var v = [], c = [], k = [], - i = 0, - iter; + i = 0; // Collect values and colors, and labels - if (Object.prototype.hasOwnProperty.call(data, "querytypes")) { - iter = data.querytypes; - } else { - iter = data; - } + var iter = Object.prototype.hasOwnProperty.call(data, "querytypes") ? data.querytypes : data; querytypeids = []; Object.keys(iter).forEach(function (key) { diff --git a/scripts/pi-hole/js/queries.js b/scripts/pi-hole/js/queries.js index 00549b95..017dff11 100644 --- a/scripts/pi-hole/js/queries.js +++ b/scripts/pi-hole/js/queries.js @@ -41,12 +41,7 @@ function add(domain, list) { return; } - var listtype; - if (list === "white") { - listtype = "Whitelist"; - } else { - listtype = "Blacklist"; - } + var listtype = list === "white" ? "Whitelist" : "Blacklist"; alProcessing.children(alDomain).html(domain); alProcessing.children(alList).html(listtype); @@ -311,14 +306,9 @@ $(function () { } // Check for existence of sixth column and display only if not Pi-holed - var replytext, - replyid = data[5]; - - if (replyid >= 0 && replyid < replyTypes.length) { - replytext = replyTypes[replyid]; - } else { - replytext = "? (" + replyid + ")"; - } + var replyid = data[5]; + var replytext = + replyid >= 0 && replyid < replyTypes.length ? replyTypes[replyid] : "? (" + replyid + ")"; replytext += '';