Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
stw
stwkit
Commits
4d81e793
Commit
4d81e793
authored
Aug 31, 2017
by
Tomas Pettersson
🏸
Browse files
first add
parent
fb4ab1db
Changes
4
Hide whitespace changes
Inline
Side-by-side
.vscode/tasks.json
View file @
4d81e793
{
//
See
https://go.microsoft.com/fwlink/?LinkId=
733558
//
for
the
documentation
about
the
tasks.json
format
"version"
:
"0.1.0"
,
"command"
:
"
tsc
"
,
"command"
:
"
echo
"
,
"isShellCommand"
:
true
,
"args"
:
[
"-p"
,
"."
],
"showOutput"
:
"silent"
,
"problemMatcher"
:
"$tsc"
"args"
:
[
"Hello World"
],
"showOutput"
:
"never"
}
\ No newline at end of file
README.md
View file @
4d81e793
# stwkit
## Description
Utility kit for stw apps
\ No newline at end of file
Utility kit for stw apps
\ No newline at end of file
bower.json
0 → 100644
View file @
4d81e793
{
"name"
:
"stwkit"
,
"version"
:
"0.0.1"
,
"homepage"
:
"https://git.smhi.se/stw/stwkit"
,
"authors"
:
[
"Tomas Pettersson <tomas.pettersson@smhi.se>"
],
"description"
:
"Utility kit for STW apps"
,
"main"
:
[
"src/stwkit.js"
],
"repository"
:
{
"type"
:
"git"
,
"url"
:
"git@git.smhi.se:stw/stwkit.git"
},
"dependencies"
:
{},
"devDependencies"
:
{},
"license"
:
"MIT"
,
"ignore"
:
[
"**/.*"
,
"node_modules"
,
"bower_components"
],
"moduleType"
:
[
"es6"
]
}
\ No newline at end of file
src/stwkit.js
0 → 100644
View file @
4d81e793
var
STWkit
=
{
getParamValue
:
function
(
name
,
params
)
{
for
(
var
i
=
0
;
i
<
params
.
length
;
i
++
)
{
if
((
params
[
i
][
0
]
==
name
))
return
params
[
i
][
1
];
}
return
null
;
},
deleteParam
:
function
(
name
,
params
)
{
for
(
var
i
=
0
;
i
<
params
.
length
;
i
++
)
{
if
(
params
[
i
][
0
]
==
name
)
params
.
splice
(
i
,
1
);;
}
},
getSearchUrl
:
function
(
params
)
{
var
search
=
""
;
if
(
params
.
length
>
0
)
search
+=
"
?
"
;
for
(
var
i
=
0
;
i
<
params
.
length
;
i
++
)
{
search
+=
params
[
i
][
0
]
+
'
=
'
+
params
[
i
][
1
];
if
(
i
<
params
.
length
-
1
)
search
+=
'
&
'
;
}
return
search
;
},
jsonToQueryString
:
function
(
json
)
{
var
keys
=
Object
.
keys
(
json
);
var
query
=
[];
for
(
var
i
=
0
;
i
<
keys
.
length
;
i
++
)
{
var
key
=
keys
[
i
];
var
value
=
json
[
key
];
if
(
typeof
value
===
'
string
'
)
{
value
=
[
value
];
}
for
(
var
j
=
0
;
j
<
value
.
length
;
j
++
)
{
query
.
push
(
key
+
'
=
'
+
value
[
j
]);
}
}
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
;
}
};
\ No newline at end of file
Write
Preview
Markdown
is supported
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