| 1234567891011121314151617181920 |
- (() => {
- const menu = document.getElementById('site-menu');
- const mobile = matchMedia('(max-width: 820px)');
- function syncMenu() { if (menu) menu.open = !mobile.matches; }
- syncMenu();
- mobile.addEventListener('change', syncMenu);
- function showSource() {
- let id;
- try { id = decodeURIComponent(location.hash.slice(1)); } catch { return; }
- const target = document.getElementById(id);
- if (!target) return;
- if (target.matches('details')) target.open = true;
- for (let parent = target.parentElement; parent; parent = parent.parentElement) {
- if (parent.matches('details')) parent.open = true;
- }
- if (id.startsWith('source-')) requestAnimationFrame(() => target.scrollIntoView({ block: 'start' }));
- }
- addEventListener('hashchange', showSource);
- showSource();
- })();
|