From 4bf018b52c124dd13bb0e8406bce900d9293844b Mon Sep 17 00:00:00 2001 From: DL6ER Date: Thu, 4 Jun 2020 16:57:55 +0200 Subject: [PATCH] Add missing radix information in parseInt(). Signed-off-by: DL6ER --- scripts/pi-hole/js/db_graph.js | 10 +++++----- scripts/pi-hole/js/db_queries.js | 4 ++-- scripts/pi-hole/js/footer.js | 6 +++--- scripts/pi-hole/js/groups-domains.js | 7 +++++-- scripts/pi-hole/js/index.js | 10 +++++----- scripts/pi-hole/js/network.js | 2 +- scripts/pi-hole/js/queries.js | 4 ++-- scripts/pi-hole/js/settings.js | 6 +++--- 8 files changed, 26 insertions(+), 23 deletions(-) diff --git a/scripts/pi-hole/js/db_graph.js b/scripts/pi-hole/js/db_graph.js index d1c2f2ac..73a9e6bd 100644 --- a/scripts/pi-hole/js/db_graph.js +++ b/scripts/pi-hole/js/db_graph.js @@ -100,14 +100,14 @@ function updateQueriesOverTime() { for (hour in data.domains_over_time[0]) { if (Object.prototype.hasOwnProperty.call(data.domains_over_time[0], hour)) { - dates.push(parseInt(data.domains_over_time[0][hour])); + dates.push(parseInt(data.domains_over_time[0][hour], 10)); } } for (hour in data.ads_over_time[0]) { if (Object.prototype.hasOwnProperty.call(data.ads_over_time[0], hour)) { - if (dates.indexOf(parseInt(data.ads_over_time[0][hour])) === -1) { - dates.push(parseInt(data.ads_over_time[0][hour])); + if (dates.indexOf(parseInt(data.ads_over_time[0][hour], 10)) === -1) { + dates.push(parseInt(data.ads_over_time[0][hour], 10)); } } } @@ -248,8 +248,8 @@ $(function () { label: function (tooltipItems, data) { if (tooltipItems.datasetIndex === 0) { var percentage = 0; - var permitted = parseInt(data.datasets[1].data[tooltipItems.index]); - var blocked = parseInt(data.datasets[0].data[tooltipItems.index]); + var permitted = parseInt(data.datasets[1].data[tooltipItems.index], 10); + var blocked = parseInt(data.datasets[0].data[tooltipItems.index], 10); if (permitted + blocked > 0) { percentage = (100 * blocked) / (permitted + blocked); } diff --git a/scripts/pi-hole/js/db_queries.js b/scripts/pi-hole/js/db_queries.js index 7396f23b..e2810b30 100644 --- a/scripts/pi-hole/js/db_queries.js +++ b/scripts/pi-hole/js/db_queries.js @@ -28,8 +28,8 @@ window.location.search }); if ("from" in GETDict && "until" in GETDict) { - from = parseInt(GETDict.from); - until = parseInt(GETDict.until); + from = parseInt(GETDict.from, 10); + until = parseInt(GETDict.until, 10); start__ = moment(1000 * from); end__ = moment(1000 * until); instantquery = true; diff --git a/scripts/pi-hole/js/footer.js b/scripts/pi-hole/js/footer.js index 227787b3..5a84dcaf 100644 --- a/scripts/pi-hole/js/footer.js +++ b/scripts/pi-hole/js/footer.js @@ -44,7 +44,7 @@ function piholeChanged(action) { function countDown() { var ena = $("#enableLabel"); var enaT = $("#enableTimer"); - var target = new Date(parseInt(enaT.html())); + var target = new Date(parseInt(enaT.html(), 10)); var seconds = Math.round((target.getTime() - new Date().getTime()) / 1000); if (seconds > 0) { @@ -207,7 +207,7 @@ function initCPUtemp() { $(function () { var enaT = $("#enableTimer"); - var target = new Date(parseInt(enaT.html())); + var target = new Date(parseInt(enaT.html(), 10)); var seconds = Math.round((target.getTime() - new Date().getTime()) / 1000); if (seconds > 0) { setTimeout(countDown, 100); @@ -262,7 +262,7 @@ $("#pihole-disable-custom").on("click", function (e) { // Session timer var sessionTimerCounter = document.getElementById("sessiontimercounter"); -var sessionvalidity = parseInt(sessionTimerCounter.textContent); +var sessionvalidity = parseInt(sessionTimerCounter.textContent, 10); var start = new Date(); function updateSessionTimer() { diff --git a/scripts/pi-hole/js/groups-domains.js b/scripts/pi-hole/js/groups-domains.js index 5a0ad202..ae43fef3 100644 --- a/scripts/pi-hole/js/groups-domains.js +++ b/scripts/pi-hole/js/groups-domains.js @@ -221,7 +221,7 @@ function initTable() { var applyBtn = "#btn_apply_" + data.id; // Highlight row (if url parameter "domainid=" is used) - if ("domainid" in GETDict && data.id === parseInt(GETDict.domainid)) { + if ("domainid" in GETDict && data.id === parseInt(GETDict.domainid, 10)) { $(row).find("td").addClass("highlight"); } @@ -265,7 +265,10 @@ function initTable() { }, initComplete: function () { if ("domainid" in GETDict) { - var pos = table.column(0, { order: "current" }).data().indexOf(parseInt(GETDict.domainid)); + var pos = table + .column(0, { order: "current" }) + .data() + .indexOf(parseInt(GETDict.domainid, 10)); if (pos >= 0) { var page = Math.floor(pos / table.page.info().length); table.page(page).draw(false); diff --git a/scripts/pi-hole/js/index.js b/scripts/pi-hole/js/index.js index 24f43029..703aa174 100644 --- a/scripts/pi-hole/js/index.js +++ b/scripts/pi-hole/js/index.js @@ -252,8 +252,8 @@ function updateQueriesOverTime() { 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]); - if (parseInt(data.ads_over_time[0][0]) < 1200) { + 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 { @@ -416,7 +416,7 @@ function updateClientsOverTime() { } } - var d = new Date(1000 * parseInt(timestamps[j])); + var d = new Date(1000 * parseInt(timestamps[j], 10)); clientsChart.data.labels.push(d); } @@ -820,8 +820,8 @@ $(function () { label: function (tooltipItems, data) { if (tooltipItems.datasetIndex === 0) { var percentage = 0; - var permitted = parseInt(data.datasets[1].data[tooltipItems.index]); - var blocked = parseInt(data.datasets[0].data[tooltipItems.index]); + var permitted = parseInt(data.datasets[1].data[tooltipItems.index], 10); + var blocked = parseInt(data.datasets[0].data[tooltipItems.index], 10); var total = permitted + blocked; if (total > 0) { percentage = (100 * blocked) / total; diff --git a/scripts/pi-hole/js/network.js b/scripts/pi-hole/js/network.js index 504cef21..7471554c 100644 --- a/scripts/pi-hole/js/network.js +++ b/scripts/pi-hole/js/network.js @@ -70,7 +70,7 @@ $(function () { rowCallback: function (row, data) { var color; var iconClasses; - var lastQuery = parseInt(data.lastQuery); + var lastQuery = parseInt(data.lastQuery, 10); var diff = getTimestamp() - lastQuery; var networkRecent = $(".network-recent").css("background-color"); var networkOld = $(".network-old").css("background-color"); diff --git a/scripts/pi-hole/js/queries.js b/scripts/pi-hole/js/queries.js index e6ee5347..e9da5b30 100644 --- a/scripts/pi-hole/js/queries.js +++ b/scripts/pi-hole/js/queries.js @@ -260,7 +260,7 @@ $(function () { default: blocked = false; colorClass = false; - fieldtext = "Unknown (" + parseInt(data[4]) + ")"; + fieldtext = "Unknown (" + parseInt(data[4], 10) + ")"; buttontext = ""; } @@ -343,7 +343,7 @@ $(function () { replytext = "upstream error"; break; default: - replytext = "? (" + parseInt(data[6]) + ")"; + replytext = "? (" + parseInt(data[6], 10) + ")"; } } else { replytext = "-"; diff --git a/scripts/pi-hole/js/settings.js b/scripts/pi-hole/js/settings.js index 37598007..93ab09cb 100644 --- a/scripts/pi-hole/js/settings.js +++ b/scripts/pi-hole/js/settings.js @@ -149,11 +149,11 @@ function loadCacheInfo() { } // Fill table with obtained values - $("#cache-size").text(parseInt(data.cacheinfo["cache-size"])); - $("#cache-inserted").text(parseInt(data.cacheinfo["cache-inserted"])); + $("#cache-size").text(parseInt(data.cacheinfo["cache-size"], 10)); + $("#cache-inserted").text(parseInt(data.cacheinfo["cache-inserted"], 10)); // Highlight early cache removals when present - var cachelivefreed = parseInt(data.cacheinfo["cache-live-freed"]); + var cachelivefreed = parseInt(data.cacheinfo["cache-live-freed"], 10); $("#cache-live-freed").text(cachelivefreed); if (cachelivefreed > 0) { $("#cache-live-freed").parent("tr").addClass("lookatme");