Skip to content

Commit f0038b8

Browse files
ventunotrentmwillis
authored andcommitted
HTML Reporter: Change how the list of modules is rendered and filtered.
1 parent ec81c83 commit f0038b8

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

reporter/html.js

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -334,17 +334,17 @@ export function escapeText( s ) {
334334
return filter;
335335
}
336336

337-
function moduleListHtml() {
337+
function moduleListHtml( modules ) {
338338
var i, checked,
339339
html = "";
340340

341-
for ( i = 0; i < config.modules.length; i++ ) {
342-
if ( config.modules[ i ].name !== "" ) {
343-
checked = config.moduleId.indexOf( config.modules[ i ].moduleId ) > -1;
341+
for ( i = 0; i < modules.length; i++ ) {
342+
if ( modules[ i ].name !== "" ) {
343+
checked = config.moduleId.indexOf( modules[ i ].moduleId ) > -1;
344344
html += "<li><label class='clickable" + ( checked ? " checked" : "" ) +
345-
"'><input type='checkbox' " + "value='" + config.modules[ i ].moduleId + "'" +
345+
"'><input type='checkbox' " + "value='" + modules[ i ].moduleId + "'" +
346346
( checked ? " checked='checked'" : "" ) + " />" +
347-
escapeText( config.modules[ i ].name ) + "</label></li>";
347+
escapeText( modules[ i ].name ) + "</label></li>";
348348
}
349349
}
350350

@@ -402,7 +402,7 @@ export function escapeText( s ) {
402402
addEvent( commit, "click", applyUrlParams );
403403

404404
dropDownList.id = "qunit-modulefilter-dropdown-list";
405-
dropDownList.innerHTML = moduleListHtml();
405+
dropDownList.innerHTML = moduleListHtml( config.modules );
406406

407407
dropDown.id = "qunit-modulefilter-dropdown";
408408
dropDown.style.display = "none";
@@ -448,20 +448,20 @@ export function escapeText( s ) {
448448
}
449449
}
450450

451+
function filterModules( searchText ) {
452+
return config.modules
453+
.filter( module => module.name.toLowerCase().indexOf( searchText ) > -1 );
454+
}
455+
451456
// Processes module search box input
457+
var searchInputTimeout;
452458
function searchInput() {
453-
var i, item,
454-
searchText = moduleSearch.value.toLowerCase(),
455-
listItems = dropDownList.children;
456-
457-
for ( i = 0; i < listItems.length; i++ ) {
458-
item = listItems[ i ];
459-
if ( !searchText || item.textContent.toLowerCase().indexOf( searchText ) > -1 ) {
460-
item.style.display = "";
461-
} else {
462-
item.style.display = "none";
463-
}
464-
}
459+
window.clearTimeout( searchInputTimeout );
460+
searchInputTimeout = window.setTimeout( () => {
461+
var searchText = moduleSearch.value.toLowerCase(),
462+
filteredModules = filterModules( searchText );
463+
dropDownList.innerHTML = moduleListHtml( filteredModules );
464+
}, 200 );
465465
}
466466

467467
// Processes selection changes

0 commit comments

Comments
 (0)