Repository navigation
Expand file tree
/
Copy pathscript.js
More file actions
61 lines (52 loc) · 1.83 KB
/
Copy pathscript.js
File metadata and controls
61 lines (52 loc) · 1.83 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
// Discord copy + toast
const discordLink = document.getElementById('discord-link');
const DISCORD_USERNAME = 'arkanegd';
const notification = document.createElement('div');
notification.className = 'notification';
notification.setAttribute('role', 'status');
document.body.appendChild(notification);
function showToast(message) {
notification.textContent = message;
notification.classList.add('show');
clearTimeout(showToast._t);
showToast._t = setTimeout(() => notification.classList.remove('show'), 2000);
}
if (discordLink) {
discordLink.addEventListener('click', async () => {
try {
await navigator.clipboard.writeText(DISCORD_USERNAME);
showToast('Discord username copied to clipboard!');
} catch (err) {
console.error('Failed to copy username:', err);
showToast('Failed to copy username');
}
});
}
// Card border light follows the pointer
document.querySelectorAll('.card').forEach((el) => {
el.addEventListener('pointermove', (e) => {
const rect = el.getBoundingClientRect();
el.style.setProperty('--pointer-x', `${e.clientX - rect.left}px`);
el.style.setProperty('--pointer-y', `${e.clientY - rect.top}px`);
});
});
// Run stats, saved in this browser and shared with the mini level
const STATS_KEY = 'arkane-run';
function loadStats() {
const stats = { attempts: 0, jumps: 0, clears: 0, bests: {} };
try {
return { ...stats, ...JSON.parse(localStorage.getItem(STATS_KEY)) };
} catch (err) {
return stats;
}
}
function saveStats(stats) {
try {
localStorage.setItem(STATS_KEY, JSON.stringify(stats));
} catch (err) {
// Storage blocked, stats last until the page closes
}
}
document.getElementById('attempt').textContent = `Attempt ${Math.max(loadStats().attempts, 1)}`;
// Footer year
document.getElementById('year').textContent = new Date().getFullYear();