Commit 4d81e793 authored by Tomas Pettersson's avatar Tomas Pettersson 🏸
Browse files

first add

parent fb4ab1db
{
// 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
# stwkit
## Description
Utility kit for stw apps
\ No newline at end of file
Utility kit for stw apps
\ No newline at end of file
{
"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
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
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