@@ -33,6 +33,13 @@ if (window.location.search.length > 0) {
3333 resultsList . sort ( 'status-sort' , { order : "desc" } ) ;
3434}
3535
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+
3643// Record URL parameters after new sort (but do not update URL yet)
3744resultsList . on ( 'sortComplete' , function updateSortURL ( ) {
3845 var sortElements = document . getElementsByClassName ( 'sort' ) ;
@@ -184,3 +191,24 @@ function countClasses() {
184191 badge . innerHTML = count . toString ( ) ;
185192 }
186193}
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