landing: compact GOA alt display and all-account bank fallback
Wire goa-amount.js into bank/exchange/merchant intros, deploy it with the landings, and deepen the in-container bank stats fallback to scan all accounts (skip only exchange) when the host timer is down.
This commit is contained in:
parent
746d7a41af
commit
48f77139c5
8 changed files with 363 additions and 39 deletions
|
|
@ -30,6 +30,22 @@
|
|||
if (el) el.textContent = v == null || v === "" ? "—" : String(v);
|
||||
}
|
||||
|
||||
function setAmt(id, rowOrAmt, altMap) {
|
||||
var el = document.getElementById(id);
|
||||
if (!el) return;
|
||||
if (window.GoaAmount) {
|
||||
var f = GoaAmount.pick(rowOrAmt, altMap);
|
||||
el.textContent = f.display;
|
||||
if (f.title && f.title !== f.display) el.setAttribute("title", f.title);
|
||||
else el.removeAttribute("title");
|
||||
} else {
|
||||
var raw = rowOrAmt && typeof rowOrAmt === "object"
|
||||
? (rowOrAmt.amount_alt || rowOrAmt.amount || "—")
|
||||
: (rowOrAmt == null || rowOrAmt === "" ? "—" : String(rowOrAmt));
|
||||
el.textContent = raw;
|
||||
}
|
||||
}
|
||||
|
||||
function showFallback(msg) {
|
||||
var box = document.getElementById("stats");
|
||||
var foot = document.getElementById("st-foot");
|
||||
|
|
@ -68,6 +84,7 @@
|
|||
})
|
||||
.then(function (d) {
|
||||
if (!d || !d.ok) throw new Error("bad stats");
|
||||
if (window.GoaAmount) GoaAmount.rememberAlt(d);
|
||||
var w = d.withdraws || {};
|
||||
var h24 = w.last_24h || {};
|
||||
var h7 = w.last_7d || {};
|
||||
|
|
@ -78,10 +95,10 @@
|
|||
var fwd = flow.withdraw || {};
|
||||
set("st-accounts", ba.total != null ? ba.total : "—");
|
||||
set("st-wallets", wl.unique_reserves != null ? wl.unique_reserves : "—");
|
||||
set("st-incoming", fin.amount || flow.total_in || "—");
|
||||
set("st-withdraw", fwd.amount || w.total_amount || "—");
|
||||
set("st-24h", h24.amount || "GOA:0");
|
||||
set("st-7d", h7.amount || "GOA:0");
|
||||
setAmt("st-incoming", fin.amount_alt ? fin : (fin.amount || flow.total_in || "—"), d.alt_unit_names);
|
||||
setAmt("st-withdraw", fwd.amount_alt ? fwd : (fwd.amount || w.total_amount || "—"), d.alt_unit_names);
|
||||
setAmt("st-24h", h24.amount_alt ? h24 : (h24.amount || "GOA:0"), d.alt_unit_names);
|
||||
setAmt("st-7d", h7.amount_alt ? h7 : (h7.amount || "GOA:0"), d.alt_unit_names);
|
||||
|
||||
var list = document.getElementById("st-recent");
|
||||
if (list) {
|
||||
|
|
@ -97,7 +114,13 @@
|
|||
var li = document.createElement("li");
|
||||
var amt = document.createElement("span");
|
||||
amt.className = "amt";
|
||||
amt.textContent = row.amount || "?";
|
||||
if (window.GoaAmount) {
|
||||
var af = GoaAmount.pick(row, d.alt_unit_names);
|
||||
amt.textContent = af.display;
|
||||
if (af.title && af.title !== af.display) amt.setAttribute("title", af.title);
|
||||
} else {
|
||||
amt.textContent = row.amount_alt || row.amount || "?";
|
||||
}
|
||||
var meta = document.createElement("span");
|
||||
meta.className = "meta";
|
||||
meta.textContent = fmtCest(row.at_unix, row.at || row.at_iso) || "";
|
||||
|
|
@ -112,7 +135,8 @@
|
|||
foot.className = "stats-foot";
|
||||
foot.innerHTML =
|
||||
'Source: <a href="' + BANK_INTRO + '">bank.hacktivism.ch</a>' +
|
||||
(d.generated_at_human ? " · " + d.generated_at_human : "");
|
||||
(d.generated_at_human ? " · " + d.generated_at_human : "") +
|
||||
(d.source ? " · " + d.source : "");
|
||||
}
|
||||
})
|
||||
.catch(function () {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue