8ed2d68b3774dcfe96b43cb0d60ed36ca84009bd tdreszer Fri Jul 29 14:59:06 2011 -0700 Integrate my dragScroll with Larry's new json hash code. diff --git src/hg/hgTracks/imageV2.c src/hg/hgTracks/imageV2.c index b515bde..a182926 100644 --- src/hg/hgTracks/imageV2.c +++ src/hg/hgTracks/imageV2.c @@ -1860,40 +1860,45 @@ struct imgSlice *slice = imgTrackSliceGetByType(imgBox->imgTracks,stData); if(slice) offset = (slice->offsetX * -1); // This works because the ruler has a slice } hPrintf("<style type='text/css'>\n"); if(offset != 0) hPrintf("td.tdData {background-image:url(\"%s\");background-repeat:repeat-y;background-position:%dpx;}\n",imgBox->bgImg->file,offset); else hPrintf("td.tdData {background-image:url(\"%s\");background-repeat:repeat-y;}\n",imgBox->bgImg->file); hPrintf("</style>\n"); } #ifdef IMAGEv2_DRAG_SCROLL if(imgBox->showPortal) { - hPrintf("<script type='text/javascript'>var imgBoxPortal=true;"); - hPrintf("var imgBoxChromStart=%d;var imgBoxChromEnd=%d;var imgBoxWidth=%d;", - imgBox->chromStart, imgBox->chromEnd,(imgBox->width - imgBox->sideLabelWidth)); - hPrintf("var imgBoxPortalStart=%d;var imgBoxPortalEnd=%d;var imgBoxPortalWidth=%d;", - imgBox->portalStart, imgBox->portalEnd, imgBox->portalWidth); - hPrintf("var imgBoxLeftLabel=%d;var imgBoxPortalOffsetX=%d;var imgBoxBasesPerPixel=%lf;</script>\n", - (imgBox->plusStrand?imgBox->sideLabelWidth:0), - (int)((imgBox->portalStart - imgBox->chromStart) / imgBox->basesPerPixel),imgBox->basesPerPixel); + // Let js code know what's up + jsonHashAddBoolean(jsonForClient,"imgBoxPortal", TRUE); + jsonHashAddNumber( jsonForClient,"imgBoxChromStart", imgBox->chromStart); + jsonHashAddNumber( jsonForClient,"imgBoxChromEnd", imgBox->chromEnd); + jsonHashAddNumber( jsonForClient,"imgBoxWidth", (imgBox->width - imgBox->sideLabelWidth)); + jsonHashAddNumber( jsonForClient,"imgBoxPortalStart", imgBox->portalStart); + jsonHashAddNumber( jsonForClient,"imgBoxPortalEnd", imgBox->portalEnd); + jsonHashAddNumber( jsonForClient,"imgBoxPortalWidth", imgBox->portalWidth); + jsonHashAddNumber( jsonForClient,"imgBoxLeftLabel", (imgBox->plusStrand?imgBox->sideLabelWidth:0)); + jsonHashAddNumber( jsonForClient,"imgBoxPortalOffsetX",(long)((imgBox->portalStart - imgBox->chromStart) / imgBox->basesPerPixel)); + jsonHashAddDouble( jsonForClient,"imgBoxBasesPerPixel",imgBox->basesPerPixel); } +else #endif//def IMAGEv2_DRAG_SCROLL + jsonHashAddBoolean(jsonForClient,"imgBoxPortal", FALSE); hPrintf("<TABLE id='imgTbl' border=0 cellspacing=0 cellpadding=0 BGCOLOR='%s'",COLOR_WHITE);//COLOR_RED); // RED to help find bugs hPrintf(" width=%d",imgBox->showPortal?(imgBox->portalWidth+imgBox->sideLabelWidth):imgBox->width); hPrintf(" class='tableWithDragAndDrop'"); hPrintf(" style='border:1px solid blue;border-collapse:separate;'>\n"); struct jsonHashElement *jsonTdbVars = newJsonHash(newHash(8)); jsonTdbSettingsInit(jsonTdbVars); char *newLine = NEWLINE_TO_USE(cgiClientBrowser(NULL,NULL,NULL)); struct imgTrack *imgTrack = imgBox->imgTracks; for(;imgTrack!=NULL;imgTrack=imgTrack->next) { char *trackName = (imgTrack->name != NULL ? imgTrack->name : imgTrack->tdb->track ); struct track *track = hashFindVal(trackHash, trackName);