05e67c59a20a5d00b810a981aef3b00c5bef82e1
max
  Fri Sep 20 06:03:18 2024 -0700
more features to hubtools: search in both parent and subdirs, better docs

diff --git src/hg/js/hgTracks.js src/hg/js/hgTracks.js
index 29deda6..81e2ee6 100644
--- src/hg/js/hgTracks.js
+++ src/hg/js/hgTracks.js
@@ -2114,30 +2114,65 @@
 
 };
 
   ///////////////////////////////////////
  //// rightClick (aka context menu) ////
 ///////////////////////////////////////
 var rightClick = {
 
     menu: null,
     selectedMenuItem: null,   // currently choosen context menu item (via context menu).
     floatingMenuItem: null,
     currentMapItem:   null,
     supportZoomCodon: true,  // add zoom to exon and zoom to codon to right click menu
     clickedHighlightIdx : null,  // the index (0,1,...) of the highlight item that overlaps the last right-click
 
+    hideTracks: function (ids) 
+    {
+        var cartVars = [];
+        var cartVals = [];
+
+        for (var i = 0; i<ids.length; i++) {
+            var id = ids[i];
+            var rec = hgTracks.trackDb[id];
+            if (tdbIsSubtrack(rec)) {
+                // Remove subtrack level vis and explicitly uncheck.
+                //cart.setVars( [ id, id+"_sel" ], [ '[]', 0 ] ); 
+                cartVars.push(id);
+                cartVals.push('[]');
+
+                cartVars.push(id+"_sel");
+                cartVals.push(0);
+            } else if (tdbIsFolderContent(rec)) {
+                // supertrack children need to have _sel set to trigger superttrack reshaping
+                //cart.setVars( [ id, id+"_sel" ], [ 'hide', 0 ] ); 
+                cartVars.push(id);
+                cartVals.push('hide');
+
+                cartVars.push(id+"_sel");
+                cartVals.push(0);
+            } else {
+                //cart.setVars([id], ['hide']);  // Others, just set vis hide.
+                cartVars.push(id);
+                cartVals.push('hide');
+            }
+            $(document.getElementById('tr_' + id)).remove();
+        }
+        imageV2.afterImgChange(true);
+        cart.setVars( cartVars, cartVals );
+    },
+
     makeMapItem: function (id)
     {   // Create a dummy mapItem on the fly
         // (for objects that don't have corresponding entry in the map).
         if (id && id.length > 0 && hgTracks.trackDb) {
             var title;
             var rec = hgTracks.trackDb[id];
             if (rec) {
                 title = rec.shortLabel;
             } else {
                 title = id;
             }
             return {id: id, title: "configure " + title};
         } else {
             return null;
         }
@@ -2419,30 +2454,39 @@
                     break;
                 }
             }
 
             $.ajax({
                 type: "PUT",
                 async: false,
                 url: "../cgi-bin/hgCollection",
                 data: "cmd=addTrack&track=" + id + "&collection=" + collectionName + "&hgsid=" + getHgsid(),
                 trueSuccess: mySuccess,
                 success: catchErrorOrDispatch,
                 error: errorHandler,
             });
 
             imageV2.fullReload();
+        } else if (cmd === "hideOthers") {
+            var hideIds = [];
+            for (var otherId in hgTracks.trackDb) {
+                if (otherId!==id) 
+                    hideIds.push(otherId);
+            }
+            rightClick.hideTracks(hideIds);
+        } else if (cmd === "moveTop") {
+
         } else if ((cmd === 'sortExp') || (cmd === 'sortSim')) {
             url = "hgTracks?hgsid=" + getHgsid() + "&" + cmd + "=";
             rec = hgTracks.trackDb[id];
             if (tdbHasParent(rec) && tdbIsLeaf(rec))
                 url += rec.parentTrack;
             else {
                 // The button already has the ref
                 var link2 = normed($( 'td#td_btn_'+ rightClick.selectedMenuItem.id ).children('a')); 
                 if (link2)
                     url = $(link2).attr('href');
                 else
                     url += rightClick.selectedMenuItem.id;
             }
             location.assign(url);
 
@@ -2586,41 +2630,42 @@
                 updateObj[key] = 1;
                 cart.setVarsObj(updateObj,null,false);
                 imageV2.requestImgUpdate(id, id + ".doMergeItems=1");
             }
         } else {   // if ( cmd in 'hide','dense','squish','pack','full','show' )
             // Change visibility settings:
             //
             // First change the select on our form:
             rec = hgTracks.trackDb[id];
             selectUpdated = vis.update(id, cmd);
 
             // Now change the track image
             if (imageV2.enabled && cmd === 'hide') {
                 // Hide local display of this track and update server side cart.
                 // Subtracks controlled by 2 settings so del vis and set sel=0.
-                if (tdbIsSubtrack(rec)) {
+                rightClick.hideTracks([id]);
+                /* if (tdbIsSubtrack(rec)) {
                     // Remove subtrack level vis and explicitly uncheck.
                     cart.setVars( [ id, id+"_sel" ], [ '[]', 0 ] ); 
                 } else if (tdbIsFolderContent(rec)) {
                     // supertrack children need to have _sel set to trigger superttrack reshaping
                     cart.setVars( [ id, id+"_sel" ], [ 'hide', 0 ] ); 
                 } else {
                     cart.setVars([id], ['hide']);  // Others, just set vis hide.
                 }
                 $(document.getElementById('tr_' + id)).remove();
-                imageV2.afterImgChange(true);
+                imageV2.afterImgChange(true); */
             } else if (!imageV2.mapIsUpdateable) {
                 jQuery('body').css('cursor', 'wait');
                 if (selectUpdated) {
                     // assert(document.TrackForm);
                     document.TrackForm.submit();
                 } else {
                         // Add vis update to queue then submit
                         cart.setVars([id], [cmd], null, false); // synchronous
                         document.TrackHeaderForm.submit();
                 }
             } else {
                 imageV2.requestImgUpdate(id, id + "=" + cmd, "", cmd);
             }
         }
     },
