a9f92e1f57d906e8c985d8d1894057d00878a782 hiram Wed Aug 21 10:10:10 2024 -0700 record requests made so can avoid repeating request refs #32596 diff --git src/hg/js/assemblySearch.js src/hg/js/assemblySearch.js index fb444a1..dfd6944 100644 --- src/hg/js/assemblySearch.js +++ src/hg/js/assemblySearch.js @@ -1,25 +1,27 @@ // global variables: var measureTiming = false; var urlParams; var searchFor = ""; var maxItemsOutput = 500; var asmIdText = null; var betterCommonName = null; var comment = null; var requestSubmitButton = null; +var completedAsmId = new Map(); // keep track of requests completed + // so they won't be repeated // This function is called on DOMContentLoaded as the initialization // procedure for first time page draw document.addEventListener('DOMContentLoaded', function() { // allow semi colon separators as well as ampersand var queryString = window.location.search.replaceAll(";", "&"); urlParams = new URLSearchParams(queryString); if (urlParams.has('measureTiming')) { // accepts no value or other string var measureValue = urlParams.get('measureTiming'); if ("0" === measureValue | "off" === measureValue) { measureTiming = false; } else { // any other string turns it on measureTiming = true; } } @@ -77,31 +79,31 @@ } document.getElementById("measureTiming").style.display = "none"; }); // refresh the thead columns in the specified table function headerRefresh(tableHead) { // clear existing content tableHead.innerHTML = ''; // 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 += '
view/
request ⓘ"view" opens the genome browser for an existing assembly, "request" opens an assembly request form.
'; headerRow += '
English common name ⓘEnglish common name
'; headerRow += '
scientific name (count) ⓘbinomial scientific name
'; - headerRow += '
NCBI Assembly ⓘLinks to NCBI resource record.
'; + headerRow += '
NCBI Assembly ⓘLinks to NCBI resource record
or UCSC downloads for local UCSC assemblies
'; headerRow += '
genark clade ⓘclade specification as found in the GenArk system.
'; headerRow += '
description ⓘother meta data for this assembly.
'; headerRow += ''; tableHead.innerHTML = headerRow; } // 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('resultCounts').innerHTML = ""; document.getElementById('elapsedTime').innerHTML = "0"; // Clear existing table content @@ -115,45 +117,46 @@ for (var key in jsonData) { if (jsonData[key].scientificName) { genomicEntries[key] = jsonData[key]; } else { extraInfo[key] = jsonData[key]; } } headerRefresh(tableHeader); var count = 0; for (var id in genomicEntries) { var dataRow = ''; var browserUrl = id; - var ncbiUrl = id; + var asmInfoUrl = id; if (genomicEntries[id].browserExists) { if (id.startsWith("GC")) { browserUrl = "view"; - ncbiUrl = "" + id + ""; + asmInfoUrl = "" + id + ""; } else { browserUrl = "view"; + asmInfoUrl = "" + id + ""; } dataRow += "" + browserUrl + ""; } else { dataRow += ""; } dataRow += "" + genomicEntries[id].scientificName + ""; dataRow += "" + genomicEntries[id].commonName + ""; - dataRow += "" + ncbiUrl + ""; + dataRow += "" + asmInfoUrl + ""; dataRow += "" + genomicEntries[id].clade + ""; dataRow += "" + genomicEntries[id].description + ""; dataRow += ''; tableBody.innerHTML += dataRow; } var dataTable = document.getElementById('dataTable'); sorttable.makeSortable(dataTable); var itemCount = parseInt(extraInfo.itemCount, 10); var totalMatchCount = parseInt(extraInfo.totalMatchCount, 10); var availableAssemblies = parseInt(extraInfo.availableAssemblies, 10); var resultCounts = "results for search string: '" + extraInfo.genomeSearch + "', "; if ( itemCount === totalMatchCount ) { resultCounts += "showing " + itemCount.toLocaleString() + " match results, "; @@ -348,31 +351,39 @@ var descr = "n/a"; var i = 0; for (i = 0; i < colGroup.children.length; i++) { if (colGroup.children[i].id === "comName") { comName = pTable.rows[thisRow].cells[i].innerText; } else if (colGroup.children[i].id === "sciName") { sciName = pTable.rows[thisRow].cells[i].innerText; } else if (colGroup.children[i].id === "description") { descr = pTable.rows[thisRow].cells[i].innerText; } } document.getElementById("commonName").textContent = comName; document.getElementById("formSciName").textContent = sciName; document.getElementById("formAsmId").textContent = e.name; document.getElementById("comment").textContent = descr; + if (completedAsmId.has(e.name)) { + requestSubmitButton.value = "request completed"; + requestSubmitButton.disabled = false; + document.getElementById("modalWrapper").className = "overlay"; + return; + } else { + completedAsmId.set(e.name, true); requestSubmitButton.value = "Submit request"; + } document.getElementById("modalWrapper").className = "overlay"; requestSubmitButton.disabled = false; var overflow = modalWindow.offsetHeight - document.documentElement.clientHeight; if (overflow > 0) { modalWindow.style.maxHeight = (parseInt(window.getComputedStyle(modalWindow).height) - overflow) + "px"; } modalWindow.style.marginTop = (-modalWindow.offsetHeight)/2 + "px"; modalWindow.style.marginLeft = (-modalWindow.offsetWidth)/2 + "px"; } if (e.preventDefault) { e.preventDefault(); } else { e.returnValue = false; } }