-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.html
More file actions
342 lines (293 loc) · 9.44 KB
/
Copy pathindex.html
File metadata and controls
342 lines (293 loc) · 9.44 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Frogspawn Activities</title>
<style>
:root {
--bg: #f4f2ea;
--ink: #182025;
--muted: #44525d;
--card: #fffef8;
--accent: #005b68;
--accent-2: #9a3412;
--line: #d6d0bf;
}
* {
box-sizing: border-box;
}
body {
margin: 0;
font-family: "Avenir Next", "Gill Sans", "Segoe UI", sans-serif;
color: var(--ink);
background:
radial-gradient(circle at 15% 15%, #fff8dc 0%, transparent 30%),
radial-gradient(circle at 90% 80%, #dbeafe 0%, transparent 35%),
var(--bg);
min-height: 100vh;
}
.container {
width: min(1080px, 92vw);
margin: 0 auto;
padding: 2.5rem 0 3rem;
}
h1 {
margin: 0;
font-size: clamp(1.8rem, 3vw, 2.8rem);
letter-spacing: 0.02em;
}
.subtitle {
margin: 0.8rem 0 0;
color: var(--muted);
font-size: 1.05rem;
max-width: 72ch;
line-height: 1.5;
}
.grid {
margin-top: 2rem;
display: grid;
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
gap: 1rem;
}
.card {
background: var(--card);
border: 1px solid var(--line);
border-radius: 14px;
padding: 1rem;
box-shadow: 0 4px 12px rgba(24, 32, 37, 0.06);
display: flex;
flex-direction: column;
gap: 0.85rem;
}
.badge {
width: fit-content;
background: rgba(0, 91, 104, 0.1);
color: var(--accent);
border: 1px solid rgba(0, 91, 104, 0.25);
border-radius: 999px;
font-size: 0.78rem;
font-weight: 700;
letter-spacing: 0.03em;
padding: 0.3rem 0.55rem;
text-transform: uppercase;
}
.title {
margin: 0;
font-size: 1.2rem;
}
.desc {
margin: 0;
color: var(--muted);
line-height: 1.45;
min-height: 3.3em;
}
.meta {
margin: 0;
color: var(--muted);
font-size: 0.92rem;
}
.actions {
display: flex;
flex-wrap: wrap;
gap: 0.6rem;
margin-top: auto;
}
.btn {
display: inline-block;
text-decoration: none;
border-radius: 10px;
border: 1px solid var(--accent);
color: white;
background: var(--accent);
font-weight: 600;
padding: 0.58rem 0.85rem;
transition: transform 120ms ease, filter 120ms ease;
}
.btn:hover {
transform: translateY(-1px);
filter: brightness(1.03);
}
.btn-secondary {
background: white;
color: var(--accent-2);
border-color: var(--accent-2);
}
.status {
margin-top: 1rem;
font-size: 0.95rem;
color: var(--muted);
}
.error {
color: #8b1e3f;
}
.embedded-shell {
display: flex;
flex-direction: column;
min-height: calc(100vh - 5.5rem);
gap: 0.8rem;
}
.embedded-header {
display: flex;
align-items: center;
justify-content: space-between;
gap: 0.8rem;
flex-wrap: wrap;
}
.embedded-title {
margin: 0;
font-size: clamp(1.2rem, 2.3vw, 1.8rem);
}
.embedded-frame {
width: 100%;
flex: 1 1 auto;
min-height: 72vh;
border: 1px solid var(--line);
border-radius: 14px;
background: #ffffff;
}
</style>
</head>
<body>
<main class="container">
<h1>Frogspawn Activity Launcher</h1>
<p class="subtitle">
Choose an activity to launch the participant inbox or open the control panel.
Activities are loaded from <code>activities.json</code> and each card pulls details from its activity settings file.
</p>
<section id="activityGrid" class="grid" aria-live="polite"></section>
<p id="status" class="status">Loading activities...</p>
</main>
<script>
function toAbsolute(value) {
return new URL(value, window.location.href).toString();
}
function ensureTrailingSlash(value) {
return value.endsWith('/') ? value : `${value}/`;
}
function parseActivities(catalog) {
const items = catalog && catalog.activities;
if (!items) return [];
return Object.entries(items)
.map(([name, entry]) => ({
name,
baseUrl: entry && entry.url ? entry.url : ''
}))
.filter((entry) => !!entry.baseUrl);
}
async function fetchCatalog() {
const response = await fetch('activities.json', { cache: 'no-store' });
if (!response.ok) throw new Error(`Could not load activities catalog (${response.status})`);
return response.json();
}
async function fetchSettings(baseUrl) {
const settingsUrl = new URL('settings.json', ensureTrailingSlash(toAbsolute(baseUrl))).toString();
const response = await fetch(settingsUrl, { cache: 'no-store' });
if (!response.ok) throw new Error(`Could not load settings (${response.status})`);
return response.json();
}
function renderEmbeddedActivity(activity, mode = 'inbox') {
const resolvedBaseUrl = ensureTrailingSlash(toAbsolute(activity.baseUrl));
const normalizedMode = (mode || 'inbox').toLowerCase();
const page = normalizedMode === 'control' ? 'controls.html' : 'inbox.html';
const paramName = normalizedMode === 'control' ? 'activityBase' : 'url';
const targetHref = `${page}?${paramName}=${encodeURIComponent(resolvedBaseUrl)}`;
const frame = document.createElement('iframe');
frame.style.position = 'fixed';
frame.style.inset = '0';
frame.style.width = '100vw';
frame.style.height = '100vh';
frame.style.border = '0';
frame.src = targetHref;
frame.title = `${normalizedMode === 'control' ? 'Control Panel' : 'Inbox'} for ${activity.name}`;
document.body.innerHTML = '';
document.body.style.margin = '0';
document.body.style.padding = '0';
document.body.appendChild(frame);
}
function buildCard(activity, settings) {
const card = document.createElement('article');
card.className = 'card';
const resolvedBaseUrl = ensureTrailingSlash(toAbsolute(activity.baseUrl));
const badge = document.createElement('div');
badge.className = 'badge';
badge.textContent = activity.name;
const title = document.createElement('h2');
title.className = 'title';
title.textContent = settings.title || activity.name;
const desc = document.createElement('p');
desc.className = 'desc';
desc.textContent = settings.description || 'No description available.';
const meta = document.createElement('p');
meta.className = 'meta';
const location = settings.location ? `Location: ${settings.location}` : 'Location not specified';
const startDate = settings.date ? `Start date: ${settings.date}` : 'Start date not specified';
meta.textContent = `${location} | ${startDate}`;
const actions = document.createElement('div');
actions.className = 'actions';
const inboxHref = `inbox.html?url=${encodeURIComponent(resolvedBaseUrl)}`;
const controlPanelHref = `controls.html?activityBase=${encodeURIComponent(resolvedBaseUrl)}`;
const openBtn = document.createElement('a');
openBtn.className = 'btn';
openBtn.href = inboxHref;
openBtn.textContent = 'Open Inbox';
const controlBtn = document.createElement('a');
controlBtn.className = 'btn btn-secondary';
controlBtn.href = controlPanelHref;
controlBtn.textContent = 'Open Control Panel';
actions.appendChild(openBtn);
actions.appendChild(controlBtn);
card.appendChild(badge);
card.appendChild(title);
card.appendChild(desc);
card.appendChild(meta);
card.appendChild(actions);
return card;
}
async function init() {
const grid = document.getElementById('activityGrid');
const status = document.getElementById('status');
const params = new URLSearchParams(window.location.search);
const requestedActivity = params.get('activity');
const requestedMode = (params.get('mode') || 'inbox').toLowerCase();
try {
const catalog = await fetchCatalog();
const activities = parseActivities(catalog);
if (activities.length === 0) {
status.textContent = 'No activities were found in activities.json.';
status.classList.add('error');
return;
}
if (requestedActivity) {
const selected = activities.find((activity) => activity.name === requestedActivity);
if (selected) {
renderEmbeddedActivity(selected, requestedMode);
return;
}
}
const cards = await Promise.all(
activities.map(async (activity) => {
try {
const settings = await fetchSettings(activity.baseUrl);
return buildCard(activity, settings);
} catch (err) {
return buildCard(activity, {
title: activity.name,
description: `Unable to load activity settings from ${activity.baseUrl}.`,
location: '',
date: ''
});
}
})
);
cards.forEach((card) => grid.appendChild(card));
status.textContent = `Loaded ${cards.length} activities.`;
} catch (err) {
status.textContent = err.message;
status.classList.add('error');
}
}
init();
</script>
</body>
</html>