theseus/statusbar.html

58 lines
3 KiB
HTML
Raw Normal View History

<!doctype html>
<html>
<head><meta charset="utf-8">
<style>
:root { color-scheme: dark; font-family: system-ui, sans-serif; }
html, body { margin: 0; height: 100%; }
body { display: flex; align-items: center; gap: 8px; padding: 0 12px;
background: #0b0f18; color: #8b93a7; font-size: 11.5px; white-space: nowrap;
overflow: hidden; border-top: 1px solid #ffffff10; user-select: none; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #5e6678; flex: none; }
.dot.chain { background: #d6ff3d; } .dot.sia { background: #b39ddb; }
.dot.server { background: #4fd1a5; } .dot.web { background: #8b93a7; } .dot.err { background: #f6768a; }
#host { color: #e7eaf1; }
#src { color: #bfeae4; }
.reg { color: #d6ff3d; }
.sep { color: #3a4152; }
#records { color: #6f7789; font-family: ui-monospace, monospace; }
#cert { color: #6f7789; margin-left: auto; font-family: ui-monospace, monospace;
overflow: hidden; text-overflow: ellipsis; }
</style></head>
<body>
<span class="dot" id="dot"></span>
<span id="host"></span>
<span id="sep1" class="sep" hidden>·</span>
<span id="src"></span>
<span id="sep2" class="sep" hidden>·</span>
<span class="reg" id="reg"></span>
<span id="records"></span>
<span id="cert"></span>
<script>
const $ = (id) => document.getElementById(id);
function clear() { for (const id of ["host","src","reg","records","cert"]) $(id).textContent = ""; $("sep1").hidden = $("sep2").hidden = true; }
window.theseus.onNav((d) => {
const dot = $("dot"); dot.className = "dot";
clear();
if (!d || d.kind === "home") { $("host").textContent = "Theseus — decentralized web navigator"; return; }
if (d.kind === "resolving") { $("host").textContent = "resolving " + d.host + " on the BCH chain…"; return; }
if (d.kind === "nxdomain") { dot.classList.add("err"); $("host").textContent = d.host + " → not registered on chain (NXDOMAIN)"; return; }
if (d.kind === "error") { dot.classList.add("err"); $("host").textContent = "error: " + (d.error || "resolution failed"); return; }
if (d.kind === "web") {
dot.classList.add("web");
$("host").textContent = d.host || "";
$("sep1").hidden = false; $("src").textContent = "web (ICANN DNS)";
return;
}
// kind === "ok": a resolved BNS name
const cls = (d.source || "").includes("chain") ? "chain" : (d.source || "").includes("Sia") ? "sia" : (d.source || "").includes("server") ? "server" : "web";
dot.classList.add(cls);
$("host").textContent = d.host || "";
$("sep1").hidden = false; $("src").textContent = "served from " + (d.source || "chain");
if (d.registry || d.tld) { $("sep2").hidden = false; $("reg").textContent = (d.registry || "BCNR") + (d.tld ? " ·." + d.tld : ""); }
if (d.records && d.records.length) $("records").textContent = " [" + d.records.join(",") + "]";
if (d.category) $("cert").textContent = "cert " + String(d.category).slice(0, 16) + "…";
});
</script>
</body>
</html>