1f0b23fe45c8fd5c2a6e2416dbc864f8f6cbf9ab
gperez2
  Sun May 4 22:13:34 2025 -0700
Edits to hgGateway.c and hgGateway.js following Jairo's code review feedback, #35591

diff --git src/hg/hgGateway/hgGateway.c src/hg/hgGateway/hgGateway.c
index e5cd235920a..861baac32c0 100644
--- src/hg/hgGateway/hgGateway.c
+++ src/hg/hgGateway/hgGateway.c
@@ -21,31 +21,30 @@
 #include "htmshell.h"
 #include "hubConnect.h"
 #include "hui.h"
 #include "jsHelper.h"
 #include "jsonParse.h"
 #include "obscure.h"  // for readInGulp
 #include "regexHelper.h"
 #include "suggest.h"
 #include "trackHub.h"
 #include "web.h"
 #include "botDelay.h"
 #include "genark.h"
 #include "assemblyList.h"
 #include <limits.h>
 
-
 /* Global Variables */
 struct cart *cart = NULL;             /* CGI and other variables */
 struct hash *oldVars = NULL;          /* Old contents of cart before it was updated by CGI */
 
 static boolean issueBotWarning = FALSE;
 static int measureTiming = 0;
 static long enteredMainTime = 0;
 
 #define SEARCH_TERM "hggw_term"
 
 static char *maybeGetDescriptionText(char *db)
 /* Slurp the description.html file for db into a string (if possible, don't die if
  * we can't read it) and return it. */
 {
 struct errCatch *errCatch = errCatchNew();
@@ -400,38 +399,39 @@
 webIncludeResourceFile("jquery-ui.css");
 jsIncludeFile("jquery-ui.js", NULL);
 jsIncludeFile("jquery.watermarkinput.js", NULL);
 jsIncludeFile("autocompleteCat.js",NULL);
 jsIncludeFile("utils.js",NULL);
 
 // Phylogenetic tree .js file, produced by dbDbTaxonomy.pl:
 char *defaultDbDbTree = webTimeStampedLinkToResource("dbDbTaxonomy.js", FALSE);
 char *dbDbTree = cfgOptionDefault("hgGateway.dbDbTaxonomy", defaultDbDbTree);
 if (isNotEmpty(dbDbTree))
     printf("<script src=\"%s\"></script>\n", dbDbTree);
 
 // Main JS for hgGateway:
 jsIncludeFile("hgGateway.js", NULL);
 
-// Shepherd.js CSS - fine to load this synchronously
+if (cfgOptionBooleanDefault("showTutorial", TRUE))
+    {
     puts("<link rel=\"stylesheet\" href=\"https://cdn.jsdelivr.net/npm/shepherd.js@11.0.1/dist/css/shepherd.css\" />");
+    puts("<script src=\"https://cdn.jsdelivr.net/npm/shepherd.js@11.0.1/dist/js/shepherd.min.js\"></script>");
+    jsIncludeFile("gatewayTutorial.js", NULL);
 
-// Shepherd.js script (load async + defer)
-puts("<script src=\"https://cdn.jsdelivr.net/npm/shepherd.js@11.0.1/dist/js/shepherd.min.js\" defer></script>");
-
-// Load Gateway tutorial
-puts("<script src=\"../js/gatewayTutorial.js\" defer></script>");
+    if (sameOk(cgiOptionalString("startTutorial"), "true"))
+        jsInline("var startTutorialOnLoad = true;");
+    }
 
 #define TIMING_WARNING_BOX_START "<div id='hogWarningRow' class='jwRow'>" \
          "<div id='hogWarningBox' class='jwWarningBox'>"
 #define TIMING_WARNING_BOX_END "</div></div>"
 if (measureTiming)
     {
     printf("%selapsed time %ld ms (%d ms bottleneck)%s\n",
 	TIMING_WARNING_BOX_START, clock1000() - enteredMainTime,
 	botDelayMillis, TIMING_WARNING_BOX_END);
     }
 webIncludeFile("inc/jWestFooter.html");
 
 cartFlushHubWarnings();
 
 webEndJWest();