CoolFace
Apppublic

inderjeet/esd_study_guide

sourceHugging Faceupdated 5mo agoView on Hugging Face
0likes
app.js25 linesDownload Raw Back to root
1// ESD Study Guide — Shared JS2function toggle(el){el.parentElement.classList.toggle('open')}3function toggleA(el){el.parentElement.classList.toggle('open')}4 5// Nav active highlighting on scroll6document.addEventListener('DOMContentLoaded',()=>{7  const sections=document.querySelectorAll('section[id]');8  const links=document.querySelectorAll('nav a[href^="#"]');9  const onScroll=()=>{10    let cur='';11    sections.forEach(s=>{if(window.scrollY>=s.offsetTop-90)cur=s.id});12    links.forEach(a=>{a.classList.remove('active');if(a.getAttribute('href')==='#'+cur)a.classList.add('active')});13  };14  window.addEventListener('scroll',onScroll,{passive:true});15 16  // expand all button17  document.querySelectorAll('.expand-all').forEach(btn=>{18    btn.addEventListener('click',()=>{19      const container=btn.closest('section')||document;20      container.querySelectorAll('.qa,.asgn-q').forEach(el=>el.classList.add('open'));21      btn.textContent='✓ All expanded';22    });23  });24});25