Add a link to search for incomplete profiles

This commit is contained in:
James Nylen 2020-05-04 21:49:22 +00:00
parent de7db578ba
commit f6384c90cb

View file

@ -17,9 +17,19 @@ function setupSearch() {
searchExplanation.id = 'search-explanation'; searchExplanation.id = 'search-explanation';
searchExplanation.innerHTML = ( searchExplanation.innerHTML = (
'Use the text box above to search all of our company data.' 'Use the text box above to search all of our company data.'
+ ' You can also '
+ '<a href="#" id="search-incomplete">search for incomplete company profiles</a>.'
); );
table.parentNode.insertBefore( searchExplanation, table ); table.parentNode.insertBefore( searchExplanation, table );
document.getElementById( 'search-incomplete' )
.addEventListener( 'click', function( event ) {
event.preventDefault();
searchInput.value = '_incomplete';
initializeSearch();
updateSearch();
} );
var searchLoading = false; var searchLoading = false;
var searchData = null; var searchData = null;
var searchIndex = null; var searchIndex = null;
@ -155,7 +165,7 @@ function setupSearch() {
} ); } );
} }
searchInput.addEventListener( 'focus', function() { function initializeSearch() {
if ( searchData || searchLoading ) { if ( searchData || searchLoading ) {
return; return;
} }
@ -189,7 +199,9 @@ function setupSearch() {
}; };
xhr.send(); xhr.send();
} ); }
searchInput.addEventListener( 'focus', initializeSearch );
searchInput.addEventListener( 'keyup', function() { searchInput.addEventListener( 'keyup', function() {
if ( updateTimeout ) { if ( updateTimeout ) {