59c8729fc621dfc9c9170d0250e0bd5cd85c1b3e
larrym
  Fri Jul 29 00:44:34 2011 -0700
code cleanup
diff --git src/hg/js/hgTracks.js src/hg/js/hgTracks.js
index 7312e0e..7d1c735 100644
--- src/hg/js/hgTracks.js
+++ src/hg/js/hgTracks.js
@@ -1700,31 +1700,31 @@
                 } else {
                     var newPosition = setPositionByCoordinates(chrom, chromStart, chromEnd);
                     var reg = new RegExp("hgg_gene=([^&]+)");
                     var a = reg.exec(href);
                     var name;
                     // pull item name out of the url so we can set hgFind.matches (redmine 3062)
                     if(a && a[1]) {
                         name = a[1];
                     } else {
                         reg = new RegExp("[&?]i=([^&]+)");
                         a = reg.exec(href);
                         if(a && a[1]) {
                             name = a[1];
                         }
                     }
-                    if(false && mapIsUpdateable) {
+                    if(inPlaceUpdate) {
                         // XXXX This attempt to "update whole track image in place" didn't work for a variety of reasons
                         // (e.g. safari doesn't parse map when we update on the client side), so this is currently dead code.
                         // However, this now works in all other browsers, so we may turn this on for non-safari browsers
                         // (see redmine #4667).
                         jQuery('body').css('cursor', '');
                         var data = "hgt.trackImgOnly=1&hgt.ideogramToo=1&position=" + newPosition + "&hgsid=" + getHgsid();
                         if(name)
                             data += "&hgFind.matches=" + name;
                         $.ajax({
                                    type: "GET",
                                    url: "../cgi-bin/hgTracks",
                                    data: data,
                                    dataType: "html",
                                    trueSuccess: handleUpdateTrackMap,
                                    success: catchErrorOrDispatch,
@@ -2513,31 +2513,31 @@
     var reg = new RegExp(str);
     var a = reg.exec(html);
     if(a && a[1]) {
         $('#tr_' + id).html(a[1]);
         // NOTE: Want to examine the png? Uncomment:
         //var img = $('#tr_' + id).find("img[id^='img_data_']").attr('src');
         //warn("Just parsed image:<BR>"+img);
         return true;
     } else {
         return false;
     }
 }
 
 function handleUpdateTrackMap(response, status)
 {
-// Handle ajax response with an updated trackMap image (gif or png) and map.
+// Handle ajax response with an updated trackMap image, map and optional ideogram.
 //
 // this.cmd can be used to figure out which menu item triggered this.
 // this.id == appropriate track if we are retrieving just a single track.
 
     // update local hgTracks.trackDb to reflect possible side-effects of ajax request.
     var json = scrapeVariable(response, "hgTracks");
     if(json == undefined) {
         showWarning("hgTracks object is missing from the response");
     } else {
         if(this.id != null) {
             if(json.trackDb[this.id]) {
                 var visibility = visibilityStrsOrder[json.trackDb[this.id].visibility];
                 var limitedVis;
                 if(json.trackDb[this.id].limitedVis)
                     limitedVis = visibilityStrsOrder[json.trackDb[this.id].limitedVis];
@@ -2565,38 +2565,36 @@
           } else {
                showWarning("Couldn't parse out new image for id: " + id);
                //alert("Couldn't parse out new image for id: " + id+"BR"+response);  // Very helpful
           }
     } else {
         if(imageV2) {
             // Implement in-place updating of hgTracks image
             //
             // We update rows one at a time (updating the whole imgTable at one time doesn't work in IE).
             for (id in hgTracks.trackDb) {
                 if(!updateTrackImgForId(response, id)) {
                     showWarning("Couldn't parse out new image for id: " + id);
                     //alert("Couldn't parse out new image for id: " + id+"BR"+response);  // Very helpful
                 }
             }
-            // update hgTracks as appropriate (XXXX should we just copy over the whole thing rather than just specific keys?)
-            hgTracks.chromName = json.chromName;
-            hgTracks.winStart = json.winStart;
-            hgTracks.winEnd = json.winEnd;
+            if(json != undefined) {
+                hgTracks = json;
             $("input[name='c']").val(json.chromName);
             $("input[name='l']").val(json.winStart);
             $("input[name='r']").val(json.winEnd);
-            hgTracks.newWinWidth = json.newWinWidth;
+            }
             setPositionByCoordinates(hgTracks.chromName, hgTracks.winStart + 1, hgTracks.winEnd);
             originalPosition = undefined;
             initVars();
             afterImgTblReload();
         } else {
             a= /<IMG([^>]+SRC[^>]+id='trackMap[^>]*)>/.exec(response);
             // Deal with a is null
             if(a[1]) {
                     var b = /WIDTH\s*=\s*['"]?(\d+)['"]?/.exec(a[1]);
                     var width = b[1];
                     b = /HEIGHT\s*=\s*['"]?(\d+)['"]?/.exec(a[1]);
                     var height = b[1];
                     b = /SRC\s*=\s*"([^")]+)"/.exec(a[1]);
                     var src = b[1];
                     $('#trackMap').attr('src', src);