Changeset 2729 for trunk/phpgwapi/js/tools/xscript.js
- Timestamp:
- 05/06/10 17:30:43 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/phpgwapi/js/tools/xscript.js
r2703 r2729 5 5 var _new = [ ]; 6 6 7 function _ add( pURL)7 function _inline( ) 8 8 { 9 for ( var i = 0; i < _loaded.length; i++ ) 10 if ( _loaded[ i ] == pURL ) 11 return false; 9 _new[ _new.length ] = { 10 "type" : "inline", 11 "content" : arguments[ 0 ] 12 }; 13 } 12 14 13 _new[ _new.length ] = pURL; 14 15 return true; 15 function _external( ) 16 { 17 _new[ _new.length ] = { 18 "type" : "external", 19 "content" : arguments[ 0 ] 20 }; 16 21 } 17 22 18 23 function _load( ) 19 24 { 20 var _handler = null; 21 if ( arguments.length && typeof arguments[ 0 ] == 'function' ) 22 _handler = arguments[ 0 ]; 25 var _count = 0; 26 function _handler( ) 27 { 28 var _scripts = [ ]; 29 _script : while ( _count < _new.length && _new[ _count ].type != 'inline' ) 30 { 31 for ( var i = 0; i < _loaded.length; i++ ) 32 if ( _loaded[ i ] == _new[ _count ].content ) 33 { 34 _count++; 35 continue _script; 36 } 23 37 24 var _inline = '';25 if ( arguments.length && typeof arguments[ 1 ] == 'string' )26 _inline = arguments[ 1 ];38 _scripts[ _scripts.length ] = _loaded[ _loaded.length ] = _new[ _count ].content; 39 _count++; 40 } 27 41 28 if ( ! _new.length ) 29 { 30 window.eval( _inline); 31 if ( _handler ) 32 _handler( ); 42 _scripts = _scripts.join( ';' ); 43 44 if ( _scripts.length ) 45 _connector.go( { 46 "access" : URL_SERVER + 'controller.php?action=phpgwapi.javascript.get_source&source=' + _scripts, 47 "handler" : function( data ) 48 { 49 window.eval( data ); 50 if ( _count < _new.length && _new[ _count ].type == 'inline' ) 51 { 52 window.eval( _new[ _count ].content ); 53 _count++; 54 _handler( ); 55 } 56 else 57 { 58 _count++; 59 _handler( ); 60 } 61 } 62 } ); 63 else 64 if ( _count < _new.length && _new[ _count ].type == 'inline' ) 65 { 66 window.eval( _new[ _count ].content ); 67 _count++; 68 _handler( ); 69 } 70 71 if ( _count == _new.length ) 72 _new = [ ]; 33 73 } 34 else 35 { 36 var _scripts = _new.join( ';' ); 37 38 for ( var i = 0; i < _new.length; i++ ) 39 _loaded[ _loaded.length ] = _new[ i ]; 40 41 _new = [ ]; 42 43 _connector.go( { 44 "access" : URL_SERVER + 'controller.php?action=phpgwapi.javascript.get_source&source=' + _scripts, 45 "handler" : function( data ) 46 { 47 window.eval( data + _inline); 48 49 if ( _handler ) 50 _handler( ); 51 } 52 } ); 53 } 74 _handler( ); 54 75 } 55 76 … … 61 82 } 62 83 63 Script.prototype.add = _add; 84 Script.prototype.external = _external; 85 Script.prototype.inline = _inline; 64 86 Script.prototype.load = _load; 65 87
Note: See TracChangeset
for help on using the changeset viewer.