Skip to content

Commit

Permalink
Loop over all IPs to populate tooltip even when MAXIPDISPLAY is reached
Browse files Browse the repository at this point in the history
Signed-off-by: RD WebDesign <github@rdwebdesign.com.br>
  • Loading branch information
rdwebdesign committed Aug 8, 2024
1 parent 88bf5a6 commit 4aa049b
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions scripts/pi-hole/js/network.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ $(function () {
rowCallback: function (row, data) {
var color;
var index;
var maxiter;
var iconClasses;
var lastQuery = parseInt(data.lastQuery, 10);
var diff = getTimestamp() - lastQuery;
Expand Down Expand Up @@ -137,18 +136,21 @@ $(function () {
$("td:eq(5)", row).html(data.numQueries.toLocaleString());

var ips = [],
iptxt = [];
maxiter = Math.min(data.ips.length, MAXIPDISPLAY);
for (index = 0; index < maxiter; index++) {
var ip = data.ips[index];
iptitles = [];

for (index = 0; index < data.ips.length; index++) {
var ip = data.ips[index],
iptext = ip.ip;

if (ip.name !== null && ip.name.length > 0) {
iptxt.push(ip.ip + " (" + ip.name + ")");
ips.push(
'<a href="queries.lp?client_ip=' + ip.ip + '">' + ip.ip + " (" + ip.name + ")</a>"
);
} else {
iptxt.push(ip.ip);
ips.push('<a href="queries.lp?client_ip=' + ip.ip + '">' + ip.ip + "</a>");
iptext = iptext + " (" + ip.name + ")";
}

iptitles.push(iptext);

// Only add IPs to the table if we have not reached the maximum
if (index < MAXIPDISPLAY) {
ips.push('<a href="queries.lp?client_ip=' + ip.ip + '">' + iptext + "</a>");
}
}

Expand All @@ -157,7 +159,7 @@ $(function () {
// have more to show here
ips.push("...");
// Show the IPs on the title when there are more than MAXIPDISPLAY items
$("td:eq(0)", row).attr("title", iptxt.join("\n"));
$("td:eq(0)", row).attr("title", iptitles.join("\n"));
}

// Show the IPs in the first column
Expand Down

0 comments on commit 4aa049b

Please sign in to comment.