upda
timfa Tim Falken · pushed by timfa
Authored 2026-05-06 · 6 months ago
- Hash
fffc2d3bf0bc5f1bf46d32734a3e68db5aec4826- Parent
d0af36bc
1 file changed
+227
−181
@@ -1,11 +1,18 @@
1
1
<!DOCTYPE html>
2
2
<html lang="nl">
3
3
4
<head>
4
5
<meta charset="UTF-8" />
5
6
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
7
<title>Gedeeld bestand</title>
7
8
<style>
8
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
9
*,
10
*::before,
11
*::after {
12
box-sizing: border-box;
13
margin: 0;
14
padding: 0;
15
}
9
16
10
17
:root {
11
18
--bg: #0f1117;
@@ -21,8 +28,17 @@
21
28
--radius: 10px;
22
29
}
23
30
24
html, body { height: 100%; font-family: system-ui, -apple-system, sans-serif; }
25
body { background: var(--bg); color: var(--text); min-height: 100vh; }
31
html,
32
body {
33
height: 100%;
34
font-family: system-ui, -apple-system, sans-serif;
35
}
36
37
body {
38
background: var(--bg);
39
color: var(--text);
40
min-height: 100vh;
41
}
26
42
27
43
/* ── Timer bar ── */
28
44
#timer-bar {
@@ -39,14 +55,21 @@
39
55
font-size: 0.9rem;
40
56
color: var(--text-muted);
41
57
}
58
42
59
#timer-bar .timer-clock {
43
60
font-variant-numeric: tabular-nums;
44
61
font-weight: 600;
45
62
color: var(--text);
46
63
letter-spacing: 0.05em;
47
64
}
48
#timer-bar.expired { color: var(--danger); }
49
#timer-bar.expired .timer-clock { color: var(--danger); }
65
66
#timer-bar.expired {
67
color: var(--danger);
68
}
69
70
#timer-bar.expired .timer-clock {
71
color: var(--danger);
72
}
50
73
51
74
/* ── Main card ── */
52
75
#main {
@@ -69,6 +92,7 @@
69
92
margin-bottom: 0.3rem;
70
93
word-break: break-all;
71
94
}
95
72
96
.card .meta {
73
97
font-size: 0.85rem;
74
98
color: var(--text-muted);
@@ -88,12 +112,20 @@
88
112
border: none;
89
113
transition: background 0.15s;
90
114
}
115
91
116
.btn-primary {
92
117
background: var(--accent);
93
118
color: #fff;
94
119
}
95
.btn-primary:hover { background: var(--accent-hover); }
96
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; }
120
121
.btn-primary:hover {
122
background: var(--accent-hover);
123
}
124
125
.btn-primary:disabled {
126
opacity: 0.45;
127
cursor: not-allowed;
128
}
97
129
98
130
/* ── Preview area ── */
99
131
#preview-wrap {
@@ -115,7 +147,11 @@
115
147
max-height: 60vh;
116
148
display: block;
117
149
}
118
#preview-wrap audio { padding: 1rem; width: 100%; }
150
151
#preview-wrap audio {
152
padding: 1rem;
153
width: 100%;
154
}
119
155
120
156
#preview-wrap pre {
121
157
padding: 1.2rem;
@@ -141,8 +177,15 @@
141
177
text-align: center;
142
178
padding: 4rem 1rem;
143
179
}
144
#error-state h2 { font-size: 1.4rem; margin-bottom: 0.5rem; }
145
#error-state p { color: var(--text-muted); }
180
181
#error-state h2 {
182
font-size: 1.4rem;
183
margin-bottom: 0.5rem;
184
}
185
186
#error-state p {
187
color: var(--text-muted);
188
}
146
189
147
190
/* ── Loading spinner ── */
148
191
#loading {
@@ -152,202 +195,205 @@
152
195
}
153
196
</style>
154
197
</head>
155
<body>
156
198
157
<div id="timer-bar" style="display:none">
158
<span>Geldig nog</span>
159
<span id="timer-clock" class="timer-clock">--:--:--</span>
160
</div>
199
<body>
161
200
162
<div id="main">
163
<div id="loading">Laden…</div>
164
<div id="error-state" style="display:none">
165
<h2 id="error-title">Niet gevonden</h2>
166
<p id="error-msg">De link bestaat niet of is verlopen.</p>
201
<div id="timer-bar" style="display:none">
202
<span>Geldig voor</span>
203
<span id="timer-clock" class="timer-clock">--:--:--</span>
167
204
</div>
168
205
169
<div id="content" style="display:none">
170
<div class="card">
171
<h1 id="file-name"></h1>
172
<p id="file-meta" class="meta"></p>
173
<a id="btn-download" class="btn btn-primary" href="#" download>
174
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none"
175
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
176
<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" />
177
<polyline points="7 10 12 15 17 10" />
178
<line x1="12" y1="15" x2="12" y2="3" />
179
</svg>
180
<span id="btn-download-label">Downloaden</span>
181
</a>
206
<div id="main">
207
<div id="loading">Laden…</div>
208
<div id="error-state" style="display:none">
209
<h2 id="error-title">Niet gevonden</h2>
210
<p id="error-msg">De link bestaat niet of is verlopen.</p>
182
211
</div>
183
212
184
<div id="preview-wrap" style="display:none"></div>
213
<div id="content" style="display:none">
214
<div class="card">
215
<h1 id="file-name"></h1>
216
<p id="file-meta" class="meta"></p>
217
<a id="btn-download" class="btn btn-primary" href="#" download>
218
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none"
219
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
220
<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" />
221
<polyline points="7 10 12 15 17 10" />
222
<line x1="12" y1="15" x2="12" y2="3" />
223
</svg>
224
<span id="btn-download-label">Downloaden</span>
225
</a>
226
</div>
227
228
<div id="preview-wrap" style="display:none"></div>
229
</div>
185
230
</div>
186
</div>
187
188
<script>
189
(function () {
190
'use strict';
191
231
192
const token = location.pathname.split('/').pop();
193
let expiresAt = null;
194
let timerInterval = null;
232
<script>
233
(function ()
234
{
235
'use strict';
195
236
196
// ── Timer ───────────────────────────────────────────────────────────────
197
function startTimer ()
198
{
199
const bar = document.getElementById('timer-bar');
200
const clock = document.getElementById('timer-clock');
201
bar.style.display = '';
237
const token = location.pathname.split('/').pop();
238
let expiresAt = null;
239
let timerInterval = null;
202
240
203
function tick ()
204
{
205
const remaining = expiresAt - Date.now();
206
if (remaining <= 0)
241
// ── Timer ───────────────────────────────────────────────────────────────
242
function startTimer ()
207
243
{
208
clock.textContent = '00:00:00';
209
bar.classList.add('expired');
210
bar.querySelector('span').textContent = 'Verlopen —';
211
const dlBtn = document.getElementById('btn-download');
212
if (dlBtn) dlBtn.setAttribute('disabled', 'disabled');
213
clearInterval(timerInterval);
214
return;
215
}
216
const totalSecs = Math.floor(remaining / 1000);
217
const hh = String(Math.floor(totalSecs / 3600)).padStart(2, '0');
218
const mm = String(Math.floor((totalSecs % 3600) / 60)).padStart(2, '0');
219
const ss = String(totalSecs % 60).padStart(2, '0');
220
clock.textContent = `${hh}:${mm}:${ss}`;
221
}
244
const bar = document.getElementById('timer-bar');
245
const clock = document.getElementById('timer-clock');
246
bar.style.display = '';
222
247
223
tick();
224
timerInterval = setInterval(tick, 1000);
225
}
248
function tick ()
249
{
250
const remaining = expiresAt - Date.now();
251
if (remaining <= 0)
252
{
253
clock.textContent = '00:00:00';
254
bar.classList.add('expired');
255
bar.querySelector('span').textContent = 'Verlopen —';
256
const dlBtn = document.getElementById('btn-download');
257
if (dlBtn) dlBtn.setAttribute('disabled', 'disabled');
258
clearInterval(timerInterval);
259
return;
260
}
261
const totalSecs = Math.floor(remaining / 1000);
262
const hh = String(Math.floor(totalSecs / 3600)).padStart(2, '0');
263
const mm = String(Math.floor((totalSecs % 3600) / 60)).padStart(2, '0');
264
const ss = String(totalSecs % 60).padStart(2, '0');
265
clock.textContent = `${hh}:${mm}:${ss}`;
266
}
267
268
tick();
269
timerInterval = setInterval(tick, 1000);
270
}
226
271
227
// ── Preview ──────────────────────────────────────────────────────────────
228
function tryPreview (name, isDir)
229
{
230
if (isDir) return; // no preview for folders
272
// ── Preview ──────────────────────────────────────────────────────────────
273
function tryPreview (name, isDir)
274
{
275
if (isDir) return; // no preview for folders
231
276
232
const wrap = document.getElementById('preview-wrap');
233
const ext = name.split('.').pop().toLowerCase();
277
const wrap = document.getElementById('preview-wrap');
278
const ext = name.split('.').pop().toLowerCase();
234
279
235
const imageExts = ['jpg','jpeg','png','gif','webp','svg','bmp','avif','ico'];
236
const videoExts = ['mp4','webm','ogg','mov'];
237
const audioExts = ['mp3','wav','ogg','flac','aac','opus','m4a'];
238
const textExts = ['txt','md','json','js','ts','html','css','xml','csv','yaml','yml','sh','log','ini','toml','py','rb','go','java','c','cpp','h','rs'];
280
const imageExts = ['jpg', 'jpeg', 'png', 'gif', 'webp', 'svg', 'bmp', 'avif', 'ico'];
281
const videoExts = ['mp4', 'webm', 'ogg', 'mov'];
282
const audioExts = ['mp3', 'wav', 'ogg', 'flac', 'aac', 'opus', 'm4a'];
283
const textExts = ['txt', 'md', 'json', 'js', 'ts', 'html', 'css', 'xml', 'csv', 'yaml', 'yml', 'sh', 'log', 'ini', 'toml', 'py', 'rb', 'go', 'java', 'c', 'cpp', 'h', 'rs'];
239
284
240
const previewUrl = `/api/share/preview/${token}`;
241
let el;
285
const previewUrl = `/api/share/preview/${token}`;
286
let el;
242
287
243
if (imageExts.includes(ext))
244
{
245
el = document.createElement('img');
246
el.src = previewUrl;
247
el.alt = name;
248
} else if (videoExts.includes(ext))
249
{
250
el = document.createElement('video');
251
el.src = previewUrl;
252
el.controls = true;
253
} else if (audioExts.includes(ext))
254
{
255
el = document.createElement('audio');
256
el.src = previewUrl;
257
el.controls = true;
258
} else if (textExts.includes(ext))
259
{
260
fetch(previewUrl)
261
.then(r =>
288
if (imageExts.includes(ext))
262
289
{
263
if (!r.ok) throw new Error('preview failed');
264
return r.text();
265
})
266
.then(text =>
290
el = document.createElement('img');
291
el.src = previewUrl;
292
el.alt = name;
293
} else if (videoExts.includes(ext))
267
294
{
268
const pre = document.createElement('pre');
269
pre.textContent = text;
270
wrap.innerHTML = '';
271
wrap.appendChild(pre);
272
wrap.style.display = '';
273
})
274
.catch(() => { /* no preview available */ });
275
return;
276
} else
277
{
278
return; // no preview
279
}
280
281
el.addEventListener('error', () => { wrap.innerHTML = '<div class="no-preview">Geen voorbeeldweergave beschikbaar.</div>'; wrap.style.display = ''; });
282
wrap.innerHTML = '';
283
wrap.appendChild(el);
284
wrap.style.display = '';
285
}
286
287
// ── Boot ─────────────────────────────────────────────────────────────────
288
function showError (title, msg)
289
{
290
document.getElementById('loading').style.display = 'none';
291
document.getElementById('content').style.display = 'none';
292
document.getElementById('error-title').textContent = title;
293
document.getElementById('error-msg').textContent = msg;
294
document.getElementById('error-state').style.display = '';
295
}
296
297
function formatBytes (bytes)
298
{
299
if (bytes == null) return '';
300
if (bytes < 1024) return bytes + ' B';
301
if (bytes < 1024 * 1024) return (bytes / 1024).toFixed(1) + ' KB';
302
if (bytes < 1024 * 1024 * 1024) return (bytes / (1024 * 1024)).toFixed(1) + ' MB';
303
return (bytes / (1024 * 1024 * 1024)).toFixed(2) + ' GB';
304
}
305
306
fetch(`/api/share/info/${token}`)
307
.then(r => r.json().then(d => ({ ok: r.ok, status: r.status, data: d })))
308
.then(({ ok, status, data }) =>
309
{
310
document.getElementById('loading').style.display = 'none';
295
el = document.createElement('video');
296
el.src = previewUrl;
297
el.controls = true;
298
} else if (audioExts.includes(ext))
299
{
300
el = document.createElement('audio');
301
el.src = previewUrl;
302
el.controls = true;
303
} else if (textExts.includes(ext))
304
{
305
fetch(previewUrl)
306
.then(r =>
307
{
308
if (!r.ok) throw new Error('preview failed');
309
return r.text();
310
})
311
.then(text =>
312
{
313
const pre = document.createElement('pre');
314
pre.textContent = text;
315
wrap.innerHTML = '';
316
wrap.appendChild(pre);
317
wrap.style.display = '';
318
})
319
.catch(() => { /* no preview available */ });
320
return;
321
} else
322
{
323
return; // no preview
324
}
311
325
312
if (status === 410)
313
{
314
showError('Link verlopen', 'Deze deellink is niet meer geldig.');
315
return;
326
el.addEventListener('error', () => { wrap.innerHTML = '<div class="no-preview">Geen voorbeeldweergave beschikbaar.</div>'; wrap.style.display = ''; });
327
wrap.innerHTML = '';
328
wrap.appendChild(el);
329
wrap.style.display = '';
316
330
}
317
if (!ok)
331
332
// ── Boot ─────────────────────────────────────────────────────────────────
333
function showError (title, msg)
318
334
{
319
showError('Niet gevonden', data.error || 'De link bestaat niet.');
320
return;
335
document.getElementById('loading').style.display = 'none';
336
document.getElementById('content').style.display = 'none';
337
document.getElementById('error-title').textContent = title;
338
document.getElementById('error-msg').textContent = msg;
339
document.getElementById('error-state').style.display = '';
321
340
}
322
341
323
expiresAt = data.expiresAt;
324
startTimer();
325
326
document.getElementById('file-name').textContent = data.name;
327
const metaLine = data.isDir ? 'Map (download als .zip)' : 'Bestand';
328
document.getElementById('file-meta').textContent = metaLine;
329
330
const dlBtn = document.getElementById('btn-download');
331
dlBtn.href = `/api/share/download/${token}`;
332
if (data.isDir)
342
function formatBytes (bytes)
333
343
{
334
document.getElementById('btn-download-label').textContent = 'Downloaden als .zip';
335
dlBtn.download = data.name + '.zip';
336
} else
337
{
338
document.getElementById('btn-download-label').textContent = 'Downloaden';
339
dlBtn.download = data.name;
344
if (bytes == null) return '';
345
if (bytes < 1024) return bytes + ' B';
346
if (bytes < 1024 * 1024) return (bytes / 1024).toFixed(1) + ' KB';
347
if (bytes < 1024 * 1024 * 1024) return (bytes / (1024 * 1024)).toFixed(1) + ' MB';
348
return (bytes / (1024 * 1024 * 1024)).toFixed(2) + ' GB';
340
349
}
341
350
342
document.getElementById('content').style.display = '';
343
344
tryPreview(data.name, data.isDir);
345
})
346
.catch(() =>
347
{
348
showError('Fout', 'Kon de server niet bereiken.');
349
});
350
}());
351
</script>
351
fetch(`/api/share/info/${token}`)
352
.then(r => r.json().then(d => ({ ok: r.ok, status: r.status, data: d })))
353
.then(({ ok, status, data }) =>
354
{
355
document.getElementById('loading').style.display = 'none';
356
357
if (status === 410)
358
{
359
showError('Link verlopen', 'Deze deellink is niet meer geldig.');
360
return;
361
}
362
if (!ok)
363
{
364
showError('Niet gevonden', data.error || 'De link bestaat niet.');
365
return;
366
}
367
368
expiresAt = data.expiresAt;
369
startTimer();
370
371
document.getElementById('file-name').textContent = data.name;
372
const metaLine = data.isDir ? 'Map (download als .zip)' : 'Bestand';
373
document.getElementById('file-meta').textContent = metaLine;
374
375
const dlBtn = document.getElementById('btn-download');
376
dlBtn.href = `/api/share/download/${token}`;
377
if (data.isDir)
378
{
379
document.getElementById('btn-download-label').textContent = 'Downloaden als .zip';
380
dlBtn.download = data.name + '.zip';
381
} else
382
{
383
document.getElementById('btn-download-label').textContent = 'Downloaden';
384
dlBtn.download = data.name;
385
}
386
387
document.getElementById('content').style.display = '';
388
389
tryPreview(data.name, data.isDir);
390
})
391
.catch(() =>
392
{
393
showError('Fout', 'Kon de server niet bereiken.');
394
});
395
}());
396
</script>
352
397
</body>
353
</html>
398
399
</html>
@@ -1,11 +1,18 @@1
<!DOCTYPE html>1
<!DOCTYPE html>2
<html lang="nl">2
<html lang="nl">3
3
<head>4
<head>4
<meta charset="UTF-8" />5
<meta charset="UTF-8" />5
<meta name="viewport" content="width=device-width, initial-scale=1.0" />6
<meta name="viewport" content="width=device-width, initial-scale=1.0" />6
<title>Gedeeld bestand</title>7
<title>Gedeeld bestand</title>7
<style>8
<style>8
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }9
*,10
*::before,11
*::after {12
box-sizing: border-box;13
margin: 0;14
padding: 0;15
}9
16
10
:root {17
:root {11
--bg: #0f1117;18
--bg: #0f1117;@@ -21,8 +28,17 @@21
--radius: 10px;28
--radius: 10px;22
}29
}23
30
24
html, body { height: 100%; font-family: system-ui, -apple-system, sans-serif; }31
html,25
body { background: var(--bg); color: var(--text); min-height: 100vh; }32
body {33
height: 100%;34
font-family: system-ui, -apple-system, sans-serif;35
}36
37
body {38
background: var(--bg);39
color: var(--text);40
min-height: 100vh;41
}26
42
27
/* ── Timer bar ── */43
/* ── Timer bar ── */28
#timer-bar {44
#timer-bar {@@ -39,14 +55,21 @@39
font-size: 0.9rem;55
font-size: 0.9rem;40
color: var(--text-muted);56
color: var(--text-muted);41
}57
}58
42
#timer-bar .timer-clock {59
#timer-bar .timer-clock {43
font-variant-numeric: tabular-nums;60
font-variant-numeric: tabular-nums;44
font-weight: 600;61
font-weight: 600;45
color: var(--text);62
color: var(--text);46
letter-spacing: 0.05em;63
letter-spacing: 0.05em;47
}64
}48
#timer-bar.expired { color: var(--danger); }65
49
#timer-bar.expired .timer-clock { color: var(--danger); }66
#timer-bar.expired {67
color: var(--danger);68
}69
70
#timer-bar.expired .timer-clock {71
color: var(--danger);72
}50
73
51
/* ── Main card ── */74
/* ── Main card ── */52
#main {75
#main {@@ -69,6 +92,7 @@69
margin-bottom: 0.3rem;92
margin-bottom: 0.3rem;70
word-break: break-all;93
word-break: break-all;71
}94
}95
72
.card .meta {96
.card .meta {73
font-size: 0.85rem;97
font-size: 0.85rem;74
color: var(--text-muted);98
color: var(--text-muted);@@ -88,12 +112,20 @@88
border: none;112
border: none;89
transition: background 0.15s;113
transition: background 0.15s;90
}114
}115
91
.btn-primary {116
.btn-primary {92
background: var(--accent);117
background: var(--accent);93
color: #fff;118
color: #fff;94
}119
}95
.btn-primary:hover { background: var(--accent-hover); }120
96
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; }121
.btn-primary:hover {122
background: var(--accent-hover);123
}124
125
.btn-primary:disabled {126
opacity: 0.45;127
cursor: not-allowed;128
}97
129
98
/* ── Preview area ── */130
/* ── Preview area ── */99
#preview-wrap {131
#preview-wrap {@@ -115,7 +147,11 @@115
max-height: 60vh;147
max-height: 60vh;116
display: block;148
display: block;117
}149
}118
#preview-wrap audio { padding: 1rem; width: 100%; }150
151
#preview-wrap audio {152
padding: 1rem;153
width: 100%;154
}119
155
120
#preview-wrap pre {156
#preview-wrap pre {121
padding: 1.2rem;157
padding: 1.2rem;@@ -141,8 +177,15 @@141
text-align: center;177
text-align: center;142
padding: 4rem 1rem;178
padding: 4rem 1rem;143
}179
}144
#error-state h2 { font-size: 1.4rem; margin-bottom: 0.5rem; }180
145
#error-state p { color: var(--text-muted); }181
#error-state h2 {182
font-size: 1.4rem;183
margin-bottom: 0.5rem;184
}185
186
#error-state p {187
color: var(--text-muted);188
}146
189
147
/* ── Loading spinner ── */190
/* ── Loading spinner ── */148
#loading {191
#loading {@@ -152,202 +195,205 @@152
}195
}153
</style>196
</style>154
</head>197
</head>155
<body>156
198
157
<div id="timer-bar" style="display:none">199
<body>158
<span>Geldig nog</span>159
<span id="timer-clock" class="timer-clock">--:--:--</span>160
</div>161
200
162
<div id="main">201
<div id="timer-bar" style="display:none">163
<div id="loading">Laden…</div>202
<span>Geldig voor</span>164
<div id="error-state" style="display:none">203
<span id="timer-clock" class="timer-clock">--:--:--</span>165
<h2 id="error-title">Niet gevonden</h2>166
<p id="error-msg">De link bestaat niet of is verlopen.</p>167
</div>204
</div>168
205
169
<div id="content" style="display:none">206
<div id="main">170
<div class="card">207
<div id="loading">Laden…</div>171
<h1 id="file-name"></h1>208
<div id="error-state" style="display:none">172
<p id="file-meta" class="meta"></p>209
<h2 id="error-title">Niet gevonden</h2>173
<a id="btn-download" class="btn btn-primary" href="#" download>210
<p id="error-msg">De link bestaat niet of is verlopen.</p>174
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none"175
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">176
<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" />177
<polyline points="7 10 12 15 17 10" />178
<line x1="12" y1="15" x2="12" y2="3" />179
</svg>180
<span id="btn-download-label">Downloaden</span>181
</a>182
</div>211
</div>183
212
184
<div id="preview-wrap" style="display:none"></div>213
<div id="content" style="display:none">214
<div class="card">215
<h1 id="file-name"></h1>216
<p id="file-meta" class="meta"></p>217
<a id="btn-download" class="btn btn-primary" href="#" download>218
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none"219
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">220
<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" />221
<polyline points="7 10 12 15 17 10" />222
<line x1="12" y1="15" x2="12" y2="3" />223
</svg>224
<span id="btn-download-label">Downloaden</span>225
</a>226
</div>227
228
<div id="preview-wrap" style="display:none"></div>229
</div>185
</div>230
</div>186
</div>187
188
<script>189
(function () {190
'use strict';191
231
192
const token = location.pathname.split('/').pop();232
<script>193
let expiresAt = null;233
(function ()194
let timerInterval = null;234
{235
'use strict';195
236
196
// ── Timer ───────────────────────────────────────────────────────────────237
const token = location.pathname.split('/').pop();197
function startTimer ()238
let expiresAt = null;198
{239
let timerInterval = null;199
const bar = document.getElementById('timer-bar');200
const clock = document.getElementById('timer-clock');201
bar.style.display = '';202
240
203
function tick ()241
// ── Timer ───────────────────────────────────────────────────────────────204
{242
function startTimer ()205
const remaining = expiresAt - Date.now();206
if (remaining <= 0)207
{243
{208
clock.textContent = '00:00:00';244
const bar = document.getElementById('timer-bar');209
bar.classList.add('expired');245
const clock = document.getElementById('timer-clock');210
bar.querySelector('span').textContent = 'Verlopen —';246
bar.style.display = '';211
const dlBtn = document.getElementById('btn-download');212
if (dlBtn) dlBtn.setAttribute('disabled', 'disabled');213
clearInterval(timerInterval);214
return;215
}216
const totalSecs = Math.floor(remaining / 1000);217
const hh = String(Math.floor(totalSecs / 3600)).padStart(2, '0');218
const mm = String(Math.floor((totalSecs % 3600) / 60)).padStart(2, '0');219
const ss = String(totalSecs % 60).padStart(2, '0');220
clock.textContent = `${hh}:${mm}:${ss}`;221
}222
247
223
tick();248
function tick ()224
timerInterval = setInterval(tick, 1000);249
{225
}250
const remaining = expiresAt - Date.now();251
if (remaining <= 0)252
{253
clock.textContent = '00:00:00';254
bar.classList.add('expired');255
bar.querySelector('span').textContent = 'Verlopen —';256
const dlBtn = document.getElementById('btn-download');257
if (dlBtn) dlBtn.setAttribute('disabled', 'disabled');258
clearInterval(timerInterval);259
return;260
}261
const totalSecs = Math.floor(remaining / 1000);262
const hh = String(Math.floor(totalSecs / 3600)).padStart(2, '0');263
const mm = String(Math.floor((totalSecs % 3600) / 60)).padStart(2, '0');264
const ss = String(totalSecs % 60).padStart(2, '0');265
clock.textContent = `${hh}:${mm}:${ss}`;266
}267
268
tick();269
timerInterval = setInterval(tick, 1000);270
}226
271
227
// ── Preview ──────────────────────────────────────────────────────────────272
// ── Preview ──────────────────────────────────────────────────────────────228
function tryPreview (name, isDir)273
function tryPreview (name, isDir)229
{274
{230
if (isDir) return; // no preview for folders275
if (isDir) return; // no preview for folders231
276
232
const wrap = document.getElementById('preview-wrap');277
const wrap = document.getElementById('preview-wrap');233
const ext = name.split('.').pop().toLowerCase();278
const ext = name.split('.').pop().toLowerCase();234
279
235
const imageExts = ['jpg','jpeg','png','gif','webp','svg','bmp','avif','ico'];280
const imageExts = ['jpg', 'jpeg', 'png', 'gif', 'webp', 'svg', 'bmp', 'avif', 'ico'];236
const videoExts = ['mp4','webm','ogg','mov'];281
const videoExts = ['mp4', 'webm', 'ogg', 'mov'];237
const audioExts = ['mp3','wav','ogg','flac','aac','opus','m4a'];282
const audioExts = ['mp3', 'wav', 'ogg', 'flac', 'aac', 'opus', 'm4a'];238
const textExts = ['txt','md','json','js','ts','html','css','xml','csv','yaml','yml','sh','log','ini','toml','py','rb','go','java','c','cpp','h','rs'];283
const textExts = ['txt', 'md', 'json', 'js', 'ts', 'html', 'css', 'xml', 'csv', 'yaml', 'yml', 'sh', 'log', 'ini', 'toml', 'py', 'rb', 'go', 'java', 'c', 'cpp', 'h', 'rs'];239
284
240
const previewUrl = `/api/share/preview/${token}`;285
const previewUrl = `/api/share/preview/${token}`;241
let el;286
let el;242
287
243
if (imageExts.includes(ext))288
if (imageExts.includes(ext))244
{245
el = document.createElement('img');246
el.src = previewUrl;247
el.alt = name;248
} else if (videoExts.includes(ext))249
{250
el = document.createElement('video');251
el.src = previewUrl;252
el.controls = true;253
} else if (audioExts.includes(ext))254
{255
el = document.createElement('audio');256
el.src = previewUrl;257
el.controls = true;258
} else if (textExts.includes(ext))259
{260
fetch(previewUrl)261
.then(r =>262
{289
{263
if (!r.ok) throw new Error('preview failed');290
el = document.createElement('img');264
return r.text();291
el.src = previewUrl;265
})292
el.alt = name;266
.then(text =>293
} else if (videoExts.includes(ext))267
{294
{268
const pre = document.createElement('pre');295
el = document.createElement('video');269
pre.textContent = text;296
el.src = previewUrl;270
wrap.innerHTML = '';297
el.controls = true;271
wrap.appendChild(pre);298
} else if (audioExts.includes(ext))272
wrap.style.display = '';299
{273
})300
el = document.createElement('audio');274
.catch(() => { /* no preview available */ });301
el.src = previewUrl;275
return;302
el.controls = true;276
} else303
} else if (textExts.includes(ext))277
{304
{278
return; // no preview305
fetch(previewUrl)279
}306
.then(r =>280
307
{281
el.addEventListener('error', () => { wrap.innerHTML = '<div class="no-preview">Geen voorbeeldweergave beschikbaar.</div>'; wrap.style.display = ''; });308
if (!r.ok) throw new Error('preview failed');282
wrap.innerHTML = '';309
return r.text();283
wrap.appendChild(el);310
})284
wrap.style.display = '';311
.then(text =>285
}312
{286
313
const pre = document.createElement('pre');287
// ── Boot ─────────────────────────────────────────────────────────────────314
pre.textContent = text;288
function showError (title, msg)315
wrap.innerHTML = '';289
{316
wrap.appendChild(pre);290
document.getElementById('loading').style.display = 'none';317
wrap.style.display = '';291
document.getElementById('content').style.display = 'none';318
})292
document.getElementById('error-title').textContent = title;319
.catch(() => { /* no preview available */ });293
document.getElementById('error-msg').textContent = msg;320
return;294
document.getElementById('error-state').style.display = '';321
} else295
}322
{296
323
return; // no preview297
function formatBytes (bytes)324
}298
{299
if (bytes == null) return '';300
if (bytes < 1024) return bytes + ' B';301
if (bytes < 1024 * 1024) return (bytes / 1024).toFixed(1) + ' KB';302
if (bytes < 1024 * 1024 * 1024) return (bytes / (1024 * 1024)).toFixed(1) + ' MB';303
return (bytes / (1024 * 1024 * 1024)).toFixed(2) + ' GB';304
}305
306
fetch(`/api/share/info/${token}`)307
.then(r => r.json().then(d => ({ ok: r.ok, status: r.status, data: d })))308
.then(({ ok, status, data }) =>309
{310
document.getElementById('loading').style.display = 'none';311
325
312
if (status === 410)326
el.addEventListener('error', () => { wrap.innerHTML = '<div class="no-preview">Geen voorbeeldweergave beschikbaar.</div>'; wrap.style.display = ''; });313
{327
wrap.innerHTML = '';314
showError('Link verlopen', 'Deze deellink is niet meer geldig.');328
wrap.appendChild(el);315
return;329
wrap.style.display = '';316
}330
}317
if (!ok)331
332
// ── Boot ─────────────────────────────────────────────────────────────────333
function showError (title, msg)318
{334
{319
showError('Niet gevonden', data.error || 'De link bestaat niet.');335
document.getElementById('loading').style.display = 'none';320
return;336
document.getElementById('content').style.display = 'none';337
document.getElementById('error-title').textContent = title;338
document.getElementById('error-msg').textContent = msg;339
document.getElementById('error-state').style.display = '';321
}340
}322
341
323
expiresAt = data.expiresAt;342
function formatBytes (bytes)324
startTimer();325
326
document.getElementById('file-name').textContent = data.name;327
const metaLine = data.isDir ? 'Map (download als .zip)' : 'Bestand';328
document.getElementById('file-meta').textContent = metaLine;329
330
const dlBtn = document.getElementById('btn-download');331
dlBtn.href = `/api/share/download/${token}`;332
if (data.isDir)333
{343
{334
document.getElementById('btn-download-label').textContent = 'Downloaden als .zip';344
if (bytes == null) return '';335
dlBtn.download = data.name + '.zip';345
if (bytes < 1024) return bytes + ' B';336
} else346
if (bytes < 1024 * 1024) return (bytes / 1024).toFixed(1) + ' KB';337
{347
if (bytes < 1024 * 1024 * 1024) return (bytes / (1024 * 1024)).toFixed(1) + ' MB';338
document.getElementById('btn-download-label').textContent = 'Downloaden';348
return (bytes / (1024 * 1024 * 1024)).toFixed(2) + ' GB';339
dlBtn.download = data.name;340
}349
}341
350
342
document.getElementById('content').style.display = '';351
fetch(`/api/share/info/${token}`)343
352
.then(r => r.json().then(d => ({ ok: r.ok, status: r.status, data: d })))344
tryPreview(data.name, data.isDir);353
.then(({ ok, status, data }) =>345
})354
{346
.catch(() =>355
document.getElementById('loading').style.display = 'none';347
{356
348
showError('Fout', 'Kon de server niet bereiken.');357
if (status === 410)349
});358
{350
}());359
showError('Link verlopen', 'Deze deellink is niet meer geldig.');351
</script>360
return;361
}362
if (!ok)363
{364
showError('Niet gevonden', data.error || 'De link bestaat niet.');365
return;366
}367
368
expiresAt = data.expiresAt;369
startTimer();370
371
document.getElementById('file-name').textContent = data.name;372
const metaLine = data.isDir ? 'Map (download als .zip)' : 'Bestand';373
document.getElementById('file-meta').textContent = metaLine;374
375
const dlBtn = document.getElementById('btn-download');376
dlBtn.href = `/api/share/download/${token}`;377
if (data.isDir)378
{379
document.getElementById('btn-download-label').textContent = 'Downloaden als .zip';380
dlBtn.download = data.name + '.zip';381
} else382
{383
document.getElementById('btn-download-label').textContent = 'Downloaden';384
dlBtn.download = data.name;385
}386
387
document.getElementById('content').style.display = '';388
389
tryPreview(data.name, data.isDir);390
})391
.catch(() =>392
{393
showError('Fout', 'Kon de server niet bereiken.');394
});395
}());396
</script>352
</body>397
</body>353
</html>398
399
</html>