async function loadAnnotations(){ const panel=document.getElementById('active-note-panel'); const marks=[...document.querySelectorAll('.annotated-highlight[data-note-id]')]; if(!panel || !marks.length) return; const emptyHTML='
Click a highlighted passage in the text to read its annotation.
'; const res=await fetch('data/annotations.json'); const notes=await res.json(); const byId=Object.fromEntries(notes.map(n=>[n.id,n])); function clear(){ document.querySelectorAll('.annotated-highlight.is-active').forEach(el=>el.classList.remove('is-active')); panel.dataset.empty='true'; panel.className='active-note-panel'; panel.innerHTML=emptyHTML; } function render(noteId, mark){ const note=byId[noteId]; if(!note) return; document.querySelectorAll('.annotated-highlight.is-active').forEach(el=>el.classList.remove('is-active')); mark.classList.add('is-active'); panel.dataset.empty='false'; panel.className=`active-note-panel ${note.type || ''}`.trim(); panel.innerHTML=`${note.text || ''}
`}