initial currency values setted on header controller
This commit is contained in:
parent
e71876f79a
commit
e540112b4b
@ -3,37 +3,32 @@
|
|||||||
angular.module('insight.currency').controller('CurrencyController',
|
angular.module('insight.currency').controller('CurrencyController',
|
||||||
function($scope, $rootScope, Currency) {
|
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) {
|
var _roundFloat = function(x, n) {
|
||||||
if(!parseInt(n, 10) || !parseFloat(x)) n = 0;
|
if(!parseInt(n, 10) || !parseFloat(x)) n = 0;
|
||||||
|
|
||||||
return Math.round(x * Math.pow(10, n)) / Math.pow(10, n);
|
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) {
|
$scope.setCurrency = function(currency) {
|
||||||
$rootScope.currency.symbol = currency;
|
$rootScope.currency.symbol = currency;
|
||||||
|
|
||||||
|
|||||||
@ -4,6 +4,12 @@ angular.module('insight.system').controller('HeaderController',
|
|||||||
function($scope, $rootScope, getSocket, Global, Block) {
|
function($scope, $rootScope, getSocket, Global, Block) {
|
||||||
$scope.global = Global;
|
$scope.global = Global;
|
||||||
|
|
||||||
|
$rootScope.currency = {
|
||||||
|
factor: 1,
|
||||||
|
bitstamp: 0,
|
||||||
|
symbol: 'BTC'
|
||||||
|
};
|
||||||
|
|
||||||
$scope.menu = [
|
$scope.menu = [
|
||||||
{
|
{
|
||||||
'title': 'Blocks',
|
'title': 'Blocks',
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user