6ebcc1b85cd5bd3a14205dc7552d35a80f1b3efa chmalee Fri Oct 28 14:53:40 2022 -0700 Fix bogus no results message when entering hgSearch with no cgi arguments, refs #29693 diff --git src/hg/js/hgSearch.js src/hg/js/hgSearch.js index ad601d8..d85f865 100644 --- src/hg/js/hgSearch.js +++ src/hg/js/hgSearch.js @@ -597,31 +597,31 @@ subList.innerHTML += "<input type='hidden' id='" + idAttr.value + "_" + categoryCount + "showMore' value='0'>"; subList.innerHTML += "<img height='18' width='18' id='" + idAttr.value + "_" + categoryCount + "_showMoreButton' src='../images/add_sm.gif'>"; if (matches.length > 500) subList.innerHTML += "<div class='showMoreDiv' id='" + idAttr.value+"_"+categoryCount+"_showMoreDiv'> Show 490 (out of " + (matches.length) + " total) more matches for " + searchDesc + "</div></li>"; else subList.innerHTML += "<div class='showMoreDiv' id='" + idAttr.value+"_"+categoryCount+"_showMoreDiv'> Show " + (matches.length - 10) + " more matches for " + searchDesc + "</div></li>"; } newListObj.append(subList); newList.append(newListObj); // make result list collapsible: $('#'+idAttr.value+categoryCount+"_button").click(collapseNode); $('#'+idAttr.value+"_" +categoryCount+"_showMoreButton").click(showMoreResults); categoryCount += 1; }); - } else if (uiState) { + } else if (uiState && uiState.search !== undefined) { // No results from match var msg = "<p>No results for: <b>" + uiState.search + "<b></p>"; parentDiv.empty(); parentDiv.html(msg); clearOldFacetCounts(); } else { parentDiv.empty(); } } function fillOutAssemblies(e) { organism = $("#speciesSelect")[0].value; select = $("#dbSelect"); select.empty(); _.each(_.sortBy(uiState.genomes[organism], ['orderKey']), function(assembly) { @@ -720,31 +720,31 @@ updateStateAndPage(jsonData, true); } $("#spinner").remove(); } function handleErrorState(jqXHR, textStatus) { cart.defaultErrorCallback(jqXHR, textStatus); $("#spinner").remove(); } function sendUserSearch() { // User has clicked the search button, if they also entered a search // term, fire off a search cart.debug(debugCartJson); var searchTerm = $("#searchBarSearchString").val().replaceAll("\"",""); - if (searchTerm !== undefined) { + if (searchTerm !== undefined && searchTerm.length > 0) { // put up a loading image $("#searchBarSearchButton").after("<i id='spinner' class='fa fa-spinner fa-spin'></i>"); // if the user entered a plain position string like chr1:blah-blah, just // go to the old cgi/hgTracks var canonMatch = searchTerm.match(canonicalRangeExp); var gbrowserMatch = searchTerm.match(gbrowserRangeExp); var lengthMatch = searchTerm.match(lengthRangeExp); var bedMatch = searchTerm.match(bedRangeExp); var sqlMatch = searchTerm.match(sqlRangeExp); var singleMatch = searchTerm.match(singleBaseExp); var positionMatch = canonMatch || gbrowserMatch || lengthMatch || bedMatch || sqlMatch || singleMatch; if (positionMatch !== null) { var prevCgi = uiState.prevCgi !== undefined ? uiState.prevCgi : "hgTracks"; window.location.replace("../cgi-bin/" + prevCgi + "?db=" + db + "position=" + searchTerm);