fix: paginate weinfo times and read min deposit from ranking_info

- weinfo.html now pages times with the API's zero-based page offset instead of block heights\n- bal.js renders page metadata and hides dead next links on the last page\n- index.html and terms.html read amount from /ranking_info/{chain}
This commit is contained in:
2026-11-06 21:10:20 -04:00
parent 33df29b7a8
commit c87ce760e2
4 changed files with 44 additions and 23 deletions

29
bal.js
View File

@@ -77,18 +77,39 @@ async function fetchDataAndPopulateTable(url,params,fnPopulateTable,downloadOpt,
document.getElementById("chainth").innerHTML = chain; document.getElementById("chainth").innerHTML = chain;
const pag = document.getElementById("paginator"); const pag = document.getElementById("paginator");
pag.innerHTML = ""; pag.innerHTML = "";
const currentPage = paginator && paginator.page != null
? paginator.page
: (Number(page) || 0);
const prevPage = paginator && paginator.prev != null
? paginator.prev
: Math.max(currentPage - 1, 0);
const nextPage = paginator && paginator.next != null
? paginator.next
: currentPage + 1;
const hasPrev = paginator && paginator.hasPrev != null
? paginator.hasPrev
: currentPage > 0;
const hasNext = paginator && paginator.hasNext != null
? paginator.hasNext
: true;
// prev (a plain, dimmed arrow on the first page), "page N", next // prev (a plain, dimmed arrow on the first page), "page N", next
if (page > 0) { if (hasPrev) {
pag.appendChild(createlink("‹","?page="+paginator.prev)); pag.appendChild(createlink("‹","?page="+prevPage));
} else { } else {
const off = document.createElement("span"); const off = document.createElement("span");
off.className = "pg-off"; off.innerHTML = "‹"; off.className = "pg-off"; off.innerHTML = "‹";
pag.appendChild(off); pag.appendChild(off);
} }
const lbl = document.createElement("span"); const lbl = document.createElement("span");
lbl.className = "pg-label"; lbl.textContent = "page " + page; lbl.className = "pg-label"; lbl.textContent = "page " + currentPage;
pag.appendChild(lbl); pag.appendChild(lbl);
pag.appendChild(createlink("›","?page="+paginator.next)); if (hasNext) {
pag.appendChild(createlink("›","?page="+nextPage));
} else {
const off = document.createElement("span");
off.className = "pg-off"; off.innerHTML = "›";
pag.appendChild(off);
}
} }
} }

View File

@@ -712,8 +712,9 @@ async function fetchData() {
async function fetchMinAmount() { async function fetchMinAmount() {
const chain = getChain(); const chain = getChain();
try { try {
const r = await fetch('/min_deposit/' + chain); const r = await fetch('/ranking_info/' + chain);
const data = await r.json();
const val = parseInt(data.amount, 10); const val = parseInt(data.amount, 10);
if (isNaN(val)) throw new Error('invalid'); if (isNaN(val)) throw new Error('invalid');
minAmount = val; minAmount = val;

View File

@@ -724,8 +724,9 @@ l-49 -25 -880 0 -880 0 -3 704 c-2 557 0 706 10 713 7 4 407 7 888 5 818 -2
// The #thr-min span is inside Section 1 (01 · PAYMENT). // The #thr-min span is inside Section 1 (01 · PAYMENT).
const chain = location.hash ? location.hash.slice(1) : 'bitcoin'; const chain = location.hash ? location.hash.slice(1) : 'bitcoin';
try { try {
const r = await fetch('/min_deposit/' + chain); const r = await fetch('/ranking_info/' + chain);
const val = parseInt(await r.text(), 10); const data = await r.json();
const val = parseInt(data.amount, 10);
if (!isNaN(val)) { if (!isNaN(val)) {
const txt = Number(val).toLocaleString('en-US'); const txt = Number(val).toLocaleString('en-US');
document.getElementById('thr-min').textContent = txt; document.getElementById('thr-min').textContent = txt;

View File

@@ -166,9 +166,8 @@ footer a{color:var(--accent);text-decoration:none}
<section class="card rounds"> <section class="card rounds">
<div class="head"> <div class="head">
<div><h2>WeTime rounds</h2><div class="note">Each round: the block hash sent by this server and how fast it was. Chain: <span class="mono" id="chainth"></span>. The full list is in the download below.</div></div> <div><h2>WeTime rounds</h2><div class="note">Each round: the block hash sent by this server and how fast it was. Chain: <span class="mono" id="chainth"></span>. The full list is in the download below.</div></div>
<!-- The server returns the latest 100 rounds only (no paging): no prev/next here. --> <!-- The API supports page offsets; bal.js draws the prev/next links here. -->
<div class="pager" id="paginator" hidden></div> <div class="pager" id="paginator"></div>
<span class="badge">Latest 100 rounds</span>
</div> </div>
<div class="table-wrap"> <div class="table-wrap">
<table id="wetimes"> <table id="wetimes">
@@ -348,18 +347,17 @@ footer a{color:var(--accent);text-decoration:none}
} else { } else {
tableBody.innerHTML = '<tr><td colspan="7" style="padding:24px;text-align:center;color:var(--muted)">No rounds yet.</td></tr>'; tableBody.innerHTML = '<tr><td colspan="7" style="padding:24px;text-align:center;color:var(--muted)">No rounds yet.</td></tr>';
} }
var prev=0; const urlParams = new URLSearchParams(window.location.search);
var next=0; const currentPage = Math.max(parseInt(urlParams.get('page') || '0', 10) || 0, 0);
if (data.times && data.times.length > 0){ const pageSize = Math.min(Number(limit) || 100, 100);
prev = data.times[0].blockHeight+data.times.length; const hasNext = !!data.times && data.times.length >= pageSize;
next = data.times[data.times.length-1].blockHeight; return {
if (prev < 0 ){ page: currentPage,
prev = 0; prev: Math.max(currentPage - 1, 0),
} next: currentPage + 1,
} hasPrev: currentPage > 0,
hasNext: hasNext,
const paginator = {prev:prev,next:next}; };
return paginator;
},{elementName:"download",fileName:"weinfo_"+cdate+".json",linkText:"download"}) },{elementName:"download",fileName:"weinfo_"+cdate+".json",linkText:"download"})
} }