|
|
@@ -27,3 +27,57 @@ window["makeTree"] = function (ulRoot) {
|
|
|
for (var i = 0; i < ulRoot.children.length; ++i)
|
|
|
makeTree(ulRoot.children[i]);
|
|
|
}
|
|
|
+
|
|
|
+$(() => {
|
|
|
+ var FILTER = "";
|
|
|
+
|
|
|
+ function treeChildren(root) {
|
|
|
+ let result = [];
|
|
|
+ if (root.classList.contains("treeroot"))
|
|
|
+ return root.children;
|
|
|
+ for (var i of root.children)
|
|
|
+ if (i.classList.contains("treebranch"))
|
|
|
+ for (var j of i.children)
|
|
|
+ if (j.classList.contains("treeitem"))
|
|
|
+ result.push(j);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ function updateUiFilter(filterText, treeNode) {
|
|
|
+ if (isFiltered(filterText, treeNode)) {
|
|
|
+ treeNode.classList.add("hidden");
|
|
|
+ } else {
|
|
|
+ setChildVisibility(treeNode);
|
|
|
+ if ((treeNode.dataset?.fullname?.toLowerCase() || "").indexOf(filterText) >= 0)
|
|
|
+ return;
|
|
|
+ for (var treeBranch of treeChildren(treeNode))
|
|
|
+ updateUiFilter(filterText, treeBranch);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ function setChildVisibility(treeNode) {
|
|
|
+ treeNode.classList.remove("hidden");
|
|
|
+ for (var i of treeNode.querySelectorAll(".treeitem.hidden"))
|
|
|
+ i.classList.remove("hidden");
|
|
|
+ }
|
|
|
+
|
|
|
+ function isFiltered(filterText, node) {
|
|
|
+ return node.textContent.toLowerCase().indexOf(filterText) < 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ function filterUpdated() {
|
|
|
+ updateUiFilter(FILTER.toLowerCase(), document.querySelector(".treeroot"));
|
|
|
+ }
|
|
|
+
|
|
|
+ const searchInput = document.getElementById("searchinput");
|
|
|
+
|
|
|
+ function onSearchInputChanged() {
|
|
|
+ if (FILTER === searchInput.value)
|
|
|
+ return;
|
|
|
+ FILTER = searchInput.value;
|
|
|
+ filterUpdated();
|
|
|
+ }
|
|
|
+ searchInput.addEventListener('input', onSearchInputChanged);
|
|
|
+ onSearchInputChanged();
|
|
|
+});
|
|
|
+
|