Repository navigation
Expand file tree
/
Copy pathdisplay.html
More file actions
351 lines (300 loc) · 9.8 KB
/
Copy pathdisplay.html
File metadata and controls
351 lines (300 loc) · 9.8 KB
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
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Fenger Management System (FMS)</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;700&display=swap" rel="stylesheet">
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
html {
/* Scale all rem-based sizes with the viewport width.
At 400px (OBS corner): ~5px base → compact overlay.
At 1920px (full display): ~23px base → large scores. */
font-size: 1.2vw;
}
body {
background-color: transparent;
color: #fff;
font-family: 'IBM Plex Mono', 'Courier New', monospace;
overflow: hidden;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
height: 100vh;
}
.container {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
position: relative;
}
.scores-container {
display: flex;
justify-content: space-around;
width: 100%;
max-width: 1400px;
margin-bottom: 50px;
}
.team-score {
text-align: center;
position: relative;
}
.score-number {
font-size: 15rem;
font-weight: bold;
line-height: 1;
}
.red-score {
color: #ff4444;
}
.blue-score {
color: #4444ff;
}
.red-score.highlight {
color: #ff6347;
}
.blue-score.highlight {
color: #6495ed;
}
.score-indicator {
width: 50px;
height: 50px;
border-radius: 50%;
position: absolute;
top: 50%;
transform: translateY(-50%);
opacity: 0;
transition: opacity 0.3s;
}
.score-indicator.show {
opacity: 1;
}
.red-indicator {
background-color: #ff6347;
right: -80px;
}
.blue-indicator {
background-color: #6495ed;
left: -80px;
}
.team-details {
font-size: 2rem;
margin-top: 20px;
}
.auto-score {
color: #888;
}
.penalty {
color: #fff;
margin-top: 10px;
}
.timer {
font-size: 5rem;
margin-bottom: 30px;
font-weight: bold;
}
.timer.endgame {
font-size: 20rem;
animation: pulse 1s infinite;
}
@keyframes pulse {
0%, 100% { opacity: 1; }
50% { opacity: 0.7; }
}
.phase-indicator {
font-size: 2.5rem;
margin-top: 20px;
}
.paused-indicator {
font-size: 2.5rem;
margin-top: 10px;
color: #ffff00;
}
.winner-banner {
font-size: 2.5rem;
margin-bottom: 30px;
font-weight: bold;
}
.winner-banner.red {
color: #ff4444;
}
.winner-banner.blue {
color: #4444ff;
}
.winner-banner.tie {
color: #fff;
}
.phase-blink {
font-size: 6rem;
font-weight: bold;
animation: blink 0.5s step-start infinite;
}
@keyframes blink {
0%, 50% { opacity: 1; }
51%, 100% { opacity: 0; }
}
.phase-blink.pickup {
animation: blink-alt 0.5s step-start infinite;
}
@keyframes blink-alt {
0%, 25% { opacity: 1; }
26%, 50% { opacity: 0; }
51%, 75% { opacity: 1; }
76%, 100% { opacity: 0; }
}
.error-message {
color: #ff0000;
font-size: 2rem;
text-align: center;
}
#connect-screen {
display: flex;
flex-direction: column;
align-items: center;
gap: 24px;
}
#connect-screen h1 {
font-size: 3rem;
letter-spacing: 0.05em;
}
#connect-screen label {
font-size: 1.5rem;
color: #aaa;
}
#ip-input {
font-family: inherit;
font-size: 2rem;
background: #111;
color: #fff;
border: 2px solid #444;
border-radius: 6px;
padding: 12px 24px;
text-align: center;
outline: none;
width: 360px;
}
#ip-input:focus {
border-color: #888;
}
#connect-btn {
font-family: inherit;
font-size: 1.5rem;
background: #222;
color: #fff;
border: 2px solid #555;
border-radius: 6px;
padding: 10px 40px;
cursor: pointer;
}
#connect-btn:hover {
background: #333;
border-color: #888;
}
#connect-error {
color: #ff4444;
font-size: 1.2rem;
min-height: 1.5em;
}
</style>
</head>
<body>
<div class="container" id="connect-screen">
<h1>Fenger Management System</h1>
<label for="ip-input">FMS Server IP Address</label>
<input id="ip-input" type="text" placeholder="192.168.1.100" autocomplete="off" spellcheck="false" />
<button id="connect-btn">Connect</button>
<div id="connect-error"></div>
</div>
<div class="container" id="display" style="display:none"></div>
<script>
let API_URL = '';
function updateDisplay(data) {
const container = document.getElementById('display');
container.innerHTML = buildScoresDisplay(data);
}
function buildScoresDisplay(data) {
const timeRemaining = data.matchRunning ? data.timeRemaining : 0;
const isEndgame = timeRemaining <= 10 && data.matchRunning && !data.auto;
const timerDisplay = isEndgame
? `<div class="timer endgame">${timeRemaining}</div>`
: `<div class="timer">${timeRemaining}</div>`;
const redHighlight = data.redBlink > 0 ? 'highlight' : '';
const blueHighlight = data.blueBlink > 0 ? 'highlight' : '';
const redIndicatorShow = data.redBlink > 0 ? 'show' : '';
const blueIndicatorShow = data.blueBlink > 0 ? 'show' : '';
return `
${timerDisplay}
<div class="scores-container">
<div class="team-score">
<div class="score-indicator blue-indicator ${blueIndicatorShow}"></div>
<div class="score-number blue-score ${blueHighlight}">${data.blueScore}</div>
</div>
<div class="team-score">
<div class="score-indicator red-indicator ${redIndicatorShow}"></div>
<div class="score-number red-score ${redHighlight}">${data.redScore}</div>
</div>
</div>
</div>
`;
}
async function fetchScores() {
try {
const response = await fetch(API_URL);
if (!response.ok) throw new Error('Server error');
const data = await response.json();
updateDisplay(data);
} catch (error) {
document.getElementById('display').innerHTML =
`<div class="error-message">Error connecting to server: ${error.message}<br>Make sure the Fenger Management System (FMS) is running.</div>`;
}
}
let pollInterval = null;
function startPolling(ip) {
API_URL = `http://${ip}:8080/scores`;
document.getElementById('connect-screen').style.display = 'none';
document.getElementById('display').style.display = 'flex';
pollInterval = setInterval(fetchScores, 100);
fetchScores();
}
// If loaded from the FMS server directly (e.g. OBS browser source),
// skip the IP prompt and use the URL's hostname.
if (window.location.hostname) {
startPolling(window.location.hostname);
}
async function connect() {
const ip = document.getElementById('ip-input').value.trim();
const errEl = document.getElementById('connect-error');
if (!ip) {
errEl.textContent = 'Please enter an IP address.';
return;
}
const testUrl = `http://${ip}:8080/scores`;
errEl.textContent = 'Connecting...';
try {
const response = await fetch(testUrl, { signal: AbortSignal.timeout(3000) });
if (!response.ok) throw new Error(`Server returned ${response.status}`);
await response.json();
} catch (e) {
errEl.textContent = `Could not connect to ${ip}:8080 — ${e.message}`;
return;
}
startPolling(ip);
}
document.getElementById('connect-btn').addEventListener('click', connect);
document.getElementById('ip-input').addEventListener('keydown', e => {
if (e.key === 'Enter') connect();
});
</script>
</body>
</html>