Show ETH price, split headline into ETH balance and total USD
Some checks failed
check / check (push) Has been cancelled
Some checks failed
check / check (push) Has been cancelled
Headline shows active address ETH balance with ETH-only USD value in parentheses. Small "Total:" subtitle below includes ETH + token values. A centered well between Send/Receive buttons and the wallet list displays the current ETH price in USD.
This commit is contained in:
@@ -27,17 +27,31 @@ function findActiveAddr() {
|
||||
|
||||
function renderTotalValue() {
|
||||
const el = $("total-value");
|
||||
const subEl = $("total-value-sub");
|
||||
const priceEl = $("eth-price-display");
|
||||
if (!el) return;
|
||||
|
||||
const ethPrice = getPrice("ETH");
|
||||
if (priceEl) {
|
||||
priceEl.textContent = ethPrice ? "ETH " + formatUsd(ethPrice) : "";
|
||||
}
|
||||
|
||||
const addr = findActiveAddr();
|
||||
if (!addr) {
|
||||
el.textContent = "";
|
||||
if (subEl) subEl.textContent = "";
|
||||
return;
|
||||
}
|
||||
const ethBal = parseFloat(addr.balance || "0");
|
||||
const ethStr = ethBal.toFixed(4) + " ETH";
|
||||
const usd = getAddressValueUsd(addr);
|
||||
const usdStr = usd !== null ? " (" + formatUsd(usd) + " USD)" : "";
|
||||
el.textContent = ethStr + usdStr;
|
||||
const ethUsd = ethPrice ? " (" + formatUsd(ethBal * ethPrice) + ")" : "";
|
||||
el.textContent = ethStr + ethUsd;
|
||||
|
||||
if (subEl) {
|
||||
const totalUsd = getAddressValueUsd(addr);
|
||||
subEl.textContent =
|
||||
totalUsd !== null ? "Total: " + formatUsd(totalUsd) : "";
|
||||
}
|
||||
}
|
||||
|
||||
const EXT_ICON =
|
||||
|
||||
Reference in New Issue
Block a user