diff --git a/public/js/controllers/currency.js b/public/js/controllers/currency.js index bfbf593..e5c7c62 100644 --- a/public/js/controllers/currency.js +++ b/public/js/controllers/currency.js @@ -6,7 +6,26 @@ angular.module('insight.currency').controller('CurrencyController', $rootScope.currency = { factor: 1, bitstamp: 0, - symbol: 'BTC' + symbol: 'BTC', + getConvertion: function(value) { + if (typeof value !== 'undefined' && value !== null) { + var response; + + if (this.symbol === 'USD') { + response = _roundFloat((value * this.factor), 2); + } else if (this.symbol === 'mBTC') { + this.factor = 1000; + response = _roundFloat((value * this.factor), 5); + } else { + this.factor = 1; + response = value; + } + + return response + ' ' + this.symbol; + } + + return 'value error'; + } }; var _roundFloat = function(x, n) { @@ -29,26 +48,6 @@ angular.module('insight.currency').controller('CurrencyController', } }; - $scope.getConvertion = function(value) { - if (typeof value !== 'undefined' && value !== null) { - var response; - - if ($rootScope.currency.symbol === 'USD') { - response = _roundFloat((value * $rootScope.currency.factor), 2); - } else if ($rootScope.currency.symbol === 'mBTC') { - $rootScope.currency.factor = 1000; - response = _roundFloat((value * $rootScope.currency.factor), 5); - } else { - $rootScope.currency.factor = 1; - response = value; - } - - return response + ' ' + $rootScope.currency.symbol; - } - - return 'value error'; - }; - // Get initial value Currency.get({}, function(res) { $rootScope.currency.bitstamp = res.data.bitstamp; diff --git a/public/views/address.html b/public/views/address.html index a8d065c..4c5e9df 100644 --- a/public/views/address.html +++ b/public/views/address.html @@ -12,19 +12,19 @@
Total Received | -{{getConvertion(address.totalReceived)}} | +{{$root.currency.getConvertion(address.totalReceived)}} | |||||||
Total Sent | -{{getConvertion(address.totalSent)}} | +{{$root.currency.getConvertion(address.totalSent)}} | |||||||
Final Balance | -{{getConvertion(address.balance)}} | +{{$root.currency.getConvertion(address.balance)}} | |||||||
No. Transactions | diff --git a/public/views/transaction.html b/public/views/transaction.html index 71f4870..bcf0074 100644 --- a/public/views/transaction.html +++ b/public/views/transaction.html @@ -37,19 +37,19 @@
Total Input | -{{getConvertion(tx.valueIn)}} | +{{$root.currency.getConvertion(tx.valueIn)}} |
Total Output | -{{getConvertion(tx.valueOut)}} | +{{$root.currency.getConvertion(tx.valueOut)}} |
Fees | -{{getConvertion(tx.fees)}} | +{{$root.currency.getConvertion(tx.fees)}} |
- Type - {{vout.scriptPubKey.type}} -
-- scriptPubKey - {{vout.scriptPubKey.asm}} -
- -+ Type + {{vout.scriptPubKey.type}} +
++ scriptPubKey + {{vout.scriptPubKey.asm}} +
+ +