Fix warnings

Signed-off-by: Christian König <ckoenig@posteo.de>
This commit is contained in:
Christian König
2023-04-08 21:16:06 +02:00
parent 8a4436a048
commit 34e45edbda
9 changed files with 49 additions and 49 deletions

View File

@@ -76,11 +76,11 @@ function updateTopClientsChart() {
data.top_sources[utils.escapeHtml(client)] = data.top_sources[client];
}
if (client.indexOf("|") !== -1) {
if (client.indexOf("|") === -1) {
clientname = client;
} else {
var idx = client.indexOf("|");
clientname = client.substr(0, idx);
} else {
clientname = client;
}
percentage = (data.top_sources[client] / sum) * 100;

View File

@@ -95,15 +95,15 @@ var tableApi, statistics;
function handleAjaxError(xhr, textStatus) {
if (textStatus === "timeout") {
alert("The server took too long to send the data.");
} else if (xhr.responseText.indexOf("Connection refused") !== -1) {
alert("An error occurred while loading the data: Connection refused. Is FTL running?");
} else {
} else if (xhr.responseText.indexOf("Connection refused") === -1) {
alert(
"An unknown error occurred while loading the data.\n" +
xhr.responseText +
"\nCheck the server's log files (/var/log/lighttpd/error-pihole.log) for details.\n\nYou may need to increase PHP memory limit." +
"\n\nYou can find more info in pi-hole's FAQ:\nhttps://docs.pi-hole.net/main/faq/#error-while-loading-data-from-the-long-term-database"
);
} else {
alert("An error occurred while loading the data: Connection refused. Is FTL running?");
}
$("#all-queries_processing").hide();
@@ -457,10 +457,10 @@ $(function () {
});
$("#all-queries tbody").on("click", "button", function () {
var data = tableApi.row($(this).parents("tr")).data();
if ([1, 4, 5, 9, 10, 11].indexOf(data[4]) !== -1) {
utils.addFromQueryLog(data[2], "white");
} else {
if ([1, 4, 5, 9, 10, 11].indexOf(data[4]) === -1) {
utils.addFromQueryLog(data[2], "black");
} else {
utils.addFromQueryLog(data[2], "white");
}
});

View File

@@ -34,11 +34,11 @@ function eventsource() {
// Detect ${OVER}
var newString = "<------";
if (e.data.indexOf(newString) !== -1) {
if (e.data.indexOf(newString) === -1) {
ta.append(e.data);
} else {
ta.text(ta.text().substring(0, ta.text().lastIndexOf("\n")) + "\n");
ta.append(e.data.replace(newString, ""));
} else {
ta.append(e.data);
}
},
false

View File

@@ -79,7 +79,7 @@ $(function () {
statusEl.on("change", editGroup);
$("td:eq(3)", row).html('<input id="desc_' + data.id + '" class="form-control">');
var desc = data.description !== null ? data.description : "";
var desc = data.description === null ? "" : data.description;
var descEl = $("#desc_" + data.id, row);
descEl.val(utils.unescapeHtml(desc));
descEl.on("change", editGroup);

View File

@@ -491,13 +491,13 @@ function updateTopClientsChart() {
}
client = utils.escapeHtml(client);
if (client.indexOf("|") !== -1) {
if (client.indexOf("|") === -1) {
clientname = client;
clientip = client;
} else {
idx = client.indexOf("|");
clientname = client.substr(0, idx);
clientip = client.substr(idx + 1, client.length - idx);
} else {
clientname = client;
clientip = client;
}
url =
@@ -531,7 +531,7 @@ function updateTopClientsChart() {
}
client = utils.escapeHtml(client);
if (client.indexOf("|") !== -1) {
if (client.indexOf("|") === -1) {
idx = client.indexOf("|");
clientname = client.substr(0, idx);
clientip = client.substr(idx + 1, client.length - idx);
@@ -719,10 +719,10 @@ function updateSummaryData(runOnce) {
}, 500);
})
.done(function () {
if (!FTLoffline) {
setTimer(1);
} else {
if (FTLoffline) {
setTimer(10);
} else {
setTimer(1);
}
})
.fail(function () {

View File

@@ -20,10 +20,10 @@ var DAY_IN_SECONDS = 24 * 60 * 60;
function handleAjaxError(xhr, textStatus) {
if (textStatus === "timeout") {
alert("The server took too long to send the data.");
} else if (xhr.responseText.indexOf("Connection refused") !== -1) {
alert("An error occurred while loading the data: Connection refused. Is FTL running?");
} else {
} else if (xhr.responseText.indexOf("Connection refused") === -1) {
alert("An unknown error occurred while loading the data.\n" + xhr.responseText);
} else {
alert("An error occurred while loading the data: Connection refused. Is FTL running?");
}
$("#network-entries_processing").hide();

View File

@@ -31,10 +31,10 @@ var colTypes = ["time", "query type", "domain", "client", "status", "reply type"
function handleAjaxError(xhr, textStatus) {
if (textStatus === "timeout") {
alert("The server took too long to send the data.");
} else if (xhr.responseText.indexOf("Connection refused") !== -1) {
alert("An error occurred while loading the data: Connection refused. Is FTL running?");
} else {
} else if (xhr.responseText.indexOf("Connection refused") === -1) {
alert("An unknown error occurred while loading the data.\n" + xhr.responseText);
} else {
alert("An error occurred while loading the data: Connection refused. Is FTL running?");
}
$("#all-queries_processing").hide();

View File

@@ -366,15 +366,15 @@ $(function () {
var bargraphs = $("#bargraphs");
var chkboxData = localStorage ? localStorage.getItem("barchart_chkbox") : null;
if (chkboxData !== null) {
// Restore checkbox state
bargraphs.prop("checked", chkboxData === "true");
} else {
if (chkboxData === null) {
// Initialize checkbox
bargraphs.prop("checked", true);
if (localStorage) {
localStorage.setItem("barchart_chkbox", true);
}
} else {
// Restore checkbox state
bargraphs.prop("checked", chkboxData === "true");
}
bargraphs.on("click", function () {
@@ -386,15 +386,15 @@ $(function () {
var colorfulQueryLog = $("#colorfulQueryLog");
var chkboxData = localStorage ? localStorage.getItem("colorfulQueryLog_chkbox") : null;
if (chkboxData !== null) {
// Restore checkbox state
colorfulQueryLog.prop("checked", chkboxData === "true");
} else {
if (chkboxData === null) {
// Initialize checkbox
colorfulQueryLog.prop("checked", false);
if (localStorage) {
localStorage.setItem("colorfulQueryLog_chkbox", false);
}
} else {
// Restore checkbox state
colorfulQueryLog.prop("checked", chkboxData === "true");
}
colorfulQueryLog.on("click", function () {
@@ -452,15 +452,15 @@ $(function () {
var nonfatalwarnigns = $("#hideNonfatalDnsmasqWarnings");
var chkboxData = localStorage ? localStorage.getItem("hideNonfatalDnsmasqWarnings_chkbox") : null;
if (chkboxData !== null) {
// Restore checkbox state
nonfatalwarnigns.prop("checked", chkboxData === "true");
} else {
if (chkboxData === null) {
// Initialize checkbox
nonfatalwarnigns.prop("checked", false);
if (localStorage) {
localStorage.setItem("hideNonfatalDnsmasqWarnings_chkbox", false);
}
} else {
// Restore checkbox state
nonfatalwarnigns.prop("checked", chkboxData === "true");
}
nonfatalwarnigns.on("click", function () {

View File

@@ -243,7 +243,7 @@ function stateLoadCallback(itemName) {
// Receive previous state from client's local storage area
if (localStorage === null) {
var item = backupStorage[itemName];
data = typeof item === "undefined" ? null : item;
data = item === "undefined" ? null : item;
} else {
data = localStorage.getItem(itemName);
}
@@ -310,15 +310,7 @@ function addFromQueryLog(domain, list) {
},
success: function (response) {
alProcessing.hide();
if (!response.success) {
// Failure
alNetworkErr.hide();
alCustomErr.html(response.message);
alFailure.fadeIn(1000);
setTimeout(function () {
alertModal.modal("hide");
}, 10000);
} else {
if (response.success) {
// Success
alSuccess.children(alDomain).text(domain);
alSuccess.children(alList).text(listtype);
@@ -326,6 +318,14 @@ function addFromQueryLog(domain, list) {
setTimeout(function () {
alertModal.modal("hide");
}, 2000);
} else {
// Failure
alNetworkErr.hide();
alCustomErr.html(response.message);
alFailure.fadeIn(1000);
setTimeout(function () {
alertModal.modal("hide");
}, 10000);
}
},
error: function () {