Sha256: 86ddbb4a9da2bda64b200d6c930a444580d58a773c7b09db684215a91cd334f6

Contents?: true

Size: 1.44 KB

Versions: 11

Compression:

Stored size: 1.44 KB

Contents

/**
* $.parseParams - parse query string paramaters into an object.
*/
(function($) {
var re = /([^&=]+)=?([^&]*)/g;
var decodeRE = /\+/g; // Regex for replacing addition symbol with a space
var decode = function (str) {return decodeURIComponent( str.replace(decodeRE, " ") );};
$.parseParams = function(query) {
    var params = {}, e;
    while ( e = re.exec(query) ) {
        var k = decode( e[1] ), v = decode( e[2] );
        if (k.substring(k.length - 2) === '[]') {
            k = k.substring(0, k.length - 2);
            (params[k] || (params[k] = [])).push(v);
        }
        else params[k] = v;
    }
    return params;
};
})(jQuery);

/**
* str.QueryStringToJSON() - parse query string paramaters into an object.
*/
String.prototype.QueryStringToJSON = function () {
href = this;
qStr = href.replace(/(.*?\?)/, '');
qArr = qStr.split('&');
stack = {};
for (var i in qArr) {
    var a = qArr[i].split('=');
    var name = a[0],
        value = isNaN(a[1]) ? a[1] : parseFloat(a[1]);
    if (name.match(/(.*?)\[(.*?)]/)) {
        name = RegExp.$1;
        name2 = RegExp.$2;
        //alert(RegExp.$2)
        if (name2) {
            if (!(name in stack)) {
                stack[name] = {};
            }
            stack[name][name2] = value;
        } else {
            if (!(name in stack)) {
                stack[name] = [];
            }
            stack[name].push(value);
        }
    } else {
        stack[name] = value;
    }
}
return stack;
}

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
bonethug-0.0.17 skel/project_types/silverstripe3/public/abc/javascript/library/jQuery/jquery.parseParams.js
bonethug-0.0.16 skel/project_types/silverstripe3/public/abc/javascript/library/jQuery/jquery.parseParams.js
bonethug-0.0.15 skel/project_types/silverstripe3/public/abc/javascript/library/jQuery/jquery.parseParams.js
bonethug-0.0.14 skel/project_types/silverstripe3/public/abc/javascript/library/jQuery/jquery.parseParams.js
bonethug-0.0.13 skel/project_types/silverstripe3/public/abc/javascript/library/jQuery/jquery.parseParams.js
bonethug-0.0.12 skel/project_types/silverstripe3/public/abc/javascript/library/jQuery/jquery.parseParams.js
bonethug-0.0.11 skel/project_types/silverstripe3/public/abc/javascript/library/jQuery/jquery.parseParams.js
bonethug-0.0.10 skel/project_types/silverstripe3/public/abc/javascript/library/jQuery/jquery.parseParams.js
bonethug-0.0.7 skel/project_types/silverstripe3/public/abc/javascript/library/jQuery/jquery.parseParams.js
bonethug-0.0.6 skel/project_types/silverstripe3/public/abc/javascript/library/jQuery/jquery.parseParams.js
bonethug-0.0.5 skel/project_types/silverstripe3/public/abc/javascript/library/jQuery/jquery.parseParams.js