From 6a8df7d6614ee6c6548acffa80ea1aa50ceee08c Mon Sep 17 00:00:00 2001 From: Nathan Woodburn Date: Thu, 20 Nov 2025 18:15:01 +1100 Subject: [PATCH] fix: Names with different stats --- templates/index.html | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/templates/index.html b/templates/index.html index b3a24a6..be23a9f 100644 --- a/templates/index.html +++ b/templates/index.html @@ -547,6 +547,11 @@ const formatValue = (value) => (value / 1e6).toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2}) + ' HNS'; const formatDate = (timestamp) => new Date(timestamp * 1000).toLocaleString(); + // If name doesn't exist (no info), show error + if (!info) { + return `
Name not found
`; + } + let html = `
@@ -558,7 +563,10 @@
Value: ${formatValue(info.value)}
Highest Bid: ${formatValue(info.highest)}
Renewals: ${info.renewals}
-
Expiry Block: ${info.stats.renewalPeriodEnd.toLocaleString()}
+ ${info.stats.renewalPeriodEnd ? ` +
Expiry Block: ${info.stats.renewalPeriodEnd.toLocaleString()}
+ ` : ''} +
Expired: ${info.expired ? 'Yes' : 'No'}
Revoked: ${info.revoked > 0 ? 'Yes' : 'No'}
Weak: ${info.weak ? 'Yes' : 'No'}
@@ -567,12 +575,27 @@ ${info.stats ? `
-

Expiration Info

+

Additional Info

-
Blocks Until Expire: ${info.stats.blocksUntilExpire.toLocaleString()}
-
Days Until Expire: ${info.stats.daysUntilExpire.toFixed(2)}
-
Renewal Period Start: ${info.stats.renewalPeriodStart.toLocaleString()}
-
Renewal Period End: ${info.stats.renewalPeriodEnd.toLocaleString()}
+ ${Object.entries(info.stats).map(([key, value]) => { + // Format the key from camelCase to Title Case + const formattedKey = key.replace(/([A-Z])/g, ' $1').replace(/^./, str => str.toUpperCase()); + + // Format the value based on type + let formattedValue; + if (typeof value === 'number') { + // Check if it looks like a block number (large integer) or a decimal (days/hours) + if (Number.isInteger(value) && value > 100) { + formattedValue = value.toLocaleString(); + } else { + formattedValue = value.toFixed(2); + } + } else { + formattedValue = value; + } + + return `
${formattedKey}: ${formattedValue}
`; + }).join('')}
` : ''}