// bonzi homepage — minimal, no framework (() => { 'use strict'; // ── 1. Live UTC timestamp (every 60s) ────────────────── const stamp = (d) => { const p = (n) => String(n).padStart(2, '0'); return `${d.getUTCFullYear()}-${p(d.getUTCMonth()+1)}-${p(d.getUTCDate())} ${p(d.getUTCHours())}:${p(d.getUTCMinutes())} UTC`; }; const setNow = () => { const s = stamp(new Date()); document.querySelectorAll('#now, #footer-now').forEach((el) => { el.textContent = s; }); }; setNow(); setInterval(setNow, 60_000); // ── 2. Reveal-on-scroll ──────────────────────────────── const blocks = document.querySelectorAll('[data-reveal]'); if ('IntersectionObserver' in window) { const io = new IntersectionObserver((entries) => { entries.forEach((e) => { if (e.isIntersecting) { e.target.classList.add('in'); io.unobserve(e.target); } }); }, { threshold: 0.1 }); blocks.forEach((b) => io.observe(b)); } else { blocks.forEach((b) => b.classList.add('in')); } // ── 3. Last commit timestamp from gitea ───────────────── // CORS-friendly public endpoint. Falls back silently if it fails. const lastCommitEl = document.getElementById('last-commit'); if (lastCommitEl) { fetch('https://git.molberg.cloud/api/v1/repos/bonzi/bonzi-homepage/commits?limit=1') .then((r) => r.ok ? r.json() : null) .then((data) => { if (!data || !data[0]) return; const ts = data[0].commit?.committer?.timestamp || data[0].commit?.author?.timestamp; if (!ts) return; const d = new Date(ts); const p = (n) => String(n).padStart(2, '0'); // Show as YYYY-MM-DD lastCommitEl.textContent = `${d.getUTCFullYear()}-${p(d.getUTCMonth()+1)}-${p(d.getUTCDate())}`; }) .catch(() => { /* silent fallback — text stays as "—" */ }); } })();