-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathkiosk_iframe.html
More file actions
298 lines (268 loc) · 9.18 KB
/
kiosk_iframe.html
File metadata and controls
298 lines (268 loc) · 9.18 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
<!DOCTYPE html>
<html>
<head>
<title>CECS Channel</title>
<style type="text/css">
html {
overflow: hidden;
background: #1C1C1C;
color: white;
font-family: "Roboto", sans-serif;
cursor: cell!important;
--timeout: 60s;
}
* {
margin: 0;
box-sizing: border-box;
border: none;
}
.poster {
position: fixed;
width: 100%;
height: calc(100vh);
z-index: 99999;
background: black;
}
.else {
display: none;
}
.center {
width: 100%;
margin: 10px auto;
text-align: center;
position: relative;
}
.center > div {
position: absolute;
top: 0;
left: 0;
right: 0;
}
#logo {
animation-name: el1_transition;
animation-duration: var(--timeout);
animation-iteration-count: infinite;
}
marquee, p {
margin: 15px 0;
font-size: 32px;
position: absolute;
right: 0;
}
p {
text-align: center;
margin: auto;
}
#time {
font-size: 42px;
margin-top: 5px;
color: black;
font-weight: bolder;
}
.time {
position: absolute;
padding: 25px;
background: #D2990B;
height: 100px;
margin: 0;
top: 0;
left: 0;
z-index: 9999999;
}
span {
color: #d2990b;
}
space {
margin: 0 20px;
color: #d2990b;
font-weight: bold;
}
space:after {
content: "🛡";
}
@keyframes el1_transition {
0% {opacity: 0;}
5% {opacity: 0;}
45% {opacity: 0;}
50% {opacity: 1;}
95% {opacity: 1;}
100% {opacity: 0;}
}
@keyframes el2_transition {
0% {opacity: 1;}
5% {opacity: 1;}
45% {opacity: 1;}
50% {opacity: 0;}
95% {opacity: 0;}
100% {opacity: 1;}
}
.poster > .img {
margin: auto;
width: calc(100%);
height: calc(100%);
position: absolute;
display: inline-block;
top: calc(50%);
transform: translateY(-50%);
background-repeat: no-repeat;
background-size: contain;
background-position: center;
}
#primary {
animation-name: el1_transition;
animation-duration: var(--timeout);
animation-iteration-count: infinite;
animation-play-state: paused;
}
#secondary {
animation-name: el2_transition;
animation-duration: var(--timeout);
animation-iteration-count: infinite;
animation-play-state: paused;
}
</style>
</head>
<body>
<!-- Kiosk -->
<div class="poster" id="primary">
<div class="img" style="background-image: url(/HackUCF_Full.svg)"></div>
</div>
<div class="poster" id="secondary">
<div class="img" style="background-image: url(/HackUCF_Full.svg)"></div>
</div>
<div class="else">
<div class="time">
<span id="time"></span>
</div>
<div onclick="refreshMarquee()" id="marquee">
</div>
</div>
<script type="text/javascript">
// CORS support is provided complimentary by SenkoAPI.
const CORS_PREFIX = "https://api.awoo.dev/cors/get?url=";
// Sync slideshow (animations + refreshes) with system clock.
function getTime() {
let date = new Date(Date.now());
let second = date.getSeconds();
if (second == 0) {
// Animation syncing
document.querySelector("#primary").style.animationPlayState = "running";
document.querySelector("#secondary").style.animationPlayState = "running";
// Image update syncing (when no transitions are happening)
setTimeout(_ => {
setInterval(_ => {
// Update marquee
refreshMarquee();
refreshKiosk();
}, 30000);
}, 15000);
// Stop sync routine
console.log("Timings synced.")
clearInterval(timeSync);
}
}
let timeSync = setInterval(function(){
getTime();
}, 10);
// Imports a Newton-compatible kiosk manifest.
async function getManifest(url) {
const manifest = await fetch((CORS_PREFIX + url + "/index.txt"));
const text = await manifest.text();
const lines = text.split("\n");
let images = []
// Collate images.
for (let line in lines) {
line = lines[line]; // idx -> element
// SPEC VIOLATION: md5 checksum checks are not done.
const image_path = line.split(" ");
if (image_path.length == 1) {
continue;
}
// Appends image file to list.
images.push((url + "/" + image_path[1]));
}
return images;
}
// Gets kiosk image list.
async function getKioskImages() {
// Earlier kiosks take precident.
const kiosks = [
"https://cdn.hackucf.org/kiosk",
"http://newton.i2lab.ucf.edu/kiosk"
]
let images = []
// Import data
for (let kiosk in kiosks) {
kiosk = kiosks[kiosk]; // idx -> element
const kiosk_response = await getManifest(kiosk);
images = images.concat(kiosk_response);
}
// Allow overrides
let cache = [];
let images_dedupe = [];
for (let image in images) {
image = images[image]; // idx -> element
let split = image.split("/");
let filename = split[split.length-1];
if (!cache.includes(filename)) {
images_dedupe.push(image);
cache.push(filename);
}
}
return images_dedupe;
}
// Refreshes kiosk.
async function refreshKiosk() {
const images = await getKioskImages();
let secondOffset = (new Date(Date.now()).getSeconds()) < 30 ? 0 : 1;
let hash = ((new Date(Date.now()).getMinutes() * 2) + secondOffset) % images.length;
let new_image = images[hash % images.length];
let prefix = new_image.indexOf("http://") !== -1 ? CORS_PREFIX : "";
if (secondOffset == 0) { // secondary on screen
console.log(`[^ secondary] ${hash}: Primary to ${hash}`);
document.querySelector("#primary > div").style.backgroundImage = `url(${prefix + new_image})`;
} else { // primary on screen
console.log(`[v primary] ${hash}: Secondary to ${hash}`);
document.querySelector("#secondary > div").style.backgroundImage = `url(${prefix + new_image})`;
}
}
// Refreshes marquee.
function refreshMarquee() {
fetch("https://cdn.hackucf.org/messages.txt")
.then(data => {
return data.text();
})
.then(text => {
const messages = text.split("\n");
let output = `<p>Welcome to the <span>LMCO CyberLab!</span></p>`
if (messages.length > 1) {
// Marquee constructor
output = `<marquee behavior="scroll">`
let spacer = `<space></space>`
for (let i = 0; i < messages.length; i++) {
if (messages[i].replaceAll(" ", "") != "")
output += messages[i] + spacer;
}
// Clear last spacer
output = output.substring(0, output.length - spacer.length);
output += `</marquee>`
} else if (messages.length == 1) {
// Static text constructor
output = `<p>${messages[0]}</p>`;
}
if (document.getElementById("marquee").innerHTML != output)
// intentional xss.
document.getElementById("marquee").innerHTML = output;
})
}
// As frequent as possible
setInterval(_=> {
now = new Date(Date.now());
document.getElementById("time").innerText = now.toLocaleString("en-us", {"dateStyle": undefined, "timeStyle": "medium", "calendar": "iso8601"});
}, 250)
// init marquee
refreshMarquee();
refreshKiosk();
</script>
</body>
</html>