-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.html
58 lines (53 loc) · 2.34 KB
/
index.html
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
47
48
49
50
51
52
53
54
55
56
57
58
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<title>Did Thanos Kill You?</title>
<meta name="description" content="Did Thanos kill you?">
<meta name="keywords" content="did,Thanos,kill,me,you,avengers,infinity,war,half,fifty,50,percent,snap">
<meta name="author" content="Tristan Bellman-Greenwood">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script>
function getCookie(cname) {
var name = cname + "=";
var decodedCookie = decodeURIComponent(document.cookie);
var ca = decodedCookie.split(';');
for(var i = 0; i <ca.length; i++) {
var c = ca[i];
while (c.charAt(0) === ' ') {
c = c.substring(1);
}
if (c.indexOf(name) === 0) {
return c.substring(name.length, c.length);
}
}
return "";
}
function onLoad() {
var displayElement = document.getElementById("display");
var randomNumber = getCookie("thanosNumber");
if (!randomNumber) {
randomNumber = Math.random();
document.cookie = "thanosNumber=" + randomNumber + "; expires=Sat, 27 Apr 2019 00:00:00 UTC";
} else {
randomNumber = Number(randomNumber);
}
if (randomNumber < 0.5) {
displayElement.textContent = "You were slain by Thanos, for the good of the Universe.";
} else {
displayElement.textContent = "You were spared by Thanos.";
}
}
function clearCookie() {
document.cookie = "thanosNumber=; expires=Thu, 01 Jan 1970 00:00:00 UTC";
location.reload();
}
</script>
</head>
<body onload="onLoad()">
<div style="width: 100%; height: 100%;">
<span id="display" style="position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); font-family: sans-serif; font-size: 4em; text-align: center;"></span>
<!-- <button onclick="clearCookie()">Clear Cookie</button> -->
</div>
</body>
</html>