forked from GameChaos/gckzstats
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathleaderboards.html
137 lines (119 loc) · 3.79 KB
/
leaderboards.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<!doctype html>
<script src="https://code.jquery.com/jquery-3.4.1.min.js"
integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script>
<script src="js/helpers.js"></script>
<link rel="stylesheet" href="css/style.css">
<head>
<title>GCKZStats</title>
<!--<link rel="stylesheet" href="css/main.css" />-->
<!--<link href="css/main.css" rel="stylesheet" type="text/css" />-->
<!--<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous" />-->
</head>
<body>
<select onchange="OnTPRunDropdownChanged()" id="tpRun-dropdown" name="TP/Pro">
<option value="false">Pro</option>
<option value="true">TP</option>
</select>
<select onchange="OnModeDropdownChanged()" id="mode-dropdown" name="Mode">
<option value="kz_timer">KZTimer</option>
<option value="kz_simple">SimpleKZ</option>
<option value="kz_vanilla">Vanilla</option>
</select>
<h3 id="leaderboard-title">Top Players for MODE TPORPRO</h3>
<div style="padding:0px 1% 0px 1%; float: left">
<h4>Point Leaderboard</h4>
<table id="leaderboard-points" style="width:75%;">
<tr>
<th>#</th>
<th>Player</th>
<th>Records</th>
</tr>
</table>
</div>
<div style="padding:0px 1% 0px 1%; float: left">
<h4>World Record Leaderboard</h4>
<table id="leaderboard-world-records" style="width:75%;">
<tr>
<th>#</th>
<th>Player</th>
<th>Records</th>
</tr>
</table>
</div>
</body>
<script>
OnPageOpened()
function OnPageOpened()
{
UpdateLeaderboardTitle()
UpdatePointLeaderboard()
UpdateWorldRecordLeaderboard()
}
function OnTPRunDropdownChanged()
{
UpdateLeaderboardTitle()
UpdatePointLeaderboard()
UpdateWorldRecordLeaderboard()
}
function OnModeDropdownChanged()
{
UpdateLeaderboardTitle()
UpdatePointLeaderboard()
UpdateWorldRecordLeaderboard()
}
function UpdateLeaderboardTitle()
{
$('#leaderboard-title').text("Top Players for " + GetRunModePretty() + " " + GetRunTypePretty())
}
function UpdatePointLeaderboard()
{
// https://kztimerglobal.com/api/v1.0/records/top/world_records?stages=0&mode_ids=200&has_teleports=false
RemoveAllChildrenFromNode(document.getElementById("leaderboard-points"))
$('#leaderboard-points').append('\
<tr>\
<th>#</th>\
<th>Player</th>\
<th>Total</th>\
<th>Average</th>\
</tr>')
// https://kztimerglobal.com/api/v1.0/player_ranks?stages=0&mode_ids=200&tickrates=128&has_teleports=false
$.getJSON('https://kztimerglobal.com/api/v1.0/player_ranks?stages=0&mode_ids=' + GetModeID(GetRunMode()) + '&tickrates=128&has_teleports=' + GetRunType(), function (data)
{
$.each(data, function (index, value)
{
$('#leaderboard-points').append('\
<tr>\
<td>' + (index + 1) + '</td>\
<td>' + CreatePlayerProfileLink(data[index].steamid, data[index].player_name) + '</td>\
<td>' + data[index].points.toLocaleString() + '</td>\
<td>' + data[index].average.toFixed(1) + '</td>\
</tr>')
})
})
}
function UpdateWorldRecordLeaderboard()
{
// https://kztimerglobal.com/api/v1.0/records/top/world_records?stages=0&mode_ids=200&has_teleports=false
RemoveAllChildrenFromNode(document.getElementById("leaderboard-world-records"))
$('#leaderboard-world-records').append('\
<tr>\
<th>#</th>\
<th>Player</th>\
<th>Records</th>\
</tr>')
$.getJSON('https://kztimerglobal.com/api/v1.0/records/top/world_records?stages=0&mode_ids=' + GetModeID(GetRunMode()) + '&tickrates=128&has_teleports=' + GetRunType(), function (data)
{
$.each(data, function (index, value)
{
$('#leaderboard-world-records').append('\
<tr>\
<td>' + (index + 1) + '</td>\
<td>' + CreatePlayerProfileLink(data[index].steam_id, data[index].player_name) + '</td>\
<td>' + data[index].count + '</td>\
</tr>')
})
})
}
</script>
</html>