aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/util.js
diff options
context:
space:
mode:
authorDan Finlay <dan@danfinlay.com>2016-08-19 22:57:35 +0800
committerDan Finlay <dan@danfinlay.com>2016-08-19 22:57:35 +0800
commit8592ffd85582612ae18b5f4e5ed6749401f86f3b (patch)
tree2699144c48878f637e202235e6a56bdef8e90766 /ui/app/util.js
parentfe5fff3248bd40803db3b9f3553728d9693e740d (diff)
parent9c29328085fbad82ce7bce4659ce6968405a7b3c (diff)
downloadtangerine-wallet-browser-8592ffd85582612ae18b5f4e5ed6749401f86f3b.tar
tangerine-wallet-browser-8592ffd85582612ae18b5f4e5ed6749401f86f3b.tar.gz
tangerine-wallet-browser-8592ffd85582612ae18b5f4e5ed6749401f86f3b.tar.bz2
tangerine-wallet-browser-8592ffd85582612ae18b5f4e5ed6749401f86f3b.tar.lz
tangerine-wallet-browser-8592ffd85582612ae18b5f4e5ed6749401f86f3b.tar.xz
tangerine-wallet-browser-8592ffd85582612ae18b5f4e5ed6749401f86f3b.tar.zst
tangerine-wallet-browser-8592ffd85582612ae18b5f4e5ed6749401f86f3b.zip
Merge branch 'master' into i390-TransactionLimit
Diffstat (limited to 'ui/app/util.js')
-rw-r--r--ui/app/util.js15
1 files changed, 10 insertions, 5 deletions
diff --git a/ui/app/util.js b/ui/app/util.js
index e1fd6e399..2d1c753dd 100644
--- a/ui/app/util.js
+++ b/ui/app/util.js
@@ -141,16 +141,21 @@ function shortenBalance (balance, decimalsToKeep = 1) {
var convertedBalance = parseFloat(balance)
if (convertedBalance > 1000000) {
truncatedValue = (balance / 1000000).toFixed(decimalsToKeep)
- return `>${truncatedValue}m`
+ return `${truncatedValue}m`
} else if (convertedBalance > 1000) {
truncatedValue = (balance / 1000).toFixed(decimalsToKeep)
- return `>${truncatedValue}k`
+ return `${truncatedValue}k`
} else if (convertedBalance === 0) {
return '0'
+ } else if (convertedBalance < 0.001) {
+ return '<0.001'
} else if (convertedBalance < 1) {
- var exponent = balance.match(/\.0*/)[0].length
- truncatedValue = (convertedBalance * Math.pow(10, exponent)).toFixed(decimalsToKeep)
- return `<${truncatedValue}e-${exponent}`
+ var stringBalance = convertedBalance.toString()
+ if (stringBalance.split('.')[1].length > 3) {
+ return convertedBalance.toFixed(3)
+ } else {
+ return stringBalance
+ }
} else {
return convertedBalance.toFixed(decimalsToKeep)
}