Spaces:
Sleeping
Sleeping
Update templates/index.html
Browse files- templates/index.html +15 -68
templates/index.html
CHANGED
|
@@ -1,70 +1,17 @@
|
|
| 1 |
-
<!
|
| 2 |
<html lang="en">
|
| 3 |
-
<head>
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
}
|
| 18 |
-
h1 {
|
| 19 |
-
font-size: 2rem;
|
| 20 |
-
color: #aaa;
|
| 21 |
-
margin-bottom: 10px;
|
| 22 |
-
}
|
| 23 |
-
#debt {
|
| 24 |
-
font-size: 3rem;
|
| 25 |
-
white-space: nowrap;
|
| 26 |
-
}
|
| 27 |
-
</style>
|
| 28 |
-
</head>
|
| 29 |
-
<body>
|
| 30 |
-
<h1>U.S. National Debt (Real-Time Estimate)</h1>
|
| 31 |
-
<div id="debt">Loading...</div>
|
| 32 |
-
|
| 33 |
-
<script>
|
| 34 |
-
let startingDebt = 0;
|
| 35 |
-
let ratePerSecond = 0;
|
| 36 |
-
let startTime = Date.now();
|
| 37 |
-
let currentDisplayDebt = 0;
|
| 38 |
-
|
| 39 |
-
function animateDebt() {
|
| 40 |
-
const now = Date.now();
|
| 41 |
-
const elapsed = (now - startTime) / 1000;
|
| 42 |
-
const targetDebt = startingDebt + (ratePerSecond * elapsed);
|
| 43 |
-
|
| 44 |
-
// Easing toward target
|
| 45 |
-
currentDisplayDebt += (targetDebt - currentDisplayDebt) * 0.05;
|
| 46 |
-
|
| 47 |
-
document.getElementById('debt').textContent = '$' + currentDisplayDebt.toLocaleString(undefined, {
|
| 48 |
-
minimumFractionDigits: 2,
|
| 49 |
-
maximumFractionDigits: 2
|
| 50 |
-
});
|
| 51 |
-
|
| 52 |
-
requestAnimationFrame(animateDebt);
|
| 53 |
-
}
|
| 54 |
-
|
| 55 |
-
fetch('/api/debt')
|
| 56 |
-
.then(res => res.json())
|
| 57 |
-
.then(data => {
|
| 58 |
-
startingDebt = data.startingDebt;
|
| 59 |
-
ratePerSecond = data.ratePerSecond;
|
| 60 |
-
startTime = Date.now();
|
| 61 |
-
currentDisplayDebt = startingDebt;
|
| 62 |
-
animateDebt();
|
| 63 |
-
})
|
| 64 |
-
.catch(err => {
|
| 65 |
-
document.getElementById('debt').textContent = 'Error loading data';
|
| 66 |
-
console.error(err);
|
| 67 |
-
});
|
| 68 |
-
</script>
|
| 69 |
-
</body>
|
| 70 |
</html>
|
|
|
|
| 1 |
+
<!doctype html>
|
| 2 |
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="utf-8">
|
| 5 |
+
<title>U.S. Debt Clock – Demo</title>
|
| 6 |
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
| 7 |
+
<style>
|
| 8 |
+
body{font-family:system-ui,Roboto,Arial,sans-serif;
|
| 9 |
+
display:flex;justify-content:center;align-items:center;
|
| 10 |
+
min-height:100vh;margin:0;background:#f5f7fa}
|
| 11 |
+
</style>
|
| 12 |
+
</head>
|
| 13 |
+
<body>
|
| 14 |
+
<div class="ntd-debt-clock"></div>
|
| 15 |
+
<script src="/embed.js" defer></script>
|
| 16 |
+
</body>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
</html>
|