OSDN Git Service

Version 0.6.144, fix Gesture for iOS4, fix Node.css, fix X.Net.
authoritozyun <itozyun@user.sourceforge.jp>
Thu, 30 Apr 2015 15:35:44 +0000 (00:35 +0900)
committeritozyun <itozyun@user.sourceforge.jp>
Thu, 30 Apr 2015 15:35:44 +0000 (00:35 +0900)
13 files changed:
0.6.x/js/01_core/09_XPair.js [new file with mode: 0644]
0.6.x/js/01_core/14_XTimer.js
0.6.x/js/02_dom/02_XNode.js
0.6.x/js/02_dom/06_XNodeCSS.js
0.6.x/js/02_dom/10_XNodeAnime.js
0.6.x/js/05_util/01_XNinjaIframe.js
0.6.x/js/06_net/00_XNet.js
0.6.x/js/06_net/01_XNetXHR.js
0.6.x/js/06_net/02_XNetJSONP.js
0.6.x/js/06_net/04_XNetImage.js
0.6.x/js/07_audio/01_XWebAudio.js
0.6.x/js/20_ui/05_XUI_Gesture.js
0.6.x/js/import.js

diff --git a/0.6.x/js/01_core/09_XPair.js b/0.6.x/js/01_core/09_XPair.js
new file mode 100644 (file)
index 0000000..60fb3dc
--- /dev/null
@@ -0,0 +1,76 @@
+X[ 'Pair' ] = {\r
+       'create'  : X_Pair_create,\r
+       \r
+       'get'     : X_Pair_get,\r
+       \r
+       'release' : X_Pair_release\r
+};\r
+\r
+var X_Pair_SIZE            = 1000,\r
+       X_Pair_KEY_STORE_LIST  = [[]],\r
+       X_Pair_PAIR_STORE_LIST = [[]],\r
+       X_Pair_functionString  = new Function( 's', 'p', 'k', (function(){\r
+               var ret = 'var i=0,l=s.length,a;' +\r
+                                 'for(;i<l;++i){' +\r
+                                 'a=s[i];' +\r
+                                 'switch(k){',\r
+                       j = 0, hex;\r
+               for( ; j < X_Pair_SIZE; ++j ){\r
+                       hex = j.toString( 16 );\r
+                       ret += 'case a[0x' + hex + ']:return p[i][0x' + hex + '];';\r
+               };\r
+               return ret + '}}';\r
+       })()),\r
+       X_Pair_noChashe = false,\r
+       \r
+       // TODO キャッシュするペアの数とヒット率、探索時間の記録\r
+       X_Pair_lastKey, X_Pair_lastPair;\r
+\r
+function X_Pair_create( key, pair ){\r
+       var keyStore  = X_Pair_KEY_STORE_LIST[ X_Pair_KEY_STORE_LIST.length - 1 ],\r
+               pairStore = X_Pair_PAIR_STORE_LIST[ X_Pair_PAIR_STORE_LIST.length - 1 ];\r
+       \r
+       X_Pair_noChashe = true;\r
+       if( X_Pair_get( key ) ) return;\r
+       \r
+       if( keyStore.length === X_Pair_SIZE ){\r
+               keyStore  = X_Pair_KEY_STORE_LIST[ X_Pair_KEY_STORE_LIST.length   ] = [];\r
+               pairStore = X_Pair_PAIR_STORE_LIST[ X_Pair_PAIR_STORE_LIST.length ] = [];\r
+       };\r
+       \r
+       keyStore[  keyStore.length  ] = key;\r
+       pairStore[ pairStore.length ] = pair;\r
+};\r
+\r
+function X_Pair_get( key ){\r
+       var chashe = !X_Pair_noChashe, pair;\r
+       \r
+       X_Pair_noChashe = false;\r
+       if( key === X_Pair_lastKey ) return X_Pair_lastPair; // quick\r
+       \r
+       if( ( pair = X_Pair_functionString( X_Pair_KEY_STORE_LIST, X_Pair_PAIR_STORE_LIST, key ) ) && chashe ){\r
+               X_Pair_lastKey  = key;\r
+               X_Pair_lastPair = pair;\r
+       };\r
+       return pair;\r
+};\r
+\r
+function X_Pair_release( key, opt_pair ){\r
+       var i = 0,\r
+               l = X_Pair_KEY_STORE_LIST.length,\r
+               keyStore, pairStore, j;\r
+       \r
+       for( ; i < l; ++i ){\r
+               keyStore  = X_Pair_KEY_STORE_LIST[ i ];\r
+               pairStore = X_Pair_PAIR_STORE_LIST[ i ];\r
+               j = keyStore.indexOf( key );\r
+               if( j !== -1 && ( opt_pair === undefined || pairStore[ j ] === opt_pair ) ){\r
+                       keyStore.splice( j, 1 );\r
+                       pairStore.splice( j, 1 );\r
+                       if( X_Pair_lastKey === key ){\r
+                               X_Pair_lastKey = X_Pair_lastPair = null;\r
+                       };\r
+                       break;\r
+               };\r
+       };\r
+};\r
index 741d12c..c6d8378 100644 (file)
@@ -407,7 +407,7 @@ if( X_UA[ 'iOS' ] ){
                        X_Timer_timeStamp = now;\r
                        X_Timer_waitTime  = last / X_Timer_INTERVAL_TIME | 0;\r
                };\r
-               X_ViewPort[ 'getScrollPosition' ](); // X_DomEvent のための X_ViewPort_scrollX & Y の更新、\r
+               X[ 'ViewPort' ][ 'getScrollPosition' ](); // X_DomEvent のための X_ViewPort_scrollX & Y の更新、\r
        });\r
 };\r
 \r
index b432339..451ea0e 100644 (file)
@@ -1199,16 +1199,13 @@ function X_Node_call( name /*, opt_args... */ ){
        switch( name ){\r
                case 'nodeType' :\r
                        return this[ '_tag' ] ? 1 : 3;\r
-               case 'text' :\r
-                       return this[ 'text' ]();\r
-               case 'html' :\r
-               case 'innerHTML' :\r
-                       return this[ 'html' ]();\r
                case 'outerHTML' :\r
                        X_Node_outerXNode = X_Node_body; // == true ならなんでもよい。型を合わすために xbody にしている\r
                        v = this[ 'html' ]();\r
                        X_Node_outerXNode = null;\r
                        return v;\r
+               case 'treeIsDirty' :\r
+                       return !!X_Node_updateTimerID;\r
                case 'fontSize' :\r
                        return X_Node_CSS_getCharSize( this );\r
                case 'inGPU' :\r
index 4f22524..31fee5c 100644 (file)
@@ -524,8 +524,9 @@ Node.prototype[ 'css' ] = function( nameOrObj /* orUnitID, valuOrUnitOrName */ )
                        if( css[ name ] === v ) continue;
                        flags = X_Node_CSS_setStyle( css, flags, name, v );
                };
-               this[ '_flags' ] |= X_Node_State.DIRTY_CSS | X_Node_State.OLD_CSSTEXT;
-               this[ '_flags' ] & X_Node_State.IN_TREE && X_Node_reserveUpdate();
+               flags |= X_Node_State.DIRTY_CSS | X_Node_State.OLD_CSSTEXT;
+               this[ '_flags' ] = flags;
+               flags & X_Node_State.IN_TREE && X_Node_reserveUpdate();
                delete this[ '_cssText' ];
                return this;
        } else
