Changeset 2756


Ignore:
Timestamp:
05/11/10 15:13:27 (14 years ago)
Author:
rodsouza
Message:

Ticket #1058 - Melhorando a manipulação de javascripts.

Location:
trunk/phpgwapi/js/tools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/phpgwapi/js/tools/xlink.js

    r2741 r2756  
    7171                function _handler( data ) 
    7272                { 
     73                        data = data.trim( ); 
    7374                        data = data.replace( /\n/g, '__LINE_FEED_CHARACTER__' ); 
    74                         var js = data.match( /<script[^>]*>.*?<\/script>/gi ); 
    75                         if ( js ) 
     75                        data = data.replace( /\r|\t/g, '' ); 
     76                        var _js = data.match( /<script[^>]*>.*?<\/script>/gi ); 
     77                        if ( _js ) 
    7678                        { 
    77                                 var _tag = /<script([^>]*src="(\S+)"[^>]*|[^>]*)>(.*?)<\/script>/i; 
    78                                 for ( var i = 0; i < js.length; i++ ) 
     79                                var _tag = /<script([^>]+src=["'](\S+)["'])?[^>]*>(.*?)<\/script>/i; 
     80                                for ( var i = 0; i < _js.length; i++ ) 
    7981                                { 
    80                                         var _type = _tag.exec( js[ i ] ); 
    81                                         data = data.replace( _type[ 0 ], '' ); 
     82                                        data = data.replace( _js[ i ], '' ); 
    8283 
    83                                         if ( _type[ 2 ] == undefined || _type[ 2 ].length == 0 ) 
    84                                                 _script.inline( _type[ 3 ].replace( /__LINE_FEED_CHARACTER__/g, '\n' ) ); 
     84                                        _js[ i ] = _tag.exec( _js[ i ] ); 
     85 
     86                                        if ( _js[ i ][ 2 ] == undefined || _js[ i ][ 2 ].length == 0 ) 
     87                                                _script.inline( _js[ i ][ 3 ].replace( /__LINE_FEED_CHARACTER__/g, '\n' ) ); 
    8588                                        else 
    8689                                        { 
    87                                                 if ( _type[ 2 ].indexOf( window.location.host ) < 0 ) 
    88                                                         _type[ 2 ] = window.location.protocol + '//' + window.location.host + _type[ 2 ]; 
     90                                                var _external = _js[ i ][ 2 ]; 
     91 
     92                                                if ( _external.indexOf( window.location.host ) < 0 ) 
     93                                                        _external = window.location.protocol + '//' + window.location.host + _external; 
    8994 
    9095                                                _script.external( 
    91                                                         _type[ 2 ].substr( 
     96                                                        _external.substr( 
    9297                                                                _path.length - 1, 
    93                                                                 _type[ 2 ].length - _path.length + 1 - ( 
    94                                                                         ( _type[ 2 ].indexOf( '?' ) < 0 ) ? 
    95                                                                                 0 : ( _type[ 2 ].length - _type[ 2 ].indexOf( '?' ) ) 
     98                                                                _external.length - _path.length + 1 - ( 
     99                                                                        ( _external.indexOf( '?' ) < 0 ) ? 
     100                                                                                0 : ( _external.length - _external.indexOf( '?' ) ) 
    96101                                                                ) 
    97102                                                        ) 
  • trunk/phpgwapi/js/tools/xscript.js

    r2729 r2756  
    4747                                        "handler" : function( data ) 
    4848                                        { 
    49                                                 window.eval( data ); 
    5049                                                if ( _count < _new.length && _new[ _count ].type == 'inline' ) 
    51                                                 { 
    52                                                         window.eval( _new[ _count ].content ); 
    53                                                         _count++; 
    54                                                         _handler( ); 
    55                                                 } 
     50                                                        data += _new[ _count ].content; 
     51 
     52                                                if ( window.execScript ) 
     53                                                        window.execScript( data ); 
    5654                                                else 
    57                                                 { 
    58                                                         _count++; 
    59                                                         _handler( ); 
    60                                                 } 
     55                                                        with ( window ) 
     56                                                                window.eval( data ); 
     57 
     58                                                _count++; 
     59                                                _handler( ); 
    6160                                        } 
    6261                                } ); 
     
    6463                                if ( _count < _new.length && _new[ _count ].type == 'inline' ) 
    6564                                { 
    66                                         window.eval( _new[ _count ].content ); 
     65                                        if ( window.execScript ) 
     66                                                window.execScript( _new[ _count ].content ); 
     67                                        else 
     68                                                with ( window ) 
     69                                                        window.eval( _new[ _count ].content ); 
     70 
    6771                                        _count++; 
    6872                                        _handler( ); 
Note: See TracChangeset for help on using the changeset viewer.