diff --git a/app/controllers/currency.js b/app/controllers/currency.js index 9642e97..244ef32 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 4e9a987..23b6ce8 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 0000000..e5c7c62 --- /dev/null +++ b/public/js/controllers/currency.js @@ -0,0 +1,56 @@ +'use strict'; + +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); + }; + + $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; + } + }; + + // 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 28744bc..047ba1e 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 cf63deb..e5fa3ac 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 c6c8269..4c5e9df 100644 --- a/public/views/address.html +++ b/public/views/address.html @@ -16,15 +16,15 @@ Total Received - {{$root.currency.getConversion(address.totalReceived)}} + {{$root.currency.getConvertion(address.totalReceived)}} Total Sent - {{$root.currency.getConversion(address.totalSent)}} + {{$root.currency.getConvertion(address.totalSent)}} Final Balance - {{$root.currency.getConversion(address.balance)}} + {{$root.currency.getConvertion(address.balance)}} No. Transactions diff --git a/public/views/includes/currency.html b/public/views/includes/currency.html index 3dc3ef2..c9acb46 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 7873536..bcf0074 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)}}{{$root.currency.getConvertion(tx.valueIn)}}
Total Output{{$root.currency.getConversion(tx.valueOut)}}{{$root.currency.getConvertion(tx.valueOut)}}
Fees{{$root.currency.getConversion(tx.fees)}}{{$root.currency.getConvertion(tx.fees)}}
- diff --git a/public/views/transaction/tx.html b/public/views/transaction/tx.html index 154dca2..2d6cce8 100644 --- a/public/views/transaction/tx.html +++ b/public/views/transaction/tx.html @@ -11,109 +11,109 @@
-
-
-
-
{{$root.currency.getConversion(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}}
-
-
-
-
{{$root.currency.getConversion(vin.value)}}
-
- {{vin.addr}} - {{vin.addr}} - {{vin.addr}} -
+
+
+
{{$root.currency.getConvertion(vin.value)}}
+
+    + {{vin.addr}} + {{vin.addr}}
-
-
-
{{$root.currency.getConversion(vin.value)}}
-
-    - {{vin.addr}} - {{vin.addr}} -
-
-
-
-
- - scriptSig - {{vin.scriptSig.asm}} - -
-
-
-
-
-
- - -
-
-
-
-
{{$root.currency.getConversion(vout.value)}}
-
- {{vout.addr}} - {{vout.addr}} - {{address}} -
-
-
-
-
-
{{$root.currency.getConversion(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}} + +
+
+
+
+ +
+
+ + + +
+