aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian T <julian@jtle.dk>2019-09-18 20:52:14 +0200
committerJulian T <julian@jtle.dk>2019-09-18 20:52:14 +0200
commit923393d6f50b8df486125bdff224588086e44266 (patch)
tree9a4fe959a37efc154a1df574d758eb91d60760bc
parentc14b6a9b3e2f0a6128750e967c67f8324b46c0d3 (diff)
Added cool search function
-rw-r--r--index.sh33
1 files changed, 33 insertions, 0 deletions
diff --git a/index.sh b/index.sh
index 8650d4e..cc597d3 100644
--- a/index.sh
+++ b/index.sh
@@ -3,6 +3,11 @@
echo '# Julian Noter'
echo
+cat << EOF
+<input type="text" id="search" onkeyup="filter(event)" placeholder="Search">
+
+EOF
+
# Make toc
HTML_FILES=$@
@@ -10,3 +15,31 @@ for url in $HTML_FILES; do
echo "- [$url]($url)"
done
+cat << EOF
+
+<script>
+function filter(e) {
+ var li = document.getElementsByTagName('li');
+
+
+ var input = document.getElementById('search');
+ var filter = input.value.toUpperCase();
+
+ for (i = 0; i < li.length; i++) {
+ var a = li[i].getElementsByTagName("a")[0];
+ txtValue = a.textContent || a.innerText;
+ if (txtValue.toUpperCase().indexOf(filter) > -1) {
+ li[i].style.display = "";
+ if( e.key == "Enter") {
+ window.location.href = a.href;
+ return;
+ }
+ } else {
+ li[i].style.display = "none";
+ }
+ }
+}
+
+</script>
+EOF
+