ff24452dd4f8ae69c2f45c1fc481b71abbafb406 hiram Sat Aug 17 23:52:49 2024 -0700 refresh the header row so the sorttable will function properly refs #32596 diff --git src/hg/js/assemblySearch.js src/hg/js/assemblySearch.js index bdcf16a..f8832b0 100644 --- src/hg/js/assemblySearch.js +++ src/hg/js/assemblySearch.js @@ -8,53 +8,68 @@ }); searchForm.addEventListener('submit', function(event) { event.preventDefault(); // Prevent form submission var searchTerm = document.getElementById('searchBox').value; var resultCountLimit = document.getElementById('limitResultCount'); var browserExist = document.querySelector('input[name="browserExist"]:checked').value; var wordMatch = document.querySelector('input[name="wordMatch"]:checked').value; makeRequest(searchTerm, browserExist, resultCountLimit.value, wordMatch); }); }); // Function to generate the table and extra information function populateTableAndInfo(jsonData) { + var tableHeader = document.getElementById('tableHeader'); var tableBody = document.getElementById('tableBody'); var metaData = document.getElementById('metaData'); document.getElementById('searchString').innerHTML = ""; document.getElementById('matchCounts').innerHTML = "0"; document.getElementById('availableAssemblies').innerHTML = "0"; document.getElementById('elapsedTime').innerHTML = "0"; // Clear existing table content + tableHeader.innerHTML = ''; tableBody.innerHTML = ''; metaData.innerHTML = ''; // Extract the genomic entries and the extra info const genomicEntries = {}; const extraInfo = {}; for (const key in jsonData) { if (jsonData[key].scientificName) { genomicEntries[key] = jsonData[key]; } else { extraInfo[key] = jsonData[key]; } } + // re-populate header row - the sortable system added a class to + // the last sorted column, need to rebuild the headerRow to get the + // header back to pristine condition for the next sort + var headerRow = '<tr>'; + headerRow += '<th>count</th>'; + headerRow += '<th>name</th>'; + headerRow += '<th>scientificName</th>'; + headerRow += '<th>commonName</th>'; + headerRow += '<th>clade</th>'; + headerRow += '<th>description</th>'; + headerRow += '</tr>'; + tableHeader.innerHTML = headerRow; + var count = 0; for (const id in genomicEntries) { var dataRow = '<tr>'; dataRow += "<th>" + ++count + "</th>"; var urlReference = id; if (genomicEntries[id].browserExists) { if (id.startsWith("GC")) { urlReference = "<a href='/h/" + id + "?position=lastDbPos' target=_blank>" + id + "</a>"; } else { urlReference = "<a href='/cgi-bin/hgTracks?db=" + id + "' target=_blank>" + id + "</a>"; } } dataRow += "<th>" + urlReference + "</th>"; dataRow += "<td>" + genomicEntries[id].scientificName + "</td>"; dataRow += "<td>" + genomicEntries[id].commonName + "</td>";