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;
const pag = document.getElementById("paginator");
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
if (page > 0) {
pag.appendChild(createlink("‹","?page="+paginator.prev));
if (hasPrev) {
pag.appendChild(createlink("‹","?page="+prevPage));
} else {
const off = document.createElement("span");
off.className = "pg-off"; off.innerHTML = "‹";
pag.appendChild(off);
}
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(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() {
const chain = getChain();
try {
const r = await fetch('/min_deposit/' + chain);
try {
const r = await fetch('/ranking_info/' + chain);
const data = await r.json();
const val = parseInt(data.amount, 10);
if (isNaN(val)) throw new Error('invalid');
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).
const chain = location.hash ? location.hash.slice(1) : 'bitcoin';
try {
const r = await fetch('/min_deposit/' + chain);
const val = parseInt(await r.text(), 10);
const r = await fetch('/ranking_info/' + chain);
const data = await r.json();
const val = parseInt(data.amount, 10);
if (!isNaN(val)) {
const txt = Number(val).toLocaleString('en-US');
document.getElementById('thr-min').textContent = txt;

View File

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