-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
175 lines (155 loc) · 6.21 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
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
<!DOCTYPE html>
<html lang="en">
<head>
<script
src="https://code.jquery.com/jquery-3.6.0.min.js"
integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4="
crossorigin="anonymous"></script>
<script src="https://cdn.datatables.net/1.10.23/js/jquery.dataTables.min.js" crossorigin="anonymous"></script>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BmbxuPwQa2lc/FVzBcNJ7UAyJxM6wuqIj61tLrc4wSX0szH/Ev+nYRRuWlolflfl" crossorigin="anonymous">
<link href="https://cdn.datatables.net/1.10.23/css/jquery.dataTables.min.css" rel="stylesheet" crossorigin="anonymous">
<meta charset="UTF-8">
<title>UD-Master - Classement</title>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<div class="container-fluid">
<a class="navbar-brand" href="#">UDMaster</a>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<li class="nav-item">
<a class="nav-link active" href="index.html">Classement</a>
</li>
<li class="nav-item">
<a class="nav-link" href="stats.html">Stats</a>
</li>
<li class="nav-item">
<a class="nav-link" href="ud9.html">UD9</a>
</li>
</ul>
</div>
</div>
</nav>
<div class="container">
<table id="champ" class="table table-dark table-striped">
<thead>
<tr>
<th>#</th>
<th>Runner</th>
<th>Score</th>
<th>Temps</th>
<th>UD1</th>
<th>UD2</th>
<th>UD3</th>
<th>UD4</th>
<th>UD5</th>
<th>UD6</th>
<th>UD7</th>
<th>UD8</th>
<th>UD9</th>
<th>card</th>
</tr>
</thead>
<tbody id="leaderboard-body"></tbody>
</table>
</div>
</body>
</html>
<script>
let fullChampionshipInfos = [];
let seasonsList = [1, 2, 3, 4, 5, 6, 7, 8, 9];
calcChamp();
function calcChamp()
{
seasonsList.forEach(function (season) {
getSeasonInfos(season);
});
fullChampionshipInfos.sort(function (a, b) {
if (b.scoreTotal === a.scoreTotal) {
return a.timeTotal - b.timeTotal;
} else {
return b.scoreTotal - a.scoreTotal;
}
});
generateTable();
$('#champ').DataTable({
"order": []
});
}
function generateTable() {
let tbody = document.querySelector("#leaderboard-body")
let lastBestScore = null;
let counter = 1;
for (let runner of fullChampionshipInfos) {
if (runner != undefined) {
let row = tbody.insertRow();
let rank = '-';
if (lastBestScore != runner.scoreTotal) {
rank = counter;
lastBestScore = runner.scoreTotal;
}
++counter;
let cellRank = row.insertCell();
let textRank = document.createTextNode(rank);
cellRank.appendChild(textRank);
let cellRunner = row.insertCell();
let textRunner = document.createTextNode(runner.pseudo);
cellRunner.appendChild(textRunner);
let cellScore = row.insertCell();
let textScore = document.createTextNode(runner.scoreTotal);
cellScore.appendChild(textScore);
let cellTime = row.insertCell();
let textTime = document.createTextNode(new Date(runner.timeTotal * 1000).toISOString().substr(11, 8));
cellTime.appendChild(textTime);
for (const [season, seasonScore] of Object.entries(runner.seasons)) {
let score = seasonScore;
let cellGame = row.insertCell();
let textGame = document.createTextNode(score);
cellGame.appendChild(textGame);
}
let card = row.insertCell();
let cardLink = document.createElement('a');
cardLink.href = 'card.html?runner=' + runner.pseudo;
let cardLinkText = document.createTextNode('ici');
cardLink.appendChild(cardLinkText);
card.appendChild(cardLink);
}
}
}
function getSeasonInfos(season)
{
$.ajax({
url: "https://masters.ultimedecathlon.com/graphql",
data: {
query: 'query seasonChampionship { ChampionshipResults (season: ' + season + ', groupment: "grind") { user { id username alias } timeTotal scoreTotal }}'
},
async: false,
context: document.body
}).done(function(seasonChampionship) {
seasonChampionship.data.ChampionshipResults.forEach(function (row) {
let runnerPseudo = row.user.alias ? row.user.alias : row.user.username;
if (!fullChampionshipInfos[row.user.id]) {
fullChampionshipInfos[row.user.id] = {
pseudo: runnerPseudo,
scoreTotal: 0,
timeTotal: 0,
seasons: {
1: 0,
2: 0,
3: 0,
4: 0,
5: 0,
6: 0,
7: 0,
8: 0,
9: 0,
}
};
}
fullChampionshipInfos[row.user.id].scoreTotal += row.scoreTotal;
fullChampionshipInfos[row.user.id].timeTotal += row.timeTotal;
fullChampionshipInfos[row.user.id].seasons[season] = row.scoreTotal;
})
});
}
</script>