removed unnecessary CurrencyController calls
This commit is contained in:
parent
398babaa8f
commit
2a4d3f0252
|
@ -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;
|
||||
|
|
|
@ -12,19 +12,19 @@
|
|||
</div>
|
||||
<div class="m20v">
|
||||
<h4>Summary</h4>
|
||||
<table class="table" data-ng-controller="CurrencyController">
|
||||
<table class="table">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="small">Total Received</td>
|
||||
<td class="address ellipsis text-right">{{getConvertion(address.totalReceived)}}</td>
|
||||
<td class="address ellipsis text-right">{{$root.currency.getConvertion(address.totalReceived)}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="small">Total Sent</td>
|
||||
<td class="address ellipsis text-right">{{getConvertion(address.totalSent)}}</td>
|
||||
<td class="address ellipsis text-right">{{$root.currency.getConvertion(address.totalSent)}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="small">Final Balance</td>
|
||||
<td class="address ellipsis text-right">{{getConvertion(address.balance)}}</td>
|
||||
<td class="address ellipsis text-right">{{$root.currency.getConvertion(address.balance)}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="small">No. Transactions</td>
|
||||
|
|
|
@ -37,19 +37,19 @@
|
|||
</div>
|
||||
<div data-ng-show="!tx.isCoinBase">
|
||||
<h2>Inputs and Outputs</h2>
|
||||
<table class="table" data-ng-controller="CurrencyController">
|
||||
<table class="table">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><strong>Total Input</strong></td>
|
||||
<td class="text-muted text-right">{{getConvertion(tx.valueIn)}}</td>
|
||||
<td class="text-muted text-right">{{$root.currency.getConvertion(tx.valueIn)}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Total Output</strong></td>
|
||||
<td class="text-muted text-right">{{getConvertion(tx.valueOut)}}</td>
|
||||
<td class="text-muted text-right">{{$root.currency.getConvertion(tx.valueOut)}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Fees</strong></td>
|
||||
<td class="text-muted text-right">{{getConvertion(tx.fees)}}</td>
|
||||
<td class="text-muted text-right">{{$root.currency.getConvertion(tx.fees)}}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
<div data-ng-controller="CurrencyController">
|
||||
<div class="line-bot row">
|
||||
<div class="col-xs-12 col-md-6">
|
||||
<button class="btn-expand pull-left" data-ng-click="itemsExpanded = !itemsExpanded"><span class="glyphicon glyphicon-plus" data-ng-class="{'glyphicon-minus': itemsExpanded}" tooltip="Show/Hide items details" tooltip-placement="right"></span></button>
|
||||
|
@ -15,7 +14,7 @@
|
|||
<div class="col-md-5">
|
||||
<div class="row" data-ng-show="tx.isCoinBase">
|
||||
<div class="col-md-12 transaction-vin-vout" data-ng-repeat="vin in tx.vin">
|
||||
<div class="text-muted pull-right btc-value"><small>{{getConvertion(vin.reward)}}</small></div>
|
||||
<div class="text-muted pull-right btc-value"><small>{{$root.currency.getConvertion(vin.reward)}}</small></div>
|
||||
<div class="ellipsis">
|
||||
<span>No Inputs (Newly Generated Coins)</span>
|
||||
</div>
|
||||
|
@ -24,7 +23,7 @@
|
|||
<div class="row" data-ng-show="!tx.isCoinBase">
|
||||
<div data-ng-repeat="vin in tx.vinSimple" data-ng-show="!itemsExpanded">
|
||||
<div class="col-md-12 transaction-vin-vout">
|
||||
<div class="text-muted pull-right btc-value" data-ng-class="{'text-danger': $root.currentAddr == vin.addr}"><small>{{getConvertion(vin.value)}}</small></div>
|
||||
<div class="text-muted pull-right btc-value" data-ng-class="{'text-danger': $root.currentAddr == vin.addr}"><small>{{$root.currency.getConvertion(vin.value)}}</small></div>
|
||||
<div class="ellipsis">
|
||||
<span data-ng-show="vin.notAddr">{{vin.addr}}</span>
|
||||
<span class="text-muted" title="Current Bitcoin Address" data-ng-show="vin.addr == $root.currentAddr">{{vin.addr}}</span>
|
||||
|
@ -34,7 +33,7 @@
|
|||
</div>
|
||||
<div data-ng-repeat="vin in tx.vin" data-ng-show="itemsExpanded">
|
||||
<div class="col-md-12 transaction-vin-vout">
|
||||
<div class="text-muted pull-right btc-value"><small>{{getConvertion(vin.value)}}</small></div>
|
||||
<div class="text-muted pull-right btc-value"><small>{{$root.currency.getConvertion(vin.value)}}</small></div>
|
||||
<div class="ellipsis">
|
||||
<a class="glyphicon glyphicon-chevron-right" href="/#!/tx/{{vin.txid}}" title="Outpoint: {{vin.txid}},{{vin.vout}}"></a>
|
||||
<span data-ng-show="vin.notAddr">{{vin.addr}}</span>
|
||||
|
@ -64,7 +63,7 @@
|
|||
<div class="row">
|
||||
<div data-ng-repeat="vout in tx.voutSimple" data-ng-show="!itemsExpanded">
|
||||
<div class="col-md-12 transaction-vin-vout">
|
||||
<div class="text-muted pull-right btc-value" data-ng-class="{'text-success': $root.currentAddr == vout.addr}"><small>{{getConvertion(vout.value)}}</small></div>
|
||||
<div class="text-muted pull-right btc-value" data-ng-class="{'text-success': $root.currentAddr == vout.addr}"><small>{{$root.currency.getConvertion(vout.value)}}</small></div>
|
||||
<div class="ellipsis">
|
||||
<span data-ng-show="vout.notAddr">{{vout.addr}}</span>
|
||||
<span class="text-muted" title="Current Bitcoin Address" data-ng-show="address == $root.currentAddr" data-ng-repeat="address in vout.addr.split(',')">{{vout.addr}}</span>
|
||||
|
@ -74,7 +73,7 @@
|
|||
</div>
|
||||
<div data-ng-repeat="vout in tx.vout" data-ng-show="itemsExpanded">
|
||||
<div class="col-md-12 transaction-vin-vout">
|
||||
<div class="text-muted pull-right btc-value"><small>{{getConvertion(vout.value)}}</small></div>
|
||||
<div class="text-muted pull-right btc-value"><small>{{$root.currency.getConvertion(vout.value)}}</small></div>
|
||||
<div class="ellipsis">
|
||||
<a href="/address/{{address}}" data-ng-repeat="address in vout.scriptPubKey.addresses">{{address}}</a>
|
||||
</div>
|
||||
|
@ -110,12 +109,11 @@
|
|||
</div>
|
||||
<div class="line-top row">
|
||||
<div class="col-xs-4 col-md-6">
|
||||
<button data-ng-show="!tx.isCoinBase" class="btn btn-default">Fees: {{getConvertion(tx.fees)}}</button>
|
||||
<button data-ng-show="!tx.isCoinBase" class="btn btn-default">Fees: {{$root.currency.getConvertion(tx.fees)}}</button>
|
||||
</div>
|
||||
<div class="col-xs-8 col-md-6 text-right">
|
||||
<button data-ng-show="tx.confirmations" class="btn btn-success">{{tx.confirmations}} Confirmations</button>
|
||||
<button data-ng-show="!tx.confirmations" class="btn btn-danger">Unconfirmed Transaction!</button>
|
||||
<button class="btn btn-primary">{{getConvertion(tx.valueOut)}}</button>
|
||||
</div>
|
||||
<button class="btn btn-primary">{{$root.currency.getConvertion(tx.valueOut)}}</button>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue