3 X_System_postMessageAccessKey = window.postMessage ? Math.random() * 10000 | 0 : 0,
\r
5 X_System_MESSAGE_RECIVERS = X_System_postMessageAccessKey && {},
\r
7 X_System = X_Class_override(
\r
10 monitor : function(){
\r
18 message : function( name, callback ){
\r
19 var key = Math.random() * 10000 | 0;
\r
20 if( !X_System_postMessageAccessKey ) return;
\r
22 X_System_MESSAGE_RECIVERS[ name + key ] = callback;
\r
23 X_ViewPort[ 'listen' ]( 'message', X_System );
\r
25 return X_System_postMessageAccessKey + '-' + name + key;
\r
28 handleEvent : function( e ){
\r
32 if( e.origin === X.URL.BASE_URL ){
\r
33 i = e.data.indexOf( '-' );
\r
34 console.log( 'msg ||| ' + e.data.substr( 0, i ) );
\r
35 if( e.data.substr( 0, i ) == X_System_postMessageAccessKey ){
\r
36 name = e.data.substr( i, _i = e.data.indexOf( ' ' ) );
\r
37 if( X_System_MESSAGE_RECIVERS[ name ] ){
\r
38 X_System_MESSAGE_RECIVERS[ name ]( e.data.substr( _i + name.length ) );
\r
42 console.log( e.origin + ' ' + X.URL.BASE_URL );
\r
44 return X_CALLBACK_PREVENT_DEFAULT | X_CALLBACK_STOP_PROPAGATION;
\r
50 X_System_javascriptScore;
\r
55 X_TEMP.onRearchEndOfScript = function(){
\r
56 var callbacks = X_TEMP.onSystemReady,
\r
57 i = callbacks.length,
\r
58 now = X_Timer_now(),
\r
59 speed = now - X[ 'bootTime' ];
\r
61 X[ 'bootSpeed' ] = X_System_javascriptScore = speed;
\r
62 console.log( 'js score ' + speed );
\r
64 delete X_TEMP.onRearchEndOfScript;
\r
65 delete X_TEMP.onSystemReady;
\r
68 callbacks[ --i ]( X_System );
\r