Created
September 25, 2010 14:51
-
-
Save makotokw/596905 to your computer and use it in GitHub Desktop.
Sencha touch for Chrome Extension
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Sencha touch for Chrome Extension | |
* Copyright(c) 2010 makoto_kw | |
* @license GNU GPL license v3 | |
*/ | |
if (Ext) { | |
Ext.apply(Ext.is, { | |
ChromeExtension: true | |
}); | |
Ext.apply(Ext.Ajax, { | |
onComplete: function(r){ | |
var status = r.xhr.status, options = r.options, success = true, response; | |
if (status == 0 || (status >= 200 && status < 300) || status == 304) { | |
response = this.createResponse(r); | |
this.fireEvent('requestcomplete', this, response, options); | |
if (options.success) { | |
if (!options.scope) { | |
options.success(response, options); | |
} | |
else { | |
options.success.call(options.scope, response, options); | |
} | |
} | |
} | |
else { | |
success = false; | |
switch (status) { | |
case 12002: | |
case 12029: | |
case 12030: | |
case 12031: | |
case 12152: | |
case 13030: | |
response = this.createException(r); | |
break; | |
default: | |
response = this.createResponse(r); | |
} | |
this.fireEvent('requestexception', this, response, options); | |
if (options.failure) { | |
if (!options.scope) { | |
options.failure(response, options); | |
} | |
else { | |
options.failure.call(options.scope, response, options); | |
} | |
} | |
} | |
if (options.callback) { | |
if (!options.scope) { | |
options.callback(options, success, response); | |
} | |
else { | |
options.callback.call(options.scope, options, success, response); | |
} | |
} | |
delete this.requests[r.id]; | |
} | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment