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..bfbf593a
--- /dev/null
+++ b/public/js/controllers/currency.js
@@ -0,0 +1,57 @@
+'use strict';
+
+angular.module('insight.currency').controller('CurrencyController',
+ function($scope, $rootScope, Currency) {
+
+ $rootScope.currency = {
+ factor: 1,
+ bitstamp: 0,
+ symbol: 'BTC'
+ };
+
+ 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;
+ }
+ };
+
+ $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/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..a8d065cb 100644
--- a/public/views/address.html
+++ b/public/views/address.html
@@ -12,19 +12,19 @@
Summary
-
+
Total Received |
- {{$root.currency.getConversion(address.totalReceived)}} |
+ {{getConvertion(address.totalReceived)}} |
Total Sent |
- {{$root.currency.getConversion(address.totalSent)}} |
+ {{getConvertion(address.totalSent)}} |
Final Balance |
- {{$root.currency.getConversion(address.balance)}} |
+ {{getConvertion(address.balance)}} |
No. Transactions |
diff --git a/public/views/includes/currency.html b/public/views/includes/currency.html
index 3dc3ef22..c9acb46c 100644
--- a/public/views/includes/currency.html
+++ b/public/views/includes/currency.html
@@ -1,8 +1,8 @@
-
+
Currency:
- USD ·
- BTC ·
- mBTC
+ USD ·
+ BTC ·
+ mBTC
diff --git a/public/views/transaction.html b/public/views/transaction.html
index 78735363..71f48700 100644
--- a/public/views/transaction.html
+++ b/public/views/transaction.html
@@ -27,36 +27,32 @@
-
- Details
+ Details
View information about a bitcoin transaction
-
-
Inputs and Outputs
-
+
Total Input |
- {{$root.currency.getConversion(tx.valueIn)}} |
+ {{getConvertion(tx.valueIn)}} |
Total Output |
- {{$root.currency.getConversion(tx.valueOut)}} |
+ {{getConvertion(tx.valueOut)}} |
Fees |
- {{$root.currency.getConversion(tx.fees)}} |
+ {{getConvertion(tx.fees)}} |
-
diff --git a/public/views/transaction/tx.html b/public/views/transaction/tx.html
index 154dca21..18d8595d 100644
--- a/public/views/transaction/tx.html
+++ b/public/views/transaction/tx.html
@@ -1,20 +1,21 @@
-
-
-
-
-
-
{{tx.txid}}
+
+
+
+
+
-
-
-
-
-
+
-
{{$root.currency.getConversion(vin.reward)}}
+
{{getConvertion(vin.reward)}}
No Inputs (Newly Generated Coins)
@@ -23,7 +24,7 @@
-
{{$root.currency.getConversion(vin.value)}}
+
{{getConvertion(vin.value)}}
{{vin.addr}}
{{vin.addr}}
@@ -33,7 +34,7 @@
-
{{$root.currency.getConversion(vin.value)}}
+
{{getConvertion(vin.value)}}
{{vin.addr}}
@@ -63,7 +64,7 @@
-
{{$root.currency.getConversion(vout.value)}}
+
{{getConvertion(vout.value)}}
{{vout.addr}}
{{vout.addr}}
@@ -73,7 +74,7 @@
-
{{$root.currency.getConversion(vout.value)}}
+
{{getConvertion(vout.value)}}
@@ -101,7 +102,7 @@
- BlockHash
+ BlockHash
{{tx.blockhash}}
@@ -109,11 +110,12 @@
-
+
-
+
+