From 015923746c4d3db65cb7eef3327b34532a7c1ae9 Mon Sep 17 00:00:00 2001 From: Hsieh Chin Fan Date: Tue, 10 Dec 2024 20:02:29 +0800 Subject: nginx: autoindex -> fancyindex --- nginx/modules/fancyindex/addNginxFancyIndexForm.js | 33 ++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 nginx/modules/fancyindex/addNginxFancyIndexForm.js (limited to 'nginx/modules/fancyindex/addNginxFancyIndexForm.js') diff --git a/nginx/modules/fancyindex/addNginxFancyIndexForm.js b/nginx/modules/fancyindex/addNginxFancyIndexForm.js new file mode 100644 index 0000000..c0d7506 --- /dev/null +++ b/nginx/modules/fancyindex/addNginxFancyIndexForm.js @@ -0,0 +1,33 @@ +// addNginxFancyIndexForm.js +// Add a small form to filter through the output of Nginx FancyIndex page +// © 2017, Lilian Besson (Naereen) and contributors, +// open-sourced under the MIT License, https://lbesson.mit-license.org/ +// hosted on GitHub, https://GitHub.com/Naereen/Nginx-Fancyindex-Theme +var form = document.createElement('form'); +var input = document.createElement('input'); + +input.name = 'filter'; +input.id = 'search'; +input.placeholder = 'Type to search...'; + +form.appendChild(input); + +document.querySelector('h1').after(form); + +var listItems = [].slice.call(document.querySelectorAll('#list tbody tr')); + +input.addEventListener('keyup', function () { + var i, + // Word sequence _matching_ to input. All, except last, words must be _complete_. + e = "(^|.*[^\\pL])" + this.value.trim().split(/\s+/).join("([^\\pL]|[^\\pL].*[^\\pL])") + ".*$", + n = RegExp(e, "i"); + listItems.forEach(function(item) { + item.removeAttribute('hidden'); + }); + listItems.filter(function(item) { + i = item.querySelector('td').textContent.replace(/\s+/g, " "); + return !n.test(i); + }).forEach(function(item) { + item.hidden = true; + }); +}); -- cgit v1.2.3-70-g09d2