forked from srobo/srcomp-screens
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathoutside.html
214 lines (185 loc) · 7.78 KB
/
outside.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>SR Outside Screen</title>
<script src="bower_components/webcomponentsjs/webcomponents.js"></script>
<link rel="import" href="bower_components/core-pages/core-pages.html" />
<link rel="import" href="components/sr-comp/component.html" />
<link rel="import" href="components/sr-clock/component.html" />
<link rel="import" href="components/sr-progress/component.html" />
<link rel="import" href="components/sr-competitor-schedule/component.html" />
<link rel="import" href="components/sr-leaderboard/component.html" />
<link rel="import" href="components/sr-scores/component.html" />
<link rel="import" href="components/sr-knockout-diagram/component.html" />
<link rel="import" href="components/moment/component.html" />
<style>
body {
position: fixed;
width: 100%;
height: 100%;
top: 0;
right: 0;
bottom: 0;
left: 0;
margin: 0;
padding: 0;
font-family: 'Open Sans', sans-serif;
background: black;
color: white;
font-size: 100%;
}
#pages {
height: 90%;
width: 100%;
overflow: auto;
flex: 1 1 auto;
-webkit-flex: 1 1 auto;
display: flex;
display: -webkit-flex;
flex-direction: column;
-webkit-flex-direction: column;
align-items: center;
-webkit-align-items: center;
justify-content: center;
-webkit-justify-content: center;
}
#pages > * {
display: none;
position: static !important; /* wrestle with core-pages */
}
#pages > .core-selected {
display: block;
}
#progress {
height: 10%;
width: 100%;
flex: 0 0 auto;
-webkit-flex: 0 0 auto;
display: flex;
display: -webkit-flex;
align-items: center;
-webkit-align-items: center;
border-top: 1px solid rgb(100, 100, 100);
}
#progress > h1, #progress > p {
color: rgb(200, 200, 200);
margin: 0.1em 0.3em;
flex: 1 1 auto;
-webkit-flex: 1 1 auto;
}
#progress > h1 {
font-size: 2.6em;
}
#progress > p {
font-size: 1.7em;
font-style: italic;
}
#progress > sr-clock {
font-size: 2.6em;
margin: 0.1em 0.3em;
}
</style>
</head>
<body>
<sr-comp id="comp"></sr-comp>
<core-pages id="pages" selected="0">
<sr-competitor-schedule
data-title="Schedule"
data-website-url-slug="schedule"
data-needs-comp
></sr-competitor-schedule>
<sr-leaderboard
data-title="League Leaderboard"
data-website-url-slug="league"
data-needs-comp
></sr-leaderboard>
<sr-scores
data-title="League Scores"
data-website-url-slug="league"
data-needs-comp
></sr-scores>
<sr-knockout-diagram
data-title="Knockouts"
data-website-url-slug="knockout"
data-needs-comp
></sr-knockout-diagram>
</core-pages>
<sr-progress id="progress" progress="1">
<h1 id="progress-title"></h1>
<p id="website-url"></p>
<sr-clock></sr-clock>
</sr-progress>
<script>
document.addEventListener('sr-ready', function() {
var comp = document.querySelector('#comp');
var needsComp = document.querySelectorAll('[data-needs-comp]');
for (var i = 0; i < needsComp.length; i++) {
needsComp[i].comp = comp;
}
var knockoutTime = undefined;
var noLeaderboardTime = undefined;
comp.api.getKnockoutMatches(function(matches) {
if (matches.length > 0) {
// show the knockouts from 1 hour before the first knockout match
knockoutTime = moment(matches[0].times.slot.start).subtract(1, 'hours');
// hide the leaderboard once the knockouts actually start
noLeaderboardTime = moment(matches[0].times.game.start);
} else {
knockoutTime = undefined;
noLeaderboardTime = undefined;
}
});
var pages = document.querySelector('#pages');
var progress = document.querySelector('#progress');
var progressTitle = document.querySelector('#progress-title');
var websiteUrl = document.querySelector('#website-url');
var nextPage = function() {
pages.selected = (pages.selected + 1) % pages.children.length;
progressTitle.textContent = pages.children[pages.selected].dataset.title;
websiteUrl.textContent = "srobo.org/comp/" + pages.children[pages.selected].dataset.websiteUrlSlug;
progress.progress = 0;
};
var shouldSelectAutomatically = function(index) {
if (index == 3) { // knockouts
if (knockoutTime != null && moment().isBefore(knockoutTime)) {
return false;
}
}
if (index == 1) { // leaderboard
if (noLeaderboardTime != null && moment().isAfter(noLeaderboardTime)) {
return false;
}
}
return true;
};
setInterval(function() {
progress.progress += 0.02;
if (progress.progress >= 1) {
do {
nextPage();
} while (!shouldSelectAutomatically(pages.selected));
}
}, 200);
// Advance to the next page on click; note that this
// always shows _all_ the pages
document.addEventListener('click', nextPage);
/* Work around an issue with Firefox. When the arena fields
above are set, the changed callback should get called
immediately giving time for listeners to be registered on
the stream before it is loaded below. However, in Firefox,
the changed callbacks happen *after* this call below.
Therefore, we wrap it in a 'setTimeout' to ensure it happens
in the next tick, after the changed callbacks.
Rather concerningly, using a value of 0ms in the
'setTimeout' doesn't solve the problem. Therefore the 500ms
as it is currently might have to be increased for the
Raspberry Pis which have a lower processing speed than my
laptop. */
setTimeout(function() {
comp.stream.load();
}, 500);
});
</script>
</body>
</html>