@@ -33,6 +33,13 @@ if (window.location.search.length > 0) {
33
33
resultsList . sort ( 'status-sort' , { order : "desc" } ) ;
34
34
}
35
35
36
+ // Show a message if no tests match current filters
37
+ var alertPlaceholder = document . getElementById ( 'noResultsAlert' ) ;
38
+ warnIfNone ( ) ; // Initialize
39
+ resultsList . on ( 'updated' , function ( ) {
40
+ warnIfNone ( ) ;
41
+ } )
42
+
36
43
// Record URL parameters after new sort (but do not update URL yet)
37
44
resultsList . on ( 'sortComplete' , function updateSortURL ( ) {
38
45
var sortElements = document . getElementsByClassName ( 'sort' ) ;
@@ -184,3 +191,24 @@ function countClasses() {
184
191
badge . innerHTML = count . toString ( ) ;
185
192
}
186
193
}
194
+
195
+ function warnIfNone ( ) {
196
+ if ( resultsList . visibleItems . length === 0 ) { // Show info box
197
+ alertPlaceholder . innerHTML = '<div class="alert alert-info" role="alert">' +
198
+ '<h4 class="alert-heading">No tests found</h4>' +
199
+ '<p class="m-0">Try adjusting any active filters or searches, or ' +
200
+ '<a href="javascript:clearAll()" class="alert-link">clear all</a>.</p>' +
201
+ '</div>' ;
202
+ } else { // Remove info box
203
+ alertPlaceholder . innerHTML = '' ;
204
+ }
205
+ }
206
+
207
+ // Clear active search and filters
208
+ function clearAll ( ) {
209
+ document . getElementsByClassName ( 'search' ) [ 0 ] . value = '' ;
210
+ resultsList . search ( '' ) ;
211
+ searchParams . delete ( 'q' ) ;
212
+ resetFilters ( ) ;
213
+ updateURL ( ) ;
214
+ }
0 commit comments