From c258c26925df8d32deb50995ea4182b31376572c Mon Sep 17 00:00:00 2001 From: pbca26 Date: Sun, 5 Feb 2017 19:50:45 +0300 Subject: [PATCH] #70 added decimal places fix --- js/filters/decimalPlacesFormat.js | 7 ++++--- js/lang/en.js | 2 +- js/settings.js | 3 ++- partials/dashboard-main.html | 28 +++++++--------------------- 4 files changed, 14 insertions(+), 26 deletions(-) diff --git a/js/filters/decimalPlacesFormat.js b/js/filters/decimalPlacesFormat.js index beec48b021..de5c87cef9 100644 --- a/js/filters/decimalPlacesFormat.js +++ b/js/filters/decimalPlacesFormat.js @@ -2,7 +2,7 @@ angular.module('IguanaGUIApp') .filter('decimalPlacesFormat', function() { - return function(value, type) { + return function(value, type, limit) { if (value && type) { var valueComponents = value.toString().split('.'), decimalPlaces = { @@ -11,8 +11,10 @@ angular.module('IguanaGUIApp') }; if (value < 1 && value > 0) { - for (var i=valueComponents[1].length; i > -1; i--) { + for (var i=valueComponents[1].length ; i > -1; i--) { if (Number(valueComponents[1][i]) !== 0) { + if (i > settings.maxDecimalPlacesLimit && limit) i = settings.maxDecimalPlacesLimit; // max. decimal places limit + decimalPlaces.coin = i; decimalPlaces.currency = decimalPlaces.coin; break; @@ -26,7 +28,6 @@ angular.module('IguanaGUIApp') if (!valueComponents[1]) { // show only the whole number if right part eq zero decimalPlaces.coin = decimalPlaces.currency = 0; } - } return decimalPlaces ? Number(value).toFixed( diff --git a/js/lang/en.js b/js/lang/en.js index f1fa3a019d..8f2cfe4e0a 100644 --- a/js/lang/en.js +++ b/js/lang/en.js @@ -271,7 +271,7 @@ var lang = { 'DAY': 'day ago', 'DAYS': 'days ago' }, - 'EXPERIMENTAL':{ + 'EXPERIMENTAL': { 'ARE': 'are', 'IS': 'is', 'DASHBOARD_OUT_OF_SYNC_P3': 'out of sync. Information about balances, transactions and send/receive functions is limited.', diff --git a/js/settings.js b/js/settings.js index 4cbb55e6ff..301a246378 100644 --- a/js/settings.js +++ b/js/settings.js @@ -8,7 +8,8 @@ var _settings = { decimalPlacesCoin: 1, decimalPlacesCurrency: 2, decimalPlacesTxUnit: 5, - dashboardUpdateTimout: 15, // sec + maxDecimalPlacesLimit: 8, + dashboardUpdateTimeout: 15, // sec, deprecated defaultCurrency: 'USD', defaultLang: 'EN', portPollUpdateTimeout: 60, // sec diff --git a/partials/dashboard-main.html b/partials/dashboard-main.html index 8aa59a1a6d..4a5bfdf49f 100644 --- a/partials/dashboard-main.html +++ b/partials/dashboard-main.html @@ -5,7 +5,7 @@
{{ 'DASHBOARD.TOTAL_BALANCE' | lang }}
- {{ totalBalance > 0 ? (totalBalance | decimalPlacesFormat: 'currency') : 0 }} + {{ totalBalance > 0 ? (totalBalance | decimalPlacesFormat: 'currency' : true) : 0 }} {{ currency }}
@@ -18,7 +18,8 @@ data-coin-balance-value="{{ item.coinBalanceUnformatted }}" ng-class="{ 'active': ( activeCoin === item.id || activeCoin === $index ) && !util.isMobile(), 'syncing': coinSyncInfo[item.id].loaderBar }" ng-repeat="item in sideBarCoins | orderBy: 'id'" - ng-click="util.isMobile() ? setActiveCoin(item) : ( activeCoin !== item.id ? setActiveCoin(item) : null )"> + ng-click="util.isMobile() ? setActiveCoin(item) : ( activeCoin !== item.id ? setActiveCoin(item) : null )" + title="isIguana ? Blocks: {{ coinSyncInfo[item.id].localBlocks }} / {{ coinSyncInfo[item.id].totalBlocks }} Bundles: {{ coinSyncInfo[item.id].localBundles }} / {{ coinSyncInfo[item.id].totalBundles }}">
@@ -35,26 +36,11 @@
-
{{ item.coinValue > 0 ? (item.coinValue | decimalPlacesFormat: 'coin') : 0 }} {{ item.coinIdUc }}
-
{{ item.currencyValue > 0 ? (item.currencyValue | decimalPlacesFormat: 'currency') : 0 }} {{ item.currencyName }}
+
{{ item.coinValue > 0 ? (item.coinValue | decimalPlacesFormat: 'coin' : true) : 0 }} {{ item.coinIdUc }}
+
{{ item.currencyValue > 0 ? (item.currencyValue | decimalPlacesFormat: 'currency' : true) : 0 }} {{ item.currencyName }}
- @@ -71,11 +57,11 @@ {{ 'DASHBOARD.INFORMATION' | lang }}
- {{ txUnit.activeCoinBalance > 0 ? (txUnit.activeCoinBalance | decimalPlacesFormat: 'coin') : 0 }} + {{ txUnit.activeCoinBalance > 0 ? (txUnit.activeCoinBalance | decimalPlacesFormat: 'coin' : true) : 0 }} {{ activeCoin.toUpperCase() }}
- {{ txUnit.activeCoinBalanceCurrency > 0 ? (txUnit.activeCoinBalanceCurrency | decimalPlacesFormat: 'currency') : 0 }} + {{ txUnit.activeCoinBalanceCurrency > 0 ? (txUnit.activeCoinBalanceCurrency | decimalPlacesFormat: 'currency' : true) : 0 }} {{ currency }}