929d72bd9fa34529245e7969d992a8977da365af hiram Mon Aug 26 14:42:56 2024 -0700 now with RefSeq representative and RefSeq latest selection options refs #32596 diff --git src/hg/js/assemblySearch.js src/hg/js/assemblySearch.js index 3e71f2b..c5b8472 100644 --- src/hg/js/assemblySearch.js +++ src/hg/js/assemblySearch.js @@ -131,30 +131,41 @@ document.getElementById('mustExist').checked = true; } if (stateObject.browser === "notExist") { document.getElementById('notExist').checked = true; } if (stateObject.browser === "mayExist") { document.getElementById('mustExist').checked = true; document.getElementById('notExist').checked = true; } advancedSearchVisible(stateObject.advancedSearchVisible); if (stateObject.wordMatch === "allWords") { document.getElementById("allWords").checked = true; } else { document.getElementById("anyWord").checked = true; } + if (stateObject.refSeqLatest) { + document.getElementById('refSeqLatest').checked = true; + } else { + document.getElementById('refSeqLatest').checked = false; + } + if (stateObject.refSeqRepresentative) { + document.getElementById('refSeqRepresentative').checked = true; + } else { + document.getElementById('refSeqRepresentative').checked = false; + } + document.getElementById('searchBox').value = stateObject.queryString; populateTableAndInfo(JSON.parse(stateObject.jsonData)); // alert("state: '" + JSON.stringify(stateObject) + "'"); } }); var tableHeader = document.getElementById('tableHeader'); headerRefresh(tableHeader); if (urlParams.has('maxItemsOutput')) { maxItemsOutput = parseInt(urlParams.get('maxItemsOutput'), 10); if (maxItemsOutput < 1) { maxItemsOutput = 1; } else if (maxItemsOutput > 1000) { maxItemsOutput = 1000; @@ -498,74 +509,89 @@ } modalWindow.style.marginTop = (-modalWindow.offsetHeight)/2 + "px"; modalWindow.style.marginLeft = (-modalWindow.offsetWidth)/2 + "px"; } if (e.preventDefault) { e.preventDefault(); } else { e.returnValue = false; } } function makeRequest(query, browserExist, resultLimit, wordMatch) { // Disable the submit button disableButtons(); var queryString = query; + // if 'latest' requested, add '+latest' if not already in query + if (document.getElementById('refSeqLatest').checked) { + if (! /latest/.test(queryString) ) { + queryString += " +latest"; + } + } + if (document.getElementById('refSeqRepresentative').checked) { + if (! /representative/.test(queryString) ) { + queryString += " +representative"; + } + } // for allWords, place + sign in front of each word if not already there if (wordMatch === "allWords") { - var words = query.split(/\s+/); + var words = queryString.split(/\s+/); if (words.length > 1) { // not needed on only one word var queryPlus = ""; // compose new query string words.forEach(function(word) { if (word.startsWith("+")) { queryPlus += " " + word; // space separates each word } else { queryPlus += " +" + word; } }); - queryString = queryPlus.trimStart(); // remove first space character + queryString = queryPlus.trim(); } } + // remove stray white space from beginning or end + queryString = queryString.trim(); // Show the wait spinner document.querySelector(".submitContainer").classList.add("loading"); document.getElementById("loadingSpinner").style.display = "block"; var xhr = new XMLHttpRequest(); var urlPrefix = "/cgi-bin/hubApi"; var url = "/findGenome?q=" + encodeURIComponent(queryString); url += ";browser=" + browserExist; url += ";maxItemsOutput=" + resultLimit; var historyUrl = "?q=" + encodeURIComponent(queryString) + ";browser=" + browserExist + ";maxItemsOutput=" + resultLimit; if (debug) { historyUrl += ";debug=1"; } if (measureTiming) { historyUrl += ";measureTiming=1"; } if (debug) { var apiUrl = "<a href='" + urlPrefix + url + "' target=_blank>" + url + "</a>"; document.getElementById("recentAjax").innerHTML = apiUrl; } stateObject.queryString = queryString; stateObject.maxItemsOutput = maxItemsOutput; stateObject.browser = browserExist; stateObject.debug = debug; stateObject.measureTiming = measureTiming; stateObject.wordMatch = wordMatch; + stateObject.refSeqLatest = document.getElementById('refSeqLatest').checked; + stateObject.refSeqRepresentative = document.getElementById('refSeqRepresentative').checked; xhr.open('GET', urlPrefix + url, true); xhr.onload = function() { if (xhr.status === 200) { // Hide the wait spinner once the AJAX request is complete document.querySelector(".submitContainer").classList.remove("loading"); document.getElementById("loadingSpinner").style.display = "none"; enableButtons(); stateObject.jsonData = xhr.responseText; history.pushState(stateObject, '', historyUrl); var data = JSON.parse(xhr.responseText); populateTableAndInfo(data);