function get(key) {
var searchParams = {},
search = window.location.search.substring(1); // substring to remove the ?
if (search) {
search = search.split('&');
for (var i in search) {
if (search.hasOwnProperty(i) && i !== '') {
var pair = search[i].split('=');
pair[0] = decodeURIComponent(pair[0]);
pair[1] = decodeURIComponent(pair[1]);
searchParams[pair[0]] = pair[1];
}
}
}
if (key) {
return searchParams[key];
}
return searchParams;