981af4b2d0d08b1b67e7a50dbd8e85caa7a03d23 larrym Wed Feb 22 13:04:16 2012 -0800 add whatWeDid parameter to stripJsEmbedded; wordsmithing diff --git src/hg/js/utils.js src/hg/js/utils.js index 547db2e..6c22916 100644 --- src/hg/js/utils.js +++ src/hg/js/utils.js @@ -1183,77 +1183,81 @@ function stripHgErrors(returnedHtml) { // strips HGERROR style 'early errors' and shows them in the warnBox var cleanHtml = returnedHtml; while(cleanHtml.length > 0) { var bounds = bindings.outside('<!-- HGERROR-START -->','<!-- HGERROR-END -->',cleanHtml); if (bounds.start == -1) break; var warnMsg = bindings.insideOut('<P>','</P>',cleanHtml,bounds.start,bounds.stop); if (warnMsg.length > 0) warn(warnMsg); cleanHtml = cleanHtml.slice(0,bounds.start) + cleanHtml.slice(bounds.stop); } return cleanHtml; } -function stripJsFiles(returnedHtml,showError) +function stripJsFiles(returnedHtml,debug) { // strips javascript files from html returned by ajax var cleanHtml = returnedHtml; var shlurpPattern=/\<script type=\'text\/javascript\' SRC\=\'.*\'\>\<\/script\>/gi; - if (showError) { + if (debug) { var jsFiles = cleanHtml.match(shlurpPattern); if (jsFiles && jsFiles.length > 0) alert("jsFiles:'"+jsFiles+"'\n---------------\n"+cleanHtml); // warn() interprets html, etc. } cleanHtml = cleanHtml.replace(shlurpPattern,""); return cleanHtml; } -function stripCssFiles(returnedHtml,showError) +function stripCssFiles(returnedHtml,debug) { // strips csst files from html returned by ajax var cleanHtml = returnedHtml; var shlurpPattern=/\<LINK rel=\'STYLESHEET\' href\=\'.*\' TYPE=\'text\/css\' \/\>/gi; - if (showError) { + if (debug) { var cssFiles = cleanHtml.match(shlurpPattern); if (cssFiles && cssFiles.length > 0) alert("cssFiles:'"+cssFiles+"'\n---------------\n"+cleanHtml); } cleanHtml = cleanHtml.replace(shlurpPattern,""); return cleanHtml; } -function stripJsEmbedded(returnedHtml,showError) +function stripJsEmbedded(returnedHtml, debug, whatWeDid) { // strips embedded javascript from html returned by ajax // NOTE: any warnBox style errors will be put into the warnBox + // If whatWeDid != null, we use it to return info about what we stripped out and processed (current just warnMsg). var cleanHtml = returnedHtml; // embedded javascript? while(cleanHtml.length > 0) { var begPattern = /\<script type=\'text\/javascript\'\>/i; var endPattern = /\<\/script\>/i; var bounds = bindings.outside(begPattern,endPattern,cleanHtml); if (bounds.start == -1) break; var jsEmbeded = cleanHtml.slice(bounds.start,bounds.stop); if(-1 == jsEmbeded.indexOf("showWarnBox")) { - if (showError) + if (debug) alert("jsEmbedded:'"+jsEmbeded+"'\n---------------\n"+cleanHtml); } else { var warnMsg = bindings.insideOut('<li>','</li>',cleanHtml,bounds.start,bounds.stop); - if (warnMsg.length > 0) + if (warnMsg.length > 0) { warn(warnMsg); + if(whatWeDid != null) + whatWeDid.warnMsg = warnMsg; + } } cleanHtml = cleanHtml.slice(0,bounds.start) + cleanHtml.slice(bounds.stop); } return stripHgErrors(cleanHtml); // Certain early errors are not called via warnBox } function visTriggersHiddenSelect(obj) { // SuperTrack child changing vis should trigger superTrack reshaping. // This is done by setting hidden input "_sel" var trackName_Sel = $(obj).attr('name') + "_sel"; var theForm = $(obj).closest("form"); var visible = (obj.selectedIndex != 0); if (visible) { updateOrMakeNamedVariable(theForm,trackName_Sel,"1"); } else