Skip to content

gitflarePublicPartly agent-ready50

cf-durable-whiteboard

Realtime collaborative whiteboard on Cloudflare Durable Objects: presence cursors, WebSocket hibernation, SQLite storage, undo, PNG export.

Keep board zoom and pan stable across reloads6eb4fbd
JavaScript15 lines967 B
import { newBoardId, loadRecent } from "./protocol.js";document.getElementById("new").onclick = () => { location.href = "/b/" + newBoardId(); };const ul = document.getElementById("recent");const ids = loadRecent(localStorage);ul.textContent = "";if (!ids.length) { const li = document.createElement("li"); li.className = "empty"; li.textContent = "No boards yet. Create one and it will appear here."; ul.append(li); }for (const id of ids) {  const li = document.createElement("li"), a = document.createElement("a"), m = document.createElement("span");  a.className = "card"; a.href = "/b/" + id; a.textContent = id; m.className = "meta"; m.textContent = "Loading…";  a.append(m); li.append(a); ul.append(li);  fetch("/api/boards/" + id).then((r) => (r.ok ? r.json() : Promise.reject())).then((j) => {    const n = j.shapes ?? j.shapeCount ?? 0; m.textContent = n + (n === 1 ? " shape" : " shapes");  }).catch(() => { m.textContent = "Open board"; });}