1
Fork 0
mirror of https://github.com/caddyserver/caddy.git synced 2024-12-16 21:56:40 -05:00

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

This allows creating links that display only a subset of files in a directory.
This commit is contained in:
Jeremy Lin 2020-02-08 11:36:37 -08:00 committed by GitHub
parent 9bdd6caa0b
commit 98bbc54fdc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -228,7 +228,7 @@ footer {
}
</style>
</head>
<body onload='filter()'>
<body onload='initFilter()'>
<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;">
<defs>
<!-- Folder -->
@ -379,6 +379,16 @@ footer {
var filterEl = document.getElementById('filter');
filterEl.focus();
function initFilter() {
if (!filterEl.value) {
var filterParam = new URL(window.location.href).searchParams.get('filter');
if (filterParam) {
filterEl.value = filterParam;
}
}
filter();
}
function filter() {
var q = filterEl.value.trim().toLowerCase();
var elems = document.querySelectorAll('tr.file');