Commit 76fd2f78 authored by Tomas Pettersson's avatar Tomas Pettersson 🏸
Browse files

updated getURLParams

parent 9a0b2dde
...@@ -59,6 +59,24 @@ var STWkit = { ...@@ -59,6 +59,24 @@ var STWkit = {
} }
return '?' + query.join('&'); return '?' + query.join('&');
}, },
// getURLParams: function(param) {
// var match,
// pl = /\+/g, // Regex for replacing addition symbol with a space
// search = /([^&=]+)=?([^&]*)/g,
// decode = function (s) { return decodeURIComponent(s.replace(pl, " ")); },
// query = window.location.search.substring(1);
// var urlParams = [];
// while (match = search.exec(query)) {
// if (param == decode(match[1])) {
// urlParams.push();
// urlParams[urlParams.length] = decode(match[2]);
// } else {
// urlParams.push();
// urlParams[urlParams.length] = [decode(match[1]), decode(match[2])];
// }
// }
// return urlParams;
// },
getURLParams: function(param) { getURLParams: function(param) {
var match, var match,
pl = /\+/g, // Regex for replacing addition symbol with a space pl = /\+/g, // Regex for replacing addition symbol with a space
...@@ -67,9 +85,11 @@ var STWkit = { ...@@ -67,9 +85,11 @@ var STWkit = {
query = window.location.search.substring(1); query = window.location.search.substring(1);
var urlParams = []; var urlParams = [];
while (match = search.exec(query)) { while (match = search.exec(query)) {
if (param == decode(match[1])) { if (param) {
urlParams.push(); if (param == decode(match[1])) {
urlParams[urlParams.length] = decode(match[2]); urlParams.push();
urlParams[urlParams.length] = decode(match[2]);
}
} else { } else {
urlParams.push(); urlParams.push();
urlParams[urlParams.length] = [decode(match[1]), decode(match[2])]; urlParams[urlParams.length] = [decode(match[1]), decode(match[2])];
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment