(function () { 'use strict'; function updateOnlineStatus() { const badge = document.getElementById('offline-badge'); if (!badge) return; badge.hidden = navigator.onLine; } window.addEventListener('online', updateOnlineStatus); window.addEventListener('offline', updateOnlineStatus); document.addEventListener('DOMContentLoaded', updateOnlineStatus); async function loadListing() { const container = document.getElementById('literature-list'); if (!container) return; try { const res = await fetch('/literature/index.json'); if (!res.ok) { container.innerHTML = '

No literature available yet. Add a .txt file to public/text/ and push to GitHub.

'; return; } const items = await res.json(); if (!Array.isArray(items) || items.length === 0) { container.innerHTML = '

No books converted yet.

'; return; } const html = items.map(book => { const dateStr = book.datePublished ? `${book.datePublished}` : ''; const descStr = book.description ? `

${book.description}

` : ''; return `

${book.title}

by ${book.author}

${dateStr} ${descStr}
`; }).join('\n'); container.innerHTML = html; } catch (err) { console.error('Failed to load listing:', err); container.innerHTML = '

Could not load literature catalogue. You may be offline.

'; } } document.addEventListener('DOMContentLoaded', loadListing); })();