Spaces:
Sleeping
Sleeping
Update static/embed.js
Browse files- static/embed.js +24 -21
static/embed.js
CHANGED
|
@@ -1,28 +1,36 @@
|
|
| 1 |
-
/* embed.js
|
| 2 |
(() => {
|
| 3 |
const API = "https://ntdservices-debt-clock.hf.space/api/debt";
|
| 4 |
const CLS = "ntd-debt-clock";
|
| 5 |
|
| 6 |
-
/* ββ 1.
|
| 7 |
-
if (!document.getElementById("dseg-
|
| 8 |
-
const
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
}
|
| 14 |
|
| 15 |
/* ββ 2. mount logic βββββββββββββββββββββββββββββββββββββββββββββββ */
|
| 16 |
function mount(el) {
|
| 17 |
Object.assign(el.style, {
|
| 18 |
-
font: "
|
| 19 |
-
color: "#ffb400",
|
| 20 |
-
textShadow: "0 0
|
| 21 |
background: "rgba(0,0,0,.65)",
|
| 22 |
-
padding: "
|
| 23 |
borderRadius: "6px",
|
| 24 |
whiteSpace: "nowrap",
|
| 25 |
-
letterSpacing: ".
|
| 26 |
position: "absolute",
|
| 27 |
top: "40%",
|
| 28 |
left: "50%",
|
|
@@ -38,20 +46,15 @@
|
|
| 38 |
const rate = d.ratePerSecond;
|
| 39 |
let last = performance.now();
|
| 40 |
|
| 41 |
-
/* update 4Γ/sec
|
| 42 |
setInterval(() => {
|
| 43 |
const now = performance.now();
|
| 44 |
const dt = (now - last) / 1000;
|
| 45 |
last = now;
|
| 46 |
debt += rate * dt;
|
| 47 |
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
.toString()
|
| 51 |
-
.replace(/\B(?=(\d{3})+(?!\d))/g, ",")
|
| 52 |
-
.split(",");
|
| 53 |
-
|
| 54 |
-
el.textContent = "$" + parts.join(",");
|
| 55 |
}, 250);
|
| 56 |
})
|
| 57 |
.catch(err => {
|
|
|
|
| 1 |
+
/* embed.js β guaranteed 7-segment look */
|
| 2 |
(() => {
|
| 3 |
const API = "https://ntdservices-debt-clock.hf.space/api/debt";
|
| 4 |
const CLS = "ntd-debt-clock";
|
| 5 |
|
| 6 |
+
/* ββ 1. inject a real DSEG7-Classic-Bold font once βββββββββββββββ */
|
| 7 |
+
if (!document.getElementById("dseg-face")) {
|
| 8 |
+
const style = document.createElement("style");
|
| 9 |
+
style.id = "dseg-face";
|
| 10 |
+
style.textContent = `
|
| 11 |
+
@font-face {
|
| 12 |
+
font-family: "DSEG7";
|
| 13 |
+
src:
|
| 14 |
+
url("https://cdn.jsdelivr.net/npm/@fontsource/dseg7-classic/files/dseg7-classic-latin-700-normal.woff2") format("woff2");
|
| 15 |
+
font-weight: 700;
|
| 16 |
+
font-style: normal;
|
| 17 |
+
font-display: swap;
|
| 18 |
+
}
|
| 19 |
+
`;
|
| 20 |
+
document.head.appendChild(style);
|
| 21 |
}
|
| 22 |
|
| 23 |
/* ββ 2. mount logic βββββββββββββββββββββββββββββββββββββββββββββββ */
|
| 24 |
function mount(el) {
|
| 25 |
Object.assign(el.style, {
|
| 26 |
+
font: "700 5.2rem 'DSEG7', monospace",
|
| 27 |
+
color: "#ffb400",
|
| 28 |
+
textShadow: "0 0 8px rgba(255, 180, 0, .9)",
|
| 29 |
background: "rgba(0,0,0,.65)",
|
| 30 |
+
padding: "10px 18px",
|
| 31 |
borderRadius: "6px",
|
| 32 |
whiteSpace: "nowrap",
|
| 33 |
+
letterSpacing: ".06em",
|
| 34 |
position: "absolute",
|
| 35 |
top: "40%",
|
| 36 |
left: "50%",
|
|
|
|
| 46 |
const rate = d.ratePerSecond;
|
| 47 |
let last = performance.now();
|
| 48 |
|
| 49 |
+
/* update 4Γ/sec so it βticksβ but doesnβt blur */
|
| 50 |
setInterval(() => {
|
| 51 |
const now = performance.now();
|
| 52 |
const dt = (now - last) / 1000;
|
| 53 |
last = now;
|
| 54 |
debt += rate * dt;
|
| 55 |
|
| 56 |
+
el.textContent =
|
| 57 |
+
"$" + Math.round(debt).toLocaleString("en-US"); // 3-digit commas
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
}, 250);
|
| 59 |
})
|
| 60 |
.catch(err => {
|