Update index.html
Fix random server order: use /datalist (ordered) instead of /data (unordered HashMap)
This commit is contained in:
10
index.html
10
index.html
@@ -461,10 +461,14 @@ async function fetchData() {
|
|||||||
const params = new URLSearchParams({ page: 0, limit: 100 });
|
const params = new URLSearchParams({ page: 0, limit: 100 });
|
||||||
if (!withTor) params.append("onion", "no");
|
if (!withTor) params.append("onion", "no");
|
||||||
try {
|
try {
|
||||||
const response = await fetch(`/data/${chain}?${params}`);
|
// NOTE: /data/{chain} returns a HashMap, whose JSON key order is not
|
||||||
|
// guaranteed (it can change on every backend restart). /datalist/{chain}
|
||||||
|
// returns an ordered array (Vec) that preserves the server-side sort
|
||||||
|
// (donation DESC, balance DESC, base_fee ASC, wetime_points DESC) — see terms.html §3.
|
||||||
|
const response = await fetch(`/datalist/${chain}?${params}`);
|
||||||
if (!response.ok) throw new Error(`HTTP ${response.status}`);
|
if (!response.ok) throw new Error(`HTTP ${response.status}`);
|
||||||
const obj = await response.json();
|
const list = await response.json();
|
||||||
allServers = Object.entries(obj).map(([key, s]) => ({ id: key, ...s }));
|
allServers = list;
|
||||||
render();
|
render();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Fetch error:', err);
|
console.error('Fetch error:', err);
|
||||||
|
|||||||
Reference in New Issue
Block a user