[projects/pld-builder.new] queue.html: keep the search and filters over a reload
arekm
arekm at pld-linux.org
Thu Nov 12 09:28:08 CET 2026
commit 8fc23f5e8697060ece5835768e39bdff29414b61
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date: Thu Nov 12 09:27:23 2026 +0100
queue.html: keep the search and filters over a reload
They go into the address (?q=...&from=...&unfinished=1), so a reload
shows the same requests and the link can be sent to someone else.
PLD_Builder/script.js | 13 +++++++++++++
1 file changed, 13 insertions(+)
---
diff --git a/PLD_Builder/script.js b/PLD_Builder/script.js
index 52ab83e..538f28e 100644
--- a/PLD_Builder/script.js
+++ b/PLD_Builder/script.js
@@ -51,10 +51,23 @@ function filter() {
for (; el && el.tagName != 'H2'; el = el.nextElementSibling) any = any || !el.hidden;
day.hidden = !any;
});
+ // kept in the address, so a reload or a link someone is sent shows the same
+ var params = new URLSearchParams();
+ if (search.value) params.set('q', search.value);
+ if (requester.value) params.set('from', requester.value);
+ if (unfinished.checked) params.set('unfinished', '1');
+ var query = params.toString();
+ history.replaceState(null, '', (query ? '?' + query : location.pathname) + location.hash);
}
requester.onchange = unfinished.onchange = filter;
search.oninput = filter;
+var asked = new URLSearchParams(location.search);
+search.value = asked.get('q') || '';
+requester.value = asked.get('from') || '';
+unfinished.checked = asked.has('unfinished');
+if (asked.toString()) filter();
+
// "/" goes to the search, as on many sites; Escape clears it
document.addEventListener('keydown', function(e) {
if (e.key == '/' && document.activeElement != search) {
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/projects/pld-builder.new.git/commitdiff/8fc23f5e8697060ece5835768e39bdff29414b61
More information about the pld-cvs-commit
mailing list