This repository was archived by the owner on Nov 25, 2026. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathindex.html
More file actions
597 lines (590 loc) · 23.4 KB
/
Copy pathindex.html
File metadata and controls
597 lines (590 loc) · 23.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
<!DOCTYPE html>
<html lang="zh-Hant">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>SCASH Address Balances Dashboard</title>
<link rel="icon" type="image/png" href="assets\satoshicash.webp" />
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<script src="https://cdn.jsdelivr.net/npm/chartjs-plugin-datalabels@2"></script>
<link rel="stylesheet" href="assets/dashboard.css" />
</head>
<body>
<div class="container">
<div
style="
display: flex;
align-items: center;
justify-content: space-between;
"
>
<h1 style="margin-bottom: 0">
<img
src="assets/satoshicash.webp"
alt="SCASH Logo"
style="height: 48px; vertical-align: middle; margin-right: 12px"
/>
SCASH 地址余额看板
</h1>
<div id="refreshTime" class="refresh-time"></div>
<span
id="refreshCountdownText"
style="margin-left: 12px; font-size: 1em; color: #7c4dff"
></span>
</div>
<div class="flex">
<div class="chart-area">
<canvas
id="pieChart"
width="420"
height="420"
style="
width: 420px;
height: 420px;
display: block;
margin: 0 auto;
max-width: none;
max-height: none;
"
></canvas>
</div>
<div class="table-area">
<h2>
地址余额排行榜
<span
id="top100Total"
style="font-size: 1rem; color: #7c4dff"
></span>
</h2>
<div class="mb-16 collapsible" data-target="rankTable10">
<b>前10名 ▼</b>
</div>
<div class="collapsible-content" id="wrap-rankTable10">
<table id="rankTable10">
<thead>
<tr>
<th class="rank-col">排名</th>
<th class="address-col">地址</th>
<th class="balance-col">余额</th>
<th class="change-col">变动数量</th>
<th class="update-time-col">更新时间</th>
</tr>
</thead>
<tbody class="scrollable-tbody"></tbody>
</table>
</div>
<div class="mt-16 collapsible" data-target="rankTable50">
<b>第11~50名 ▼</b>
</div>
<div class="collapsible-content" id="wrap-rankTable50">
<table id="rankTable50">
<thead>
<tr>
<th class="rank-col">排名</th>
<th class="address-col">地址</th>
<th class="balance-col">余额</th>
<th class="change-col">变动数量</th>
<th class="update-time-col">更新时间</th>
</tr>
</thead>
<tbody class="scrollable-tbody"></tbody>
</table>
</div>
<div class="mt-16 collapsible" data-target="rankTable100">
<b>第51~100名 ▼</b>
</div>
<div class="collapsible-content" id="wrap-rankTable100">
<table id="rankTable100">
<thead>
<tr>
<th class="rank-col">排名</th>
<th class="address-col">地址</th>
<th class="balance-col">余额</th>
<th class="change-col">变动数量</th>
<th class="update-time-col">更新时间</th>
</tr>
</thead>
<tbody class="scrollable-tbody"></tbody>
</table>
</div>
</div>
</div>
<div class="section-title">
<b>大额转账记录(金额 > 500 SCASH,最近100笔)</b>
</div>
<table class="tx-table" id="txTable">
<thead>
<tr>
<th>区块高度</th>
<th>TxID</th>
<th>地址</th>
<th>金额</th>
<th>时间</th>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
<script>
// ========== 資料載入與初始化 ========== //
// 動態插入 dashboard_data.js,並加上隨機參數防快取
const script = document.createElement("script");
script.src =
"assets/dashboard_data.js?v=" +
Math.random().toString(36).substring(2, 10);
script.onload = function () {
// dashboard_data.js 載入完成後再初始化
console.log("addressBalances", addressBalances);
renderPieChart();
renderRankTables();
renderTxTable();
updateTop100Total();
};
document.head.appendChild(script);
// ========== 自動刷新與倒數顯示 ========== //
let countdown = 600; // 10分鐘
function updateRefreshTime() {
const now = new Date();
const pad = (n) => n.toString().padStart(2, "0");
// 顯示倒數(分鐘:秒)
const min = Math.floor(countdown / 60);
const sec = countdown % 60;
document.getElementById(
"refreshCountdownText"
).innerHTML = `<b>(距下次自動刷新:${pad(min)}:${pad(sec)})</b>`;
}
function resetCountdown() {
countdown = 600;
}
setInterval(() => {
countdown--;
if (countdown <= 0) {
fetchDataAndRender();
resetCountdown();
}
updateRefreshTime();
}, 1000);
updateRefreshTime(); // 頁面載入時立即顯示一次
document.getElementById("refreshTime").onclick = function () {
resetCountdown();
location.reload();
};
window.addEventListener("keydown", function (e) {
if (e.key === "F5") resetCountdown();
});
// ========== 折疊排行榜表格功能 ========== //
document.addEventListener("DOMContentLoaded", function () {
// 預設只展開前10名
document.querySelectorAll(".collapsible").forEach(function (btn, idx) {
const target = btn.getAttribute("data-target");
const wrap = document.getElementById("wrap-" + target);
if (idx > 0) {
btn.classList.add("collapsed");
btn.innerHTML = btn.innerHTML.replace("▼", "▲");
wrap.style.maxHeight = "0";
wrap.style.opacity = "0.2";
wrap.style.pointerEvents = "none";
} else {
btn.classList.remove("collapsed");
btn.innerHTML = btn.innerHTML.replace("▲", "▼");
wrap.style.maxHeight = "2000px";
wrap.style.opacity = "1";
wrap.style.pointerEvents = "auto";
}
btn.addEventListener("click", function (e) {
e.stopPropagation();
const isCollapsed = btn.classList.toggle("collapsed");
if (isCollapsed) {
btn.innerHTML = btn.innerHTML.replace("▼", "▲");
wrap.style.maxHeight = "0";
wrap.style.opacity = "0.2";
wrap.style.pointerEvents = "none";
} else {
btn.innerHTML = btn.innerHTML.replace("▲", "▼");
wrap.style.maxHeight = "2000px";
wrap.style.opacity = "1";
wrap.style.pointerEvents = "auto";
}
});
});
});
// ========== 圓餅圖渲染 ========== //
function renderPieChart() {
const ctx = document.getElementById("pieChart").getContext("2d");
const top10 = addressBalances.slice(0, 10);
const group11_50 = addressBalances.slice(10, 50);
const group51_100 = addressBalances.slice(50, 100);
const sum11_50 = group11_50.reduce((a, b) => a + b.balance, 0);
const sum51_100 = group51_100.reduce((a, b) => a + b.balance, 0);
// 標籤顯示
const labels = [
...top10.map(
(x, i) =>
`#${i + 1} ${
x.address.length > 12
? x.address.slice(0, 6) + "..." + x.address.slice(-4)
: x.address
}`
),
"第11~50名合计",
"第51~100名合计",
];
const data = [...top10.map((x) => x.balance), sum11_50, sum51_100];
const colors = [
"#4e79a7",
"#f28e2b",
"#e15759",
"#76b7b2",
"#59a14f",
"#edc949",
"#af7aa1",
"#ff9da7",
"#9c755f",
"#bab0ab",
"#b39ddb",
"#ce93d8",
];
ctx.canvas.onclick = null; // 先移除舊事件
const chart = new Chart(ctx, {
type: "pie",
data: {
labels: labels,
datasets: [{ data: data, backgroundColor: colors }],
},
options: {
responsive: false,
maintainAspectRatio: false,
plugins: {
legend: { position: "bottom" },
title: { display: true, text: "前10+分组地址余额分布" },
datalabels: {
color: "#fff",
font: { weight: "bold", size: 16 },
formatter: function (value, context) {
const total = context.chart.data.datasets[0].data.reduce(
(a, b) => a + b,
0
);
const percent = total ? (value / total) * 100 : 0;
return percent > 2 ? percent.toFixed(1) + "%" : "";
},
},
tooltip: {
callbacks: {
label: function (context) {
if (context.dataIndex < 10) {
const addr = addressBalances[context.dataIndex].address;
return `${context.label}: ${addr} (${context.parsed})`;
}
return `${context.label}: ${context.parsed}`;
},
},
},
},
onClick: (e, elements) => {
if (elements.length > 0) {
const idx = elements[0].index;
if (idx < 10) {
const addr = addressBalances[idx].address;
window.open(`https://scash.one/?search=${addr}`, "_blank");
}
}
},
},
plugins: [ChartDataLabels],
});
}
// ========== 排行榜表格渲染 ========== //
function renderRankTables() {
// 前10
const tbody10 = document.querySelector("#rankTable10 tbody");
tbody10.innerHTML = "";
addressBalances.slice(0, 10).forEach((x, i) => {
const tr = document.createElement("tr");
// 地址顯示前12...後10
const shortAddr =
x.address.length > 12
? `${x.address.slice(0, 12)}...${x.address.slice(-10)}`
: x.address;
const addrLink = `<a href='https://scash.one/?search=${x.address}' target='_blank' rel='noopener' title='${x.address}' style='word-break:break-all;max-width:700px;display:inline-block;'>${shortAddr}</a>`;
let changeCell = "";
let updateTime = x.update_time || x.scan_time || "";
// 轉換格式 yyyy-MM-dd HH:mm:ss -> yyyy/MM/dd HH:mm
let updateDate = "";
if (updateTime) {
const dt = updateTime.split(" ");
if (dt.length === 2) {
const d = dt[0].replace(/-/g, "/");
const t = dt[1].slice(0, 5);
updateDate = `${d} ${t}`;
} else {
updateDate = updateTime.replace(/-/g, "/");
}
}
let updateTimeCell = updateTime ? updateDate : "";
let hasChange = x.change_str && x.change_str !== "0" && x.update_time;
if (hasChange) {
let num = parseFloat(x.change_str);
let str = (Math.round(num * 100) / 100).toFixed(2);
if (num > 0) str = "+" + str;
changeCell = str;
updateTimeCell = `<span style='color:#7c4dff;'>${updateDate}</span>`;
} else {
changeCell = "±0";
}
tr.innerHTML = `<td class='rank-col'>${
i + 1
}</td><td class="address-col">${addrLink}</td><td class="balance-col">${(
Math.round(x.balance * 100) / 100
).toFixed(
2
)}</td><td class="change-col">${changeCell}</td><td class="update-time-col">${updateTimeCell}</td>`;
tbody10.appendChild(tr);
});
// 第11~50名
const tbody50 = document.querySelector("#rankTable50 tbody");
tbody50.innerHTML = "";
addressBalances.slice(10, 50).forEach((x, i) => {
const tr = document.createElement("tr");
const shortAddr =
x.address.length > 12
? `${x.address.slice(0, 12)}...${x.address.slice(-10)}`
: x.address;
const addrLink = `<a href='https://scash.one/?search=${x.address}' target='_blank' rel='noopener' title='${x.address}' style='word-break:break-all;max-width:700px;display:inline-block;'>${shortAddr}</a>`;
let changeCell = "";
let updateTime = x.update_time || x.scan_time || "";
let updateDate = "";
if (updateTime) {
const dt = updateTime.split(" ");
if (dt.length === 2) {
const d = dt[0].replace(/-/g, "/");
const t = dt[1].slice(0, 5);
updateDate = `${d} ${t}`;
} else {
updateDate = updateTime.replace(/-/g, "/");
}
}
let updateTimeCell = updateTime ? updateDate : "";
let hasChange = x.change_str && x.change_str !== "0" && x.update_time;
if (hasChange) {
let num = parseFloat(x.change_str);
let str = (Math.round(num * 100) / 100).toFixed(2);
if (num > 0) str = "+" + str;
changeCell = str;
updateTimeCell = `<span style='color:#7c4dff;'>${updateDate}</span>`;
} else {
changeCell = "±0";
}
tr.innerHTML = `<td class='rank-col'>${
i + 11
}</td><td class="address-col">${addrLink}</td><td class="balance-col">${(
Math.round(x.balance * 100) / 100
).toFixed(
2
)}</td><td class="change-col">${changeCell}</td><td class="update-time-col">${updateTimeCell}</td>`;
tbody50.appendChild(tr);
});
// 第51~100名
const tbody100 = document.querySelector("#rankTable100 tbody");
tbody100.innerHTML = "";
addressBalances.slice(50, 100).forEach((x, i) => {
const tr = document.createElement("tr");
const shortAddr =
x.address.length > 12
? `${x.address.slice(0, 12)}...${x.address.slice(-10)}`
: x.address;
const addrLink = `<a href='https://scash.one/?search=${x.address}' target='_blank' rel='noopener' title='${x.address}' style='word-break:break-all;max-width:700px;display:inline-block;'>${shortAddr}</a>`;
let changeCell = "";
let updateTime = x.update_time || x.scan_time || "";
let updateDate = "";
if (updateTime) {
const dt = updateTime.split(" ");
if (dt.length === 2) {
const d = dt[0].replace(/-/g, "/");
const t = dt[1].slice(0, 5);
updateDate = `${d} ${t}`;
} else {
updateDate = updateTime.replace(/-/g, "/");
}
}
let updateTimeCell = updateTime ? updateDate : "";
let hasChange = x.change_str && x.change_str !== "0" && x.update_time;
if (hasChange) {
let num = parseFloat(x.change_str);
let str = (Math.round(num * 100) / 100).toFixed(2);
if (num > 0) str = "+" + str;
changeCell = str;
updateTimeCell = `<span style='color:#7c4dff;'>${updateDate}</span>`;
} else {
changeCell = "±0";
}
tr.innerHTML = `<td class='rank-col'>${
i + 51
}</td><td class="address-col">${addrLink}</td><td class="balance-col">${(
Math.round(x.balance * 100) / 100
).toFixed(
2
)}</td><td class="change-col">${changeCell}</td><td class="update-time-col">${updateTimeCell}</td>`;
tbody100.appendChild(tr);
});
}
// ========== 大額轉帳記錄表格渲染 ========== //
function renderTxTable() {
const tbody = document.querySelector("#txTable tbody");
tbody.innerHTML = "";
// 取區塊高度最大的最後100筆(新到舊)
const sorted = [...txRecords].sort(
(a, b) =>
b.block_height - a.block_height || b.txid.localeCompare(a.txid)
);
const last100 = sorted.slice(0, 100);
// 前20筆直接顯示
last100.slice(0, 20).forEach((x) => {
const tr = document.createElement("tr");
const blockLink = `<a href='https://scash.one/?search=${x.block_height}' target='_blank' rel='noopener'>${x.block_height}</a>`;
let txidShort = x.txid;
if (txidShort.length > 20) {
txidShort = `${x.txid.slice(0, 10)}...${x.txid.slice(-10)}`;
}
const txidLink = `<a href='https://scash.one/?search=${x.txid}' target='_blank' rel='noopener'>${txidShort}</a>`;
const addrLink = `<a href='https://scash.one/?search=${x.address}' target='_blank' rel='noopener' style='text-align:left;display:inline-block;width:100%;'>${x.address}</a>`;
const amount = (Math.round(x.amount * 100) / 100).toFixed(2);
tr.innerHTML = `<td>${blockLink}</td><td>${txidLink}</td><td style='text-align:left;'>${addrLink}</td><td style='text-align:center;'>${amount}</td><td>${x.transfer_time}</td>`;
tbody.appendChild(tr);
});
// 後80筆摺疊
if (last100.length > 20) {
// 插入摺疊按鈕
const foldTr = document.createElement("tr");
foldTr.id = "txTableFoldBtnTr";
foldTr.innerHTML = `<td colspan='5' style='text-align:center;padding:8px 0;'>
<button id='txTableFoldBtn' style='padding:4px 18px;font-size:1em;cursor:pointer;background:#ede7f6;color:#5e35b1;border:1px solid #d1c4e9;border-radius:4px;'>展開後80筆 ▼</button>
</td>`;
tbody.appendChild(foldTr);
// 後80筆預設隱藏
last100.slice(20).forEach((x, i) => {
const tr = document.createElement("tr");
tr.classList.add("txTableFoldedRow");
tr.style.display = "none";
const blockLink = `<a href='https://scash.one/?search=${x.block_height}' target='_blank' rel='noopener'>${x.block_height}</a>`;
let txidShort = x.txid;
if (txidShort.length > 20) {
txidShort = `${x.txid.slice(0, 10)}...${x.txid.slice(-10)}`;
}
const txidLink = `<a href='https://scash.one/?search=${x.txid}' target='_blank' rel='noopener'>${txidShort}</a>`;
const addrLink = `<a href='https://scash.one/?search=${x.address}' target='_blank' rel='noopener' style='text-align:left;display:inline-block;width:100%;'>${x.address}</a>`;
const amount = (Math.round(x.amount * 100) / 100).toFixed(2);
tr.innerHTML = `<td>${blockLink}</td><td>${txidLink}</td><td style='text-align:left;'>${addrLink}</td><td style='text-align:center;'>${amount}</td><td>${x.transfer_time}</td>`;
tbody.appendChild(tr);
});
// 綁定展開/收合事件
setTimeout(() => {
const btn = document.getElementById("txTableFoldBtn");
let folded = true;
btn.onclick = function () {
folded = !folded;
document.querySelectorAll(".txTableFoldedRow").forEach((tr) => {
tr.style.display = folded ? "none" : "";
});
btn.textContent = folded ? "展開後80筆 ▼" : "收合後80筆 ▲";
};
}, 0);
}
}
// ========== 前100名總持有幣數顯示 ========== //
function updateTop100Total() {
// 前100合計
const total = addressBalances
.slice(0, 100)
.reduce((a, b) => a + (b.balance || 0), 0);
// 以最後一筆最大區塊高度*50 為總量
let maxBlock = 0;
if (txRecords && txRecords.length > 0) {
maxBlock = Math.max(...txRecords.map((x) => x.block_height));
}
const totalSupply = maxBlock * 50;
// 占比
const percent = totalSupply > 0 ? (total / totalSupply) * 100 : 0;
const totalWan = Math.round((total / 10000) * 100) / 100; // 四捨五入到小數點後2位
const supplyWan = Math.round((totalSupply / 10000) * 100) / 100;
const percentStr = percent > 0 ? percent.toFixed(2) : "0.00";
document.getElementById(
"top100Total"
).textContent = `(前100合計:${totalWan} 萬|總量:${supplyWan} 萬|占比:${percentStr}%)`;
}
// ========== 折疊/展開「更新時間」欄位 ========== //
document.addEventListener("click", function (e) {
if (e.target.classList.contains("fold-time")) {
const fold = e.target;
const full = fold.nextElementSibling;
if (full.style.display === "none") {
fold.style.display = "none";
full.style.display = "";
} else {
fold.style.display = "";
full.style.display = "none";
}
} else if (e.target.classList.contains("full-time")) {
const full = e.target;
const fold = full.previousElementSibling;
if (fold.style.display === "none") {
fold.style.display = "";
full.style.display = "none";
}
}
});
</script>
<!-- 底部紫色版权区块 -->
<div class="footer-copyright">
SatoshiCash社区 中本聪现金中文电报社区赞助开发 Copyright 2025-2125 |
<a
href="https://github.com/Honguan/SCASH-Transfer-Query"
target="_blank"
rel="noopener"
>GitHub 项目链接</a
>
<span style="margin-left: 16px">
捐赠地址:
<span id="donateAddr" style="user-select: all; cursor: pointer">
scash1...9dlzn
</span>
<button
id="copyDonateBtn"
style="
margin-left: 4px;
padding: 1px 7px;
font-size: 0.88em;
cursor: pointer;
background: #f8bbf5;
color: #5e35b1;
border: 1px solid #d1c4e9;
border-radius: 4px;
transition: background 0.2s;
"
>
复制
</button>
<span
id="copySuccess"
style="color: rgb(237, 208, 249); display: none; margin-left: 6px"
>复制成功</span
>
</span>
<script>
document.getElementById("copyDonateBtn").onclick = function () {
const addr = "scash1qxz7d3gf9yhequz4v9h0tqkcrrlv5a4nps9dlzn";
navigator.clipboard.writeText(addr).then(function () {
const tip = document.getElementById("copySuccess");
tip.style.display = "";
setTimeout(() => {
tip.style.display = "none";
}, 1200);
});
};
document.getElementById("donateAddr").onclick = function () {
document.getElementById("copyDonateBtn").click();
};
</script>
</div>
</body>
</html>