forked from iwantzh/iwantzh.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
240 lines (206 loc) · 7.39 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
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
229
230
231
232
233
234
235
236
237
238
239
240
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>I Want Crazyhouse</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.2.13/semantic.min.css">
<style>
[v-cloak] {
display: none;
}
</style>
</head>
<body>
<h2 id="header1" class="ui header centered">
<br/>
<br/>
<span v-cloak>Redirecting you to the current hourly crazyhouse tournament.</span>
<br/>
<span>Please wait...</span>
</h2>
<div class="table ui header centered">See list of all ZH arenas:<br/><a href="https://iwantzh.github.io/list.html">https://iwantzh.github.io/list.html</a></div>
<div id="table1" class="ui celled padded table">
<!--table id="table10" class="ui celled padded table">
<thead>
<tr>
<th>id</th>
<th>created by</th>
<th>Players#</th>
<th>variant</th>
<th>starts at</th>
<th>finishes at</th>
<th>minutes</th>
<th>clock</th>
<th>status</th>
</tr>
</thead>
<tbody>
<tr v-for="tournament in tournaments">
<td class="single line">
<a v-bind:href="'https://lichess.org/tournament/' + tournament.json['id']">{{tournament.json['fullName']}}</a></span>
</td>
<td>
<span v-cloak>{{tournament.json['createdBy']}}</span>
</td>
<td>
<span v-cloak>{{tournament.json['nbPlayers']}}</span>
</td>
<td>
<span v-cloak>{{tournament.json['variant']['name']}}</span>
</td>
<td>
<span v-cloak>{{new Date(tournament.json['startsAt']).toLocaleString()}}</span>
</td>
<td>
<span v-cloak>{{new Date(tournament.json['finishesAt']).toLocaleString()}}</span>
</td>
<td>
<span v-cloak>{{tournament.json['minutes']}}</span>
</td>
<td>
<span v-cloak>{{tournament.json['clock']['limit']}} + {{tournament.json['clock']['increment']}}</span>
</td>
<td>
<span v-cloak>{{tournament.json['status']}}</span>
</td>
</tr>
</tbody>
</table-->
</div>
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.2.13/semantic.min.js"></script>
<script src="https://unpkg.com/vue"></script>
<script>
var Tournament = function(json) {
this.json = json;
}
var header1 = new Vue({
el: '#header1',
data: {
message: 'I Want Crazyhouse!'
}
});
var table1 = new Vue({
el: '#table1',
data: {
//tournamentsTulpas: [],
//tournamentsStarted: [],
//tournamentsCreated: [],
//tournamentsFinished: [],
tournamentsTmp: [],
tournaments: []
},
created: function() {
outerThis = this;
fetch( "https://lichess.org/api/tournament" ).then( function( response ) {
if ( !response.ok ) {
throw new Exception( response.status )
}
return response.json()
}).then( function( json ) {
for (var x in json["started"]){
var t = json["started"][x];
//outerThis.$data.tournamentsStarted.push(new Tournament(t));
if (t["variant"]["key"]=="crazyhouse"){
outerThis.$data.tournamentsTmp.push(new Tournament(t));
}
}
for (var x in json["created"]){
var t = json["created"][x];
//outerThis.$data.tournamentsCreated.push(new Tournament(t));
if (t["variant"]["key"]=="crazyhouse"){
outerThis.$data.tournamentsTmp.push(new Tournament(t));
}
}
//for (var x in json["finished"]){
// var t = json["finished"][x];
// //outerThis.$data.tournamentsFinished.push(new Tournament(t));
// console.log(">>>>>>>>>"+t["variant"]["key"]=="crazyhouse");
// if (t["variant"]["key"]=="crazyhouse"){
// //outerThis.$data.tournamentsTmp.push(new Tournament(t));
// }
//}
}).then ( function(){
//outerThis.$data.tournaments.sort(function(a, b){return a.json['startsAt']-b.json['startsAt']});
}).catch( function( error ) {
console.info( "Received error ", error);
}).then ( function() {
fetch( "https://lichess.org/api/user/undergroundzh1/tournament/created" ).then( function( response ) {
if ( !response.ok ) {
throw new Exception( response.status )
}
return response.text()
}).then( function( text ) {
var json = JSON.parse('['+text.split("}\n{").join("},{")+']');//oh fuck off NDJSON! because comma is not cool enough? TODO:how do i parse this shit properly
for (var x in json){
if (json[x]["status"] != 30 ) {
outerThis.$data.tournamentsTmp.push(new Tournament(json[x]));
}
}
}).then ( function(){
//outerThis.$data.tournaments.sort(function(a, b){return a.json['startsAt']-b.json['startsAt']});
}).catch( function( error ) {
console.info( "Received error ", error);
}).then ( function(){
fetch( "https://lichess.org/api/user/undergroundzh2/tournament/created" ).then( function( response ) {
if ( !response.ok ) {
throw new Exception( response.status )
}
return response.text()
}).then( function( text ) {
var json = JSON.parse('['+text.split("}\n{").join("},{")+']');//oh fuck off NDJSON! because comma is not cool enough? TODO:how do i parse this shit properly
for (var x in json){
if (json[x]["status"] != 30 ) {
outerThis.$data.tournamentsTmp.push(new Tournament(json[x]));
}
}
}).then ( function(){
//outerThis.$data.tournamentsTmp.sort(function(a, b){return a.json['startsAt']-b.json['startsAt']});
//for (x in outerThis.$data.tournamentsTmp){
// console.log(outerThis.$data.tournamentsTmp[x]);
// outerThis.$data.tournaments.push(outerThis.$data.tournamentsTmp[x]);
// }
}).catch( function( error ) {
console.info( "Received error ", error);
}).then (function(){
fetch( "https://lichess.org/api/user/blunderman1/tournament/created" ).then( function( response ) {
if ( !response.ok ) {
throw new Exception( response.status )
}
return response.text()
}).then( function( text ) {
var json = JSON.parse('['+text.split("}\n{").join("},{")+']');//oh fuck off NDJSON! because comma is not cool enough? TODO:how do i parse this shit properly
for (var x in json){
if (json[x]["status"] != 30 ) {
outerThis.$data.tournamentsTmp.push(new Tournament(json[x]));
}
}
}).then ( function(){
outerThis.$data.tournamentsTmp.sort(function(a, b){return a.json['startsAt']-b.json['startsAt']});
for (x in outerThis.$data.tournamentsTmp){
console.log(outerThis.$data.tournamentsTmp[x]);
outerThis.$data.tournaments.push(outerThis.$data.tournamentsTmp[x]);
}
}).catch( function( error ) {
console.info( "Received error ", error);
}).then (function(){
var tid = outerThis.$data.tournaments[0].json["id"];
console.log(tid);
window.location.replace('https://lichess.org/tournament/'+tid);
});
});
});
});
//////////
},
mounted: function() {
},
updated(){
//alert('Updated hook has been called');
},
methods: {
}
});
</script>
</body>
</html>