-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdisplay.html
More file actions
47 lines (44 loc) · 3.44 KB
/
display.html
File metadata and controls
47 lines (44 loc) · 3.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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<title>Reveal</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<main>
<h1 style="text-align:center;color:#c41e3a;margin-bottom:8px">🎄 Happy Holidays! 🎁</h1>
<h2 style="text-align:center;color:#165b33;margin-top:0;font-size:18px">2025 Malbert Secret Santa</h2>
<div id="card" style="padding:24px;border-radius:12px;background:linear-gradient(135deg, #fff5f5 0%, #f0f9ff 100%);border:2px solid #c41e3a;box-shadow:0 4px 12px rgba(196,30,58,0.15)">
<p id="info" style="font-size:18px;color:#333;margin-bottom:16px;text-align:center">Decoding...</p>
<div style="background:#fff;padding:20px;border-radius:8px;margin:16px 0;border:3px solid #165b33">
<p style="font-size:16px;color:#666;margin:0 0 12px 0;text-align:center;font-weight:500">🎅 YOU ARE BUYING A GIFT FOR:</p>
<p id="who" style="font-size:32px;font-weight:700;color:#c41e3a;text-align:center;margin:0;text-transform:uppercase;letter-spacing:1px"></p>
</div>
<p style="font-size:14px;color:#555;margin-top:16px;text-align:center;font-style:italic">Remember: Keep it secret, keep it fun! 🤫✨</p>
</div>
</main>
<script>
function qs(k){ const params = new URLSearchParams(location.search); return params.get(k) }
const enc = qs('e'); const seed = qs('s'); const giver = qs('giver'); const group = qs('group');
function showReceiver(name){ document.getElementById('info').innerHTML = '👋 Hi <strong>' + (giver||'there') + '</strong>!'; document.getElementById('who').textContent = name; }
// small helpers (matching app.js)
function base64UrlDecode(s){ s = s.replace(/-/g,'+').replace(/_/g,'/'); while(s.length %4) s += '='; const bin = atob(s); const arr = new Uint8Array(bin.length); for(let i=0;i<bin.length;i++) arr[i]=bin.charCodeAt(i); return arr }
function bytesToUtf8(b){ return new TextDecoder().decode(b) }
function hashStr(s){let h=2166136261; for(let i=0;i<s.length;i++){h ^= s.charCodeAt(i); h += (h<<1)+(h<<4)+(h<<7)+(h<<8)+(h<<24);} return h>>>0}
function mulberry32(seed){ let t = seed >>> 0; return function(){ t += 0x6D2B79F5; let r = Math.imul(t ^ t >>> 15, t | 1); r ^= r + Math.imul(r ^ r >>> 7, r | 61); return ((r ^ r >>> 14) >>> 0) / 4294967296 }}
function xorDecrypt(encoded, seed){ try{ const bytes = base64UrlDecode(encoded); const rnd = mulberry32(hashStr(seed.toString())); const out = new Uint8Array(bytes.length); for(let i=0;i<bytes.length;i++){ out[i] = bytes[i] ^ Math.floor(rnd()*256) } return bytesToUtf8(out) }catch(e){ return null } }
if(enc && seed){
const rec = xorDecrypt(enc, seed);
if(rec) showReceiver(rec); else document.getElementById('info').textContent = 'Unable to decode assignment.';
}else if(enc && !seed){ document.getElementById('info').textContent = 'Missing seed in URL.' }
else{
// fallback to id-based server lookup if present
const id = qs('id');
if(id){ const possible = 'assignments/' + encodeURIComponent(id) + '.json'; fetch(possible).then(r=>{ if(!r.ok) throw new Error('not found'); return r.json() }).then(obj=>{ showReceiver(obj.receiver) }).catch(()=>{ document.getElementById('info').textContent = 'No inline data. Server lookup not available.' }) }
else document.getElementById('info').textContent = 'Missing assignment data in URL.'
}
</script>
</body>
</html>