-
Notifications
You must be signed in to change notification settings - Fork 0
/
badge.html
60 lines (60 loc) · 2.12 KB
/
badge.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
<!DOCTYPE html>
<html>
<head>
<link rel="icon" type="image/x-icon" href="/favicon.ico" />
<link rel="stylesheet" type="text/css" href="/theme.css" />
<script src="/background.js"></script>
<link rel="stylesheet" type="text/css" href="/table.css" />
<link rel="stylesheet" type="text/css" href="/badges.css" />
<style>
h2 {
color: white;
}
</style>
</head>
<body>
<div class="tabs"></div>
<h1><b>{{SRANK}} {{SNAME}}</b> badge</h1>
<div id="badge_desc" class="physics"></div>
<div>
<h2>Owners of this badge:</h2>
<ul id="owners"></ul>
</div>
<div>
<h2>Leaderboard</h2>
<a href="/leaderboard/{{NAME}}" id="leaderboard_link" style="color: rgb(0, 0, 200);" class="physics">Show leaderboard for {{SNAME}}</a>
</div>
<script src="/data.js"></script>
<script src="/tabs.js"></script>
<script>
tabs.extra(3, "{{SRANK}} {{SNAME}}")
getData().then((info) => {
tabs.userfix(info.profile);
var badge_value = info.data["{{NAME}}"].badges[{{RANK}}]
var badge_desc = info.data["{{NAME}}"].badge_desc
document.querySelector("#badge_desc").innerText = `${badge_desc.replaceAll("%s", info.data["{{NAME}}"].isTime ? formatTime(badge_value) : addCommas(badge_value))}`
// owners
var owners = info.getBadgeOwners("{{NAME}}", {{RANK}})
for (var i = 0; i < owners.length; i++) {
var e = document.createElement("li")
e.appendChild(document.createElement("a"))
e.children[0].href = "/profile/" + owners[i] + location.search
e.children[0].setAttribute("style", "color: rgb(0, 0, 200);")
e.children[0].appendChild(document.createElement("b"))
e.children[0].children[0].innerText = owners[i]
e.appendChild(document.createElement("span"))
var score = info.getScore(owners[i], "{{NAME}}")
if (info.data["{{NAME}}"].isTime) {
e.children[1].innerText = ` at ${formatTime(score)}`
} else {
e.children[1].innerText = ` with ${addCommas(score)} points`
}
document.querySelector("#owners").appendChild(e)
}
})
document.querySelector("#leaderboard_link").href += location.search
</script>
<script src="https://brm.io/matter-js/build/matter.js"></script>
<script src="/matter2.js"></script>
</body>
</html>