From 2a4d3f025285894a90c643d514f803edd40faa92 Mon Sep 17 00:00:00 2001 From: Mario Colque Date: Fri, 7 Feb 2014 15:13:09 -0300 Subject: [PATCH] removed unnecessary CurrencyController calls --- public/js/controllers/currency.js | 41 +++--- public/views/address.html | 8 +- public/views/transaction.html | 8 +- public/views/transaction/tx.html | 204 +++++++++++++++--------------- 4 files changed, 129 insertions(+), 132 deletions(-) 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 @@

Summary

- +
- + - + - + 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 @@

Inputs and Outputs

-
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
+
- + - + - +
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)}}
diff --git a/public/views/transaction/tx.html b/public/views/transaction/tx.html index 18d8595..2d6cce8 100644 --- a/public/views/transaction/tx.html +++ b/public/views/transaction/tx.html @@ -1,121 +1,119 @@ -
-
-
- - - -
-
- +
+
+ + +
-
-
-
-
-
{{getConvertion(vin.reward)}}
+
+ +
+
+
+
+
+
+
{{$root.currency.getConvertion(vin.reward)}}
+
+ No Inputs (Newly Generated Coins) +
+
+
+
+
+
+
{{$root.currency.getConvertion(vin.value)}}
- No Inputs (Newly Generated Coins) + {{vin.addr}} + {{vin.addr}} + {{vin.addr}}
-
-
-
-
{{getConvertion(vin.value)}}
-
- {{vin.addr}} - {{vin.addr}} - {{vin.addr}} -
+
+
+
{{$root.currency.getConvertion(vin.value)}}
+
+    + {{vin.addr}} + {{vin.addr}}
-
-
-
{{getConvertion(vin.value)}}
-
-    - {{vin.addr}} - {{vin.addr}} -
-
-
-
-
- - scriptSig - {{vin.scriptSig.asm}} - -
-
-
-
-
-
- - -
-
-
-
-
{{getConvertion(vout.value)}}
-
- {{vout.addr}} - {{vout.addr}} - {{address}} -
-
-
-
-
-
{{getConvertion(vout.value)}}
- -
-
-
-
- -

- Type - {{vout.scriptPubKey.type}} -

-

- scriptPubKey - {{vout.scriptPubKey.asm}} -

-
-
+
+
+
+ + scriptSig + {{vin.scriptSig.asm}} +
-
-
- - BlockHash - {{tx.blockhash}} - - -
+ -
-
- -
-
- - - + +
+
+
+
+
{{$root.currency.getConvertion(vout.value)}}
+
+ {{vout.addr}} + {{vout.addr}} + {{address}} +
+
+
+
+
+
{{$root.currency.getConvertion(vout.value)}}
+ +
+
+
+
+ +

+ Type + {{vout.scriptPubKey.type}} +

+

+ scriptPubKey + {{vout.scriptPubKey.asm}} +

+
+
+
+
+
+
+
+ + BlockHash + {{tx.blockhash}} + + +
+
+
+
+ +
+
+ + + +
+