779b0a67557941da1d0402d9d6f2952ff54fb479 hiram Mon Apr 27 16:48:42 2026 -0700 add API assemblyRequest endpoint properly manage requests from the assemblySearch page system refs #31811 diff --git src/hg/js/assemblySearch.js src/hg/js/assemblySearch.js index 7475b09f83e..5f24e802dc9 100644 --- src/hg/js/assemblySearch.js +++ src/hg/js/assemblySearch.js @@ -534,55 +534,49 @@ document.addEventListener("keydown", keyHandler, false); } else { document.getElementById("modalClose").attachEvent("onclick", closeModal); document.attachEvent("onclick", clickHandler); document.attachEvent("onkeydown", keyHandler); } } function failedRequest(url) { requestSubmitButton.value = "request failed"; requestSubmitButton.disabled = true; // garStatus.innerHTML = "FAILED: '" + url + "'"; } function sendRequest(name, email, asmId, betterName, comment) { - var urlComponents = encodeURIComponent(name) + "&email=" + encodeURIComponent(email) + "&asmId=" + encodeURIComponent(asmId) + "&betterName=" + encodeURIComponent(betterName) + "&comment=" + encodeURIComponent(comment); + var url = "/cgi-bin/hubApi/assemblyRequest?" + + "asmId=" + encodeURIComponent(asmId) + ";" + + "name=" + encodeURIComponent(name) + ";" + + "email=" + encodeURIComponent(email) + ";" + + "betterName=" + encodeURIComponent(betterName) + ";" + + "comment=" + encodeURIComponent(comment); - var url = "/cgi-bin/asr?name=" + urlComponents; -// information about escaping characters: -// https://stackoverflow.com/questions/10772066/escaping-special-character-in-a-url/10772079 -// encodeURI() will not encode: ~!@#$&*()=:/,;?+' -// encodeURIComponent() will not encode: ~!*()' - -// var encoded = encodeURIComponent(url); -// encoded = encoded.replace("'","’"); -// var encoded = encodeURI(cleaner); var xmlhttp = new XMLHttpRequest(); xmlhttp.onreadystatechange = function() { if (4 === this.readyState && 200 === this.status) { requestSubmitButton.value = "request completed"; - } else { - if (4 === this.readyState && 404 === this.status) { + } else if (4 === this.readyState && this.status >= 400) { failedRequest(url); } - } }; xmlhttp.open("GET", url, true); xmlhttp.send(); -} // sendRequest: function(name, email. asmId) +} // sendRequest: function(name, email, asmId, betterName, comment) // borrowed this code from utils.js function copyToClipboard(ev) { /* copy a piece of text to clipboard. event.target is some DIV or SVG that is an icon. * The attribute data-target of this element is the ID of the element that contains the text to copy. * The text is either in the attribute data-copy or the innerText. * see C function printCopyToClipboardButton(iconId, targetId); * */ ev.preventDefault(); var buttonEl = ev.target.closest("button"); // user can click SVG or BUTTON element var targetId = buttonEl.getAttribute("data-target"); if (targetId===null)