a6177bc07e5dbb520e06cd0b341036efc2ecd3b3 angie Tue Mar 6 14:23:29 2018 -0800 In hgFind, when adding a highlight via URL that the user clicks on, use a new cart variable addHighlight instead of appending to the current highlight string because that can get too long for a URL. refs #21056 diff --git src/hg/hgTracks/hgTracks.c src/hg/hgTracks/hgTracks.c index c8c182a..8b9a6fa 100644 --- src/hg/hgTracks/hgTracks.c +++ src/hg/hgTracks/hgTracks.c @@ -9861,30 +9861,54 @@ hPrintf("<tr><td> zoom out 10x</td><td class=\"hotkey\">K</td> <td> exon view</td><td class=\"hotkey\">e then v</td> </tr>\n"); hPrintf("<tr><td> zoom out 100x</td><td class=\"hotkey\">0</td> <td> default view</td><td class=\"hotkey\">d then v</td> </tr>\n"); hPrintf("<tr><td> zoom to ...</td><td class=\"hotkey\"></td><td> view DNA</td><td class='hotkey'>v then d</td></tr>\n"); hPrintf("<tr><td> 50bp (1 zero)</td><td class=\"hotkey\">1</td><td>Reset all User Settings</td><td class='hotkey'>c then r</td></tr>\n"); hPrintf("<tr><td> 500bp (2 zeros)</td><td class=\"hotkey\">2</td><td>Tools - BLAT</td><td class='hotkey'>t then b</td></tr>\n"); hPrintf("<tr><td> 5000bp (3 zeros)</td><td class=\"hotkey\">3</td><td>Tools - Table Browser</td><td class='hotkey'>t then t</td></tr>\n"); hPrintf("<tr><td> 50kbp (4 zeros)</td><td class=\"hotkey\">4</td><td>Tools - PCR</td><td class='hotkey'>t then i</td></tr>\n"); hPrintf("<tr><td> 500kbp (5 zeros)</td><td class=\"hotkey\">5</td><td>My Sessions</td><td class='hotkey'>s then s</td></tr>\n"); hPrintf("<tr><td> 5Mbp (6 zeros)</td><td class=\"hotkey\">6</td><td>Public Sessions</td><td class='hotkey'>p then s</td></tr>\n"); hPrintf("<tr><td>Highlight all (mark)</td><td class=\"hotkey\">h then m</td><td>Clear all Highlights</td><td class='hotkey'>h then c</td></tr>\n"); hPrintf("</table>\n"); hPrintf("<img style=\"margin:8px\" src=\"../images/shortcutHelp.png\">"); hPrintf("</div>\n"); } +static void checkAddHighlight() +/* If the cart variable addHighlight is set, merge it into the highlight variable. */ +{ +char *newHighlight = cartOptionalString(cart, "addHighlight"); +if (newHighlight) + { + char *existing = cartOptionalString(cart, "highlight"); + if (isNotEmpty(existing)) + { + // Add region only if it is not already in the existing highlight setting. + char *alreadyIn = strstr(existing, newHighlight); + int len = strlen(newHighlight); + if (! (alreadyIn && (alreadyIn[len] == '|' || alreadyIn[len] == '\0'))) + { + struct dyString *dy = dyStringCreate("%s|%s", newHighlight, existing); + cartSetString(cart, "highlight", dy->string); + } + } + else + cartSetString(cart, "highlight", newHighlight); + cartRemove(cart, "addHighlight"); + } +} + void doMiddle(struct cart *theCart) /* Print the body of an html file. */ { cart = theCart; measureTiming = hPrintStatus() && isNotEmpty(cartOptionalString(cart, "measureTiming")); if (measureTiming) measureTime("Startup"); hgBotDelayFrac(0.25); /* Impose a quarter of the standard CGI penalty */ if (measureTiming) measureTime("Bottleneck delay"); char *debugTmp = NULL; /* Uncomment this to see parameters for debugging. */ /* struct dyString *state = NULL; */ @@ -9916,30 +9940,32 @@ udcSetCacheTimeout(timeout); // tell UDC where to put its statistics file char *udcLogFile; if ((udcLogFile = cfgOption("udcLog")) != NULL) { FILE *fp = mustOpen(udcLogFile, "a"); udcSetLog(fp); } initTl(); char *configPageCall = cartCgiUsualString(cart, "hgTracksConfigPage", "notSet"); char *configMultiRegionPageCall = cartCgiUsualString(cart, "hgTracksConfigMultiRegionPage", "notSet"); +checkAddHighlight(); + /* Do main display. */ if (cartUsualBoolean(cart, "hgt.trackImgOnly", FALSE)) { trackImgOnly = TRUE; ideogramToo = cartUsualBoolean(cart, "hgt.ideogramToo", FALSE); hideControls = TRUE; withNextItemArrows = FALSE; withNextExonArrows = FALSE; hgFindMatches = NULL; // XXXX necessary ??? } jsonForClient = newJsonObject(newHash(8)); jsonObjectAdd(jsonForClient, "cgiVersion", newJsonString(CGI_VERSION)); boolean searching = differentString(cartUsualString(cart, TRACK_SEARCH,"0"), "0");