Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
stw
stwkit
Commits
76fd2f78
Commit
76fd2f78
authored
Aug 31, 2017
by
Tomas Pettersson
🏸
Browse files
updated getURLParams
parent
9a0b2dde
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/stwkit.js
View file @
76fd2f78
...
...
@@ -59,6 +59,24 @@ var STWkit = {
}
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
)
{
var
match
,
pl
=
/
\+
/g
,
// Regex for replacing addition symbol with a space
...
...
@@ -67,9 +85,11 @@ var STWkit = {
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
]);
if
(
param
)
{
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
])];
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment