feat(cards): YouTube oEmbed; UI: inline actions in header, 🌝/🌚 summarize toggle, header collapse hides all

This commit is contained in:
Thomas Cravey 2025-08-17 18:24:05 -05:00
parent 2680abcf1f
commit 29d94c13d5
2 changed files with 35 additions and 3 deletions

View file

@ -46,7 +46,7 @@ function processLinks(scope){ const links = scope.querySelectorAll('a[href]:not(
left.appendChild(fav); left.appendChild(title);
const actions=document.createElement('div'); actions.className='card-actions';
const chevron=document.createElement('button'); chevron.type='button'; chevron.title='Expand/collapse'; chevron.textContent='▾'; chevron.style.padding='0 .4rem'; chevron.style.fontSize='.9rem';
const btn=document.createElement('button'); btn.type='button'; btn.title='Summarize this link'; btn.textContent='Summarize ✨'; btn.style.padding='0 .4rem'; btn.style.fontSize='.9rem';
const btn=document.createElement('button'); btn.type='button'; btn.title='Summarize this link'; btn.textContent='🌝'; btn.style.padding='0 .4rem'; btn.style.fontSize='.9rem';
const spinner=document.createElement('span'); spinner.textContent=''; spinner.style.marginLeft='.5rem';
actions.appendChild(btn); actions.appendChild(chevron); actions.appendChild(spinner);
head.appendChild(left); head.appendChild(actions);
@ -74,10 +74,10 @@ function processLinks(scope){ const links = scope.querySelectorAll('a[href]:not(
btn.onclick = async ()=>{
if(sum.style.display!== 'none' && sum.textContent){ // hide existing
sum.style.display='none'; btn.textContent='Summarize ✨'; pinBottomMulti(); return;
sum.style.display='none'; btn.textContent='🌝'; pinBottomMulti(); return;
}
btn.disabled=true; spinner.textContent='…'; sum.textContent=''; sum.style.display='';
try{ const data = await api('/api/linksummary',{query:{url:a.href}}); sum.textContent = (data && data.summary) ? data.summary : '(no summary)'; btn.textContent='Hide summary'; }
try{ const data = await api('/api/linksummary',{query:{url:a.href}}); sum.textContent = (data && data.summary) ? data.summary : '(no summary)'; btn.textContent='🌚'; }
catch(e){ sum.textContent = 'error: '+e; }
spinner.textContent=''; btn.disabled=false; pinBottomMulti();
};