Name: cockpit/lib/parsequery.js 
1:
/**
2:
 * A simple querystring parser.
3:
 * Example usage: var q = $.parseQuery(); q.fooreturns  "bar" if query contains "?foo=bar"; multiple values are added to an array.
4:
 * Values are unescaped by default and plus signs replaced with spaces, or an alternate processing function can be passed in the params object .
5:
 * http://actingthemaggot.com/jquery
6:
 *
7:
 * Copyright (c) 2008 Michael Manning (http://actingthemaggot.com)
8:
 * Dual licensed under the MIT (MIT-LICENSE.txt)
9:
 * and GPL (GPL-LICENSE.txt) licenses.
10:
 **/
11:
jQuery.parseQuery = function(qs,options) {
12:
  var q = (typeof qs === 'string'?qs:window.location.search), o = {'f':function(v){return unescape(v).replace(/\+/g,' ');}}, options = (typeof qs === 'object' && typeof options === 'undefined')?qs:options, o = jQuery.extend({}, o, options), params = {};
13:
  jQuery.each(q.match(/^\??(.*)$/)[1].split('&'),function(i,p){
14:
    p = p.split('=');
15:
    p[1] = o.f(p[1]);
16:
    params[p[0]] = params[p[0]]?((params[p[0]] instanceof Array)?(params[p[0]].push(p[1]),params[p[0]]):[params[p[0]],p[1]]):p[1];
17:
  });
18:
  return params;
19:
}