stuppid_bot

Untitled

May 8th, 2013
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. querystring = {
  2.     parse: function(s, sep, eq) {
  3.         eq = eq || '=';
  4.         var o = {};
  5.  
  6.         if (s) {
  7.             var a = s.split(sep || '&'),
  8.                 i = 0,
  9.                 l = a.length;
  10.  
  11.             while (i < l) {
  12.                 var a1 = a[i++].split(eq),
  13.                     k = a1[0],
  14.                     v = a1[1];                    
  15.  
  16.                 if (k !== '') {
  17.                     k = decodeURIComponent(k);
  18.                     v = v === undefined ? '' : decodeURIComponent(v);
  19.                    
  20.                     if (k in o) {
  21.                         if (typeof o[k] == 'string') {
  22.                             o[k] = new Array(o[k]);
  23.                         }
  24.                        
  25.                         o[k].push(v);
  26.                     }
  27.                     else {
  28.                         o[k] = v;
  29.                     }
  30.                 }
  31.             }
  32.         }
  33.  
  34.         return o;
  35.     },
  36.    
  37.     stringify: function(o, sep, eq) {
  38.         sep = sep || '&';
  39.         eq = eq || '=';
  40.         var p,
  41.             i,
  42.             l,
  43.             a,
  44.             a1 = [];
  45.  
  46.         for (p in o) {
  47.             if ( o.hasOwnProperty(p) ) {
  48.                 a = Array.prototype.concat(o[p]);
  49.                 p = encodeURIComponent(p);
  50.                
  51.                 for (i = 0, l = a.length; i < l; ++i) {
  52.                     a1.push( p + ( a[i] === '' ? '' : eq + encodeURIComponent(a[i]) ) );
  53.                 }
  54.             }
  55.         }
  56.  
  57.         return a1.join(sep);
  58.     }
  59. };
  60. // query = querystring.parse( location.search.substr(1) );
  61. // cookie = querystring.parse(document.cookie, /;\s*/);
Advertisement
Add Comment
Please, Sign In to add comment