[ADD] website.parseHash() & parseSearch() helpers

bzr revid: fme@openerp.com-20131119142007-sf2u3s6x46okkotm
This commit is contained in:
Fabien Meghazi 2013-11-19 15:20:07 +01:00
parent 176a78e161
commit 814ee75c4f
1 changed files with 25 additions and 0 deletions

View File

@ -13,6 +13,31 @@
}, dict);
};
website.parseQS = function (qs) {
var match,
params = {},
pl = /\+/g, // Regex for replacing addition symbol with a space
search = /([^&=]+)=?([^&]*)/g;
while ((match = search.exec(qs))) {
var name = decodeURIComponent(match[1].replace(pl, " "));
var value = decodeURIComponent(match[2].replace(pl, " "));
params[name] = value;
}
return params;
};
var parsedSearch;
website.parseSearch = function () {
if (!parsedSearch) {
parsedSearch = website.parseQS(window.location.search.substring(1));
}
return parsedSearch;
};
website.parseHash = function () {
return website.parseQS(window.location.hash.substring(1));
};
/* ----- TEMPLATE LOADING ---- */
var templates_def = $.Deferred().resolve();
website.add_template_file = function(template) {