ntdservices commited on
Commit
629d720
Β·
verified Β·
1 Parent(s): 3954f87

Update static/embed.js

Browse files
Files changed (1) hide show
  1. static/embed.js +24 -21
static/embed.js CHANGED
@@ -1,28 +1,36 @@
1
- /* embed.js –– digital-clock styling */
2
  (() => {
3
  const API = "https://ntdservices-debt-clock.hf.space/api/debt";
4
  const CLS = "ntd-debt-clock";
5
 
6
- /* ── 1. load a free 7-segment web-font once per page ───────────── */
7
- if (!document.getElementById("dseg-font")) {
8
- const link = document.createElement("link");
9
- link.id = "dseg-font";
10
- link.rel = "stylesheet";
11
- link.href = "https://cdn.jsdelivr.net/npm/@fontsource-variable/dseg7-classic/index.min.css";
12
- document.head.appendChild(link);
 
 
 
 
 
 
 
 
13
  }
14
 
15
  /* ── 2. mount logic ─────────────────────────────────────────────── */
16
  function mount(el) {
17
  Object.assign(el.style, {
18
- font: "900 5.5rem 'DSEG7 Classic', monospace",
19
- color: "#ffb400", // amber LEDs
20
- textShadow: "0 0 6px rgba(255,180,0,.8)",
21
  background: "rgba(0,0,0,.65)",
22
- padding: "8px 14px",
23
  borderRadius: "6px",
24
  whiteSpace: "nowrap",
25
- letterSpacing: ".08em",
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 for a mild β€œtick” */
42
  setInterval(() => {
43
  const now = performance.now();
44
  const dt = (now - last) / 1000;
45
  last = now;
46
  debt += rate * dt;
47
 
48
- /* split into 3-digit groups to mimic signage */
49
- const parts = Math.round(debt)
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 => {