-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
279 lines (273 loc) · 7.96 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
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
<!DOCTYPE html>
<html lang="cs" theme="dark">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Czechitas přestávka</title>
<meta
name="description"
content="Nástroj pro vytváření přestávkových slidů."
/>
<link rel="manifest" href="app.webmanifest" />
<meta name="color-scheme" content="light dark" />
<meta
name="theme-color"
media="(prefers-color-scheme: light)"
content="#ffffff"
/>
<meta
name="theme-color"
media="(prefers-color-scheme: dark)"
content="#000000"
/>
<meta property="og:image:width" content="1200" />
<meta property="og:image:height" content="630" />
<meta
property="og:image"
content="https://prestavka.czechitas-podklady.cz/og-image.jpg"
/>
<link rel="shortcut icon" href="icon.png" />
<link
href="library/materialize-v2.0.3-alpha/materialize/css/materialize.min.css"
rel="stylesheet"
type="text/css"
/>
<script>
const media = window.matchMedia('(prefers-color-scheme: dark)')
const updateAttribute = () => {
document.documentElement.setAttribute(
'theme',
media.matches ? 'dark' : 'light',
)
}
updateAttribute()
media.addEventListener('change', updateAttribute)
</script>
<script src="library/materialize-v2.0.3-alpha/materialize/js/materialize.min.js"></script>
<link
href="https://fonts.googleapis.com/css2?family=Open+Sans&display=block&text=0123456789:"
rel="stylesheet"
/>
<link
href="https://fonts.googleapis.com/icon?family=Material+Icons"
rel="stylesheet"
/>
<style>
body {
padding-block: 5rem;
}
#settings_link-show[href=''],
#settings_link-control[href=''] {
visibility: hidden;
}
.logo {
max-width: 1em;
height: auto;
margin-bottom: -0.15em;
}
.configuator ~ .slide {
display: none;
}
.slide {
position: fixed;
inset: 0;
background-color: #000000;
display: grid;
align-items: center;
justify-items: center;
}
.slide_in {
position: relative;
aspect-ratio: 16 / 9;
width: min(100%, calc(16 / 9 * 100vh));
width: min(100%, calc(16 / 9 * 100svh));
}
.slide .background {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
border: none;
}
.slide .countdown {
visibility: hidden;
}
.slide .countdown_text {
position: absolute;
inset: 62% auto auto 0.3%;
width: 37.9%;
height: 29.9%;
color: #ffffff;
text-align: center;
font-feature-settings: 'tnum';
font-variant-numeric: tabular-nums;
font-family: 'Open Sans', sans-serif;
--base: 11.4;
font-size: 11.4vw; /* OBS fallback */
font-size: calc(1vw * var(--base));
}
@media (min-aspect-ratio: 16 / 9) {
.slide .countdown_text {
font-size: calc(1vh * var(--base) * 16 / 9);
}
}
</style>
</head>
<body>
<div class="container">
<div class="configuator">
<h1>
<img src="icon.png" alt="" width="512" height="512" class="logo" />
Czechitas přestávka
</h1>
<h5 class="mt-6 mb-5">Nastavte si vlastní přestávkový slide:</h5>
<form class="controls row" style="gap: 5px; align-items: center">
<div class="col s12">
<div class="input-field">
<input
id="identificator"
type="text"
autocomplete="off"
autofocus
name="id"
value="czechitas-javascript-1"
/>
<label for="identificator">Identifikátor</label>
</div>
</div>
<div class="col s12 center-align">
<div class="settings">
<a
href=""
class="waves-effect waves-light btn"
id="settings_link-show"
><i class="material-icons left">visibility</i> Zobrazit
odpočet</a
>
<a
href=""
class="waves-effect waves-light btn"
id="settings_link-control"
><i class="material-icons left">settings</i> Ovládat odpočet</a
>
</div>
</div>
</form>
<h5 class="mt-6 mb-5">Nebo použijte už předchystaný:</h5>
<div class="collection">
<a class="collection-item" href="?seconds=60">1 minuta</a>
<a class="collection-item" href="?seconds=120">2 minuty</a>
<a class="collection-item" href="?seconds=300">5 minut</a>
<a class="collection-item" href="?seconds=420">7 minut</a>
<a class="collection-item" href="?seconds=600">10 minut</a>
<a class="collection-item" href="?seconds=900">15 minut</a>
<a class="collection-item" href="?seconds=1200">20 minut</a>
<a class="collection-item" href="?seconds=1800">30 minut</a>
<a class="collection-item" href="?seconds=2700">45 minut</a>
<a class="collection-item" href="?seconds=3600">60 minut (1 hodina)</a
><a class="collection-item" href="?seconds=7200"
>120 minut (2 hodiny)</a
>
<div class="collection-item">
<form class="row" style="gap: 5px; align-items: center">
<div class="col s4">
<div class="input-field">
<input
id="seconds"
name="seconds"
type="number"
step="1"
min="1"
/>
<label for="seconds">Vlastní [s]</label>
</div>
</div>
<div class="col s8">
<button
type="submit"
class="waves-effect waves-light btn-large"
>
<i class="material-icons left">visibility</i> Spustit
</button>
</div>
</form>
</div>
</div>
</div>
<div class="slide">
<div class="slide_in">
<iframe
class="background"
src="https://intro.czechitas-podklady.cz/slide.html?title=P%C5%99est%C3%A1vka"
></iframe>
<iframe
class="countdown"
src="https://just-countdown.eu/screen?id=break"
allowtransparency
></iframe>
<div class="countdown_text"></div>
</div>
</div>
</div>
<script>
const urlIdentificator = (identificator) =>
`${encodeURIComponent(identificator)}`
const urlParameters = new URLSearchParams(window.location.search)
const identificator = urlParameters.get('id')
const seconds = (() => {
const number = parseInt(urlParameters.get('seconds') ?? '')
if (Number.isNaN(number) || number <= 0) {
return null
}
return number
})()
const configuator = document.querySelector('.configuator')
const showIframe = (path) => {
configuator.remove()
const countdown = document.querySelector('.countdown')
const countdownText = document.querySelector('.countdown_text')
const url = new URL(`https://just-countdown.eu${path}`)
countdown.src = url.toString()
window.addEventListener('message', (event) => {
if (
event.origin === url.origin &&
typeof event.data.formattedTime === 'string'
) {
const minutes = Math.floor(event.data.remainingTimeInSeconds / 60)
const seconds = event.data.remainingTimeInSeconds % 60
countdownText.textContent = `${minutes
.toString()
.padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`
}
})
}
if (identificator) {
showIframe(`/screen?id=${urlIdentificator(identificator)}`)
} else if (seconds) {
showIframe(`/run?seconds=${seconds}`)
} else {
const identificatorInput = document.querySelector('#identificator')
identificatorInput.value =
localStorage.getItem('identificator') ?? identificatorInput.value
const handleChange = () => {
const identificator = identificatorInput.value
const settingsLinkShow = document.querySelector('#settings_link-show')
const settingsLinkControl = document.querySelector(
'#settings_link-control',
)
localStorage.setItem('identificator', identificator)
settingsLinkShow.href = identificator
? `?id=${urlIdentificator(identificator)}`
: ''
settingsLinkControl.href = identificator
? `https://just-countdown.eu/control?id=${urlIdentificator(
identificator,
)}`
: ''
}
handleChange()
identificatorInput.addEventListener('input', handleChange)
}
</script>
</body>
</html>