Fossil SCM

add graceful fallback for users without Javascript

jkosche 2025-05-24 12:27 quickfilter
Commit 6280151831c0c0a63cc4df301a27da1d3c1233e68ce7400ebebe352f8ed5769f
--- src/quickfilter.js
+++ src/quickfilter.js
@@ -8,10 +8,15 @@
88
**
99
** The user can type to filter the table for elements matching the typed text.
1010
*/
1111
1212
const quickfilter = document.getElementById('quickfilter');
13
+
14
+document.addEventListener('DOMContentLoaded', function(){
15
+ quickfilter.style.display = '';
16
+});
17
+
1318
quickfilter.addEventListener('input', function(){
1419
const filterrows = document.querySelectorAll('.filterable tbody tr');
1520
const filter = quickfilter.value.toLowerCase().trim();
1621
for(row of filterrows){
1722
const orig = row.innerHTML;
1823
--- src/quickfilter.js
+++ src/quickfilter.js
@@ -8,10 +8,15 @@
8 **
9 ** The user can type to filter the table for elements matching the typed text.
10 */
11
12 const quickfilter = document.getElementById('quickfilter');
 
 
 
 
 
13 quickfilter.addEventListener('input', function(){
14 const filterrows = document.querySelectorAll('.filterable tbody tr');
15 const filter = quickfilter.value.toLowerCase().trim();
16 for(row of filterrows){
17 const orig = row.innerHTML;
18
--- src/quickfilter.js
+++ src/quickfilter.js
@@ -8,10 +8,15 @@
8 **
9 ** The user can type to filter the table for elements matching the typed text.
10 */
11
12 const quickfilter = document.getElementById('quickfilter');
13
14 document.addEventListener('DOMContentLoaded', function(){
15 quickfilter.style.display = '';
16 });
17
18 quickfilter.addEventListener('input', function(){
19 const filterrows = document.querySelectorAll('.filterable tbody tr');
20 const filter = quickfilter.value.toLowerCase().trim();
21 for(row of filterrows){
22 const orig = row.innerHTML;
23
+2 -2
--- src/repolist.c
+++ src/repolist.c
@@ -405,11 +405,11 @@
405405
** for display. */
406406
login_check_credentials();
407407
style_set_current_feature("repolist");
408408
style_header("Repository List");
409409
if( quickfilter ){
410
- @ <input type="search" id="quickfilter" placeholder="filter repository list...">
410
+ @ <input type="search" id="quickfilter" style="display: none" placeholder="filter repository list...">
411411
}
412412
@ %s(blob_str(&html))
413413
style_table_sorter();
414414
if( quickfilter ){
415415
style_quickfilter();
@@ -426,11 +426,11 @@
426426
@ <title>%h(zTitle)</title>
427427
@ </head>
428428
@ <body>
429429
@ <h1 align="center">%h(zTitle)</h1>
430430
if( quickfilter ){
431
- @ <input type="search" id="quickfilter" placeholder="filter repository list...">
431
+ @ <input type="search" id="quickfilter" style="display: none" placeholder="filter repository list...">
432432
}
433433
@ %s(blob_str(&html))
434434
@ <script>%s(builtin_text("sorttable.js"))</script>
435435
if( quickfilter ){
436436
@ <script>%s(builtin_text("quickfilter.js"))</script>
437437
--- src/repolist.c
+++ src/repolist.c
@@ -405,11 +405,11 @@
405 ** for display. */
406 login_check_credentials();
407 style_set_current_feature("repolist");
408 style_header("Repository List");
409 if( quickfilter ){
410 @ <input type="search" id="quickfilter" placeholder="filter repository list...">
411 }
412 @ %s(blob_str(&html))
413 style_table_sorter();
414 if( quickfilter ){
415 style_quickfilter();
@@ -426,11 +426,11 @@
426 @ <title>%h(zTitle)</title>
427 @ </head>
428 @ <body>
429 @ <h1 align="center">%h(zTitle)</h1>
430 if( quickfilter ){
431 @ <input type="search" id="quickfilter" placeholder="filter repository list...">
432 }
433 @ %s(blob_str(&html))
434 @ <script>%s(builtin_text("sorttable.js"))</script>
435 if( quickfilter ){
436 @ <script>%s(builtin_text("quickfilter.js"))</script>
437
--- src/repolist.c
+++ src/repolist.c
@@ -405,11 +405,11 @@
405 ** for display. */
406 login_check_credentials();
407 style_set_current_feature("repolist");
408 style_header("Repository List");
409 if( quickfilter ){
410 @ <input type="search" id="quickfilter" style="display: none" placeholder="filter repository list...">
411 }
412 @ %s(blob_str(&html))
413 style_table_sorter();
414 if( quickfilter ){
415 style_quickfilter();
@@ -426,11 +426,11 @@
426 @ <title>%h(zTitle)</title>
427 @ </head>
428 @ <body>
429 @ <h1 align="center">%h(zTitle)</h1>
430 if( quickfilter ){
431 @ <input type="search" id="quickfilter" style="display: none" placeholder="filter repository list...">
432 }
433 @ %s(blob_str(&html))
434 @ <script>%s(builtin_text("sorttable.js"))</script>
435 if( quickfilter ){
436 @ <script>%s(builtin_text("quickfilter.js"))</script>
437
+1 -1
--- src/report.c
+++ src/report.c
@@ -1233,11 +1233,11 @@
12331233
@ <br>
12341234
}
12351235
output_color_key(zClrKey, 1,
12361236
"border=\"0\" cellpadding=\"3\" cellspacing=\"0\" class=\"report\"");
12371237
if( quickfilter ){
1238
- @ <input type="search" id="quickfilter" placeholder="filter ticket list...">
1238
+ @ <input type="search" id="quickfilter" style="display: none" placeholder="filter ticket list...">
12391239
}
12401240
@ <table border="1" cellpadding="2" cellspacing="0" class="report sortable filterable"
12411241
@ data-column-types='' data-init-sort='0'>
12421242
sState.rn = rn;
12431243
sState.nCount = 0;
12441244
--- src/report.c
+++ src/report.c
@@ -1233,11 +1233,11 @@
1233 @ <br>
1234 }
1235 output_color_key(zClrKey, 1,
1236 "border=\"0\" cellpadding=\"3\" cellspacing=\"0\" class=\"report\"");
1237 if( quickfilter ){
1238 @ <input type="search" id="quickfilter" placeholder="filter ticket list...">
1239 }
1240 @ <table border="1" cellpadding="2" cellspacing="0" class="report sortable filterable"
1241 @ data-column-types='' data-init-sort='0'>
1242 sState.rn = rn;
1243 sState.nCount = 0;
1244
--- src/report.c
+++ src/report.c
@@ -1233,11 +1233,11 @@
1233 @ <br>
1234 }
1235 output_color_key(zClrKey, 1,
1236 "border=\"0\" cellpadding=\"3\" cellspacing=\"0\" class=\"report\"");
1237 if( quickfilter ){
1238 @ <input type="search" id="quickfilter" style="display: none" placeholder="filter ticket list...">
1239 }
1240 @ <table border="1" cellpadding="2" cellspacing="0" class="report sortable filterable"
1241 @ data-column-types='' data-init-sort='0'>
1242 sState.rn = rn;
1243 sState.nCount = 0;
1244
--- www/javascript.md
+++ www/javascript.md
@@ -489,10 +489,14 @@
489489
490490
### <a id="filter"></a>Quickfilter
491491
492492
On some pages adding the ability to filter a table of items down to the
493493
rows matching the text typed in by the user.
494
+
495
+_Graceful Fallback:_ The input field for typing your search does not
496
+appear when JS is unavailable, removing a feature that would be unusable
497
+without Javascript.
494498
495499
496500
### <a id="tree"></a>File Browser Tree View
497501
498502
The [file browser’s tree view mode][tv] uses JavaScript to handle clicks
499503
--- www/javascript.md
+++ www/javascript.md
@@ -489,10 +489,14 @@
489
490 ### <a id="filter"></a>Quickfilter
491
492 On some pages adding the ability to filter a table of items down to the
493 rows matching the text typed in by the user.
 
 
 
 
494
495
496 ### <a id="tree"></a>File Browser Tree View
497
498 The [file browser’s tree view mode][tv] uses JavaScript to handle clicks
499
--- www/javascript.md
+++ www/javascript.md
@@ -489,10 +489,14 @@
489
490 ### <a id="filter"></a>Quickfilter
491
492 On some pages adding the ability to filter a table of items down to the
493 rows matching the text typed in by the user.
494
495 _Graceful Fallback:_ The input field for typing your search does not
496 appear when JS is unavailable, removing a feature that would be unusable
497 without Javascript.
498
499
500 ### <a id="tree"></a>File Browser Tree View
501
502 The [file browser’s tree view mode][tv] uses JavaScript to handle clicks
503

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button