1. #1
    Sencha User primolan's Avatar
    Join Date
    Sep 2009
    Location
    São Paulo - Brazil
    Posts
    21
    Vote Rating
    0
    primolan is on a distinguished road

      0  

    Default New (simple) functions in Ext

    New (simple) functions in Ext


    Hello.

    Here are my humble suggestions to implement Ext functionalities.

    Code:
    Ext.prototype = {
        isObject: function(v) {
            return (typeof(v) == 'object' && v.length == undefined);
        },
        isArray: function(v) {
            return (typeof(v) == 'object' && v.length != undefined);
        }
    };
    Thanks!

  2. #2
    Sencha User
    Join Date
    Sep 2008
    Location
    Netherlands
    Posts
    106
    Vote Rating
    1
    buz is on a distinguished road

      0  

    Default


    Don't they already exist in Ext? isObject, isBoolean, isArray?

  3. #3
    Sencha User primolan's Avatar
    Join Date
    Sep 2009
    Location
    São Paulo - Brazil
    Posts
    21
    Vote Rating
    0
    primolan is on a distinguished road

      0  

    Default New way!

    New way!


    Unfortunally Ext doesn't have that functions. I made a new one, unifying all types in one function.

    Ext.getType(var) will return var's type.

    Here's the new code:

    Code:
        Ext.prototype.getType = function(v) {
            c = v.constructor;
            a = c.toString().split(' ');
            r = a[1].toLowerCase();
            s = r.replace('()', '');
            return s;
        }
    I hope you all enjoy it!

  4. #4
    Sencha User
    Join Date
    Mar 2007
    Posts
    7,854
    Vote Rating
    4
    tryanDLS is on a distinguished road

      0  

    Default


    Those functions all exist in the library all ready

    http://www.extjs.com/deploy/dev/docs/?class=Ext

  5. #5
    Sencha User primolan's Avatar
    Join Date
    Sep 2009
    Location
    São Paulo - Brazil
    Posts
    21
    Vote Rating
    0
    primolan is on a distinguished road

      0  

    Red face Ops! My mistake!

    Ops! My mistake!


    Ops!

    My bad! I didn't see it! But theres a new way to retrieve object's type, using var.getType() instead of using Ext.isX(var).

    Code:
    Object.prototype.getType = function() {
        return this.constructor.name.toLowerCase();
    }
    Cya!

  6. #6
    Ext JS Premium Member watrboy00's Avatar
    Join Date
    Aug 2007
    Location
    Minneapolis, MN
    Posts
    473
    Vote Rating
    0
    watrboy00 is on a distinguished road

      0  
    Eric Berens
    Intranet Systems Manager @ Best Buy
    You should follow me on twitter here.

  7. #7
    Sencha User primolan's Avatar
    Join Date
    Sep 2009
    Location
    São Paulo - Brazil
    Posts
    21
    Vote Rating
    0
    primolan is on a distinguished road

      0  

    Default


    :P

    I should read with more attention!

    Ty!

Thread Participants: 3

Tags for this Thread