[2420] | 1 | ( function( ) |
---|
| 2 | { |
---|
[2628] | 3 | var _connector = null; |
---|
| 4 | var _script = null; |
---|
| 5 | |
---|
[2469] | 6 | var _container = null; |
---|
[2562] | 7 | var _divAppboxHeader = null; |
---|
[2469] | 8 | var _loading = new Image( ); |
---|
| 9 | _loading.src = URL_SERVER + '/phpgwapi/images/loading.gif'; |
---|
| 10 | |
---|
[2420] | 11 | function handler( pLink ) |
---|
| 12 | { |
---|
| 13 | var action = pLink.href; |
---|
[2565] | 14 | if ( action == '' ) |
---|
| 15 | return false; |
---|
| 16 | |
---|
[2420] | 17 | var a = ( action.indexOf( 'javascript:' ) === 0 ); |
---|
| 18 | a = ( a || ( action.indexOf( '#' ) === 0 ) ); |
---|
| 19 | a = ( a || ( action.indexOf( window.location + '#' ) === 0 ) ); |
---|
[2509] | 20 | a = ( a || ! ( action.indexOf( 'workflow' ) < 0 ) ); |
---|
[2420] | 21 | |
---|
| 22 | if ( ! a ) |
---|
| 23 | pLink.onclick = function( ) |
---|
| 24 | { |
---|
[2562] | 25 | _divAppboxHeader.innerHTML = ''; |
---|
| 26 | |
---|
[2628] | 27 | var _center = document.createElement( 'center' ); |
---|
| 28 | _center.appendChild( _loading ); |
---|
| 29 | |
---|
[2469] | 30 | _container.innerHTML = ''; |
---|
[2628] | 31 | _container.appendChild( _center ); |
---|
[2562] | 32 | |
---|
[2628] | 33 | var _cacheit = true;//( ( pLink.hasAttribute( 'cacheit' ) && pLink.getAttribute( 'cacheit' ) === 'true' ) ? true : false ); |
---|
[2562] | 34 | |
---|
[2628] | 35 | var request = _connector.go( { |
---|
[2420] | 36 | 'access' : action, |
---|
[2628] | 37 | 'cache' : _cacheit, |
---|
[2420] | 38 | 'handler' : function( data ) |
---|
| 39 | { |
---|
[2628] | 40 | var js = data.match( /<script[^>]*>.*?<\/script>/g ); |
---|
| 41 | var _new_scripts = [ ]; |
---|
| 42 | if ( js ) |
---|
| 43 | { |
---|
| 44 | var tag = /<script([^>]* src="(\S+)"|[^>]*)>(.*?)<\/script>/; |
---|
| 45 | for ( var i = 0; i < js.length; i++ ) |
---|
| 46 | { |
---|
| 47 | var type = tag.exec( js[ i ] ); |
---|
| 48 | data = data.replace( "\n\t\t" + type[ 0 ], '' ); |
---|
| 49 | _new_scripts[ _new_scripts.length ] = type; |
---|
| 50 | } |
---|
| 51 | } |
---|
| 52 | |
---|
[2420] | 53 | var el = document.createElement( 'div' ); |
---|
| 54 | el.innerHTML = data; |
---|
| 55 | |
---|
[2578] | 56 | var _links = el.getElementsByTagName( 'a' ); |
---|
| 57 | for ( var i = 0; i < _links.length; i++ ) |
---|
| 58 | handler( _links.item( i ) ); |
---|
[2420] | 59 | |
---|
[2601] | 60 | _container.innerHTML = ''; |
---|
| 61 | while ( el.hasChildNodes( ) ) |
---|
| 62 | _container.appendChild( el.firstChild ); |
---|
| 63 | |
---|
[2628] | 64 | var _inline = [ ]; |
---|
| 65 | for ( var i = 0; i < _new_scripts.length; i++ ) |
---|
| 66 | if ( _new_scripts[ i ][ 2 ] == undefined || _new_scripts[ i ][ 2 ].length == 0 ) |
---|
| 67 | _inline[ _inline.length ] = _new_scripts[ i ][ 3 ]; |
---|
[2578] | 68 | else |
---|
[2628] | 69 | _script.add( _new_scripts[ i ][ 2 ].substr( |
---|
| 70 | URL_SERVER.length, |
---|
| 71 | _new_scripts[ i ][ 2 ].indexOf( '?' ) - URL_SERVER.length |
---|
| 72 | ) ); |
---|
[2578] | 73 | |
---|
[2628] | 74 | var _it_has_loaded = _script.load( function( ) |
---|
| 75 | { |
---|
| 76 | if ( _inline.length ) |
---|
| 77 | window.eval( _inline.join( '' ) ); |
---|
| 78 | } ); |
---|
| 79 | |
---|
| 80 | if ( ! _it_has_loaded && _inline.length ) |
---|
| 81 | window.eval( _inline.join( '' ) ); |
---|
[2420] | 82 | } |
---|
| 83 | } ); |
---|
| 84 | return false; |
---|
| 85 | }; |
---|
| 86 | } |
---|
| 87 | |
---|
| 88 | XEvents.add( window, 'onload', function( ) |
---|
| 89 | { |
---|
[2628] | 90 | var _scripts = document.getElementsByTagName( 'head' ).item( 0 ).getElementsByTagName( 'script' ); |
---|
| 91 | var _loaded = [ ]; |
---|
[2473] | 92 | |
---|
[2628] | 93 | for ( var i = 0; i < _scripts.length; i++ ) |
---|
| 94 | if ( _scripts.item( i ).getAttribute( 'src' ) != null ) |
---|
| 95 | _loaded[ _loaded.length ] = _scripts.item( i ).getAttribute( 'src' ).substr( |
---|
| 96 | URL_SERVER.length, |
---|
| 97 | _scripts.item( i ).getAttribute( 'src' ).indexOf( '?' ) - URL_SERVER.length |
---|
| 98 | ); |
---|
| 99 | |
---|
| 100 | _connector = new XConnector; |
---|
| 101 | _script = new XScript( _loaded ); |
---|
| 102 | |
---|
[2562] | 103 | _divAppboxHeader = document.getElementById( 'divAppboxHeader' ); |
---|
| 104 | _divAppboxHeader.innerHTML = ''; |
---|
| 105 | |
---|
[2469] | 106 | _container = document.getElementById( 'divAppbox' ); |
---|
[2473] | 107 | |
---|
[2469] | 108 | document.getElementsByTagName( 'body' ).item( 0 ).style.overflowY = 'scroll'; |
---|
[2473] | 109 | |
---|
[2578] | 110 | var _links = document.getElementsByTagName( 'a' ); |
---|
| 111 | for ( var i = 0; i < _links.length; i++ ) |
---|
| 112 | handler( _links.item( i ) ); |
---|
[2420] | 113 | } ); |
---|
| 114 | } )( ); |
---|