-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
85 lines (81 loc) · 2.5 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title></title>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<link href="https://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet">
<style>
html {
background-color: #2C2F33;
}
.centered {
display: flex;
align-items: center;
justify-content: center;
}
</style>
<body>
<h1 style="font-family: 'Open Sans', sans-serif; font-size:72px; color:white;text-align:center">AJDS Scorer</h1>
<h2 style="font-family: 'Open Sans', sans-serif; font-size:36px; color:#99AAB5;text-align:center" id="status">Loading...</h1>
<div class="centered">
<canvas id=cnv width=300 height=300 style="display:none;"></canvas>
</div>
</body>
<script src="params.js"></script>
<script src="progress.js"></script>
<script src="swearjar.js"></script>
<script src="score.js"></script>
<script>
let canvas = document.getElementById("cnv");
let ctx = canvas.getContext("2d");
ctx.fillStyle = "white";
ctx.lineWidth = 12;
ctx.lineCap = "round";
ctx.font = "64px 'Open Sans'";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
let bar = new ProgressBar(ctx, 25, .01);
bar.progress = 0;
setInterval(() => {
bar.step();
ctx.clearRect(0, 0, cnv.width, cnv.height);
ctx.fillText(Math.round(bar.progress * 100) + "%", cnv.width / 2, cnv.height / 2);
ctx.beginPath();
ctx.strokeStyle = "gray";
bar.drawBase();
ctx.stroke();
ctx.beginPath();
ctx.strokeStyle = "white";
bar.draw();
ctx.stroke();
}, 20);
window.addEventListener("load", function () {
let token = getParams(location.href.toString()).access_token;
if (token == undefined) window.location.replace(
"https://discordapp.com/api/oauth2/authorize?client_id=536656002578251806&redirect_uri=https%3A%2F%2Fterminal-atomics.github.io%2Fajds-scorer&response_type=token&scope=identify%20email"
);
fetch("https://discordapp.com/api/users/@me", {
headers: {
"Authorization": "Bearer " + token
}
}).then(async res => {
if (res.status != 200) {
document.getElementById("status").innerHTML = "Failed";
return;
}
document.getElementById("status").style.display = "none";
let user = await res.json();
let score = await AJDSscore(user);
bar.progress = score * 2 / 100;
canvas.style.display = "block";
}).catch(err => {
document.getElementById("status").style.display = "block";
document.getElementById("status").innerText = "Error";
console.log(err);
});
});
</script>
</html>