nl_tokens: Load a script file supports both asynchronous and synchronous approaches
pl_tokens: function ( url , onLoad , onError , <mask> , synchronous ) { var me = this , isFileLoaded = this . isFileLoaded , scriptElements = this . scriptElements , noCacheUrl = url + ( this . getConfig ( 'disableCaching' ) ? ( '?' + this . getConfig ( 'disableCachingParam' ) + '=' + Ext . Date . now ( ) ) : '' ) , xhr , status , content , onScriptError ; if ( isFileLoaded [ url ] ) { return this ; } scope = scope || this ; this . isLoading = true ; if ( ! synchronous ) { onScriptError = function ( ) { //<debug error> onError . call ( scope , "Failed loading '" + url + "', please verify that the file exists" , synchronous ) ; //</debug> } ; if ( ! Ext . isReady && Ext . onDocumentReady ) { Ext . onDocumentReady ( function ( ) { if ( ! isFileLoaded [ url ] ) { scriptElements [ url ] = me . injectScriptElement ( noCacheUrl , onLoad , onScriptError , scope ) ; } } ) ; } else { scriptElements [ url ] = this . injectScriptElement ( noCacheUrl , onLoad , onScriptError , scope ) ; } } else { if ( typeof XMLHttpRequest != 'undefined' ) { xhr = new XMLHttpRequest ( ) ; } else { xhr = new ActiveXObject ( 'Microsoft.XMLHTTP' ) ; } try { xhr . open ( 'GET' , noCacheUrl , false ) ; xhr . send ( null ) ; } catch ( e ) { //<debug error> onError . call ( this , "Failed loading synchronously via XHR: '" + url + "'; It's likely that the file is either " + "being loaded from a different domain or from the local file system whereby cross origin " + "requests are not allowed due to security reasons. Use asynchronous loading with " + "Ext.require instead." , synchronous ) ; //</debug> } status = ( xhr . status == 1223 ) ? 204 : xhr . status ; content = xhr . responseText ; if ( ( status >= 200 && status < 300 ) || status == 304 || ( status == 0 && content . length > 0 ) ) { // Debugger friendly, file names are still shown even though they're eval'ed code // Breakpoints work on both Firebug and Chrome's Web Inspector Ext . globalEval ( content + "\n//@ sourceURL=" + url ) ; onLoad . call ( scope ) ; } else { //<debug> onError . call ( this , "Failed loading synchronously via XHR: '" + url + "'; please " + "verify that the file exists. " + "XHR status code: " + status , synchronous ) ; //</debug> } // Prevent potential IE memory leak xhr = null ; } }