// TODO onlineevent offlineevent, netspeed\r
X.Net = {\r
\r
- get : function( url ){\r
- return new X_NET_Queue( X_NET_TYPE_XHR, { get : url } );\r
+ xhrGet : function( url ){\r
+ return new X_NET_Queue( X_NET_TYPE_XHR, { type : 'get', get : url } );\r
},\r
\r
- post : function( url ){\r
- return new X_NET_Queue( X_NET_TYPE_XHR, { post : url } );\r
+ xhrPost : function( url ){\r
+ return new X_NET_Queue( X_NET_TYPE_XHR, { type : 'post', post : url } );\r
+ },\r
+ \r
+ formGet : function(){\r
+ \r
+ },\r
+ \r
+ formPost : function(){\r
+ \r
},\r
\r
// TODO chashe\r
jsonp : function( url ){\r
return new X_NET_Queue( X_NET_TYPE_JSONP, url );\r
+ },\r
+ \r
+ image : function(){\r
+ \r
}\r
\r
};\r
\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
this.type = type;\r
this.data = data; \r
\r
+ this.listen( X.Event.COMPLETE, this, 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
+ busy : function(){\r
+ return this === X_NET_currentQueue && X_NET_currentWrapper._busy;\r
+ },\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( 0, { type : X.Event.COMPLETE } );\r
} else\r
if( this === X_NET_currentQueue ){\r
X_NET_currentWrapper.cancel();\r
\r
function X_NET_proxyDispatch( e ){\r
switch( e.type ){\r
+ case X.Event.BEFORE_KILL_INSTANCE :\r
+ break;\r
+ case X.Event.KILL_INSTANCE :\r
+ break; \r
+ case X.Event.KILL_INSTANCE_CANCELED :\r
+ break;\r
+ case X.Event.PROGRESS :\r
+ console.log( 'q: ' + e.type );\r
+ this.dispatch( e );\r
+ break;\r
case X.Event.SUCCESS :\r
case X.Event.ERROR :\r
- this.asyncDispatch( 0, e );\r
- //this.kill();\r
+ console.log( 'q: ' + e.type );\r
+ this.dispatch( e );\r
+ this.asyncDispatch( 0, { type : X.Event.COMPLETE } );\r
+ break;\r
+ case X.Event.CANCELED :\r
+ \r
+ break;\r
+ case X.Event.COMPLETE :\r
+ this.kill();\r
X_NET_shiftQueue();\r
break;\r
- case X.Event.PROGRESS :\r
- this.dispatch( 0, e );\r
};\r
};\r
\r
if( X_NET_currentQueue ){\r
if( X_NET_currentWrapper._busy ) return;\r
X_NET_currentWrapper.unlisten( [ X.Event.SUCCESS, X.Event.ERROR, X.Event.PROGRESS ], X_NET_currentQueue, X_NET_proxyDispatch );\r
+ X_NET_currentQueue.reset();\r
};\r
\r
if( !X_NET_QUEUE_LIST.length ){\r
break;\r
};\r
\r
- X_NET_currentWrapper.listen( [ X.Event.SUCCESS, X.Event.ERROR, X.Event.PROGRESS ], X_NET_currentQueue = queue, X_NET_proxyDispatch );\r
+ X_NET_currentWrapper.listen( [ X.Event.SUCCESS, X.Event.ERROR, X.Event.PROGRESS, X.Event.COMPLETE ], X_NET_currentQueue = queue, X_NET_proxyDispatch );\r
\r
X_NET_currentWrapper.load( queue.data );\r
};\r