// init variable for jsCommentStripper variables.jsCSoutputArray = ArrayNew(1); var renderScript = ""; if ( !StructKeyExists(request,"ADFScriptsDebugging") ) request.ADFScriptsDebugging = false; if ( Application.ADF.SiteDevMode AND structKeyExists(Request.Params, "ADFscriptsDebug") and Request.Params.ADFscriptsDebug eq 1) request.ADFScriptsDebugging = true; loadedScript(arguments.scriptName); //Clean the arguments.outputHTML for javascript strings arguments.outputHTML = Trim(arguments.outputHTML); // 2011-03-27 - MFC - Output the scripts directly when in IE, not through the JavaScript loader // - Detect if IE to not load through JS if ( ListContains(CGI.HTTP_USER_AGENT, "MSIE") ) arguments.disableJSloader = true; #arguments.outputHTML# // TODO :: TEST THE FOLLOWING jsCommentStripper() METHOD :: // This function removes all JS Comments but allow external URLs to remain // (with the REGEX method below single line comments // and URLs https:// both get stripped out ) //arguments.outputHTML = jsCommentStripper(str=arguments.outputHTML); // Removing single line script comments 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"); #TRIM(renderScript)# 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; var string = arguments.str; var length = 0; var position = 0; variables.jsCSoutputArray = ArrayNew(1); _jsCS_process(str=arguments.str); if ( ArrayLen(variables.jsCSoutputArray) ) string = ArrayToList(variables.jsCSoutputArray,""); return string; var position = 0; while ( !_jsCS_atEnd(str=arguments.str,pos=position) ) { position = _jsCS_processDoubleQuotedString(str=arguments.str,pos=position); position = _jsCS_processSingleQuotedString(str=arguments.str,pos=position); position = _jsCS_processSingleLineComment(str=arguments.str,pos=position); position = _jsCS_processMultiLineComment(str=arguments.str,pos=position); if ( !_jsCS_atEnd(str=arguments.str,pos=position) ) { _jsCS_add(str=arguments.str,pos=position); position = _jsCS_next(pos=position); } } var DOUBLE_QUOTE = '"'; var position = arguments.pos; var currChar = _jsCS_getCurrentCharacter(str=arguments.str,pos=position); if ( currChar == DOUBLE_QUOTE ) { _jsCS_add(str=arguments.str,pos=position); position = _jsCS_next(pos=position); while ( !_jsCS_atEnd(str=arguments.str,pos=position) ) { currChar = _jsCS_getCurrentCharacter(str=arguments.str,pos=position); if ( currChar == DOUBLE_QUOTE && !_jsCS_isEscaping(str=arguments.str,pos=position) ) return position; _jsCS_add(str=arguments.str,pos=position); position = _jsCS_next(pos=position); } } return position; var SINGLE_QUOTE = "'"; var position = arguments.pos; var currChar = _jsCS_getCurrentCharacter(str=arguments.str,pos=position); if ( currChar == SINGLE_QUOTE ) { _jsCS_add(str=arguments.str,pos=position); position = _jsCS_next(pos=position); while (!_jsCS_atEnd(str=arguments.str,pos=position) ) { currChar = _jsCS_getCurrentCharacter(str=arguments.str,pos=position); if ( currChar == SINGLE_QUOTE && !_jsCS_isEscaping(str=arguments.str,pos=position) ) return position; _jsCS_add(str=arguments.str,pos=position); position = _jsCS_next(pos=position); } } return position; var SLASH = '/'; var NEW_LINE = '\n'; var CARRIAGE_RETURN = '\r'; var position = arguments.pos; var currChar = _jsCS_getCurrentCharacter(str=arguments.str,pos=position); var nextChar = _jsCS_getNextCharacter(str=arguments.str,pos=position); if ( currChar == SLASH ) { if ( nextChar == SLASH ) { if ( !_jsCS_atEnd(str=arguments.str,pos=position) ) { position = _jsCS_next(pos=position); while ( !_jsCS_atEnd(str=arguments.str,pos=position) ) { position = _jsCS_next(pos=position); if ( !_jsCS_atEnd(str=arguments.str,pos=position) ) { currChar = _jsCS_getCurrentCharacter(str=arguments.str,pos=position); if ( ArrayLen(REMatch(NEW_LINE,currChar)) || ArrayLen(REMatch(CARRIAGE_RETURN,currChar)) ) return position; } } } } } return position; var SLASH = '/'; var STAR = '*'; var position = arguments.pos; var currChar = _jsCS_getCurrentCharacter(str=arguments.str,pos=position); var nextChar = _jsCS_getNextCharacter(str=arguments.str,pos=position); if ( currChar EQ SLASH) { if ( nextChar EQ STAR) { while ( !_jsCS_atEnd(str=arguments.str,pos=position) ) { position = _jsCS_next(pos=position); currChar = _jsCS_getCurrentCharacter(str=arguments.str,pos=position); nextChar = _jsCS_getNextCharacter(str=arguments.str,pos=position); if ( currChar EQ STAR ) { if ( nextChar EQ SLASH) { position = _jsCS_next(pos=position); position = _jsCS_next(pos=position); return position; } } } } } return position; var caret = arguments.pos - 1; var escaped = false; var BACK_SLASH = '\\'; if ( _jsCS_getPreviousCharacter(str=arguments.str,pos=arguments.pos) == BACK_SLASH ) { while ( caret > 0) { if ( arguments.str.charAt(caret--) != BACK_SLASH ) { return escaped; } escaped = !escaped; } return escaped; } return false; var currentCharacter = _jsCS_getCurrentCharacter(str=arguments.str,pos=arguments.pos); // Add the Current Character to the jsCommentStripper output array arrayAppend(variables.jsCSoutputArray,currentCharacter); return variables.jsCSoutputArray; return arguments.str.charAt(arguments.pos); return arguments.str.charAt(arguments.pos - 1); var nextPos = arguments.pos + 1; if ( !_jsCS_atEnd(str=arguments.str,pos=nextPos) ) return arguments.str.charAt(nextPos); else return ""; if ( arguments.pos >= len(arguments.str) ) return true; else return false;