Skip to content

Instantly share code, notes, and snippets.

@makotokw
Created September 25, 2010 14:51
Show Gist options
  • Select an option

  • Save makotokw/596905 to your computer and use it in GitHub Desktop.

Select an option

Save makotokw/596905 to your computer and use it in GitHub Desktop.

Revisions

  1. makotokw created this gist Sep 25, 2010.
    61 changes: 61 additions & 0 deletions ext-touch-crx.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,61 @@
    /*
    * 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];
    }
    })
    }