9227292b25ce2fc4a36ee898691a49ab53105fab max Fri Apr 3 06:35:21 2015 -0700 2nd version of external tools menu support diff --git src/hg/hgTracks/hgTracks.c src/hg/hgTracks/hgTracks.c index 483035e..c45f4a6 100644 --- src/hg/hgTracks/hgTracks.c +++ src/hg/hgTracks/hgTracks.c @@ -2015,30 +2015,48 @@ } hvGfxBox(hvg, insideX + startPixels, 0, width, imagePixelHeight,hexColor); } } } struct hash *makeGlobalTrackHash(struct track *trackList) /* Create a global track hash and returns a pointer to it. */ { trackHash = newHash(8); rAddToTrackHash(trackHash, trackList); return trackHash; } +void domAppendToMenu(char *menu, char *url, char *label) +/* Add an entry to a drop down menu, by changing the DOM with jquery */ +{ +printf("$('#%s ul li').last().after('<li><a target=\"_BLANK\" href=\"%s\">%s</a></li>');\n", menu, url, label); +} + +void menuBarAppendExtTools() +/* printf a little javascript that adds entries to a menu */ +{ + char url[SMALLBUF]; + safef(url,ArraySize(url),"hgTracks?%s=%s&hgt.redirectTool=crispor",cartSessionVarName(), cartSessionId(cart)); + printf("<script>\n"); + printf("$(document).ready( function() {\n"); + domAppendToMenu("tools", url, "External: Tefor CRISPR sites"); + printf("});\n"); + printf("</script>\n"); +} + void makeActiveImage(struct track *trackList, char *psOutput) /* Make image and image map. */ { struct track *track; MgFont *font = tl.font; struct hvGfx *hvg; struct tempName pngTn; char *mapName = "map"; int fontHeight = mgFontLineHeight(font); int trackPastTabX = (withLeftLabels ? trackTabWidth : 0); int trackTabX = gfxBorder; int trackPastTabWidth = tl.picWidth - trackPastTabX; int pixWidth, pixHeight; int y=0; @@ -4346,54 +4364,30 @@ else { hPrintf("%s, %d, %d, %d<br />\n", track->shortLabel, track->loadTime, track->drawTime, track->loadTime + track->drawTime); if (startsWith("wigMaf", track->tdb->type)) if (track->subtracks) if (track->subtracks->loadTime) hPrintf(" %s wiggle, load %d<br />\n", track->shortLabel, track->subtracks->loadTime); } } hPrintf("</span>\n"); } - -void domAppendToMenu(char *menu, char *url, char *label) -/* Add an entry to a drop down menu, by changing the DOM with jquery */ -{ -printf("$('#%s ul li').last().after('<li><a target=\"_BLANK\" href=\"%s\">%s</a></li>');\n", menu, url, label); -} - -void appendExtTools() -{ - char posStr[SMALLBUF]; - safef(posStr,ArraySize(posStr),"%s:%d-%d",chromName, winStart, winEnd); - - char *url = "http://www.tefor.net/crisporMax/crispor.cgi?org=$org&pos=$pos&pam=NGG"; - - url = replaceChars(url, "$org", database); - url = replaceChars(url, "$pos", posStr); - - printf("<script>\n"); - printf("$(document).ready( function() {\n"); - domAppendToMenu("tools", url, "External: Tefor CRISPR sites"); - printf("});\n"); - printf("</script>\n"); -} - void doTrackForm(char *psOutput, struct tempName *ideoTn) /* Make the tracks display form with the zoom/scroll buttons and the active * image. If the ideoTn parameter is not NULL, it is filled in if the * ideogram is created. */ { struct group *group; struct track *track; char *freezeName = NULL; boolean hideAll = cgiVarExists("hgt.hideAll"); boolean defaultTracks = cgiVarExists("hgt.reset"); boolean showedRuler = FALSE; boolean showTrackControls = cartUsualBoolean(cart, "trackControlsOnMain", TRUE); long thisTime = 0, lastTime = 0; char *clearButtonJavascript; @@ -4593,52 +4587,50 @@ // 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)) { winBaseCount = winEnd - winStart; insideWidth = tl.picWidth-gfxBorder-insideX; } } /* Center everything from now on. */ hPrintf("<CENTER>\n"); // info for drag selection javascript jsonObjectAdd(jsonForClient, "winStart", newJsonNumber(winStart)); jsonObjectAdd(jsonForClient, "winEnd", newJsonNumber(winEnd)); jsonObjectAdd(jsonForClient, "chromName", newJsonString(chromName)); -//printf("adding tools<p>"); -appendExtTools(); - if(trackImgOnly && !ideogramToo) { struct track *ideoTrack = chromIdeoTrack(trackList); if (ideoTrack) { ideoTrack->limitedVisSet = TRUE; ideoTrack->limitedVis = tvHide; /* Don't draw in main gif. */ } makeActiveImage(trackList, psOutput); fflush(stdout); return; // bail out b/c we are done } if (!hideControls) { /* set white-space to nowrap to prevent buttons from wrapping when screen is * narrow */ hPrintf("<DIV STYLE=\"white-space:nowrap;\">\n"); printMenuBar(); + menuBarAppendExtTools(); /* Show title . */ freezeName = hFreezeFromDb(database); if(freezeName == NULL) freezeName = "Unknown"; hPrintf("<span style='font-size:x-large;'><B>"); if (startsWith("zoo",database) ) { hPrintf("%s %s on %s June 2002 Assembly %s target1", organization, browserName, organism, freezeName); } else { if (sameString(organism, "Archaea")) {