repos
/ orchard main

orchard

mirror

Every site I host, in one repo, along with the Cloudflare Tunnel and Caddy that front them. It's all Go, Vite, and SQLite, and it runs on a desktop at home with nothing listening on an inbound port.

blogbuncaddycloudflare-tunneldockergogolanghomelabhtml-templatemonorepoself-hostedseosqlitestatic-sitetypstuptime-monitoringviteweb-analytics

858 B · 26 lines · JavaScript Raw History
 1// The form's `action` already holds /properties/{id}/cards, so it is posted to
 2// directly rather than rebuilt from window.location.
 3document.addEventListener("DOMContentLoaded", function () {
 4  const form = document.getElementById("custom-card-form");
 5  if (!form) return;
 6
 7  form.addEventListener("change", function () {
 8    const data = [];
 9    for (const [key, value] of new FormData(form).entries()) {
10      data.push({ event: key, value: value === "on" });
11    }
12    fetch(form.action, {
13      method: "POST",
14      headers: { "Content-Type": "application/json" },
15      body: JSON.stringify(data),
16    })
17      .then((r) => {
18        if (!r.ok) throw new Error(`${form.action} returned HTTP ${r.status}`);
19        window.location.reload();
20      })
21      .catch((err) => {
22        console.error("custom cards save failed:", err);
23      });
24  });
25});