so://phie

game-engine

A lightweight JavaScript game engine
git clone git://soophie.de/game-engine

blob: 576ea189b0576c62ba18bfbda55fe5579aec4273 (610 bytes)[doc][blame][raw]

1window.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 }