-
Notifications
You must be signed in to change notification settings - Fork 2
/
profile.html
133 lines (113 loc) · 3.29 KB
/
profile.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
<!doctype html>
<head>
<title>GCKZStats - Player profile</title>
<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>
<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>
<!-- Player info -->
<div id="player-info">
<h3 id="player-name">Unknown Player</h3>
STEAM_1:X:XXXXXXXXX<br>
<a href="https://steamcommunity.com/profiles/">Steam profile</a><br>
</div>
<div style="padding:0px 1% 0px 1%; float: left">
<h4>Point Leaderboard</h4>
<table id="personal-records" style="width:75%;">
<tr>
<th>Map</th>
<th>Points</th>
<th>Run time</th>
<th>Teleports</th>
<th>Date</th>
<th>Server</th>
</tr>
</table>
</div>
</body>
<script>
let g_SteamID = "STEAM_1:0:102468802"
OnPageOpened()
function OnPageOpened()
{
let params = GetParams(window.location.href)
for (let key in params)
{
if (key == "steamid")
{
g_SteamID = params[key]
break
}
}
if ((typeof g_SteamID) !== "string")
{
// TODO: maybe fall back on some neutral steamid.
g_SteamID = "STEAM_1:0:102468802"
}
UpdatePlayerProfile(g_SteamID)
}
function OnTPRunDropdownChanged()
{
UpdatePlayerProfile(g_SteamID)
}
function OnModeDropdownChanged()
{
UpdatePlayerProfile(g_SteamID)
}
function UpdatePlayerProfile(steamID)
{
RemoveAllChildrenFromNode(document.getElementById("personal-records"))
$('#personal-records').append('\
<tr>\
<th>Map</th>\
<th>Points</th>\
<th>Run time</th>\
<th>Teleports</th>\
<th>Date</th>\
<th>Server</th>\
</tr>')
// https://kztimerglobal.com/api/v2.0/records/top?steam_id=STEAM_1%3A0%3A102468802&tickrate=128&stage=0&modes_list=kz_timer&has_teleports=false
$.getJSON("https://kztimerglobal.com/api/v2.0/records/top?steam_id=" + steamID + "&tickrate=128&stage=0&modes_list=" + GetRunMode() + "&has_teleports=" + GetRunType() + "&limit=10000", function (data)
{
if (data.length == 0)
{
return
}
RemoveAllChildrenFromNode(document.getElementById("player-info"))
$('#player-info').append('\
<h3 id="player-name">' + data[0].player_name + '</h3>\
' + data[0].steam_id + '<br>\
<a href="https://steamcommunity.com/profiles/' + data[0].steamid64 + '">Steam profile</a><br>'
)
data.sort(function(a, b) {
let date1 = new Date(a.created_on)
let date2 = new Date(b.created_on)
return date2 - date1
})
$.each(data, function (index, value)
{
$('#personal-records').append('\
<tr>\
<td>' + CreateMaptopLink(data[index].map_name) + '</td>\
<td>' + ((data[index].points == "1000") ? (data[index].points + "(WR)") : (data[index].points)) + '</td>\
<td>' + FormatTime(data[index].time) + '</td>\
<td>' + data[index].teleports + '</td>\
<td>' + new Date(data[index].created_on).toLocaleDateString("en-GB", g_DateOptions) + '</td>\
<td>' + data[index].server_name + '</td>\
</tr>')
})
})
}
</script>
</html>