a0139a75943762fc48c9995723d3bd7f9f6c6693
larrym
  Mon Jul 25 13:36:33 2011 -0700
change trackDbJson to syntax used by scrapeVariable
diff --git src/hg/js/hgTracks.js src/hg/js/hgTracks.js
index 54d6dd6..a83dc38 100644
--- src/hg/js/hgTracks.js
+++ src/hg/js/hgTracks.js
@@ -2519,57 +2519,51 @@
         //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.
 //
 // 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 trackDbJson to reflect possible side-effects of ajax request.
-    var re = /<\!-- trackDbJson -->\n<script>var trackDbJson = ([\S\s]+)<\/script>\n<\!-- trackDbJson -->/m;
-    a = re.exec(response);
-    if(a && a[1]) {
-        var json = eval("(" + a[1] + ")");
-        if(json) {
+    var json = scrapeVariable(response, "trackDbJson");
+    if(json == null) {
+        showWarning("trackDbJson is missing from the response");
+    } else {
             if(this.id != null) {
                 if(json[this.id]) {
             var visibility = visibilityStrsOrder[json[this.id].visibility];
             var limitedVis;
             if(json[this.id].limitedVis)
                 limitedVis = visibilityStrsOrder[json[this.id].limitedVis];
             if(this.newVisibility && limitedVis && this.newVisibility != limitedVis)
                 alert("There are too many items to display the track in " + this.newVisibility + " mode.");
             var rec = trackDbJson[this.id];
             rec.limitedVis = json[this.id].limitedVis;
             updateVisibility(this.id, visibility);
         } else {
             showWarning("Invalid trackDbJson received from the server");
         }
     } else {
                  trackDbJson = json;
             }
-        } else {
-            showWarning("Invalid trackDbJson received from the server");
-        }
-    } else {
-        showWarning("trackDbJson is missing from the response");
     }
     if(this.loadingId) {
         hideLoadingImage(this.loadingId);
     }
     if(imageV2 && this.id && this.cmd && this.cmd != 'wholeImage' && this.cmd != 'selectWholeGene') {
           // Extract <TR id='tr_ID'>...</TR> and update appropriate row in imgTbl;
           // this updates src in img_left_ID, img_center_ID and img_data_ID and map in map_data_ID
           var id = this.id;
           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 {