-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
34 lines (29 loc) · 962 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
const pageQuery = {
init: () => {
pageQuery.queryString();
},
queryString: () => {
const fullQuery = window.location.search.length > 0 ? window.location.search.substring(1) : null;
if (fullQuery !== null) { pageQuery.searchStrings(fullQuery); }
},
searchStrings: (fullQuery) => {
return pageQuery.searchStrings = [].slice.call(fullQuery.split('&'));
},
getValue: (wantedValue) => {
pageQuery.searchStrings.forEach((keyValuePair) => {
const keyValue = keyValuePair.split('=');
if (keyValue[0] === wantedValue) {
return keyValue[1];
}
});
},
getParameters: () => {
const allParams = [];
pageQuery.searchStrings.forEach((keyValuePair) => {
console.log(keyValuePair);
allParams.push(keyValuePair.split('=')[0]);
});
return allParams;
}
};
export default pageQuery;