if(!StructKeyExists(request,"ADFScriptsDebugging")){ request.ADFScriptsDebugging = false; } loadedScript(arguments.scriptName); //Clean the arguments.outputHTML for javascript strings arguments.outputHTML = Trim(arguments.outputHTML); #arguments.outputHTML# // Removing single line scripts because it comments code out when we remove line breaks! -> // arguments.outputHTML = ReReplace(arguments.outputHTML, '//[^\r\n]*', '', "all"); // escape forward slashes and single quotes arguments.outputHTML = Replace(arguments.outputHTML, '/', '\/', "all"); arguments.outputHTML = Replace(arguments.outputHTML, "'", "\'", "all"); // kill rtns, newlines, and tabs arguments.outputHTML = ReReplace(arguments.outputHTML,'[\r\n\t]','',"all"); var rtn = StructNew(); var tempVersion = arguments.version; var lastIndex = -1; var csAppsDir = "#request.site.csappsweburl#thirdParty/#defaultDirectory#/"; var adfDir = "/ADF/thirdParty/#defaultDirectory#/"; var tempFile = ""; var cacheString = "#defaultDirectory#/#preamble##version##postamble#"; tempVersion = Replace(tempVersion,"min","","ALL"); rtn.success=false; if(REFind("[^0-9.]",tempVersion)){ rtn.message = "Version information can only contain 0-9 and periods."; return rtn; } rtn.success=true; // Make sure the application.ADF.cache is available if ( !StructKeyExists(application.ADF,"cache") ) application.ADF.cache = StructNew(); if( !StructKeyExists(application.ADF.cache,"scriptsCache") ) { application.ADF.cache.scriptsCache = StructNew(); } else if ( StructKeyExists(application.ADF.cache.scriptsCache,cacheString) and Len(StructFind(application.ADF.cache.scriptsCache,cacheString)) ) { rtn.message = StructFind(application.ADF.cache.scriptsCache,cacheString); return rtn; } while(Len(tempVersion)){ // Search the cs_apps directory tempFile = "#csAppsDir##preamble##tempVersion##postamble#"; if(FileExists(ExpandPath(tempFile))){ rtn.message = tempFile; StructInsert(application.ADF.cache.scriptsCache,cacheString,tempFile,true); return rtn; } // Search the cs_apps directory for the Min tempFile = "#csAppsDir##preamble##tempVersion#.min#postamble#"; if(FileExists(ExpandPath(tempFile))){ rtn.message = tempFile; StructInsert(application.ADF.cache.scriptsCache,cacheString,tempFile,true); return rtn; } // Search the adf apps directory tempFile = "#adfDir##preamble##tempVersion##postamble#"; if(FileExists(ExpandPath(tempFile))){ rtn.message = tempFile; StructInsert(application.ADF.cache.scriptsCache,cacheString,tempFile,true); return rtn; } // Search the adf apps directory for the Min tempFile = "#adfDir##preamble##tempVersion#.min#postamble#"; if(FileExists(ExpandPath(tempFile))){ rtn.message = tempFile; StructInsert(application.ADF.cache.scriptsCache,cacheString,tempFile,true); return rtn; } // Preform trim lastIndex = tempVersion.lastIndexOf('.'); if(lastIndex neq -1){ tempVersion = left(tempVersion,lastIndex); }else{ tempVersion = ""; } } StructInsert(application.ADF.cache.scriptsCache,cacheString,"",true); //Uh oh, we couldnt find it. application.ADF.utils.logAppend("Unable to find script #defaultDirectory#/#preamble##version##postamble#","findScript-error.txt"); rtn.message = "Unable to find script. #defaultDirectory#/#preamble##version##postamble#"; rtn.success = false; return rtn;