Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- querystring = {
- parse: function(s, sep, eq) {
- eq = eq || '=';
- var o = {};
- if (s) {
- var a = s.split(sep || '&'),
- i = 0,
- l = a.length;
- while (i < l) {
- var a1 = a[i++].split(eq),
- k = a1[0],
- v = a1[1];
- if (k !== '') {
- k = decodeURIComponent(k);
- v = v === undefined ? '' : decodeURIComponent(v);
- if (k in o) {
- if (typeof o[k] == 'string') {
- o[k] = new Array(o[k]);
- }
- o[k].push(v);
- }
- else {
- o[k] = v;
- }
- }
- }
- }
- return o;
- },
- stringify: function(o, sep, eq) {
- sep = sep || '&';
- eq = eq || '=';
- var p,
- i,
- l,
- a,
- a1 = [];
- for (p in o) {
- if ( o.hasOwnProperty(p) ) {
- a = Array.prototype.concat(o[p]);
- p = encodeURIComponent(p);
- for (i = 0, l = a.length; i < l; ++i) {
- a1.push( p + ( a[i] === '' ? '' : eq + encodeURIComponent(a[i]) ) );
- }
- }
- }
- return a1.join(sep);
- }
- };
- // query = querystring.parse( location.search.substr(1) );
- // cookie = querystring.parse(document.cookie, /;\s*/);
Advertisement
Add Comment
Please, Sign In to add comment