@marcel91200 / caddy Mirror · read-only / commits / 98bbc54f
Fork 0

Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS

Mirrored from https://github.com/Slazee/caddy.git

Synced Nov 14, 05:15 UTC

browse: allow filter init via `filter` query param (#3027)

This allows creating links that display only a subset of files in a directory.

Jeremy Lin committed Feb 8, 2020 at 11:36 UTC 98bbc54fdcd05a2f53c10e81be7cf94d1dc62522
1 file changed +11 -1
modules/caddyhttp/fileserver/browsetpl.go
+11 -1
@@ -228,7 +228,7 @@ footer {
228 }
229 </style>
230 </head>
231 - <body onload='filter()'>
231 + <body onload='initFilter()'>
232 <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" height="0" width="0" style="position: absolute;">
233 <defs>
234 <!-- Folder -->
@@ -379,6 +379,16 @@ footer {
379 var filterEl = document.getElementById('filter');
380 filterEl.focus();
381
382 + function initFilter() {
383 + if (!filterEl.value) {
384 + var filterParam = new URL(window.location.href).searchParams.get('filter');
385 + if (filterParam) {
386 + filterEl.value = filterParam;
387 + }
388 + }
389 + filter();
390 + }
391 +
392 function filter() {
393 var q = filterEl.value.trim().toLowerCase();
394 var elems = document.querySelectorAll('tr.file');