93936600ca6a0a4e81a3fae66812e9b5045d5965
larrym
  Wed Jul 13 17:08:26 2011 -0700
more work on in-place updating
diff --git src/hg/js/hgTracks.js src/hg/js/hgTracks.js
index f533dbf..a6cb875 100644
--- src/hg/js/hgTracks.js
+++ src/hg/js/hgTracks.js
@@ -2473,45 +2473,39 @@
           if(updateTrackImgForId(response, id)) {
                afterImgTblReload();
           } 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) {
             // We update row's one at a time (updating the whole imgTable at one time doesn't work in IE).
             for (id in trackDbJson) {
                 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
                 }
             }
-            // parse out and reset position info.
-            a = /<INPUT [^>]*NAME=["']position['"] VALUE=['"]([^'"]+)/.exec(response);
-            if(a != null && a[1] != null) {
-                var o = parsePosition(a[1]);
-                setPosition(a[1], commify(o.end - o.start + 1));
-                hgTracks.winStart = o.start - 1;
-                hgTracks.winEnd = o.end;
+            var json = scrapeVariable(response, "hgTracks");
+            if(json != undefined) {
+                hgTracks.winStart = json.winStart;
+                hgTracks.winEnd = json.winEnd;
+                hgTracks.newWinWidth = json.newWinWidth;
+                setPositionByCoordinates(json.chromName, hgTracks.winStart + 1, hgTracks.winEnd);
             } else {
                 showWarning("Couldn't parse out new position info");
             }
-            abort("This is broken (needs to be fixed to pull new variable values out of the response)");
-            a = /<input [^>]*id=["']hgt\.newWinWidth['"][^>]*value=['"]([^'"]+)/.exec(response);
-            if(a != null && a[1] != null) {
-                $("#hgt\\.newWinWidth").val(a[1]);
-            }
             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);
                     var obj = imgAreaSelect.data('imgAreaSelect');
                     if(width) {
                         trackImg.attr('width', width);