Update tags.

This commit is contained in:
retoor 2025-06-22 23:17:56 +02:00
parent 990b0eaf92
commit 3bc49ec40d

View File

@ -435,7 +435,7 @@ customElements.define('note-compose', NoteCompose);
async function loadNotes(tag){ const r=await fetch(tag?`${API_BASE}/notes?tag=${encodeURIComponent(tag)}`:`${API_BASE}/notes`); const ns=r.ok?await r.json():[]; const g=document.getElementById('note-grid'); g.innerHTML=''; ns.forEach(n=>{const c=document.createElement('note-card'); c.data=n; g.appendChild(c);} ); }
async function loadTags(){ const r=await fetch(`${API_BASE}/tags`); const ts=r.ok?await r.json():[]; const l=document.getElementById('tag-list'); l.innerHTML=''; ts.forEach(t=>{const li=document.createElement('li'); li.textContent=t.name||t; li.onclick=()=>{document.querySelectorAll('#tag-list li').forEach(x=>x.classList.toggle('active',x===li)); loadNotes(t.name||t);}; l.appendChild(li);} ); }
document.addEventListener('notes-changed', () => loadNotes());
document.addEventListener('notes-changed', () => { loadNotes(); loadTags(); });
loadNotes(); loadTags();
</script>
</body>