992fb766bbcb138ced89743c9f8257a6a7273d38 tdreszer Mon May 2 15:29:32 2011 -0700 Added support for generic AJAX retrieval of static html (such as help pages). This can result in a popup, or having the text fill a predefined div withing the calling page. diff --git src/hg/js/ajax.js src/hg/js/ajax.js index b15c456..b3d33b4 100644 --- src/hg/js/ajax.js +++ src/hg/js/ajax.js @@ -299,15 +299,123 @@ } } $(div).show(); } function removeHgsid(href) { // remove session id from url parameters if(href.indexOf("?hgsid=") == -1) { href = href.replace(/\&hgsid=\d+/, ""); } else { href = href.replace(/\?hgsid=\d+\&/, "?"); } return href; } + + +///////////////////////// +// Retrieve extra html from a file +var gAppendTo = null; + +function _retrieveHtml(fileName,obj) +{ // popup cfg dialog + if (obj && obj != undefined && $(obj).length == 1) { + gAppendTo = obj; + } else + gAppendTo = null; + + $.ajax({ + type: "GET", + url: fileName, + dataType: "html", + trueSuccess: retrieveHtmlHandle, + success: catchErrorOrDispatch, + error: errorHandler, + cmd: "info", + cache: true + }); +} + +function retrieveHtml(fileName,obj,toggle) +{ // Retrieves html from file + // If no obj is supplied then html will be shown in a popup. + // if obj supplied then object's html will be replaced by what is retrieved. + // if obj and toggle == true, and obj has html, it will be emptied, resulting in toggle like calls + if (toggle && obj && obj != undefined && $(obj).length == 1) { + if ($(obj).html().length > 0) { + $(obj).html("") + return; + } + } + + waitOnFunction( _retrieveHtml, fileName, obj ); // Launches the popup but shields the ajax with a waitOnFunction +} + +function retrieveHtmlHandle(response, status) +{ +// Take html from hgTrackUi and put it up as a modal dialog. + + // make sure all links (e.g. help links) open up in a new window + response = response.replace(/ + var cleanHtml = response; + var shlurpPattern=/\