f9a3c489186a9c3bedd1548ea86394964769062c
max
  Thu Jun 30 02:16:26 2022 -0700
fixing copy button which mysteriously broke after build, refs #29583

diff --git src/hg/js/hgHubConnect.js src/hg/js/hgHubConnect.js
index cc5609c..eb17eed 100644
--- src/hg/js/hgHubConnect.js
+++ src/hg/js/hgHubConnect.js
@@ -94,37 +94,43 @@
         }
     });
     $('#hubSearchTerms').bind('keypress', function(e) {  // binds listener to text field
         if (e.which === 13) {  // listens for return key
             e.preventDefault();   // prevents return from also submitting whole form
             $('input[name="hubSearchButton"]').focus().click(); // clicks search button
         }
     });
     $('#hubDbFilter').bind('keypress', function(e) {  // binds listener to text field
         if (e.which === 13) {  // listens for return key
             e.preventDefault();   // prevents return from also submitting whole form
             $('input[name="hubSearchButton"]').focus().click(); // clicks db filter button
         }
     });
     $('.pasteIcon').bind('click', function(e) {
-        // the genome=hg19-part is stored in the <A> element two elements before
-        var link = e.target.parentElement.previousSibling.previousSibling;
+        // The genome=hg19-part is stored in the <A> element two elements before the icon SVG:
+        // Because the HTML code generated by the CGI looks like this:
+        // <td>
+        // <a href="hgTracks?hubUrl=https://hgwdev-kent.gi.ucsc.edu/~kent/t2t/hub/hub2.txt&amp;genome=hub_25068_GCA_009914755&amp;position=lastDbPos">GCA_009914755</a>
+        // <input type="hidden" value="https://hgwdev-kent.gi.ucsc.edu/~kent/t2t/hub/hub2.txt">
+        // <svg class="pasteIcon">...</svg>    <--- this is e.target
+        // </td>
+        var link = e.target.previousSibling.previousSibling;
         var href = link.href;
         var genomeArg = href.split("&")[1];
 
         // the url is in the <input> element just before the SVG
-        var copyText = e.target.parentElement.previousSibling;
+        var copyText = e.target.previousSibling;
         var myBaseUrl = copyText.baseURI.split('?')[0];
         var hgTracksUrl = myBaseUrl.replace("hgHubConnect", "hgTracks");
         var oldVal = copyText.value;
         copyText.value = hgTracksUrl+"?hubUrl="+copyText.value+"&"+genomeArg;
         copyText.style.display = 'none';
         copyText.type = 'text';
         copyText.select();
         copyText.setSelectionRange(0, 99999); /* For mobile devices */
         document.execCommand('copy');
         copyText.type = 'hidden';
         alert("Copied URL to clipboard: " + copyText.value);
         copyText.value = oldVal;
     });
 
 });