-
Notifications
You must be signed in to change notification settings - Fork 0
/
base64url.js
46 lines (41 loc) · 1.01 KB
/
base64url.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
35
36
37
38
39
40
41
42
43
44
45
46
function exampleTemplate({content=''}={}){
document.body.innerHTML = `
<style>
</style>
<header>
<h1>Roll For: </h1>
</header>
<main>
</main>
`
}
let src =[
"Mini Golf",
"Animal Farm",
"Hike Around Lake",
"Old Mill",
"Riverbend Park",
"Glade Stream Valley",
"Shaky Bridge",
"Reston Town Center",
"Pinball",
"RC Racing",
"USGS Hike",
"Meadowlark Garden",
"Sully Historical Site",
"Vienna Caboose",
"Great Falls",
"Occoquan Village",
"Blooms Park"
]
function getWinner({src}) {
const toRandom = new Uint32Array(src.length);
window.crypto.getRandomValues(toRandom);
const winningElementIndex = toRandom.reduce((a,v,i)=>{ return v>a[0] ? [v,i] : a }, [Number.NEGATIVE_INFINITY, null])[1];
return src[winningElementIndex];
}
function getSrc(){
return (new URLSearchParams( (new URL(window.location)).search )).get('src')
}
// TESTS
console.log(getWinner({src}));