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