diff --git a/scripts/pi-hole/js/index.js b/scripts/pi-hole/js/index.js index c3ea4e0ac1..1da97c816c 100644 --- a/scripts/pi-hole/js/index.js +++ b/scripts/pi-hole/js/index.js @@ -295,31 +295,32 @@ function updateTopClientsTable(blocked) { // Add note if there are no results (e.g. privacy mode enabled) if (jQuery.isEmptyObject(data.clients)) { clienttable.append('
- No data -
'); - } else { - // Populate table with content - data.clients.forEach(function (client) { - // Sanitize client - let clientname = client.name; - if (clientname.length === 0) clientname = client.ip; - url = - '' + - utils.escapeHtml(clientname) + - ""; - percentage = (client.count / sum) * 100; - - // Add row to table - clienttable.append( - " " + - utils.addTD(url) + - utils.addTD(client.count) + - utils.addTD(utils.colorBar(percentage, sum, style)) + - " " - ); - }); + return; } + // Populate table with content + data.clients.forEach(function (client) { + // Sanitize client + let clientname = client.name; + if (clientname.length === 0) clientname = client.ip; + url = + '' + + utils.escapeHtml(clientname) + + ""; + percentage = (client.count / sum) * 100; + + // Add row to table + clienttable.append( + " " + + utils.addTD(url) + + utils.addTD(client.count) + + utils.addTD(utils.colorBar(percentage, sum, style)) + + " " + ); + }); + // Hide overlay overlay.hide(); }).fail(function (data) { @@ -352,25 +353,26 @@ function updateTopDomainsTable(blocked) { // Add note if there are no results (e.g. privacy mode enabled) if (jQuery.isEmptyObject(data.domains)) { domaintable.append('
- No data -
'); - } else { - // Populate table with content - data.domains.forEach(function (item) { - // Sanitize domain - domain = encodeURIComponent(item.domain); - // Substitute "." for empty domain lookups - urlText = domain === "" ? "." : domain; - url = '' + urlText + ""; - percentage = (item.count / sum) * 100; - domaintable.append( - " " + - utils.addTD(url) + - utils.addTD(item.count) + - utils.addTD(utils.colorBar(percentage, sum, style)) + - " " - ); - }); + return; } + // Populate table with content + data.domains.forEach(function (item) { + // Sanitize domain + domain = encodeURIComponent(item.domain); + // Substitute "." for empty domain lookups + urlText = domain === "" ? "." : domain; + url = '' + urlText + ""; + percentage = (item.count / sum) * 100; + domaintable.append( + " " + + utils.addTD(url) + + utils.addTD(item.count) + + utils.addTD(utils.colorBar(percentage, sum, style)) + + " " + ); + }); + overlay.hide(); }).fail(function (data) { apiFailure(data);