324020eced2a302856ea0cbec8942b374337a3f8 chmalee Mon Oct 31 10:02:26 2022 -0700 When a user has entered a search term that resolves to a single position, such as an empty chromosome name or HGVS term, have the client redirect straight to hgTracks, refs #29693 diff --git src/hg/js/hgSearch.js src/hg/js/hgSearch.js index 69ec7f5..6db98a4 100644 --- src/hg/js/hgSearch.js +++ src/hg/js/hgSearch.js @@ -775,30 +775,42 @@ window.location = window.location.href.replace(re,"db="+newDb); } function init() { cart.setCgi('hgSearch'); cart.debug(debugCartJson); // If a user clicks search before the page has finished loading // start processing it now: $("#searchBarSearchButton").click(sendUserSearch); if (typeof cartJson !== "undefined") { if (cartJson.db !== undefined) { db = cartJson.db; } else { alert("Error no database from request"); } + // check right away for a special redirect to hgTracks: + if (cartJson.positionMatches !== undefined && + cartJson.positionMatches.length == 1 && + cartJson.positionMatches[0].matches[0].doRedirect === true) { + match = cartJson.positionMatches[0].matches[0]; + position = match.position; + newUrl = "../cgi-bin/hgTracks" + "?db=" + db + "&position=" + position; + if (match.highlight) { + newUrl += "&highlight=" + match.highlight; + } + window.location.replace(newUrl); + } var urlParts = {}; if (debugCartJson) { console.log('from server:\n', cartJson); } if (typeof cartJson.search !== "undefined") { urlParts = changeUrl({"search": cartJson.search}); } else { urlParts = changeUrl({"db": db}); cartJson.search = urlParts.urlVars.search; } _.assign(uiState,cartJson); if (typeof cartJson.categs !== "undefined") { _.each(uiState.positionMatches, function(match) { uiState.resultHash[match.name] = match; });