diff options
author | Aleksander Machniak <alec@alec.pl> | 2015-03-09 09:24:05 -0400 |
---|---|---|
committer | Aleksander Machniak <alec@alec.pl> | 2015-03-09 09:24:05 -0400 |
commit | c2df5d4e13e9ab63e8f152d638eec35284efdf2f (patch) | |
tree | 4e90346aa60b448cdb88d0625856fe99b822aeea /program/js/common.js | |
parent | 1ec105c6855c99f4f2a12038d6f9598067fdf205 (diff) |
Unified request* event arguments handling, added support for _unlock and _action parameters
Diffstat (limited to 'program/js/common.js')
-rw-r--r-- | program/js/common.js | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/program/js/common.js b/program/js/common.js index e60a14e38..3babf1efb 100644 --- a/program/js/common.js +++ b/program/js/common.js @@ -654,6 +654,34 @@ jQuery.fn.placeholder = function(text) { }); }; +// function to parse query string into an object +rcube_parse_query = function(query) +{ + if (!query) + return {}; + + var params = {}, e, k, v, + re = /([^&=]+)=?([^&]*)/g, + decodeRE = /\+/g, // Regex for replacing addition symbol with a space + decode = function (str) { return decodeURIComponent(str.replace(decodeRE, ' ')); }; + + query = query.replace(/\?/, ''); + + while (e = re.exec(query)) { + 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; +}; + // This code was written by Tyler Akins and has been placed in the // public domain. It would be nice if you left this header intact. |