From e540112b4b63f77c14898c9cc9e4f02aa6a69d2b Mon Sep 17 00:00:00 2001 From: Mario Colque Date: Fri, 7 Feb 2014 15:44:19 -0300 Subject: [PATCH] initial currency values setted on header controller --- public/js/controllers/currency.js | 45 ++++++++++++++----------------- public/js/controllers/header.js | 6 +++++ 2 files changed, 26 insertions(+), 25 deletions(-) diff --git a/public/js/controllers/currency.js b/public/js/controllers/currency.js index e5c7c62..ad68f95 100644 --- a/public/js/controllers/currency.js +++ b/public/js/controllers/currency.js @@ -3,37 +3,32 @@ 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); }; + $rootScope.currency.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'; + }; + $scope.setCurrency = function(currency) { $rootScope.currency.symbol = currency; diff --git a/public/js/controllers/header.js b/public/js/controllers/header.js index e5fa3ac..7147272 100755 --- a/public/js/controllers/header.js +++ b/public/js/controllers/header.js @@ -4,6 +4,12 @@ angular.module('insight.system').controller('HeaderController', function($scope, $rootScope, getSocket, Global, Block) { $scope.global = Global; + $rootScope.currency = { + factor: 1, + bitstamp: 0, + symbol: 'BTC' + }; + $scope.menu = [ { 'title': 'Blocks',