f0950c077f8427a3f65e8cc7ab37a42446041ae6
max
Wed Sep 16 00:18:19 2015 -0700
libifying cartGetPosition because this code is needed twice, once in
hgTracks and also in cart.c for setting the page title. refs #16022,
note 18
diff --git src/hg/hgTracks/hgTracks.c src/hg/hgTracks/hgTracks.c
index 43ed723..f3c1061 100644
--- src/hg/hgTracks/hgTracks.c
+++ src/hg/hgTracks/hgTracks.c
@@ -5339,50 +5339,33 @@
withPriorityOverride = cartUsualBoolean(cart, configPriorityOverride, FALSE);
insideX = trackOffsetX();
insideWidth = tl.picWidth-gfxBorder-insideX;
}
void tracksDisplay()
/* Put up main tracks display. This routine handles zooming and
* scrolling. */
{
char newPos[256];
char *defaultPosition = hDefaultPos(database);
char titleVar[256];
position = getPositionFromCustomTracks();
-// position=lastDbPos in URL? -> go back to the last browsed position for this db
-char dbPosKey[256];
-safef(dbPosKey, sizeof(dbPosKey), "position.%s", database);
-if (sameOk(cgiOptionalString("position"), "lastDbPos"))
- {
- char *position = cartUsualString(cart, dbPosKey, defaultPosition);
- cartSetString(cart, "position", position);
- }
-
-if (NULL == position)
- {
- position = cloneString(cartUsualString(cart, "position", NULL));
- }
+if (position == NULL)
+ position = cartGetPosition(cart, database);
-/* default if not set at all, as would happen if it came from a URL with no
- * position. Otherwise tell them to go back to the gateway. Also recognize
- * "default" as specifying the default position. */
-if (((position == NULL) || sameString(position, "default"))
- && (defaultPosition != NULL))
- position = cloneString(defaultPosition);
if (sameString(position, ""))
{
hUserAbort("Please go back and enter a coordinate range or a search term in the \"search term\" field.
For example: chr22:20100000-20200000.\n");
}
chromName = NULL;
winStart = 0;
if (isGenome(position) || NULL ==
(hgp = findGenomePos(database, position, &chromName, &winStart, &winEnd, cart)))
{
if (winStart == 0) /* number of positions found */
{
freeMem(position);
position = cloneString(cartUsualString(cart, "lastPosition", defaultPosition));
hgp = findGenomePos(database, position, &chromName, &winStart, &winEnd,cart);
@@ -5396,31 +5379,31 @@
createHgFindMatchHash();
/* This means that no single result was found
I.e., multiple results may have been found and are printed out prior to this code*/
if (NULL == chromName)
{
// In case user manually edits the browser location as described in #13009,
// revert the position. If they instead choose from the list as we expect,
// that will set the position to their choice.
char *lastPosition = cartUsualString(cart, "lastPosition", hDefaultPos(database));
cartSetString(cart, "position", lastPosition);
return;
}
// save the current position to the cart var position.
-cartSetString(cart, dbPosKey, position);
+cartSetDbPosition(cart, database, position);
seqBaseCount = hChromSize(database, chromName);
winBaseCount = winEnd - winStart;
/* Figure out basic dimensions of display. This
* needs to be done early for the sake of the
* zooming and dinking routines. */
setLayoutGlobals();
baseShowPos = cartUsualBoolean(cart, BASE_SHOWPOS, FALSE);
baseShowAsm = cartUsualBoolean(cart, BASE_SHOWASM, FALSE);
baseShowScaleBar = cartUsualBoolean(cart, BASE_SCALE_BAR, TRUE);
baseShowRuler = cartUsualBoolean(cart, BASE_SHOWRULER, TRUE);
safef(titleVar,sizeof(titleVar),"%s_%s", BASE_TITLE, database);
baseTitle = cartUsualString(cart, titleVar, "");