diff --git a/app/controllers/currency.js b/app/controllers/currency.js index 9642e970..244ef327 100644 --- a/app/controllers/currency.js +++ b/app/controllers/currency.js @@ -48,19 +48,13 @@ exports.index = function(req, res) { res.jsonp({ status: 200, - data: { - bitstamp: bitstampRate, - delay: delay - } + data: { bitstamp: bitstampRate } }); }); } else { res.jsonp({ status: 200, - data: { - bitstamp: bitstampRate, - delay: delay - } + data: { bitstamp: bitstampRate } }); } }; diff --git a/app/views/includes/foot.jade b/app/views/includes/foot.jade index 4e9a987c..23b6ce8b 100755 --- a/app/views/includes/foot.jade +++ b/app/views/includes/foot.jade @@ -35,11 +35,12 @@ script(type='text/javascript', src='/js/services/currency.js') //Application Controllers script(type='text/javascript', src='/js/controllers/index.js') script(type='text/javascript', src='/js/controllers/header.js') +script(type='text/javascript', src='/js/controllers/search.js') script(type='text/javascript', src='/js/controllers/blocks.js') script(type='text/javascript', src='/js/controllers/transactions.js') script(type='text/javascript', src='/js/controllers/address.js') -script(type='text/javascript', src='/js/controllers/search.js') script(type='text/javascript', src='/js/controllers/status.js') script(type='text/javascript', src='/js/controllers/footer.js') script(type='text/javascript', src='/js/controllers/connection.js') +script(type='text/javascript', src='/js/controllers/currency.js') script(type='text/javascript', src='/js/init.js') diff --git a/public/js/controllers/currency.js b/public/js/controllers/currency.js new file mode 100644 index 00000000..e5c7c62c --- /dev/null +++ b/public/js/controllers/currency.js @@ -0,0 +1,56 @@ +'use strict'; + +angular.module('insight.currency').controller('CurrencyController', + function($scope, $rootScope, Currency) { + + $rootScope.currency = { + factor: 1, + bitstamp: 0, + 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) { + if(!parseInt(n, 10) || !parseFloat(x)) n = 0; + + return Math.round(x * Math.pow(10, n)) / Math.pow(10, n); + }; + + $scope.setCurrency = function(currency) { + $rootScope.currency.symbol = currency; + + if (currency === 'USD') { + Currency.get({}, function(res) { + $rootScope.currency.factor = $rootScope.currency.bitstamp = res.data.bitstamp; + }); + } else if (currency === 'mBTC') { + $rootScope.currency.factor = 1000; + } else { + $rootScope.currency.factor = 1; + } + }; + + // Get initial value + Currency.get({}, function(res) { + $rootScope.currency.bitstamp = res.data.bitstamp; + }); + + }); diff --git a/public/js/controllers/footer.js b/public/js/controllers/footer.js index 28744bc3..047ba1e9 100644 --- a/public/js/controllers/footer.js +++ b/public/js/controllers/footer.js @@ -1,52 +1,7 @@ 'use strict'; angular.module('insight.system').controller('FooterController', - function($rootScope, $scope, Version, Currency) { - - var _roundFloat = function(x, n) { - if(!parseInt(n, 10) || !parseFloat(x)) n = 0; - - return Math.round(x * Math.pow(10, n)) / Math.pow(10, n); - }; - - $rootScope.currency = { - factor: 1, - symbol: 'BTC', - bitstamp: 0, - getConversion: function(value) { - if (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 null; - } - }; - - $scope.setCurrency = function(currency) { - if (currency === 'USD') { - Currency.get({}, function(res) { - $rootScope.currency.factor = $rootScope.currency.bitstamp = res.data.bitstamp; - }); - } else if (currency === 'mBTC') { - $rootScope.currency.factor = 1000; - } else { - $rootScope.currency.factor = 1; - } - - $rootScope.currency.symbol = currency; - }; + function($scope, Version) { var _getVersion = function() { Version.get({}, diff --git a/public/js/controllers/header.js b/public/js/controllers/header.js index cf63deb6..e5fa3acd 100755 --- a/public/js/controllers/header.js +++ b/public/js/controllers/header.js @@ -1,13 +1,9 @@ 'use strict'; angular.module('insight.system').controller('HeaderController', - function($scope, $rootScope, getSocket, Global, Block, Currency) { + function($scope, $rootScope, getSocket, Global, Block) { $scope.global = Global; - Currency.get({}, function(res) { - $rootScope.currency.bitstamp = res.data.bitstamp; - }); - $scope.menu = [ { 'title': 'Blocks', diff --git a/public/views/address.html b/public/views/address.html index c6c82695..4c5e9df6 100644 --- a/public/views/address.html +++ b/public/views/address.html @@ -16,15 +16,15 @@
| Total Input | -{{$root.currency.getConversion(tx.valueIn)}} | +{{$root.currency.getConvertion(tx.valueIn)}} |
| Total Output | -{{$root.currency.getConversion(tx.valueOut)}} | +{{$root.currency.getConvertion(tx.valueOut)}} |
| Fees | -{{$root.currency.getConversion(tx.fees)}} | +{{$root.currency.getConvertion(tx.fees)}} |
- Type - {{vout.scriptPubKey.type}} -
-- scriptPubKey - {{vout.scriptPubKey.asm}} -
- -+ Type + {{vout.scriptPubKey.type}} +
++ scriptPubKey + {{vout.scriptPubKey.asm}} +
+ +