Add missing radix information in parseInt().

Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
DL6ER
2020-06-04 16:57:55 +02:00
parent e20c465b33
commit 4bf018b52c
8 changed files with 26 additions and 23 deletions

View File

@@ -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);
}

View File

@@ -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;

View File

@@ -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() {

View File

@@ -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);

View File

@@ -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;

View File

@@ -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");

View File

@@ -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 = "-";

View File

@@ -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");