Files
Anya Tokugawa c1175d389f Implement Knowledge City platform, organizer and DAV integration
Capture accumulated application, UI, CLI, regression tests and design documentation changes, including task project mapping and default CalDAV list naming.

Keep deployment data, backups, local credentials and build artifacts out of Git. Move the Compose enrollment token to an ignored local environment file.
2026-09-27 14:44:43 +09:00

33 lines
2.0 KiB
JavaScript

(() => {
// At most two background listings at a time; no previews or revision fetches.
const queue = []; let active = 0;
const pump = () => { while (active < 2 && queue.length) { active++; queue.shift()().finally(() => { active--; pump(); }); } };
const enqueue = job => { queue.push(job); pump(); };
const observer = new IntersectionObserver(entries => {
for (const entry of entries) if (entry.isIntersecting) { observer.unobserve(entry.target); entry.target._load(); }
}, {rootMargin: '100px'});
for (const list of document.querySelectorAll('[data-bookmark-source]')) {
const button = list.parentElement.querySelector('[data-bookmark-load]');
let after = '', busy = false;
const load = () => {
if (busy) return; busy = true; button.disabled = true; list.setAttribute('aria-busy', 'true');
enqueue(async () => {
try {
const url = new URL(list.dataset.bookmarkSource, location.origin);
if (after) url.searchParams.set('after', after);
const response = await fetch(url, {cache: 'no-store', signal: AbortSignal.timeout(15000)});
if (!response.ok) throw new Error(String(response.status));
const data = await response.json();
for (const link of data.links) {
const li = document.createElement('li'), a = document.createElement('a');
a.href = link.href; a.textContent = link.label; li.append(a); list.append(li);
}
after = data.next; button.hidden = !after; button.textContent = button.dataset.more;
} catch (_) { button.textContent = button.dataset.error; }
finally { busy = false; button.disabled = false; list.setAttribute('aria-busy', 'false'); }
});
};
list._load = load; button.addEventListener('click', load); observer.observe(list);
}
})();