workshop-reports.js 810 B

1234567891011121314151617181920
  1. (() => {
  2. const menu = document.getElementById('site-menu');
  3. const mobile = matchMedia('(max-width: 820px)');
  4. function syncMenu() { if (menu) menu.open = !mobile.matches; }
  5. syncMenu();
  6. mobile.addEventListener('change', syncMenu);
  7. function showSource() {
  8. let id;
  9. try { id = decodeURIComponent(location.hash.slice(1)); } catch { return; }
  10. const target = document.getElementById(id);
  11. if (!target) return;
  12. if (target.matches('details')) target.open = true;
  13. for (let parent = target.parentElement; parent; parent = parent.parentElement) {
  14. if (parent.matches('details')) parent.open = true;
  15. }
  16. if (id.startsWith('source-')) requestAnimationFrame(() => target.scrollIntoView({ block: 'start' }));
  17. }
  18. addEventListener('hashchange', showSource);
  19. showSource();
  20. })();