Skip to content

Instantly share code, notes, and snippets.

@makotokw
Created September 25, 2010 14:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save makotokw/596905 to your computer and use it in GitHub Desktop.
Save makotokw/596905 to your computer and use it in GitHub Desktop.
Sencha touch for Chrome Extension
/*
* 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