15724fd4a6d6bc917c1ed86367a39cdf40404852 max Mon Jun 13 08:44:30 2022 -0700 improving the "my hubs" tab of hgHubConnect, refs #29583 diff --git src/hg/js/hgHubConnect.js src/hg/js/hgHubConnect.js index acf8c18..f802688 100644 --- src/hg/js/hgHubConnect.js +++ src/hg/js/hgHubConnect.js @@ -93,30 +93,52 @@ $('input[name="hubValidateButton"]').focus().click(); // clicks Validate Url button } }); $('#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; + 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 myBaseUrl = copyText.baseURI.split('?')[0]; + var hgTracksUrl = myBaseUrl.replace("hgHubConnect", "hgTracks"); + var oldVal = copyText.value; + copyText.value = hgTracksUrl+"?hubUrl="+copyText.value+"&"+genomeArg; + copyText.type = 'text'; + copyText.select(); + copyText.setSelectionRange(0, 99999); /* For mobile devices */ + document.execCommand('copy'); + alert("Copied the URL " + copyText.value + " to the clipboard"); + copyText.value = oldVal; + copyText.type = 'hidden'; + //navigator.clipboard.writeText(copyText.value); + }); + }); var hubSearchTree = (function() { var treeDiv; // Points to div we live in function hubSearchTreeContextMenuHandler (node, callback) { var nodeType = node.li_attr.nodetype; if (nodeType == 'track') { callback({ 'openConfig': { 'label' : 'Configure this track', 'action' : function () { window.open(node.li_attr.configlink, '_blank'); } }