Skip to content

Commit

Permalink
Handle allow- and blocklists separately from each other in Search
Browse files Browse the repository at this point in the history
Signed-off-by: DL6ER <dl6er@dl6er.de>
  • Loading branch information
DL6ER committed Feb 13, 2024
1 parent d7cf23b commit 2098a11
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions scripts/pi-hole/js/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,11 @@ function eventsource(partial) {
// Group results in res.gravity by res.gravity[].address
var grouped = {};
for (const list of res.gravity) {
if (grouped[list.address] === undefined) {
grouped[list.address] = [];
if (grouped[list.address + "_" + list.type] === undefined) {
grouped[list.address + "_" + list.type] = [];
}

grouped[list.address].push(list);
grouped[list.address + "_" + list.type].push(list);
}

const numLists = Object.keys(grouped).length;
Expand All @@ -112,14 +112,14 @@ function eventsource(partial) {
"</strong>'" +
(numLists > 0 ? ":" : ".") +
"<br><br>";
for (const address of Object.keys(grouped)) {
const list = grouped[address][0];
for (const listId of Object.keys(grouped)) {
const list = grouped[listId][0];
const color = list.type === "block" ? "red" : "green";
result +=
" - <a href='groups-lists.lp?listid=" +
list.id +
"' target='_blank'>" +
utils.escapeHtml(address) +
utils.escapeHtml(list.address) +
"</a><br> <strong class='text-" +
color +
"'>" +
Expand All @@ -144,7 +144,7 @@ function eventsource(partial) {
? '<br> comment: "' + utils.escapeHtml(list.comment) + '"'
: "<br> no comment") +
"<br> matching entries:<br>";
for (const lists of grouped[address]) {
for (const lists of grouped[listId]) {
result +=
" - <strong class='text-blue'>" + utils.escapeHtml(lists.domain) + "</strong><br>";
}
Expand Down

0 comments on commit 2098a11

Please sign in to comment.