@@ -560,6 +561,7 @@ function X_Node_CSS_setStyle( css, flags, name, newValue ){
        
        switch( name ){
                case 'display' :
+                       console.log( newValue );
                        newValue === 'none' ? ( flags |= X_Node_State.STYLE_IS_DISPLAY_NONE ) : ( flags &= ~X_Node_State.STYLE_IS_DISPLAY_NONE );
                        return flags;
                        
index 839697a..0b5a8a8 100644 (file)
@@ -329,6 +329,9 @@ function X_Node_Anime_updateAnimation( xnode ){
                        \r
                case 3 : // アニメーションの解除\r
                        obj.phase = obj.gpuParent ? 10 : 4;\r
+                       \r
+                       console.log( '#### アニメーションの解除 ' + obj.phase );\r
+                       \r
                        // このタイミングで animation 関連の css を削除したところ(X_Node_Anime_clearTransition)、iOS3、4 で再描画忘れが度々起きるように、、、\r
                        if( !obj.gpuParent ) X_Node_Anime_clearTransition( xnode );\r
                        //xnode[ 'dispatch' ]( { type : X_EVENT_ANIME_END, 'gpu' : obj.gpuParent } );\r
@@ -343,6 +346,7 @@ function X_Node_Anime_updateAnimation( xnode ){
                        // アニメーションは停止・GPUレイヤーは解除していない(再アニメーションに備えて待機)\r
                        //X_Node_Anime_clearTransition( xnode ); // TODO X_Node_Anime_releaseGPULayer に移動?\r
                        if( !obj.gpuTimerID ){\r
+                               console.log( '#### アニメーションは停止 ' + obj.wait );\r
                                if( obj.wait ){\r
                                        obj.gpuTimerID = X_Timer_once( obj.wait, xnode, X_Node_Anime_releaseGPULayer );\r
                                } else {\r
@@ -430,12 +434,12 @@ function X_Node_Anime_onTransitionEnd( e ){
        \r
        this[ '_anime' ].phase = 3;\r
        \r
+       X_Node_Anime_clearTransition( this ); // X_EVENT_ANIME_END より前で呼んでおく\r
+       \r
        X_Node_Anime_onTransition = true;\r
        this[ 'dispatch' ]( { type : X_EVENT_ANIME_END, 'gpu' : this[ '_anime' ].gpuParent } );\r
        X_Node_Anime_onTransition = false;\r
        \r
-       X_Node_Anime_clearTransition( this ); // iOS 大丈夫??\r
-       \r
        X_Node_Anime_needsDetection = true;\r
        // iOS は transitionend 内の 更新でアニメーション可能 iOS3, iOS4 で確認 \r
        // win+Gecko は不可\r
@@ -455,7 +459,7 @@ function X_Node_Anime_releaseGPULayer(){
        X_Node_ANIMATIONS.splice( X_Node_ANIMATIONS.indexOf( this ), 1 );\r
        delete obj.gpuTimerID;\r
        delete this[ '_anime' ];\r
-       //console.log( 'GPUレイヤーの破棄を指示' );\r
+       console.log( 'GPUレイヤーの破棄を指示' );\r
        \r
        X_ViewPort[ 'listenOnce' ]( X_EVENT_AFTER_UPDATE, this, X_Node_Anime_gpuReleased );\r
 };\r
index f400818..b3cb362 100644 (file)
@@ -72,7 +72,7 @@ X[ 'Util' ][ 'NinjaIframe' ] = Node[ 'inherits' ](
                                this._iwin.location.reload();\r
                        };\r
                        \r
-                       if( !opt_contentHTML ) return this;\r
+                       if( !opt_contentHTML && opt_contentHTML !== '' ) return this;\r
                        \r
                        this._contentHTML = opt_contentHTML;\r
                        X_UA[ 'IE' ] < 9 || X_Util_NinjaIframe_writeToIframe( this );\r
@@ -103,7 +103,7 @@ function X_Util_NinjaIframe_handleEvent( e ){
                        this[ 'listen' ]( [ X_UA[ 'IE' ] < 9 ? 'readystatechange' : 'load', 'error' ], this, X_Util_NinjaIframe_handleEvent );\r
                        \r
                        if( !( X_UA[ 'IE' ] < 9 ) ){\r
-                               this._contentHTML && X_Util_NinjaIframe_writeToIframe( this );\r
+                               ( this._contentHTML || this._contentHTML === '' ) && X_Util_NinjaIframe_writeToIframe( this );\r
                                this._ready = true;\r
                                return;\r
                        };\r
@@ -113,18 +113,18 @@ function X_Util_NinjaIframe_handleEvent( e ){
                        if( ( raw.readyState !== 'complete' && raw.readyState !== 'loaded' ) ) break;\r
                        // ie9-\r
                        if( !this._ready ){\r
-                               this._contentHTML && X_Util_NinjaIframe_writeToIframe( this );\r
+                               ( this._contentHTML || this._contentHTML === '' ) && X_Util_NinjaIframe_writeToIframe( this );\r
                                this._ready = true;\r
                                break;\r
                        };\r
                        // onload\r
                case 'load' :\r
                        console.log( 'iframe load.' );\r
-                       this[ 'asyncDispatch' ]( X_EVENT_SUCCESS );\r
+                       this[ 'asyncDispatch' ]( 'ninjaload' );\r
                        break;\r
 \r
                case 'error' :\r
-                       this[ 'asyncDispatch' ]( X_EVENT_ERROR );\r
+                       this[ 'asyncDispatch' ]( 'ninjaerror' );\r
                        break;\r
        };\r
        \r
index 4d96192..e7a6762 100644 (file)
 \r
 // http://bugs.jquery.com/ticket/2709\r
 // <head><base> がある場合、<script>の追加に失敗する\r
-X[ 'Net' ] = {\r
-\r
-       'xhrGet' : function( url, obj ){\r
-               if( X_Type_isString( url ) ){\r
-                       if( obj ){\r
-                               obj[ 'url' ] = url;\r
-                       } else {\r
-                               obj = { 'url' : url };\r
-                       };\r
-               } else {\r
-                       obj = url;\r
-               };\r
-               obj[ 'method' ] = 'GET';\r
-               return new X_NET_Queue( X_NET_TYPE_XHR, obj );\r
-       },\r
-       \r
-       'xhrPost' : function( url, postbody, obj ){\r
-               if( X_Type_isString( url ) ){\r
-                       if( obj ){\r
-                               obj[ 'url' ] = url;\r
-                       } else {\r
-                               obj = { 'url' : url };\r
-                       };\r
-               } else {\r
-                       obj = url;\r
-               };\r
-               obj[ 'method' ] = 'POST';\r
-               obj[ 'postbody' ] = postbody;\r
-               return new X_NET_Queue( X_NET_TYPE_XHR, obj );\r
-       },\r
-       \r
-       'formGet' : function(){\r
-               \r
-       },\r
-       \r
-       'formPost' : function(){\r
-               \r
-       },\r
-       \r
-       // TODO chashe\r
-       // TODO iframe useful or not. TODO dynamicIframe\r
-       // TODO file: では http: は使えない\r
-       'jsonp' : function( url, useIframe ){\r
-               return new X_NET_Queue( X_NET_TYPE_JSONP, url );\r
-       },\r
-       \r
-       'image' : function( url, needSize, delay, timeout ){\r
-               return new X_NET_Queue( X_NET_TYPE_IMAGE, { url : url, needSize : needSize } );\r
-       },\r
-       \r
-       'gadget' : function( obj ){\r
-               return new X_NET_Queue( 5, obj );\r
-       },\r
-       // <script>, <link>\r
-       \r
-       'amountQueue' : function(){\r
-               return X_NET_QUEUE_LIST.length;\r
-       }\r
-\r
-};\r
-\r
-/*\r
- * @interface\r
- */\r
-var X_NET_IWrapper = function(){};\r
-       X_NET_IWrapper.prototype.load   = function(){};\r
-       X_NET_IWrapper.prototype.cancel = function(){};\r
-       X_NET_IWrapper.prototype.reset  = function(){};\r
-\r
-\r
-var X_NET_TYPE_XHR   = 1,\r
-       X_NET_TYPE_JSONP = 2,\r
-       X_NET_TYPE_FORM  = 3,\r
-       X_NET_TYPE_IMAGE = 4,\r
-\r
-       X_NET_QUEUE_LIST = [],\r
-\r
-       X_NET_XHRWrapper,\r
-       X_NET_JSONPWrapper,\r
-       X_NET_FormWrapper,\r
-       X_NET_ImageWrapper,\r
-       X_NET_GIMRWrapper,\r
-\r
-       X_NET_currentWrapper,\r
-       X_NET_currentQueue;\r
 \r
 /**\r
- * フレームワークによってラップされたネットワーク機能にアクセスするためのクラス。\r
- *     \r
- * @alias X_NET_Queue\r
- * @class X_NET_Queue\r
- * @constructs X_NET_Queue\r
+ * cancel(), busy() メソッドだけを持つ。X.Pair によって、プライベートメンバは隠蔽される。X_EVENT_PROGRESS, X_EVENT_SUCCESS, X_EVENT_ERROR, X_EVENT_TIMEOUT, X_EVENT_CANCELED\r
+ * \r
+ * @alias X.Net\r
+ * @class 各種ネットワーク機能をラップしインターフェイスを共通化する。\r
+ * @constructs Net\r
  * @extends {EventDispatcher}\r
+ * @example // XHR - GET\r
+ * var net = X.Net( { xhr : urlString } )\r
+ *             .listenOnce( X.Event.PROGRESS );\r
+ *             .listen( [ X.Event.SUCCESS, X.Event.ERROR, X.Event.TIMEOUT, X.Event.CANCELED ] );\r
+ * \r
+ * // XHR - POST \r
+ * var net = X.Net( { xhr : urlString, postbody : myData } );\r
+ * \r
+ * // JSONP\r
+ * var net = X.Net( { jsonp : urlString, staticCallbackName : callbackName, useXDomainWall : false } );\r
+ * \r
+ * // Image preload & getSize\r
+ * var net = X.Net( { image : src, sizeDetection : true } );\r
+ * \r
+ * // load <script>, <link>\r
  */\r
-var X_NET_Queue = X_EventDispatcher[ 'inherits' ](\r
-               'XNetQueue',\r
-               X_Class.POOL_OBJECT,\r
+X[ 'Net' ] = X_EventDispatcher[ 'inherits' ](\r
+               'X.Net',\r
+               X_Class.NONE,\r
                \r
-               /** @lends X_NET_Queue.prototype */\r
                {\r
-                       type : 0,\r
-                       data : null,\r
-                       \r
-                       'Constructor' : function( type, data ){\r
-                               this.type = type;\r
-                               this.data = data;\r
+                       'Constructor' : function( urlOrObject, opt_options ){\r
+                               var v, opt;\r
+                               \r
+                               if( X_Type_isObject( opt = urlOrObject ) ){\r
+                                       if( v = opt[ 'xhr' ] ){\r
+                                               url  = v;\r
+                                               type = X_NET_TYPE_XHR;\r
+                                       } else\r
+                                       if( v = opt[ 'jsonp' ] ){\r
+                                               url  = v;\r
+                                               type = X_NET_TYPE_JSONP;\r
+                                       } else\r
+                                       if( v = opt[ 'img' ] || opt[ 'image' ] ){\r
+                                               url  = v;\r
+                                               type = X_NET_TYPE_IMAGE;\r
+                                       } else\r
+                                       if( v = opt[ 'form' ] ){\r
+                                               url  = v;\r
+                                               type = X_NET_TYPE_FORM;\r
+                                       } else\r
+                                       if( v = opt[ 'type' ] ){\r
+\r
+                                               switch( v ){\r
+                                                       case 'xhr' :\r
+                                                               type = X_NET_TYPE_XHR;\r
+                                                               break;\r
+                                                       case 'jsonp' :\r
+                                                               type = X_NET_TYPE_JSONP;\r
+                                                               break;\r
+                                                       case 'img' :\r
+                                                       case 'image' :\r
+                                                               type = X_NET_TYPE_IMAGE;\r
+                                                               break;\r
+                                                       case 'from' :\r
+                                                               type = X_NET_TYPE_FORM;\r
+                                                               break;\r
+                                                       default :\r
+                                                               alert( 'X.Net args error' );\r
+                                                               return; \r
+                                               };\r
+                                               \r
+                                               if( X_Type_isString( url = opt[ 'url' ] ) ){\r
+                                                       alert( 'X.Net args error' );\r
+                                                       return;\r
+                                               };\r
+                                               \r
+                                       } else {\r
+                                               alert( 'X.Net args error' );\r
+                                               return;\r
+                                       };\r
+                                       \r
+                               } else\r
+                               if( X_Type_isString( urlOrObject ) ){\r
+                                       url = urlOrObject;\r
+                                       \r
+                                       if( X_Type_isObject( opt = opt_options ) ){\r
+                                               type = opt[ 'type' ] || X_NET_TYPE_XHR;\r
+                                       } else {\r
+                                               type = X_NET_TYPE_XHR;\r
+                                               opt  = { 'url' : url, 'method' : 'GET' };\r
+                                       };\r
+                                       \r
+                               } else {\r
+                                       alert( 'X.Net args error' );\r
+                                       return;\r
+                               };\r
                                \r
-                               //this[ 'listenOnce' ]( X_EVENT_COMPLETE, X_NET_proxyDispatch );\r
-                               X_EventDispatcher_systemListen( this, X_EVENT_COMPLETE, X_NET_proxyDispatch );\r
+                               if( type === X_NET_TYPE_XHR ){\r
+                                       opt[ 'method' ] = opt[ 'method' ] || ( opt[ 'postbody' ] ? 'POST' : 'GET' );\r
+                                       \r
+                                       // XDomain -> Flash, Gears, Silverlight に切替?\r
+                               };                              \r
+                               \r
+                               opt = X_Object_clone( opt );\r
+                               opt[ 'type' ] = type;\r
+                               opt[ 'url'  ] = url;\r
+                               \r
+                               X_Pair_create( this, opt );\r
+                               \r
+                               this[ 'listenOnce' ]( X_EVENT_COMPLETE, X_NET_proxyDispatch );\r
                                \r
                                X_NET_QUEUE_LIST[ X_NET_QUEUE_LIST.length ] = this;\r
                                !X_NET_currentQueue && X_NET_shiftQueue();\r
                        },\r
                        \r
+               /**\r
+                * オブジェクトが現在通信中か?\r
+                * @alias Net.prototype.budy\r
+                * @return {boolean}\r
+                */\r
                        'busy' : function(){\r
                                return this === X_NET_currentQueue && X_NET_currentWrapper._busy;\r
                        },\r
-                       \r
+\r
+               // TODO -> kill\r
+               /**\r
+                * 通信のキャンセル\r
+                * @alias Net.prototype.cancel\r
+                * @return {Net} 自身を返す、メソッドチェーン\r
+                */\r
                        'cancel' : function(){\r
                                var i = X_NET_QUEUE_LIST.indexOf( this );\r
                                if( i !== -1 ){\r
                                        X_NET_QUEUE_LIST.splice( i, 1 );\r
                                        this[ 'asyncDispatch' ]( X_EVENT_CANCELED );\r
                                        this[ 'asyncDispatch' ]( 16, X_EVENT_COMPLETE );\r
+                                       // this[ 'listenOnce' ]( X_EVENT_COMPLETE, X_NET_proxyDispatch );\r
                                } else\r
                                if( this === X_NET_currentQueue ){\r
                                        X_NET_currentWrapper.cancel();\r
                                };\r
+                               return this;\r
                        }\r
                }\r
        );\r
+/*\r
+ * @interface\r
+ */\r
+var X_NET_IWrapper = function(){};\r
+       X_NET_IWrapper.prototype.load   = function(){};\r
+       X_NET_IWrapper.prototype.cancel = function(){};\r
+       X_NET_IWrapper.prototype.reset  = function(){};\r
+\r
+\r
+var X_NET_TYPE_XHR   = 1,\r
+       X_NET_TYPE_JSONP = 2,\r
+       X_NET_TYPE_FORM  = 3,\r
+       X_NET_TYPE_IMAGE = 4,\r
+\r
+       X_NET_QUEUE_LIST = [],\r
+\r
+       X_NET_XHRWrapper,\r
+       X_NET_JSONPWrapper,\r
+       X_NET_FormWrapper,\r
+       X_NET_ImageWrapper,\r
+       X_NET_GIMRWrapper,\r
+\r
+       X_NET_currentWrapper,\r
+       X_NET_currentQueue,\r
+       X_NET_currentData;\r
 \r
 function X_NET_proxyDispatch( e ){\r
        switch( e.type ){\r
@@ -151,9 +189,11 @@ function X_NET_proxyDispatch( e ){
                case X_EVENT_TIMEOUT :\r
                case X_EVENT_CANCELED :\r
                        this[ 'dispatch' ]( e );\r
-                       this[ 'asyncDispatch' ]( X_EVENT_COMPLETE );\r
+                       this[ 'asyncDispatch' ]( { type : X_EVENT_COMPLETE, 'lastEventType' : e.type } );\r
+                       // this[ 'listenOnce' ]( X_EVENT_COMPLETE, X_NET_proxyDispatch );\r
                        break;\r
                case X_EVENT_COMPLETE :\r
+                       X_Pair_release( this );\r
                        this[ 'kill' ]();\r
                        X_NET_shiftQueue();\r
                        break;\r
@@ -161,41 +201,41 @@ function X_NET_proxyDispatch( e ){
 };\r
 \r
 function X_NET_shiftQueue(){\r
-       var queue;\r
-       \r
+\r
        if( X_NET_currentQueue ){\r
                console.log( 'X_NET_shiftQueue ' + X_NET_currentWrapper._busy );\r
                if( X_NET_currentWrapper._busy ) return;\r
                X_NET_currentWrapper\r
                        [ 'unlisten' ]( [ X_EVENT_PROGRESS, X_EVENT_SUCCESS, X_EVENT_ERROR, X_EVENT_TIMEOUT, X_EVENT_CANCELED ], X_NET_currentQueue, X_NET_proxyDispatch )\r
                        .reset();\r
-               X_NET_currentQueue = X_NET_currentWrapper = null;\r
+               X_NET_currentQueue = X_NET_currentWrapper = X_NET_currentData = null;\r
        };\r
        \r
        if( !X_NET_QUEUE_LIST.length ) return;\r
 \r
-       queue = X_NET_QUEUE_LIST.shift();\r
+       X_NET_currentQueue = X_NET_QUEUE_LIST.shift();\r
+       X_NET_currentData  = X_Pair_get( X_NET_currentQueue );\r
        \r
-       switch( queue.type ){\r
+       switch( X_NET_currentData.type ){\r
                case X_NET_TYPE_XHR :\r
-                       X_NET_currentWrapper = X_NET_XHRWrapper;\r
+                       X_NET_currentWrapper = X_NET_XHRWrapper   || X_TEMP.X_Net_XHR_init();\r
                        break;\r
                case X_NET_TYPE_JSONP :\r
-                       X_NET_currentWrapper = X_NET_JSONPWrapper; // X_NET_JSONPWrapper || createJSONPWrapper\r
+                       X_NET_currentWrapper = X_NET_JSONPWrapper || X_TEMP.X_NET_JSONP_init();\r
                        break;\r
                case X_NET_TYPE_FORM :\r
                        X_NET_currentWrapper = X_NET_FormWrapper;\r
                        break;\r
                case X_NET_TYPE_IMAGE :\r
-                       X_NET_currentWrapper = X_NET_ImageWrapper;\r
+                       X_NET_currentWrapper = X_NET_ImageWrapper || X_TEMP.X_NET_Image_init();\r
                        break;\r
                case 5 :\r
                        X_NET_currentWrapper = X_NET_GIMRWrapper;\r
                        break;\r
        };\r
        \r
-       X_NET_currentWrapper[ 'listen' ]( [ X_EVENT_PROGRESS, X_EVENT_SUCCESS, X_EVENT_ERROR, X_EVENT_TIMEOUT, X_EVENT_CANCELED ], X_NET_currentQueue = queue, X_NET_proxyDispatch );\r
+       X_NET_currentWrapper[ 'listen' ]( [ X_EVENT_PROGRESS, X_EVENT_SUCCESS, X_EVENT_ERROR, X_EVENT_TIMEOUT, X_EVENT_CANCELED ], X_NET_currentQueue, X_NET_proxyDispatch );\r
        \r
-       X_NET_currentWrapper.load( queue.data );\r
+       X_NET_currentWrapper.load( X_NET_currentData );\r
 };\r
 \r
index 2095b96..1dc2d5a 100644 (file)
@@ -49,7 +49,9 @@ var // Opera7.6+, Safari1.2+, khtml3.?+, Gecko0.9.7+
                                'return[v[++i],new ActiveXObject(n[i])]',\r
                        '}catch(e){}',\r
                '}'\r
-       ].join( '' ) ) )();\r
+       ].join( '' ) ) )(),\r
+       \r
+       X_Net_XHR_init;\r
 \r
 if( X_Net_XHR_ACTIVE_X ){\r
        X_Net_XHR_VERSION  = X_Net_XHR_ACTIVE_X[ 0 ];\r
@@ -79,6 +81,10 @@ X[ 'Net' ][ 'XHR' ] = {
 };\r
 \r
 if( X_Net_XHR_W3C || X_Net_XHR_ACTIVE_X ){\r
+\r
+X_TEMP.X_Net_XHR_init = function(){\r
+       \r
+       delete X_TEMP.X_Net_XHR_init;\r
        \r
        X_NET_XHRWrapper = X_Class_override(\r
                X_EventDispatcher(),\r
@@ -219,27 +225,11 @@ if( X_Net_XHR_W3C || X_Net_XHR_ACTIVE_X ){
                                \r
 \r
                                raw.send( postbody || '' );\r
-                               //this._timerID = X_Timer_once( 16, this, this._lazySend, [ postbody || '', timeout ] );\r
                        },\r
-                       /*\r
-                       // send() 内で onload するケースがあり、そのときはイベントリスナが間に合わないので、タイマーをかませる。\r
-                       _lazySend : function( postbody, timeout ){\r
-                               if( this[ '_rawObject' ].timeout === undefined ){\r
-                                       this._timerID = X_Timer_once( timeout, this, this.onTimeout );\r
-                               } else {\r
-                                       this._timerID = 0;\r
-                               };\r
-                               \r
-                               // http://allabout.co.jp/gm/gc/24097/#1\r
-                               // sendをonreadystatechangeの前に記述すると、ieでは動作しなくなります、、、。\r
-                               // konquerorでエラーが発生するのでここでは、とりあえず、send('') としました。\r
-                               this[ '_rawObject' ].send( postbody );                          \r
-                       }, */\r
                        \r
                        cancel : function(){\r
                                /* X.Net.XHR.CANCELABLE && */ this[ '_rawObject' ].abort && this[ '_rawObject' ].abort();\r
                                this._canceled = true;\r
-                               this[ 'asyncDispatch' ]( X_EVENT_CANCELED );\r
                        },\r
                        \r
                        reset : function(){\r
@@ -447,5 +437,9 @@ if( X_Net_XHR_W3C || X_Net_XHR_ACTIVE_X ){
        if( X_Net_XHR_upload ){\r
                X_NET_XHRWrapper[ '_rawObject' ].upload.addEventListener( 'progress', X_NET_XHRWrapper.onUploadProgress );\r
        };\r
+       \r
+       return X_NET_XHRWrapper;\r
+};\r
+\r
 };\r
 \r
index 21d5e36..11dd975 100644 (file)
  * 
  * IE6(IETester,localhost) で動かない,
  * 
- * TODO postMessage
+ * TODO iframe 内を他ドメインにして jsonp のセキュリティを強化。他ドメインに jsonp を読み込んで 正しい JSON か?検証後にフレーム間通信で戻す。
  */
 
+       // TODO chashe
+       // TODO iframe useful or not. TODO check dynamicIframe
+       // TODO file: では http: は使えない
+
 X[ 'Net' ][ 'JSONP' ] = {
        'cb' : function( accessKey, jsonString, time, opt_json2FileSize ){
                        if( accessKey !== X_NET_JSONP_ACCESS_KEY || !X_NET_JSONPWrapper._busy ) return;
@@ -31,184 +35,180 @@ X[ 'Net' ][ 'JSONP' ] = {
                                        data : window.JSON ? JSON.parse( jsonString ) : eval( 'var a=' + jsonString + ';a' )
                                } );
                        
+                       X_Net_JSONP_errorTimerID && X_Timer_remove( X_Net_JSONP_errorTimerID );
+                       
                        console.log( 'ms : ' + time + ' speed : ' + ( ( jsonString.length + ( opt_json2FileSize || 0 ) ) / time * 1000 ) + ' バイト/秒.' );
                }
 };
 
-function X_Net_JSONP_reciveMessage( data ){
-       console.log( data );
-};
-
 var X_NET_JSONP_ACCESS_KEY = Math.random(),
        
-       X_NET_JSONP_SEND_MSG_KEY = X_System.message( 'X.Net.JSONP', X_Net_JSONP_reciveMessage ),
+       X_Net_JSONP_maxOnloadCount,
        
-       X_NET_JSONP_NinjaIframe,
+       X_Net_JSONP_onloadCount = 0,
        
-       X_Net_JSONP_onloadCount;
+       X_Net_JSONP_errorTimerID;
 
+X_TEMP.X_NET_JSONP_init = function(){
        
-
-function X_NET_JSONP_loadScriptInNinjaIframe( url ){
-       var json2Path     = 'js/libs/json2.js',
-               json2FileSize = 18103,
-               html;
+       delete X_TEMP.X_NET_JSONP_init;
        
-       X_NET_JSONP_NinjaIframe || ( X_NET_JSONP_NinjaIframe = X[ 'Util' ][ 'NinjaIframe' ]() );
+       return X_NET_JSONPWrapper = X_Class_override(
+               X[ 'Util' ][ 'NinjaIframe' ](),
+               {
        
-       // TODO '<scr'+'ipt> 化 恐らくアンチウイルスソフトが反応しないための対策
-       // TODO postMessage の利用
-       // document.postMessage()→window.postMessage() (Opera 9.50 build 9841 -)
-       // http://d.hatena.ne.jp/cnrd/20080518/1211099169
-       // 最近の仕様変更(引数のtargetOriginとかMessageEventのoriginとか)にはまだ対応してないみたい 
-
-       if( X_UA[ 'Opera' ] ){
-               html = [
-                       ( window[ 'JSON' ] ? '' : '<script src="' + json2Path + '"></script>' ),
-                       '<script>',
-                               'onunload=function(){im.onload=im.onerror=""};',
-                               'nw=+new Date;',
-                               'function cb(o){if(nw){nw-=+new Date;parent.X.Net.JSONP.cb(' + X_NET_JSONP_ACCESS_KEY + ',JSON.stringify(o),-nw', window[ 'JSON' ] ? json2FileSize : 0 ,');nw=0}}',
-                       '</script>',    
-                       '<script id="jp"></script>',
-                       '<img id="im" src="', url, '" onload="jp.src=im.src" onerror="jp.src=im.src">'
-               ];
-               X_Net_JSONP_onloadCount = 2;
-       } else
-       if( X_UA[ 'IE8' ] ){
-               html = [
-                       // JavaScriptでunicode文字列をunescapeする
-                       // http://perutago.seesaa.net/article/202801583.html
+                       _busy         : false,
+                       _canceled     : false,
                        
-                       // http://blog.livedoor.jp/dankogai/archives/51503830.html              
-                       // Ajax - IE8にもJSON入ってます。使えるとは限らないけど
-                       // Compatibility mode (別名Quirks mode) では、JSONオブジェクトは無効になります。iframeもだめです
-                       '<script id="jp"></script>',
-                       '<script>',
-                               'onunload=function(){clearTimeout(id)};',
-                               'nw=0;', // なぜか必要,,,
-                               'function cb(o){nw-=+new Date;parent.X.Net.JSONP.cb(' + X_NET_JSONP_ACCESS_KEY + ',parent.JSON.stringify(o).replace(/\\\\u([a-fA-F0-9]{4})/g,function(a,b){return String.fromCharCode(parseInt(b,16))}),-nw)}',
-                               //'function cb(o){if(nw){nw-=+new Date;postMessage("', X_NET_JSONP_SEND_MSG_KEY,' "+nw+"|"+parent.JSON.stringify(o).replace(/\\\\u([a-fA-F0-9]{4})/g,function(a,b){return String.fromCharCode(parseInt(b,16))}),"*");nw=0}}',                   
-                               'function tm(){jp.src="', url ,'";nw=+new Date}',
-                               'id=setTimeout(tm,16);',
-                       '</script>'
+                       load : function( option ){
+                               //createURL
+                               var url           = option[ 'url' ],
+                                       json2Path     = 'js/libs/json2.js',
+                                       json2FileSize = 18103,
+                                       html;
+                               
+                               // TODO '<scr'+'ipt> 化 恐らくアンチウイルスソフトが反応しないための対策
+                               // document.postMessage()→window.postMessage() (Opera 9.50 build 9841 -)
+                               // http://d.hatena.ne.jp/cnrd/20080518/1211099169
+                               // 最近の仕様変更(引数のtargetOriginとかMessageEventのoriginとか)にはまだ対応してないみたい 
                        
-                       /* 以下のコードは XP ie8 では動くけど、win8 IE11(8モード)で動かない 開発の便宜を取って,setTimeout を挟む
-                       '<script>',
-                               'function cb(o){window.parent.X.Net.JSONP.cb(' + X_NET_JSONP_ACCESS_KEY + ',window.parent.JSON.stringify(o))}',
-                       '</script>',
-                       '<script src="', url, '"></script>' */
-               ];
-               X_Net_JSONP_onloadCount = 2;
-       } else
-       if( X_UA[ 'IE9' ] ){
-               html = [
-                       '<script id="jp"></script>',
-                       '<script>',
-                               'onunload=function(){clearTimeout(id)};',
-                               'function cb(o){nw-=+new Date;parent.X.Net.JSONP.cb(' + X_NET_JSONP_ACCESS_KEY + ',JSON.stringify(o),-nw)}',
-                               'function tm(){jp.src="', url ,'";nw=+new Date}',
-                               'id=setTimeout(tm,16);',
-                       '</script>'
-               ];
-               X_Net_JSONP_onloadCount = 2;
-       } else
-       if( window[ 'JSON' ] ){
-               html = [        
-                       '<script>',
-                               'nw=+new Date;',
-                               'function cb(o){if(nw){nw-=+new Date;parent.X.Net.JSONP.cb(' + X_NET_JSONP_ACCESS_KEY + ',JSON.stringify(o),-nw);nw=0}}',
-                               //'function cb(o){if(nw){nw-=+new Date;parent.postMessage("', X_NET_JSONP_SEND_MSG_KEY,' "+nw+"|"+JSON.stringify(o),"', location.origin, '");nw=0}}',
-                       '</script>',
-                       '<script src="', url, '"></script>'
-               ];
-               X_Net_JSONP_onloadCount = 1;
-       } else
-       if( X_UA[ 'IE4' ] || X_UA[ 'MacIE' ] ){
-               html = [
-                       '<script id="jn"></script>',
-                       '<script id="jp"></script>',
-                       '<script>',
-                               'onunload=function(){clearTimeout(id)};',
-                               'function cb(o){nw-=new Date;parent.X.Net.JSONP.cb(' + X_NET_JSONP_ACCESS_KEY + ',JSON.stringify(o),-nw-16,', json2FileSize, ')}',
-                               'function t1(){document.all.jn.src="', json2Path ,'";id=setTimeout("t2()",16);nw=+new Date}',
-                               'id=setTimeout("t1()",16);',
-                               'function t2(){if(window.JSON){document.all.jp.src="', url ,'"}else{id=setTimeout("t2()",16)}}',
-                       '</script>'
-               ];
-               X_Net_JSONP_onloadCount = 3;
-       } else
-       if( X_UA[ 'IE' ] < 8 ){ // ie5-7
-               html = [
-                       '<script id="jn"></script>',
-                       '<script id="jp"></script>',
-                       '<script>',
-                               'onunload=function(){clearTimeout(id)};',
-                               'function cb(o){nw-=new Date;parent.X.Net.JSONP.cb(' + X_NET_JSONP_ACCESS_KEY + ',JSON.stringify(o),-nw-16,', json2FileSize, ')}',
-                               'function t1(){jn.src="', json2Path ,'";id=setTimeout(t2,16);nw=+new Date}',
-                               'id=setTimeout(t1,16);',
-                               'function t2(){if(window.JSON){jp.src="', url ,'"}else{id=setTimeout(t2,16)}}',
-                       '</script>'
-               ];
-               X_Net_JSONP_onloadCount = 3;
-       } else {
-               html = [
-                       '<script>',
-                               'function cb(o){if(nw){nw-=new Date;parent.X.Net.JSONP.cb(' + X_NET_JSONP_ACCESS_KEY + ',JSON.stringify(o),-nw,', json2FileSize, ');nw=0}}',
-                               'nw=+new Date;',
-                       '</script>',
-                       '<script src="', json2Path, '"></script>',
-                       '<script src="', url, '"></script>'
-               ];
-               X_Net_JSONP_onloadCount = 1;
-       };
-       
-       X_NET_JSONP_NinjaIframe
-               [ 'refresh' ]( html.join( '' ) )
-               [ 'listen' ]( [ X_EVENT_SUCCESS, X_EVENT_ERROR ], X_NET_JSONPWrapper, X_NET_JSONP_iframeListener );
+                               if( X_UA[ 'Opera' ] ){
+                                       html = [
+                                               ( window[ 'JSON' ] ? '' : '<script src="' + json2Path + '"></script>' ),
+                                               '<script>',
+                                                       'onunload=function(){im.onload=im.onerror=""};',
+                                                       'nw=+new Date;',
+                                                       'function cb(o){if(nw){nw-=+new Date;parent.X.Net.JSONP.cb(' + X_NET_JSONP_ACCESS_KEY + ',JSON.stringify(o),-nw', window[ 'JSON' ] ? json2FileSize : 0 ,');nw=0}}',
+                                               '</script>',    
+                                               '<script id="jp"></script>',
+                                               '<img id="im" src="', url, '" onload="jp.src=im.src" onerror="jp.src=im.src">'
+                                       ];
+                                       X_Net_JSONP_maxOnloadCount = 2;
+                               } else
+                               if( X_UA[ 'IE8' ] ){
+                                       html = [
+                                               // JavaScriptでunicode文字列をunescapeする
+                                               // http://perutago.seesaa.net/article/202801583.html
+                                               
+                                               // http://blog.livedoor.jp/dankogai/archives/51503830.html              
+                                               // Ajax - IE8にもJSON入ってます。使えるとは限らないけど
+                                               // Compatibility mode (別名Quirks mode) では、JSONオブジェクトは無効になります。iframeもだめです
+                                               '<script id="jp"></script>',
+                                               '<script>',
+                                                       'onunload=function(){clearTimeout(id)};',
+                                                       'nw=0;', // なぜか必要,,,
+                                                       'function cb(o){nw-=+new Date;parent.X.Net.JSONP.cb(' + X_NET_JSONP_ACCESS_KEY + ',parent.JSON.stringify(o).replace(/\\\\u([a-fA-F0-9]{4})/g,function(a,b){return String.fromCharCode(parseInt(b,16))}),-nw)}',
+                                                       //'function cb(o){if(nw){nw-=+new Date;postMessage("', X_NET_JSONP_SEND_MSG_KEY,' "+nw+"|"+parent.JSON.stringify(o).replace(/\\\\u([a-fA-F0-9]{4})/g,function(a,b){return String.fromCharCode(parseInt(b,16))}),"*");nw=0}}',                   
+                                                       'function tm(){jp.src="', url ,'";nw=+new Date}',
+                                                       'id=setTimeout(tm,16);',
+                                               '</script>'
+                                               
+                                               /* 以下のコードは XP ie8 では動くけど、win8 IE11(8モード)で動かない 開発の便宜を取って,setTimeout を挟む
+                                               '<script>',
+                                                       'function cb(o){window.parent.X.Net.JSONP.cb(' + X_NET_JSONP_ACCESS_KEY + ',window.parent.JSON.stringify(o))}',
+                                               '</script>',
+                                               '<script src="', url, '"></script>' */
+                                       ];
+                                       X_Net_JSONP_maxOnloadCount = 2;
+                               } else
+                               if( X_UA[ 'IE9' ] ){
+                                       html = [
+                                               '<script id="jp"></script>',
+                                               '<script>',
+                                                       'onunload=function(){clearTimeout(id)};',
+                                                       'function cb(o){nw-=+new Date;parent.X.Net.JSONP.cb(' + X_NET_JSONP_ACCESS_KEY + ',JSON.stringify(o),-nw)}',
+                                                       'function tm(){jp.src="', url ,'";nw=+new Date}',
+                                                       'id=setTimeout(tm,16);',
+                                               '</script>'
+                                       ];
+                                       X_Net_JSONP_maxOnloadCount = 2;
+                               } else
+                               if( window[ 'JSON' ] ){
+                                       html = [        
+                                               '<script>',
+                                                       'nw=+new Date;',
+                                                       'function cb(o){if(nw){nw-=+new Date;parent.X.Net.JSONP.cb(' + X_NET_JSONP_ACCESS_KEY + ',JSON.stringify(o),-nw);nw=0}}',
+                                                       //'function cb(o){if(nw){nw-=+new Date;parent.postMessage("', X_NET_JSONP_SEND_MSG_KEY,' "+nw+"|"+JSON.stringify(o),"', location.origin, '");nw=0}}',
+                                               '</script>',
+                                               '<script src="', url, '"></script>'
+                                       ];
+                                       X_Net_JSONP_maxOnloadCount = 1;
+                               } else
+                               if( X_UA[ 'IE4' ] || X_UA[ 'MacIE' ] ){
+                                       html = [
+                                               '<script id="jn"></script>',
+                                               '<script id="jp"></script>',
+                                               '<script>',
+                                                       'onunload=function(){clearTimeout(id)};',
+                                                       'function cb(o){nw-=new Date;parent.X.Net.JSONP.cb(' + X_NET_JSONP_ACCESS_KEY + ',JSON.stringify(o),-nw-16,', json2FileSize, ')}',
+                                                       'function t1(){document.all.jn.src="', json2Path ,'";id=setTimeout("t2()",16);nw=+new Date}',
+                                                       'id=setTimeout("t1()",16);',
+                                                       'function t2(){if(window.JSON){document.all.jp.src="', url ,'"}else{id=setTimeout("t2()",16)}}',
+                                               '</script>'
+                                       ];
+                                       X_Net_JSONP_maxOnloadCount = 3;
+                               } else
+                               if( X_UA[ 'IE' ] < 8 ){ // ie5-7
+                                       html = [
+                                               '<script id="jn"></script>',
+                                               '<script id="jp"></script>',
+                                               '<script>',
+                                                       'onunload=function(){clearTimeout(id)};',
+                                                       'function cb(o){nw-=new Date;parent.X.Net.JSONP.cb(' + X_NET_JSONP_ACCESS_KEY + ',JSON.stringify(o),-nw-16,', json2FileSize, ')}',
+                                                       'function t1(){jn.src="', json2Path ,'";id=setTimeout(t2,16);nw=+new Date}',
+                                                       'id=setTimeout(t1,16);',
+                                                       'function t2(){if(window.JSON){jp.src="', url ,'"}else{id=setTimeout(t2,16)}}',
+                                               '</script>'
+                                       ];
+                                       X_Net_JSONP_maxOnloadCount = 3;
+                               } else {
+                                       html = [
+                                               '<script>',
+                                                       'function cb(o){if(nw){nw-=new Date;parent.X.Net.JSONP.cb(' + X_NET_JSONP_ACCESS_KEY + ',JSON.stringify(o),-nw,', json2FileSize, ');nw=0}}',
+                                                       'nw=+new Date;',
+                                               '</script>',
+                                               '<script src="', json2Path, '"></script>',
+                                               '<script src="', url, '"></script>'
+                                       ];
+                                       X_Net_JSONP_maxOnloadCount = 2;
+                               };
+                               
+                               X_NET_JSONPWrapper
+                                       [ 'refresh' ]( html.join( '' ) )
+                                       [ 'listen' ]( [ 'ninjaload', 'ninjaerror' ], X_NET_JSONP_iframeListener );
+                                                       
+                               X_NET_JSONPWrapper._busy = true;
+                       },
+                       
+                       cancel : function(){
+                               X_NET_JSONPWrapper.reset();
+                               X_NET_JSONPWrapper._canceled = true;
+                       },
+                       
+                       reset : function(){
+                               X_NET_JSONPWrapper._busy = X_NET_JSONPWrapper._canceled = false;
+                               X_Net_JSONP_onloadCount = 0;
+                               X_NET_JSONPWrapper[ 'unlisten' ]( [ 'ninjaload', 'ninjaerror' ], X_NET_JSONP_iframeListener );
+                               X_NET_JSONPWrapper[ 'refresh' ]( '' );
+                               X_Net_JSONP_errorTimerID && X_Timer_remove( X_Net_JSONP_errorTimerID );
+                       }
+               }
+       );
 };
 
-
 function X_NET_JSONP_iframeListener( e ){
        switch( e.type ){
-               case X_EVENT_SUCCESS :
-                       console.log( 'iframe onload, but ' + X_NET_JSONPWrapper._onloadCount + ' < ' + X_Net_JSONP_onloadCount );
-                       if( ++X_NET_JSONPWrapper._onloadCount < X_Net_JSONP_onloadCount ) return;
-                       // TODO callback が無ければ error
-                       X_NET_JSONPWrapper[ 'asyncDispatch' ]( 1000, X_EVENT_ERROR );
+               case 'ninjaload' :
+                       console.log( 'iframe onload, but ' + X_Net_JSONP_onloadCount + ' < ' + X_Net_JSONP_maxOnloadCount );
+                       if( ++X_Net_JSONP_onloadCount < X_Net_JSONP_maxOnloadCount ) return;
+                       
+                       // TODO callback が無ければ error -> timeout を観る?
+                       X_Net_JSONP_errorTimerID = X_NET_JSONPWrapper[ 'asyncDispatch' ]( 1000, X_EVENT_ERROR );
                        break;
-               case X_EVENT_ERROR :
+               case 'ninjaerror' :
                        console.log( 'iframe onerror' );
                        X_NET_JSONPWrapper[ 'asyncDispatch' ]( X_EVENT_ERROR );
                        break;
        };
-       X_EventDispatcher_unlistenAll( X_NET_JSONP_NinjaIframe );
        return X_Callback_UN_LISTEN;
 };
-
-// TODO extend NinjaIframe
-X_NET_JSONPWrapper = X_Class_override(
-       X_EventDispatcher(),
-       {
-
-               _busy         : false,
-               _canceled     : false,
-               _onloadCount  : 0,
-               
-               load : function( url, data, timeout ){
-                       //createURL
-                       X_NET_JSONP_loadScriptInNinjaIframe( url );
-                                               
-                       this._busy = true;
-               },
-               
-               cancel : function(){
-                       this._canceled = true;
-               },
-               
-               reset : function(){
-                       this._busy = this._canceled = false;
-                       this._onloadCount = 0;
-               }
-       }
-);
index 9f5be7a..7ec0e7d 100644 (file)
@@ -26,6 +26,11 @@ if( X_Net_Image_isElement ){
  * \r
  * Opera7 では毎回 image を作る必要あり、src が異なればOK?\r
  */\r
+\r
+X_TEMP.X_NET_Image_init = function(){\r
+\r
+delete X_TEMP.X_NET_Image_init;\r
+\r
 X_NET_ImageWrapper = X_Class_override(\r
        !X_Net_Image_isElement ? X_EventDispatcher( X_Net_Image_image ) : Node( X_Net_Image_image ),\r
        {\r
@@ -40,71 +45,16 @@ X_NET_ImageWrapper = X_Class_override(
                \r
                load : function( data ){\r
                        this._busy   = true;\r
-                       this.abspath = X.URL.toAbsolutePath( data.url );\r
-                       this.delay   = data.delay || 100;\r
-                       this.timeout = data.timeout || 5000;\r
+                       this.abspath = X_URL_toAbsolutePath( data[ 'url' ] );\r
+                       this.delay   = data[ 'delay'   ] || 100;\r
+                       this.timeout = data[ 'timeout' ] || 5000;\r
 \r
                        this[ '_rawObject' ].src = this.abspath;\r
 \r
                        if( X_UA[ 'Opera7' ] && this[ '_rawObject' ].complete ){\r
                                this[ 'asyncDispatch' ]( 'load' );\r
                        } else {\r
-                               this.timerID = X_Timer_add( this.delay, 0, this, this._detect );\r
-                       };\r
-               },\r
-               \r
-               handleEvent : function( e ){\r
-                       var size;\r
-                       switch( e.type ){\r
-                               case 'error' :\r
-                               //case 'abort' : // TODO ??\r
-                                       if( this.finish ) return;\r
-                                       this._busy  = false;\r
-                                       this.finish  = true;\r
-                                       this.timerID && X_Timer_remove( this.timerID );\r
-                                       this.timerID = this[ 'asyncDispatch' ]( /*e.type === 'error' ?*/ X_EVENT_ERROR /*: X_EVENT_CANCELED*/ );\r
-                                       break;\r
-                               case 'load' :\r
-                               // if( finish === true ) return; // これがあると firefox3.6 で駄目、、、\r
-                               // if( timer ) return; // これがあると safari3.2 で駄目、、、\r
-                                       this._busy  = false;\r
-                                       this.finish = true;\r
-                                       this.timerID && X_Timer_remove( this.timerID );\r
-                                       if( X_UA[ 'Opera' ] && !this[ '_rawObject' ].complete ){\r
-                                               this.timerID = this[ 'asyncDispatch' ]( X_EVENT_ERROR );\r
-                                               return;\r
-                                       };\r
-                                       size = X.Util.Image.getActualDimension( !X_Net_Image_isElement ? this.abspath : this );\r
-                                       this.timerID = this[ 'asyncDispatch' ]( {\r
-                                               type : X_EVENT_SUCCESS,\r
-                                               src  : this.abspath,\r
-                                               w    : size[ 0 ],\r
-                                               h    : size[ 1 ]\r
-                                               // TODO feedback net speed\r
-                                               // time , this[ '_rawObject' ].fileSize\r
-                                       } );\r
-                                       break;\r
-                               case X_EVENT_KILL_INSTANCE :\r
-                                       this.reset();\r
-                                       !X_Net_Image_hasImage && this[ 'kill' ](); // if xnode\r
-                                       break;\r
-                       };\r
-               },\r
-               \r
-               _detect : function(){\r
-                       if( this.finish ) return;\r
-                       if( this[ '_rawObject' ] && this[ '_rawObject' ].complete ){\r
-                               this._busy  = false;\r
-                               this.finish = true;\r
-                               if( this[ '_rawObject' ].width ) return;\r
-                               X_Timer_remove( this.timerID );\r
-                               this.timerID = this[ 'asyncDispatch' ]( X_EVENT_ERROR );\r
-                       } else\r
-                       if( this.timeout < ( this.tick += this.delay ) ){\r
-                               this._busy  = false;\r
-                               this.finish = true;\r
-                               X_Timer_remove( this.timerID );\r
-                               this.timerID = this[ 'asyncDispatch' ]( X_EVENT_TIMEOUT );\r
+                               this.timerID = X_Timer_add( this.delay, 0, this, X_NET_Image_detect );\r
                        };\r
                },\r
                \r
@@ -114,7 +64,6 @@ X_NET_ImageWrapper = X_Class_override(
                        // this[ '_rawObject' ].src = '';\r
                        this._busy  = false;\r
                        this.finish = true;\r
-                       this[ 'asyncDispatch' ]( X_EVENT_CANCELED );\r
                },\r
                \r
                reset : function(){\r
@@ -129,6 +78,70 @@ X_NET_ImageWrapper = X_Class_override(
        }\r
 );\r
 \r
-X_NET_ImageWrapper[ 'listen' ]( [ 'load', 'error' /*, 'abort'*/, X_EVENT_KILL_INSTANCE ] );\r
+X_NET_ImageWrapper[ 'listen' ]( [ 'load', 'error' /*, 'abort'*/, X_EVENT_KILL_INSTANCE ], X_NET_Image_handleEvent );\r
+\r
+return X_NET_ImageWrapper;\r
+\r
+};\r
+\r
+function X_NET_Image_detect(){\r
+       if( this.finish ) return;\r
+       if( this[ '_rawObject' ] && this[ '_rawObject' ].complete ){\r
+               this._busy  = false;\r
+               this.finish = true;\r
+               if( this[ '_rawObject' ].width ) return;\r
+               X_Timer_remove( this.timerID );\r
+               this.timerID = this[ 'asyncDispatch' ]( X_EVENT_ERROR );\r
+       } else\r
+       if( this.timeout < ( this.tick += this.delay ) ){\r
+               this._busy  = false;\r
+               this.finish = true;\r
+               X_Timer_remove( this.timerID );\r
+               this.timerID = this[ 'asyncDispatch' ]( X_EVENT_TIMEOUT );\r
+       };\r
+};\r
+\r
+function X_NET_Image_handleEvent( e ){\r
+       var size;\r
+       \r
+       switch( e.type ){\r
+               case 'error' :\r
+               //case 'abort' : // TODO ??\r
+                       if( this.finish ) return;\r
+                       this._busy  = false;\r
+                       this.finish  = true;\r
+                       this.timerID && X_Timer_remove( this.timerID );\r
+                       this.timerID = this[ 'asyncDispatch' ]( /*e.type === 'error' ?*/ X_EVENT_ERROR /*: X_EVENT_CANCELED*/ );\r
+                       break;\r
+\r
+               case 'load' :\r
+               // if( finish === true ) return; // これがあると firefox3.6 で駄目、、、\r
+               // if( timer ) return; // これがあると safari3.2 で駄目、、、\r
+                       this._busy  = false;\r
+                       this.finish = true;\r
+                       this.timerID && X_Timer_remove( this.timerID );\r
+                       if( X_UA[ 'Opera' ] && !this[ '_rawObject' ].complete ){\r
+                               this.timerID = this[ 'asyncDispatch' ]( X_EVENT_ERROR );\r
+                               return;\r
+                       };\r
+\r
+                       size = X_Util_Image_getActualDimension( !X_Net_Image_isElement ? this.abspath : this );\r
+                       this.timerID = this[ 'asyncDispatch' ]( {\r
+                               type : X_EVENT_SUCCESS,\r
+                               src  : this.abspath,\r
+                               w    : size[ 0 ],\r
+                               h    : size[ 1 ]\r
+                               // TODO feedback net speed\r
+                               // time , this[ '_rawObject' ].fileSize\r
+                       } );\r
+                       break;\r
+\r
+               case X_EVENT_KILL_INSTANCE :\r
+                       this.reset();\r
+                       !X_Net_Image_hasImage && this[ 'kill' ](); // if xnode\r
+                       break;\r
+       };\r
+};\r
+\r
 \r
 // X_Net_Image_isElement && X_NET_ImageWrapper[ 'appendAt' ]( X.X_Node_systemNode );\r
index 8a5e1ed..958b441 100644 (file)
@@ -69,7 +69,7 @@ if( X_Audio_WebAudio_context ){
                                        // TODO 当てにしていたaudioがclose 等した場合
                                        audio.proxy[ 'listenOnce' ]( 'canplaythrough', this, this._onBufferReady );
                                } else {
-                                       this.xhr = X.Net.xhrGet( url, { type : 'arraybuffer' } )
+                                       this.xhr = X.Net( { 'xhr' : url, 'type' : 'arraybuffer' } )
                                                                        [ 'listen' ]( X_EVENT_PROGRESS, this )
                                                                        [ 'listenOnce' ]( [ X_EVENT_SUCCESS, X_EVENT_COMPLETE, X_EVENT_CANCELED ], this );                                      
                                };
index 355fbaf..bcf156f 100644 (file)
                // and we are now handling a mouse event, we stop that to prevent conflicts\r
                if( enable_detect ){\r
                        // update pointerevent\r
-                       if( Hammer.HAS_POINTEREVENTS ){ //eventType !== Hammer.EVENT_END ){\r
-                               console.log( 'e.pointerId = ' + e.pointerId );\r
-                               POINTERS[ e.identifier = e.pointerId ] = type & END ? null : e;\r
-                               touches = [];\r
-                               numTouches = -1;\r
-                               // we can use forEach since pointerEvents only is in IE10\r
-                               for( i = 0, l = POINTERS.length; i < l; ++i ){\r
-                                       POINTERS[ i ] && ( touches[ ++numTouches ] = POINTERS[ i ] );\r
-                               };\r
-                               numTouches = touches.length;\r
-                               \r
-                               ///console.log( 'numTouches ' + numTouches );\r
-                       } else\r
-                       // touch\r
-                       if ( type & TOUCH ){ //sourceEventType.match(/touch/)) {\r
-                               touches    = Hammer.DO_TOUCHES_FIX && type & END ? [] : e.touches;\r
-                               numTouches = touches.length;\r
-                       } else\r
-                       // mouse\r
-                       if( !touch_triggered ){\r
-                               numTouches = ( type & END ) ? 0 : 1;\r
-                               touches    = numTouches === 0 ? [] : [{\r
-                                       identifier : 1,\r
-                                       pageX      : e.pageX,\r
-                                       pageY      : e.pageY,\r
-                                       target     : e.target\r
-                               }];\r
+\r
+                       POINTERS[ e.pointerId ] = type & END ? null : e;\r
+                       touches    = [];\r
+                       numTouches = -1;\r
+                       // we can use forEach since pointerEvents only is in IE10\r
+                       for( i in POINTERS ){\r
+                               POINTERS[ i ] && ( touches[ ++numTouches ] = POINTERS[ i ] );\r
                        };\r
+                       ++numTouches;\r
+                       ///console.log( 'numTouches ' + numTouches );\r
+\r
                        // if we are in a end event, but when we remove one touch and\r
                        // we still have enough, set eventType to move\r
                        if( 0 < numTouches && type & END ){ // eventType === Hammer.EVENT_END ){\r
index 4b34d64..e260590 100644 (file)
@@ -14,7 +14,8 @@ document.write( [
                'js/01_core/04_XObject.js',\r
                'js/01_core/05_XString.js',\r
                'js/01_core/06_XURL.js',\r
-                                               \r
+\r
+               'js/01_core/09_XPair.js',                                               \r
                'js/01_core/10_XCallback.js',\r
                'js/01_core/11_XClass.js',\r
                'js/01_core/12_XEvent.js',\r