8a3891b32fa630eddb3808ab704836d5c9e1ffe8 larrym Sun Jul 10 20:58:40 2011 -0700 move javascript globals from hiddens to an object diff --git src/hg/hgTracks/hgTracks.c src/hg/hgTracks/hgTracks.c index 9c1bb2f..115ea12 100644 --- src/hg/hgTracks/hgTracks.c +++ src/hg/hgTracks/hgTracks.c @@ -92,30 +92,31 @@ "hide", "dense", "full" }; char *protDbName; /* Name of proteome database for this genome. */ #define MAX_CONTROL_COLUMNS 6 #define LOW 1 #define MEDIUM 2 #define BRIGHT 3 #define MAXCHAINS 50000000 boolean hgDebug = FALSE; /* Activate debugging code. Set to true by hgDebug=on in command line*/ int imagePixelHeight = 0; boolean dragZooming = TRUE; struct hash *oldVars = NULL; +struct hash *jsVarsHash = NULL; boolean hideControls = FALSE; /* Hide all controls? */ boolean trackImgOnly = FALSE; /* caller wants just the track image and track table html */ boolean ideogramToo = FALSE; /* caller wants the ideoGram (when requesting just one track) */ /* Structure returned from findGenomePos. * We use this to to expand any tracks to full * that were found to contain the searched-upon * position string */ struct hgPositions *hgp = NULL; /* Other global variables. */ struct trackHub *hubList = NULL; /* List of all relevant hubs. */ struct group *groupList = NULL; /* List of all tracks. */ char *browserName; /* Test, preview, or public browser */ @@ -2455,38 +2456,39 @@ { if(theImgBox) { // Set imgTrack in case any map items will be set sliceHeight = trackPlusLabelHeight(track, fontHeight); sliceOffsetY = y; curImgTrack = imgBoxTrackFind(theImgBox,track->tdb,NULL); } y = doTrackMap(track, hvg, y, fontHeight, trackPastTabX, trackPastTabWidth); } } /* Finish map. */ hPrintf("</MAP>\n"); -hPrintf("<input type='hidden' id='hgt.dragSelection' name='dragSelection' value='%d'>\n", dragZooming ? 1 : 0); +jsAddBoolean(jsVarsHash, "dragSelection", dragZooming); + if(rulerClickHeight) { - hPrintf("<input type='hidden' id='hgt.rulerClickHeight' name='rulerClickHeight' value='%d'>\n", rulerClickHeight); + jsAddNumber(jsVarsHash, "rulerClickHeight", rulerClickHeight); } if(newWinWidth) { - hPrintf("<input type='hidden' id='hgt.newWinWidth' name='newWinWidth' value='%d'>\n", newWinWidth); + jsAddNumber(jsVarsHash, "newWinWidth", newWinWidth); } /* Save out picture and tell html file about it. */ if(hvgSide != hvg) hvGfxClose(&hvgSide); hvGfxClose(&hvg); if(theImgBox) { imageBoxDraw(theImgBox); #ifdef IMAGEv2_DRAG_SCROLL // If a portal was established, then set the global dimensions back to the portal size if(imgBoxPortalDimensions(theImgBox,NULL,NULL,NULL,NULL,&winStart,&winEnd,&(tl.picWidth),NULL)) { pixWidth = tl.picWidth; winBaseCount = winEnd - winStart; @@ -4542,32 +4544,33 @@ zoomedToBaseLevel = (winBaseCount <= insideWidth / tl.mWidth); zoomedToCodonLevel = (ceil(winBaseCount/3) * tl.mWidth) <= insideWidth; zoomedToCdsColorLevel = (winBaseCount <= insideWidth*3); if (psOutput != NULL) { hPrintDisable(); hideControls = TRUE; withNextItemArrows = FALSE; withNextExonArrows = FALSE; hgFindMatches = NULL; } /* Tell browser where to go when they click on image. */ hPrintf("<FORM ACTION=\"%s\" NAME=\"TrackHeaderForm\" id=\"TrackHeaderForm\" METHOD=\"GET\">\n\n", hgTracksName()); -hPrintf("<input type='hidden' id='hgt.insideX' name='insideX' value='%d'>\n", insideX); -hPrintf("<input type='hidden' id='hgt.revCmplDisp' name='revCmplDisp' value='%d'>\n", revCmplDisp); +jsAddNumber(jsVarsHash, "insideX", insideX); +jsAddBoolean(jsVarsHash, "revCmplDisp", revCmplDisp); + #ifdef NEW_JQUERY hPrintf("<script type='text/javascript'>var newJQuery=true;</script>\n"); #else///ifndef NEW_JQUERY hPrintf("<script type='text/javascript'>var newJQuery=false;</script>\n"); #endif///ndef NEW_JQUERY if (!psOutput) cartSaveSession(cart); clearButtonJavascript = "document.TrackHeaderForm.position.value=''; document.getElementById('suggest').value='';"; /* See if want to include sequence search results. */ userSeqString = cartOptionalString(cart, "ss"); if (userSeqString && !ssFilesExist(userSeqString)) { userSeqString = NULL; cartRemove(cart, "ss"); } @@ -4849,36 +4852,34 @@ sprintLongWithCommas(buf, winEnd - winStart); if(dragZooming && assemblySupportsGeneSuggest(database)) hPrintf(" <a title='click for help on gene search box' target='_blank' href='../goldenPath/help/geneSearchBox.html'>gene</a> " "<input type='text' size='8' name='hgt.suggest' id='suggest'>\n" "<input type='hidden' name='hgt.suggestTrack' id='suggestTrack' value='%s'>\n", assemblyGeneSuggestTrack(database) ); hWrites(" "); hButtonWithOnClick("hgt.jump", "jump", NULL, "jumpButtonOnClick()"); hOnClickButton(clearButtonJavascript,"clear"); hPrintf(" size <span id='size'>%s</span> bp. ", buf); hWrites(" "); hButton("hgTracksConfigPage", "configure"); if (survey && differentWord(survey, "off")) hPrintf(" <span style='background-color:yellow;'><A HREF='%s' TARGET=_BLANK><EM><B>%s</EM></B></A></span>\n", survey, surveyLabel ? surveyLabel : "Take survey"); // info for drag selection javascript - hPrintf("<input type='hidden' id='hgt.winStart' name='winStart' value='%d'>\n", winStart); - hPrintf("<input type='hidden' id='hgt.winEnd' name='winEnd' value='%d'>\n", winEnd); - hPrintf("<input type='hidden' id='hgt.chromName' name='chromName' value='%s'>\n", chromName); - + jsAddNumber(jsVarsHash, "winStart", winStart); + jsAddNumber(jsVarsHash, "winEnd", winEnd); + jsAddString(jsVarsHash, "chromName", chromName); hPutc('\n'); - } } /* Make chromsome ideogram gif and map. */ makeChromIdeoImage(&trackList, psOutput, ideoTn); #ifdef USE_NAVIGATION_LINKS hPrintf("<TABLE BORDER=0 CELLPADDING=0 width='%d'><tr style='font-size:small;'>\n",tl.picWidth);//min(tl.picWidth, 800)); hPrintf("<td width='40' align='left'><a href='?hgt.left3=1' title='move 95% to the left'><<<</a>\n"); hPrintf("<td width='30' align='left'><a href='?hgt.left2=1' title='move 47.5% to the left'><<</a>\n"); #ifdef IMAGEv2_DRAG_SCROLL if(!advancedJavascriptFeaturesEnabled(cart)) #endif//def IMAGEv2_DRAG_SCROLL hPrintf("<td width='20' align='left'><a href='?hgt.left1=1' title='move 10% to the left'><</a>\n"); @@ -5806,30 +5807,31 @@ dragZooming = advancedJavascriptFeaturesEnabled(cart); /* 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 ??? } hWrites(commonCssStyles()); +jsVarsHash = newHash(8); jsIncludeFile("jquery.js", NULL); jsIncludeFile("jquery-ui.js", NULL); jsIncludeFile("utils.js", NULL); jsIncludeFile("ajax.js", NULL); boolean searching = differentString(cartUsualString(cart, TRACK_SEARCH,"0"),"0"); if(dragZooming && !searching) { jsIncludeFile("jquery.imgareaselect.js", NULL); #ifndef NEW_JQUERY webIncludeResourceFile("autocomplete.css"); jsIncludeFile("jquery.autocomplete.js", NULL); #endif///ndef NEW_JQUERY } jsIncludeFile("autocomplete.js", NULL); jsIncludeFile("hgTracks.js", NULL); @@ -5924,16 +5926,22 @@ } else if (cartVarExists(cart, configShowEncodeGroups)) { /* currently not used */ cartRemove(cart, configShowEncodeGroups); struct grp *grp = NULL, *grps = hLoadGrps(database); for (grp = grps; grp != NULL; grp = grp->next) if (startsWith("encode", grp->name)) collapseGroup(grp->name, FALSE); configPageSetTrackVis(-2); } else { tracksDisplay(); } +if(hashNumEntries(jsVarsHash)) + { + hPrintf("<script type='text/javascript'>\n"); + jsPrintHash(jsVarsHash, "hgTracks", 0); + hPrintf("</script>\n"); + } }