Skip to content

Commit d91ebff

Browse files
committed
Add basic search/filtering
I struggled to find the module of interest. This PR adds a basic search filter to the page. Just load the page, then type the module name and the list on the left will be filtered to match what you type. Any non a-z character (such as Esc) clears the filter. No UI, because I couldn't face it.
1 parent c268e98 commit d91ebff

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

buildSrc/src/main/resources/template.html

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,29 @@
116116
}
117117
showImage(document.getElementsByClassName("item")[0], "build-order.png");
118118

119+
// Basic filtering with no ui... just type things
120+
let search = '';
121+
function filter(text) {
122+
Array.from(document.getElementsByClassName("item")).forEach(li => {
123+
const cell = li.getElementsByTagName("td");
124+
if (cell.length === 0) {
125+
// Not a module...
126+
} else if (cell[0].innerText.includes(text) || text === null) {
127+
// make li visible
128+
li.style.display = "block";
129+
} else {
130+
li.style.display = "none";
131+
}
132+
});
133+
}
134+
document.addEventListener("keydown", event => {
135+
if (event.keyCode >= 65 && event.keyCode <= 90) {
136+
search = (search == null ? '' : search) + event.key;
137+
} else {
138+
search = null;
139+
}
140+
filter(search);
141+
});
119142
</script>
120143
</body>
121144
</html>

0 commit comments

Comments
 (0)