add ability to filter the container list

This commit is contained in:
Danny Colin
2022-07-15 14:20:49 -04:00
parent 7dee05ec1f
commit 47062d2bea
4 changed files with 41 additions and 2 deletions
+18 -1
View File
@@ -51,7 +51,6 @@ async function getExtensionInfo() {
return extensionInfo;
}
// This object controls all the panels, identities and many other things.
const Logic = {
_identities: [],
@@ -465,6 +464,23 @@ const Logic = {
default:
break;
}
},
filterContainerList() {
const pattern = /^\s+|\s+$/g;
const list = Array.from(document.querySelectorAll("#identities-list tr"));
const search = document.querySelector("#search-terms").value.replace(pattern, "").toLowerCase();
for (const i in list) {
const text = list[i].querySelector("td div span");
if (text.innerText.replace(pattern, "").toLowerCase().includes(search) ||
!search) {
list[i].style.display = "block";
} else {
list[i].style.display = "none";
}
}
}
};
@@ -847,6 +863,7 @@ Logic.registerPanel(P_CONTAINERS_LIST, {
document.addEventListener("keydown", Logic.keyboardNavListener);
document.addEventListener("keydown", Logic.shortcutListener);
document.addEventListener("input", Logic.filterContainerList);
MozillaVPN.handleContainerList(identities);