-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
14 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,33 @@ | ||
function getRequestQueryParams() { | ||
const keyValPairs = location.search.substring(1, location.search.length).split('&') | ||
const requestQueryParams = {} | ||
let keyValPairs = location.search.substring(1, location.search.length).split('&') | ||
let requestQueryParams = {} | ||
keyValPairs.forEach(keyValPair => { | ||
const keyAndVal = keyValPair.split('=') | ||
const key = decodeURIComponent(keyAndVal[0]) | ||
let keyAndVal = keyValPair.split('=') | ||
let key = decodeURIComponent(keyAndVal[0]) | ||
requestQueryParams[key] = decodeURIComponent(keyAndVal[1]) | ||
}) | ||
return requestQueryParams | ||
} | ||
|
||
/** Parse hash string */ | ||
function getRequestHashParams() { | ||
var fragmentString = location.hash.substring(1); | ||
var requestHashParams = {}; | ||
var regex = /([^&=]+)=([^&]*)/g, m; | ||
let fragmentString = location.hash.substring(1) | ||
let requestHashParams = {} | ||
let regex = /([^&=]+)=([^&]*)/g | ||
let m | ||
while (m = regex.exec(fragmentString)) { | ||
requestHashParams[decodeURIComponent(m[1])] = decodeURIComponent(m[2]); | ||
requestHashParams[decodeURIComponent(m[1])] = decodeURIComponent(m[2]) | ||
} | ||
return requestHashParams | ||
} | ||
|
||
function currentTimestamp() { | ||
return (new Date()).getTime(); | ||
return (new Date()).getTime() | ||
} | ||
|
||
function simpleRandom() { | ||
// just the float rand num as is but remove 0. prefix | ||
return ("" + Math.random()).substring(2) | ||
let buf = new Uint32Array(1) | ||
window.crypto.getRandomValues(buf) | ||
let b64encoded = btoa(buf) | ||
return b64encoded.replace(/=/g, '') | ||
} |