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 = ''; + headerRow += 'count'; + headerRow += 'name'; + headerRow += 'scientificName'; + headerRow += 'commonName'; + headerRow += 'clade'; + headerRow += 'description'; + headerRow += ''; + tableHeader.innerHTML = headerRow; + var count = 0; for (const id in genomicEntries) { var dataRow = ''; dataRow += "" + ++count + ""; var urlReference = id; if (genomicEntries[id].browserExists) { if (id.startsWith("GC")) { urlReference = "" + id + ""; } else { urlReference = "" + id + ""; } } dataRow += "" + urlReference + ""; dataRow += "" + genomicEntries[id].scientificName + ""; dataRow += "" + genomicEntries[id].commonName + "";