0b51a0fe8f8b8cf3b0779f61eac4db5d81669380 larrym Wed Aug 10 00:36:50 2011 -0700 update measureTiming output when doing in-place update; fix Number() cast based on tdreszer's code review diff --git src/hg/js/hgTracks.js src/hg/js/hgTracks.js index bf25fe8..d8be32f 100644 --- src/hg/js/hgTracks.js +++ src/hg/js/hgTracks.js @@ -253,31 +253,31 @@ // Handle the fact that (as of 1.3.1), jQuery.browser reports "safari" when the browser is in fact Chrome. browser = "chrome"; } else { // Safari has the following bug: if we update the hgTracks map dynamically, the browser ignores the changes (even // though if you look in the DOM the changes are there). So we have to do a full form submission when the // user changes visibility settings or track configuration. // As of 5.0.4 (7533.20.27) this is problem still exists in safari. // As of 5.1 (7534.50) this problem appears to have been fixed - unfortunately, logs for 7/2011 show vast majority of safari users // are pre-5.1 (5.0.5 is by far the most common). // // Early versions of Chrome had this problem too, but this problem went away as of Chrome 5.0.335.1 (or possibly earlier). mapIsUpdateable = false; var reg = new RegExp("Version\/(\[0-9]+\.\[0-9]+) Safari"); var a = reg.exec(navigator.userAgent); if(a && a[1]) { - var version = a[1] * 1; + var version = Number(a[1]); if(version >= 5.1) { mapIsUpdateable = true; } } } } inPlaceUpdate = hgTracks.inPlaceUpdate && mapIsUpdateable; loadImgAreaSelect(true); if($('#hgTrackUiDialog')) $('#hgTrackUiDialog').hide(); // Don't load contextMenu if jquery.contextmenu.js hasn't been loaded if(trackImg && jQuery.fn.contextMenu) { $('#hgTrackUiDialog').hide(); @@ -2528,30 +2528,51 @@ // return true if we successfully pull slice for id and update it in imgTrack. var str = "<TR id='tr_" + id + "'[^>]*>([\\s\\S]+?)</TR>"; 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 updateTiming(response) +{ +// update measureTiming text on current page based on what's in the response + var reg = new RegExp("(<span class='timing'>.+?</span>)", "g"); + var strs = []; + for(var a = reg.exec(response); a != null && a[1] != null; a = reg.exec(response)) { + strs.push(a[1]); + } + if(strs.length > 0) { + $('.timing').remove(); + for(var i = strs.length; i > 0; i--) { + $('body').prepend(strs[i - 1]); + } + } + reg = new RegExp("(<span class='trackTiming'>[\\S\\s]+?</span>)"); + a = reg.exec(response); + if(a != null && a[1] != null) { + $('.trackTiming').replaceWith(a[1]); + } +} + function handleUpdateTrackMap(response, status) { // 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]; @@ -2592,30 +2613,33 @@ $("input[name='l']").val(json.winStart); $("input[name='r']").val(json.winEnd); if(json.cgiVersion != hgTracks.cgiVersion) { // Must reload whole page because of a new version on the server; this should happen very rarely. // Note that we have already updated position based on the user's action. jQuery('body').css('cursor', 'wait'); document.TrackHeaderForm.submit(); } else { // 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 } } + if(hgTracks.measureTiming) { + updateTiming(response); + } hgTracks = json; 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];