Truncate counterparty address in tx list based on amount width
All checks were successful
check / check (push) Successful in 14s
All checks were successful
check / check (push) Successful in 14s
For every character beyond 10 in the amount string (e.g. "17.1900 USDT" is 12 chars, 2 excess), remove that many characters from the middle of the counterparty address, replaced with an ellipsis. Hover shows the full address; clicking goes to tx detail which also shows it in full. Prevents the address from wrapping onto a second line.
This commit is contained in:
@@ -65,6 +65,16 @@ function timeAgo(timestamp) {
|
|||||||
return years + " year" + (years !== 1 ? "s" : "") + " ago";
|
return years + " year" + (years !== 1 ? "s" : "") + " ago";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function truncateAddress(address, amountLen) {
|
||||||
|
const excess = amountLen - 10;
|
||||||
|
if (excess <= 0) return address;
|
||||||
|
const charsToRemove = excess;
|
||||||
|
const available = address.length - charsToRemove - 1;
|
||||||
|
if (available < 10) return address;
|
||||||
|
const half = Math.floor(available / 2);
|
||||||
|
return address.slice(0, half) + "\u2026" + address.slice(-half);
|
||||||
|
}
|
||||||
|
|
||||||
function escapeHtml(s) {
|
function escapeHtml(s) {
|
||||||
const div = document.createElement("div");
|
const div = document.createElement("div");
|
||||||
div.textContent = s;
|
div.textContent = s;
|
||||||
@@ -115,14 +125,16 @@ function renderTransactions(txs) {
|
|||||||
line1.appendChild(age);
|
line1.appendChild(age);
|
||||||
line1.appendChild(dir);
|
line1.appendChild(dir);
|
||||||
|
|
||||||
|
const amountStr = tx.value + " " + tx.symbol;
|
||||||
const line2 = document.createElement("div");
|
const line2 = document.createElement("div");
|
||||||
line2.className = "flex justify-between";
|
line2.className = "flex justify-between";
|
||||||
const addr = document.createElement("span");
|
const addr = document.createElement("span");
|
||||||
addr.className = "break-all pr-2";
|
addr.className = "pr-2";
|
||||||
addr.textContent = counterparty;
|
addr.textContent = truncateAddress(counterparty, amountStr.length);
|
||||||
|
addr.title = counterparty;
|
||||||
const amount = document.createElement("span");
|
const amount = document.createElement("span");
|
||||||
amount.className = "shrink-0";
|
amount.className = "shrink-0";
|
||||||
amount.textContent = tx.value + " " + tx.symbol;
|
amount.textContent = amountStr;
|
||||||
line2.appendChild(addr);
|
line2.appendChild(addr);
|
||||||
line2.appendChild(amount);
|
line2.appendChild(amount);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user