/*global Arenite:true*/
/*global Arenite:true*/
Utility function for interpreting url query parameters
Arenite.Url = function () {
var query_string;
var _query = function (force) {
if (!query_string || force) {
query_string = {};
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i = 0; i < vars.length; i++) {
var pair = vars[i].split("=");
if (typeof query_string[pair[0]] === "undefined") {
query_string[pair[0]] = pair[1];
} else if (typeof query_string[pair[0]] === "string") {
query_string[pair[0]] = [query_string[pair[0]], pair[1]];
} else {
query_string[pair[0]].push(pair[1]);
}
}
}
return query_string;
};
return {
url: {
Fetches the query parameters for the current url and returns them in an object. Variables will be keys in the object and the values are either the value for the variable or an array of values in the case where a variable is defined more than once.
query: _query
}
};
};