summaryrefslogtreecommitdiffhomepage
path: root/nginx/modules/fancyindex/addNginxFancyIndexForm.js
diff options
context:
space:
mode:
authorHsieh Chin Fan <pham@topo.tw>2024-12-10 20:02:29 +0800
committerHsieh Chin Fan <pham@topo.tw>2024-12-10 20:02:29 +0800
commit015923746c4d3db65cb7eef3327b34532a7c1ae9 (patch)
treefca4a7a4df00ec9e8d0dcd16e65bd6982e0ac0b5 /nginx/modules/fancyindex/addNginxFancyIndexForm.js
parent8442e6126f13a98eb010e5495793807ffabdc0ca (diff)
nginx: autoindex -> fancyindex
Diffstat (limited to 'nginx/modules/fancyindex/addNginxFancyIndexForm.js')
-rw-r--r--nginx/modules/fancyindex/addNginxFancyIndexForm.js33
1 files changed, 33 insertions, 0 deletions
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 @@
1// addNginxFancyIndexForm.js
2// Add a small form to filter through the output of Nginx FancyIndex page
3// © 2017, Lilian Besson (Naereen) and contributors,
4// open-sourced under the MIT License, https://lbesson.mit-license.org/
5// hosted on GitHub, https://GitHub.com/Naereen/Nginx-Fancyindex-Theme
6var form = document.createElement('form');
7var input = document.createElement('input');
8
9input.name = 'filter';
10input.id = 'search';
11input.placeholder = 'Type to search...';
12
13form.appendChild(input);
14
15document.querySelector('h1').after(form);
16
17var listItems = [].slice.call(document.querySelectorAll('#list tbody tr'));
18
19input.addEventListener('keyup', function () {
20 var i,
21 // Word sequence _matching_ to input. All, except last, words must be _complete_.
22 e = "(^|.*[^\\pL])" + this.value.trim().split(/\s+/).join("([^\\pL]|[^\\pL].*[^\\pL])") + ".*$",
23 n = RegExp(e, "i");
24 listItems.forEach(function(item) {
25 item.removeAttribute('hidden');
26 });
27 listItems.filter(function(item) {
28 i = item.querySelector('td').textContent.replace(/\s+/g, " ");
29 return !n.test(i);
30 }).forEach(function(item) {
31 item.hidden = true;
32 });
33});