-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplayers.html
218 lines (196 loc) · 9.85 KB
/
players.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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Players</title>
<!-- Bootstrap and jQuery -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="css/main.css" />
<link rel="stylesheet" href="css/participantpage.css" />
<script src="js/common.js"></script>
<script>
function hashChange() {
setupPage(200);
}
function setupPage(animationDuration) {
animationDuration = animationDuration || 0;
$("#player-info").hide();
$("#players-page").hide();
$("#sidebar").empty();
if (/^#([A-Za-z\-0-9 ,._]+)$/.exec(decodeURI(window.location.hash))) {
var playerId = RegExp.$1;
var player = players.filter(p => p["name"] === playerId)[0];
if (player) {
//$("#player-info").empty();
setupPlayerInfo(player);
$("#player-info").show(animationDuration);
return;
}
}
//$("#players-page").empty();
setupPlayersPage();
$("#players-page").show(animationDuration);
}
function setupPlayerInfo(player) {
$("#sidebar").append($("<a>", { href: "#", class: "fa fa-angle-left" }));
$(".player-name").text(player["name"]);
$(".player-links").empty();
if (player["discord"]) {
var discordLink = $("<a>", { href: `#${player["name"]}`, class: "btn btn-light discord" });
//discordLink.append($("<span>", { class: "fa fa-fire" }));
discordLink.append($("<img>", { src: "img/discord-icon.svg" }));
discordLink.append(` @${player["discord"]}`);
$(".player-links").append(discordLink);
}
if (player["teams"]) {
for (var team of player["teams"]) {
var teamLink = $("<a>", { href: `teams.html#${team}`, class: "btn btn-light team" });
//discordLink.append($("<span>", { class: "fa fa-fire" }));
teamLink.append($("<img>", { src: "img/team-icon.svg" }));
teamLink.append(` ${team}`);
$(".player-links").append(teamLink);
}
}
$(".category-links").empty();
for (var category of player["categories"]) {
var ctg = categories.filter(c => c.id === category)[0];
$("#sidebar").append($("<button>").text(ctg["shorthand"]).click({ "player": player, "category": category }, changeCategorySelection));
$(".category-links").append($("<button>", { class: "btn btn-light", "data-category": category }).text(ctg["name"]).click({ "player": player, "category": category }, changeCategorySelection));
}
for (var category of player["eliminated-categories"]) {
var ctg = categories.filter(c => c.id === category)[0];
$("#sidebar").append($("<button>", { class: "eliminated" }).text(ctg["shorthand"]).click({ "player": player, "category": category }, changeCategorySelection));
$(".category-links").append($("<button>", { class: "btn btn-light eliminated", "data-category": category }).text(ctg["name"]).click({ "player": player, "category": category }, changeCategorySelection));
}
changeCategorySelection({ data: { "player": player, "category": $(".category-links :first-child").attr("data-category") } });
$(".player-modules").empty();
$(".player-module-vetos").empty();
if (player["modded-modules"]) {
$(".mod-list").show();
for (var module of player["modded-modules"]) {
var moduleListing = $("<a>", { href: `https://ktane.timwi.de/HTML/${encodeModuleName(module)}.html`, class: "module-listing col-12 col-md-6 col-lg-6 col-xl-6 bg-light" });
moduleListing.append($("<img>", { src: `https://ktane.timwi.de/Icons/${encodeModuleName(module)}.png`, class: "module-image" }));
moduleListing.append(module);
$(".mod-list .player-modules").append(moduleListing);
}
var vetos = player["vetoed-modules"];
for (var opponent in vetos) {
var module = vetos[opponent];
var moduleListing = $("<a>", { href: `https://ktane.timwi.de/HTML/${encodeModuleName(module)}.html`, class: "module-listing col-12 col-md-6 col-lg-6 col-xl-6 bg-dark" });
moduleListing.append($("<img>", { src: `https://ktane.timwi.de/Icons/${encodeModuleName(module)}.png`, class: "module-image" }));
moduleListing.append(module + " ");
moduleListing.append($("<a>", { href: `players.html#${opponent}` }).text(`(against ${opponent})`));
$(".mod-list .player-module-vetos").append(moduleListing);
}
} else {
$(".mod-list").hide();
}
}
function changeCategorySelection(event) {
var category = event.data["category"];
var player = event.data["player"];
$(".category-links button").removeClass("selected");
$(`.category-links button[data-category~=${category}]`).addClass("selected");
$(".player-matches").empty();
var matchList = matches.filter(m => (m["competitors"].includes(player["name"]) || m["competitors"].some(c => player["teams"] ? player["teams"].includes(c) : false)) && m["category"] === category);
//matchList.sort((a, b) => a["group"] < b["group"] ? -1 : 1);
matchList.sort((a, b) => a["match-group"] < b["match-group"] ? -1 : 1);
for (var match of matchList) {
$(".player-matches").append(makeMatchCard(match, true));
}
}
var pageSetup = false;
var playerCards = [];
var categorySelections = {};
function setupPlayersPage() {
for (var category of categories) {
categorySelections[category["id"]] = true;
$("#sidebar").append($("<button>", { "data-category": category["id"] }).text(category["shorthand"]).click({ "category": category }, toggleSelection));
}
if (pageSetup) return;
for (let player of players.sort(dynamicSort("name"))) {
let card = makePlayerCard(player);
$(".player-list").append(card);
playerCards.push([player, card]);
}
pageSetup = true;
}
function toggleSelection(event) {
category = event.data["category"]["id"];
categorySelections[category] = !categorySelections[category];
filterSelector:
for (var playerTuple of playerCards) {
playerTuple[1].removeClass("disabled");
for (let ctg of playerTuple[0]["categories"]) {
if (categorySelections[ctg]) {
continue filterSelector;
}
}
for (let ctg of playerTuple[0]["eliminated-categories"]) {
if (categorySelections[ctg]) {
continue filterSelector;
}
}
playerTuple[1].addClass("disabled");
}
if (categorySelections[category]) {
$(`#sidebar [data-category=${category}]`).removeClass("disabled");
} else {
$(`#sidebar [data-category=${category}]`).addClass("disabled");
}
}
window.onhashchange = hashChange;
</script>
<style>
.page {
width: 100%;
height: 100%;
}
</style>
</head>
<body data-spy="scroll" data-target=".icon-bar" data-offset="50">
<!-- Import Navbar -->
<div id="navbar-placeholder" class="container"></div>
<div id="sidebar" class="icon-bar"></div>
<div id="player-info" class="page">
<h1 class="player-name">Player still loading...</h1>
<div class="text-center">
<div class="player-links btn-group d-none d-sm-block" role="group"></div>
<div class="player-links btn-group-vertical d-sm-none" role="group"></div>
</div>
<h1>Matches</h1>
<div class="text-center">
<div class="category-links btn-group d-none d-sm-block" role="group"></div>
<div class="category-links btn-group-vertical d-sm-none" role="group"></div>
</div>
<div class="player-matches"></div>
<div class="container mod-list">
<div class="row">
<div class="col-6">
<h1>Modded Modules</h1>
</div>
<div class="col-6">
<h1>Modded Module Vetos</h1>
</div>
</div>
<div class="row">
<div class="col-6">
<div class="player-modules row"></div>
</div>
<div class="col-6">
<div class="player-module-vetos row"></div>
</div>
</div>
</div>
</div>
<div id="players-page" class="page">
<h1>Players</h1>
<div class="player-list row"></div>
</div>
<div class="bottom-spacer"></div>
</body>
</html>