[ Index ] |
PHP Cross Reference of phpwcms V1.4.7 _r403 (01.11.10) |
[Summary view] [Print] [Text view]
1 /* 2 --- 3 4 script: String.QueryString.js 5 6 name: String.QueryString 7 8 description: Methods for dealing with URI query strings. 9 10 license: MIT-style license 11 12 authors: 13 - Sebastian Markbåge, Aaron Newton, Lennart Pilon, Valerio Proietti 14 15 requires: 16 - Core/Array 17 - Core/String 18 - /MooTools.More 19 20 provides: [String.QueryString] 21 22 ... 23 */ 24 25 String.implement({ 26 27 parseQueryString: function(decodeKeys, decodeValues){ 28 if (decodeKeys == null) decodeKeys = true; 29 if (decodeValues == null) decodeValues = true; 30 var vars = this.split(/[&;]/), res = {}; 31 if (vars.length) vars.each(function(val){ 32 var index = val.indexOf('='), 33 keys = index < 0 ? [''] : val.substr(0, index).match(/([^\]\[]+|(\B)(?=\]))/g), 34 value = decodeValues ? decodeURIComponent(val.substr(index + 1)) : val.substr(index + 1), 35 obj = res; 36 keys.each(function(key, i){ 37 if (decodeKeys) key = decodeURIComponent(key); 38 var current = obj[key]; 39 if(i < keys.length - 1) 40 obj = obj[key] = current || {}; 41 else if($type(current) == 'array') 42 current.push(value); 43 else 44 obj[key] = $defined(current) ? [current, value] : value; 45 }); 46 }); 47 return res; 48 }, 49 50 cleanQueryString: function(method){ 51 return this.split('&').filter(function(val){ 52 var index = val.indexOf('='), 53 key = index < 0 ? '' : val.substr(0, index), 54 value = val.substr(index + 1); 55 return method ? method.run([key, value]) : $chk(value); 56 }).join('&'); 57 } 58 59 });
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Tue Nov 16 22:51:00 2010 | Cross-referenced by PHPXref 0.7 |