@@ -2930,30 +2975,56 @@
                                        title + "...";
                             o[item] = {onclick: function(menuItemClicked, menuObject) {
                                        rightClick.hit(menuItemClicked,menuObject,"followLink");
                                        return true; }
                             };
                             any = true;
                         }
                     }
                     if (any) {
                         menu.push($.contextMenu.separator);
                         menu.push(o);
                     }
                 }
             }
 
+
+            menu.push($.contextMenu.separator);
+            o = {};
+            o[" Hide all other tracks "] = {
+                onclick: function(menuItemClicked, menuObject) {
+                    rightClick.hit(menuItemClicked, menuObject, "hideOthers");
+                    return true; }
+            };  
+            menu.push(o);
+
+            o = {};
+            o[" Move to top "] = {
+                onclick: function(menuItemClicked, menuObject) {
+                    rightClick.hit(menuItemClicked, menuObject, "moveTop");
+                    return true; }
+            };  
+            menu.push(o);
+
+            o = {};
+            o[" Move to bottom "] = {
+                onclick: function(menuItemClicked, menuObject) {
+                    rightClick.hit(menuItemClicked, menuObject, "moveBottom");
+                    return true; }
+            };  
+            menu.push(o);
+
             if (rightClick.selectedMenuItem && rec) {
                 // Add cfg options at just shy of end...
                 o = {};
                 if (tdbIsLeaf(rec)) {
 
                     if (rec.configureBy !== 'none'
                     && (!tdbIsCompositeSubtrack(rec) || rec.configureBy !== 'clickThrough')) {
                         // Note that subtracks never do clickThrough because
                         // parentTrack cfg is the desired clickThrough
                         o[rightClick.makeImgTag("wrench.png")+" Configure "+rec.shortLabel] = {
                             onclick: function(menuItemClicked, menuObject) {
                                 rightClick.hit(menuItemClicked, menuObject, "hgTrackUi_popup");
                                 return true; }
                         };
                     }
@@ -5807,37 +5878,58 @@
         newLink.setAttribute("id", "hgTracksDownload");
         newLink.setAttribute("name", "downloadTracks");
         newLink.textContent = "Download Current Track Data";
         newLink.href = "#";
         newListEl.appendChild(newLink);
         $("#downloads > ul")[0].appendChild(newListEl);
         $("#hgTracksDownload").click(downloadCurrentTrackData.showDownloadUi);
     }
 
     if (typeof showMouseovers !== 'undefined' && showMouseovers) {
         convertTitleTagsToMouseovers();
     }
 
 });
 
-function hgtWarnTiming(maxSeconds) {
+function hgtWarnTimingMinimal() {
+    /* a fallback timing warning that does not require any HTML nor javascript inline blocks using the basic confirm dialog */
+    var skipNotification = localStorage.getItem("hgTracks.hideSpeedNotification");
+    dumpCart(loadSeconds, skipNotification);
+        
+    if (skipNotification)
+        return;
+
+    msg = "This page took more than "+window.hgMaxTimeWarning/1000+" seconds to load. We strive to keep "+
+        "the UCSC Genome Browser quick and responsive. See our "+
+        "<b><a href='../FAQ/FAQtracks.html#speed' target='_blank'>display speed FAQ</a></b> for "+
+        "common causes and solutions to slow performance. If this problem continues, you can create a  "+
+        "session link via <b>My Data</b> &gt; <b>My Sessions</b> and send the link to <b>genome-www@soe.ucsc.edu</b>."+
+        " Hit OK to continue, or cancel to never show this message again."+
+        " As soon as this dialog is closed with either button, all tracks will be hidden, to make the genome browser fast again. ";
+    var isOk = confirm(msg);
+    if (!isOk)
+        localStorage.setItem(key, "1");
+    // this reloads the page and hides all tracks
+    window.location.search += '&hideTracks=1';
+}
+
+function hgtWarnTiming() {
     /* show a dialog box if the page load time was slower than x seconds. Has buttons to hide or never show this again. */
     var loadTime = window.performance.timing.domContentLoadedEventStart-window.performance.timing.navigationStart; /// in msecs
     var loadSeconds = loadTime/1000;
     if (loadSeconds < maxSeconds)
         return;
 
     var skipNotification = localStorage.getItem("hgTracks.hideSpeedNotification");
     dumpCart(loadSeconds, skipNotification);
         
     if (skipNotification)
         return;
 
-    msg = "This page took "+loadSeconds+" seconds to load. We strive to keep "+
+    msg = "This page took seconds to load. We strive to keep "+
         "the UCSC Genome Browser quick and responsive. See our "+
         "<b><a href='../FAQ/FAQtracks.html#speed' target='_blank'>display speed FAQ</a></b> for "+
         "common causes and solutions to slow performance. If this problem continues, you can create a  "+
         "session link via <b>My Data</b> &gt; <b>My Sessions</b> and send the link to <b>genome-www@soe.ucsc.edu</b>.";
     notifBoxSetup("hgTracks", "hideSpeedNotification", msg);
     notifBoxShow("hgTracks", "hideSpeedNotification");
-
 }