A lightweight JavaScript game engine
git clone git://soophie.de/game-engine
blob: a6654f34ab3c0ec3ae2986233ed8ea0abe9aa6f0 (1130 bytes)[doc][blame][raw]
1
window.onload = async function() {2
for(const rel of document.querySelectorAll('[data-rel]')) {3
rel.onclick = function() {4
const {rel: code} = rel.dataset;5
if(code === 'top') {6
window.scrollTo({ top: 0, behavior: 'smooth' });7
}8
else {9
const ref = document.querySelector(`[data-ref="${code}"]`);10
if(ref) {11
window.scrollTo({ top: ref.offsetTop - 80, behavior: 'smooth' });12
}13
}14
}15
}16
for(const ref of document.querySelectorAll('span.ref')) {17
ref.onclick = function() {18
if(ref.classList.contains('ref-link')) {19
window.open(ref.textContent, '_blank');20
}21
}22
}23
let delay;24
const snackbar = document.querySelector('.snackbar');25
for(const tone of document.querySelectorAll('.palette-tone')) {26
tone.onclick = function() {27
if(snackbar) {28
snackbar.classList.add('active');29
let time = new Date().getTime();30
setTimeout(() => {31
if(delay === time) {32
snackbar.classList.remove('active');33
}34
}, 3000);35
const value = `@color-${tone.parentNode.dataset.type}-${tone.textContent}`;36
navigator.clipboard.writeText(value);37
delay = time;38
}39
}40
}