07e88d43994dd561d2834443864d09b6098d13e6 jnavarr5 Fri May 9 16:39:52 2025 -0700 Adding an HTML ID for context-specific help links, refs #35724 diff --git src/hg/lib/web.c src/hg/lib/web.c index 569e44fd39f..4d0835b555d 100644 --- src/hg/lib/web.c +++ src/hg/lib/web.c @@ -1414,38 +1414,41 @@ if (link) { if (toFile == NULL) hPrintf("%s",link); else fprintf(toFile,"%s",link); freeMem(link); return TRUE; } return FALSE; } // overrides for default context specific help link. char *contextSpecificHelpLink = NULL; char *contextSpecificHelpLabel = NULL; +char *contextSpecificHelpId = NULL; -void setContextSpecificHelp(char *link, char *label) +void setContextSpecificHelp(char *link, char *label, char *id) // Override default behavior for the context specific help link { if(link) contextSpecificHelpLink = cloneString(link); if(label) contextSpecificHelpLabel = cloneString(label); +if(id) + contextSpecificHelpId = cloneString(id); } char *menuBarAddUiVars(char *oldString, char *cgiPrefix, char *uiVars) /* Look for CGI program calls in oldString, and add session vars hgsid to them */ { int len = strlen(oldString); char buf[4096]; /* Create a regular expression and compile it */ regex_t re; regmatch_t match[2]; safef(buf, sizeof(buf), "%s[A-Za-z]+(%c%c?)", cgiPrefix, '\\', '?'); int err = regcomp(&re, buf, REG_EXTENDED); if(err) errAbort("regcomp failed; err: %d", err); @@ -1589,85 +1592,97 @@ dyStringFree(&viewMenu); } else if (!endsWith(scriptName, "hgTracks")) { replaceChars(menuStr, "<!-- OPTIONAL_VIEW_MENU -->", ""); } dyStringFree(&viewItems); } if(scriptName) { // Provide context sensitive help links for some CGIs. char *link = NULL; char *label = NULL; + char *id = NULL; if (endsWith(scriptName, "hgBlat")) { link = "../goldenPath/help/hgTracksHelp.html#BLATAlign"; label = "Help on Blat"; + id = "hgBlatHelp"; } else if (endsWith(scriptName, "hgHubConnect")) { link = "../goldenPath/help/hgTrackHubHelp.html"; label = "Help on Track Hubs"; + id = "hgHubConnectHelp"; } else if (endsWith(scriptName, "hgNear")) { link = "../goldenPath/help/hgNearHelp.html"; label = "Help on Gene Sorter"; + id = "hgNearHelp"; } else if (endsWith(scriptName, "hgTables")) { link = "../goldenPath/help/hgTablesHelp.html"; label = "Help on Table Browser"; + id = "hgTablesHelp"; } else if (endsWith(scriptName, "hgIntegrator")) { link = "../goldenPath/help/hgIntegratorHelp.html"; label = "Help on Data Integrator"; + id = "hgIntegratorHelp"; } else if (endsWith(scriptName, "hgGenome")) { link = "../goldenPath/help/hgGenomeHelp.html"; label = "Help on Genome Graphs"; + id = "hgGenomeHelp"; } else if (endsWith(scriptName, "hgSession")) { link = "../goldenPath/help/hgSessionHelp.html"; label = "Help on Sessions"; + id = "hgSessionHelp"; } else if (endsWith(scriptName, "hgVisiGene")) { link = "../goldenPath/help/hgTracksHelp.html#VisiGeneHelp"; label = "Help on VisiGene"; + id = "hgVisiGeneHelp"; } else if (endsWith(scriptName, "hgCustom")) { link = "../goldenPath/help/customTrack.html"; label = "Help on Custom Tracks"; + id = "hgCustomHelp"; } // Don't overwrite any previously set defaults if(!contextSpecificHelpLink && link) contextSpecificHelpLink = link; if(!contextSpecificHelpLabel && label) contextSpecificHelpLabel = label; + if(!contextSpecificHelpId && id) + contextSpecificHelpId = id; } if(contextSpecificHelpLink) { char buf[1024]; - safef(buf, sizeof(buf), "<li><a href='%s'>%s</a></li>", contextSpecificHelpLink, contextSpecificHelpLabel); + safef(buf, sizeof(buf), "<li><a id='%s' href='%s'>%s</a></li>", contextSpecificHelpId, contextSpecificHelpLink, contextSpecificHelpLabel); menuStr = replaceChars(menuStr, "<!-- CONTEXT_SPECIFIC_HELP -->", buf); } // links to hgTracks need to use the web browser width and set the hgTracks image // size in pixels correctly to match the hgGateway "GO" button jsInline("$(\"#tools1 ul li a\").each( function (a) {\n" " if (this.href && this.href.indexOf(\"hgTracks\") !== -1) {\n" " var obj = this;\n" " obj.onclick = function(e) {\n" " var pix = calculateHgTracksWidth();\n" " e.currentTarget.href += \"&pix=\" + pix;\n" " }\n" " }\n" "});\n"); return menuStr;