A lightweight JavaScript game engine
git clone git://soophie.de/game-engine
blob: e6a74b3961aece8e2065732668f4405ddd1ddbba (1534 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
}41
for(const icon of document.querySelectorAll('.icon')) {42
icon.onclick = function() {43
if(snackbar) {44
snackbar.classList.add('active');45
let time = new Date().getTime();46
setTimeout(() => {47
if(delay === time) {48
snackbar.classList.remove('active');49
}50
}, 3000);51
const value = `${icon.innerHTML}`;52
navigator.clipboard.writeText(value);53
delay = time;54
}55
}56
}