-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhmo.html
228 lines (205 loc) · 8.23 KB
/
hmo.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
219
220
221
222
223
224
225
226
227
228
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport"
content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css"
integrity="sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M"
crossorigin="anonymous">
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark sticky-top">
<button class="navbar-toggler border-0"
type="button"
data-toggle="collapse"
data-target="#navbarSupportedContent"
aria-controls="navbarSupportedContent"
aria-expanded="false"
aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<span class="navbar-brand ml-3">Tournoi</span>
<span id="nbFight" class="navbar-brand ml-3"></span>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<!-- <ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="#">Disabled</a>
</li>
</ul>
<form class="form-inline my-2 my-lg-0">
<input class="form-control mr-sm-2" type="text" placeholder="Search" aria-label="Search">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
</form> -->
</div>
<!-- <div>
<ul class="nav classic-tabs tabs-cyan" role="tablist">
<li class="nav-item">
<a class="nav-link waves-light active" data-toggle="tab" href="#panel51" role="tab">Combattants</a>
</li>
<li class="nav-item">
<a class="nav-link waves-light" data-toggle="tab" href="#panel52" role="tab">Tournoi</a>
</li>
<li class="nav-item">
<a class="nav-link waves-light" data-toggle="tab" href="#panel54" role="tab">Classement</a>
</li>
</ul>
</div> -->
</nav>
<!-- <div class="container">
<table class="table table-striped">
<thead>
<tr>
<th>#</th>
<th>Nom</th>
<th>Points</th>
</tr>
</thead>
<tbody id="fighters">
</tbody>
</table>
</div> -->
<div class="container-fluid p-0">
<div class="progress">
<div class="progress-bar" role="progressbar" style="width: 25%; height: 1px;" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100"></div>
</div>
<table class="table table-sm table-striped">
<thead>
<tr>
<th>#</th>
<th style="color:red">De gueules</th>
<th style="color:blue">D'azur</th>
<th>/</th>
</tr>
</thead>
<tbody id="fights">
<!-- <tr data-toggle="collapse" data-target="#fight1" class="clickable text-muted">
<th scope="row">1</th>
<td class="font-weight-bold">Jonathan Salle</td>
<td>Charles Acquaviva</td>
<td>5-3</td>
</tr>
<tr id="fight1" class="collapse" >
<th></th>
<td><button type="button" class="btn btn-primary">+</button><button type="button" class="btn btn-primary">-</button></td>
<td></td>
<td></td>
</tr>
<tr data-toggle="collapse" data-target="#fight2" class="clickable">
<th scope="row">2</th>
<td>Ludovic David</td>
<td>Christophe David</td>
<td>2-5</td>
</tr>
<tr id="fight2" class="collapse" >
<td colspan="3">Hidden by default</td>
</tr> -->
</tbody>
</table>
</div>
<footer class="footer p-3 bg-dark" style="position: sticky;bottom:0;">
<div class="btn-toolbar justify-content-between" role="toolbar" aria-label="Toolbar with button groups">
<div class="btn-group btn-group-sm" role="group" aria-label="First group">
<button type="button" class="btn btn-danger">0</button>
<button type="button" class="btn btn-danger">1</button>
<button type="button" class="btn btn-danger">2</button>
<button type="button" class="btn btn-danger">3</button>
<button type="button" class="btn btn-danger">4</button>
<button type="button" class="btn btn-danger">5</button>
</div>
<div class="btn-group btn-group-sm" role="group" aria-label="Second group">
<button type="button" class="btn btn-primary">0</button>
<button type="button" class="btn btn-primary">1</button>
<button type="button" class="btn btn-primary">2</button>
<button type="button" class="btn btn-primary">3</button>
<button type="button" class="btn btn-primary">4</button>
<button type="button" class="btn btn-primary">5</button>
</div>
</div>
</footer>
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"
integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN"
crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.11.0/umd/popper.min.js"
integrity="sha384-b/U6ypiBEHpOf/4+1nzFpr53nxSS+GLCkfwBdFNTxtclqqenISfwAzpKaMNFNmj4"
crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/js/bootstrap.min.js"
integrity="sha384-h0AbiXch4ZDo7tp9hKZ4TsHbi047NrKGLO3SEJAg45jXxnGIfYzk4Si90RDIqNm1"
crossorigin="anonymous"></script>
<script>
//document.getElementById("demo").innerHTML = "Hello JavaScript!";
var fighters = ["Daniel Kalita", "Ludovic David", "Jonathan Salle", "Charles Acquaviva", "Gerry le Barban", "Phoenix Rodeur", "Alexis Forest", "Eric Frachebois", "Hugues Lepaien", "Sem Zorg", "Aurel Pgd", "Mika Pan", "Sylvain Mounier", "Richard Alexis", "Jérémie Martel"];
if (localStorage.getItem('fighters') == null) {
localStorage.setItem('fighters', JSON.stringify(fighters));
} else {
var fighters = JSON.parse(localStorage.getItem('fighters'));
}
var classement = "";
for (var i = 0; i < fighters.length; ++i) {
classement += '<tr><th scope="row">'+(i+1)+'</th><td>'+fighters[i]+'</td><td>170</td></tr>';
}
//document.getElementById("fighters").innerHTML = classement;
function roundRobin(fighters) {
var dummy = false;
if (fighters.length % 2 != 0) {
fighters.push("dummy");
dummy = true;
}
var numDays = fighters.length-1; // Days needed to complete tournament
var halfSize = fighters.length/2;
var team1 = fighters.shift();
var fights = [];
var pushFight = function(fight) {
if (fight.f1 != "dummy" && fight.f2 != "dummy")
fights.push(fight);
}
for (var day = 0; day < numDays; day++) {
pushFight({f1:team1, f2:fighters[day % fighters.length], score:"0/0"});
for (var idx = 1; idx < halfSize; idx++) {
var firstTeam = (day + fighters.length - idx) % fighters.length;
var secondTeam = (day + idx) % fighters.length;
pushFight({f1:fighters[firstTeam], f2:fighters[secondTeam], score:"0/0"});
}
}
if (dummy) {
fighters.pop();
}
return fights;
};
function shuffle(a) {
var j, x, i;
for (i = a.length; i; i--) {
j = Math.floor(Math.random() * i);
x = a[i - 1];
a[i - 1] = a[j];
a[j] = x;
}
};
shuffle(fighters);
var fights = roundRobin(fighters);
/*var test = false;
for (var i = 0; i < fights.length - 1; ++i) {
test |= fights[i].f1 == fights[i+1].f1 || fights[i].f1 == fights[i+1].f2 || fights[i].f2 == fights[i+1].f1 || fights[i].f2 == fights[i+1].f2;
}
console.log(test);*/
var fightList = "";
fightList += '<tr class="table-primary"><th scope="row">1</th><td>'+fights[0].f1+'</td><td>'+fights[0].f2+'</td><td>'+fights[0].score+'</td></tr>'
for (var i = 1; i < fights.length; ++i) {
fightList += '<tr><th scope="row">'+(i+1)+'</th><td>'+fights[i].f1+'</td><td>'+fights[i].f2+'</td><td>'+fights[i].score+'</td></tr>'
}
document.getElementById("fights").innerHTML = fightList;
document.getElementById("nbFight").innerHTML = "0/"+fights.length;
</script>
</body>
</html>