8a78199eaca4cb4996a056fdb69d1824ec89aed1
chmalee
  Mon Apr 3 11:28:33 2023 -0700
Explicitly set the CGI variable 'org' when doing an hgGateway ucsc db lookup, refs #30816

diff --git src/hg/js/hgGateway.js src/hg/js/hgGateway.js
index 3a8e083..bac3494 100644
--- src/hg/js/hgGateway.js
+++ src/hg/js/hgGateway.js
@@ -1394,53 +1394,53 @@
         // Note: it is not necessary to re-.Watermark if we upgrade the plugin to version >= 3.1
         $input.css('color', 'black');
         $input.val('').Watermark(watermark ,'#686868');
     }
 
     function clearSpeciesInput() {
         // Replace anything typed into the species input with the watermark.
         clearWatermarkInput($('#speciesSearch'), speciesWatermark);
     }
 
     function clearPositionInput() {
         // Replace anything typed into the position input with the watermark.
         clearWatermarkInput($('#positionInput'), positionWatermark);
     }
 
-    function setTaxId(taxId, db, doScrollToItem, doClearSpeciesInput) {
+    function setTaxId(taxId, db, org, doScrollToItem, doClearSpeciesInput) {
         // The user has selected a species (and possibly even a particular database) --
         // if we're not already using it, change to it.
         var cmd;
         if (uiState.hubUrl !== null || taxId !== uiState.taxId || (db && db !== uiState.db)) {
             uiState.taxId = taxId;
             uiState.hubUrl = null;
-            cmd = { setTaxId: { taxId: '' + taxId } };
+            cmd = { setTaxId: { taxId: '' + taxId, org: org } };
             if (db) {
                 uiState.db = db;
                 cmd.setTaxId.db = db;
             }
             cart.send(cmd, handleSetTaxId);
             cart.flush();
             clearPositionInput();
         }
         highlightLabel('textEl_' + taxId, doScrollToItem);
         if (doClearSpeciesInput) {
             clearSpeciesInput();
         }
   }
 
-    function setHubDb(hubUrl, taxId, db, hubName, isAutocomplete) {
+    function setHubDb(hubUrl, taxId, db, hubName, org, isAutocomplete) {
         // User clicked on a hub name (switch to its default genome) or selected an
         // assembly hub from autocomplete (switch to that assembly hub db).
         var cmd;
         if (hubUrl !== uiState.hubUrl ||
             (isAutocomplete && db !== uiState.db)) {
             uiState.hubUrl = hubUrl;
             uiState.taxId = taxId;
             uiState.db = trackHubSkipHubName(db);
             // Use cart variables to connect to the selected hub and switch to db
             // (hubConnectLoadHubs, called by cartNew)
             cmd = { cgiVar: { hubUrl: hubUrl,
                               genome: trackHubSkipHubName(db) },
                     setHubDb: { hubUrl: hubUrl,
                                 taxId: '' + taxId }
                     };
@@ -1448,45 +1448,46 @@
             cart.flush();
             clearPositionInput();
         }
         highlightLabel('textEl_' + hubName, isAutocomplete);
         if (! isAutocomplete) {
             clearSpeciesInput();
         }
     }
 
 
     function setDbFromAutocomplete(item) {
         // The user has selected a result from the species-search autocomplete.
         // It might be a taxId and/or db from dbDb, or it might be a hub db.
         var taxId = item.taxId || -1;
         var db = item.db;
+        var org = item.org;
         if (item.hubUrl) {
             // The autocomplete sends the hub database from hubPublic.dbList,
             // without the hub prefix -- restore the prefix here.
             db = item.hubName + '_' + item.db;
-            setHubDb(item.hubUrl, taxId, db, item.hubName, true);
+            setHubDb(item.hubUrl, taxId, db, item.hubName, org, true);
         } else {
-            setTaxId(taxId, item.db, true, false);
+            setTaxId(taxId, item.db, org, true, false);
         }
     }
 
     function onClickSpeciesLabel(taxId) {
         // When user clicks on a label, use that taxId (default db);
         // don't scroll to the label because if they clicked on it they can see it already;
         // do clear the autocomplete input.
-        setTaxId(taxId, null, false, true);
+        setTaxId(taxId, null, null, false, true);
     }
 
     function onClickHubName(hubUrl, taxId, db, hubName) {
         // This is just a wrapper -- the draw module has to know all about the contents
         // of each hub object in hubList anyway.
         setHubDb(hubUrl, taxId, db, hubName, false);
     }
 
     function onChangeDbMenu() {
         // The user selected a different db for this genome; get db info from server.
         var db = $('#selectAssembly').val();
         var cmd;
         if (db !== uiState.db) {
             setAssemblyDescriptionTitle(db, uiState.genome);
             cmd = { setDb: { db: db, position: "lastDbPos" } };