bits support. using local storage to remember selected currency
This commit is contained in:
parent
56c0660c87
commit
8ea1d1e9c4
2
public/js/angularjs-all.min.js
vendored
2
public/js/angularjs-all.min.js
vendored
File diff suppressed because one or more lines are too long
2
public/js/main.min.js
vendored
2
public/js/main.min.js
vendored
File diff suppressed because one or more lines are too long
2
public/js/vendors.min.js
vendored
2
public/js/vendors.min.js
vendored
File diff suppressed because one or more lines are too long
@ -1,6 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var defaultLanguage = localStorage.getItem('insight-language') || 'en';
|
var defaultLanguage = localStorage.getItem('insight-language') || 'en';
|
||||||
|
var defaultCurrency = localStorage.getItem('insight-currency') || 'BTC';
|
||||||
|
|
||||||
angular.module('insight',[
|
angular.module('insight',[
|
||||||
'ngAnimate',
|
'ngAnimate',
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
angular.module('insight.currency').controller('CurrencyController',
|
angular.module('insight.currency').controller('CurrencyController',
|
||||||
function($scope, $rootScope, Currency) {
|
function($scope, $rootScope, Currency) {
|
||||||
|
$rootScope.currency.symbol = defaultCurrency;
|
||||||
|
|
||||||
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;
|
||||||
@ -22,6 +23,9 @@ angular.module('insight.currency').controller('CurrencyController',
|
|||||||
} else if (this.symbol === 'mBTC') {
|
} else if (this.symbol === 'mBTC') {
|
||||||
this.factor = 1000;
|
this.factor = 1000;
|
||||||
response = _roundFloat((value * this.factor), 5);
|
response = _roundFloat((value * this.factor), 5);
|
||||||
|
} else if (this.symbol === 'bits') {
|
||||||
|
this.factor = 1000000;
|
||||||
|
response = _roundFloat((value * this.factor), 2);
|
||||||
} else {
|
} else {
|
||||||
this.factor = 1;
|
this.factor = 1;
|
||||||
response = value;
|
response = value;
|
||||||
@ -37,6 +41,7 @@ angular.module('insight.currency').controller('CurrencyController',
|
|||||||
|
|
||||||
$scope.setCurrency = function(currency) {
|
$scope.setCurrency = function(currency) {
|
||||||
$rootScope.currency.symbol = currency;
|
$rootScope.currency.symbol = currency;
|
||||||
|
localStorage.setItem('insight-currency', currency);
|
||||||
|
|
||||||
if (currency === 'USD') {
|
if (currency === 'USD') {
|
||||||
Currency.get({}, function(res) {
|
Currency.get({}, function(res) {
|
||||||
@ -44,6 +49,8 @@ angular.module('insight.currency').controller('CurrencyController',
|
|||||||
});
|
});
|
||||||
} else if (currency === 'mBTC') {
|
} else if (currency === 'mBTC') {
|
||||||
$rootScope.currency.factor = 1000;
|
$rootScope.currency.factor = 1000;
|
||||||
|
} else if (currency === 'bits') {
|
||||||
|
$rootScope.currency.factor = 1000000;
|
||||||
} else {
|
} else {
|
||||||
$rootScope.currency.factor = 1;
|
$rootScope.currency.factor = 1;
|
||||||
}
|
}
|
||||||
@ -51,7 +58,7 @@ angular.module('insight.currency').controller('CurrencyController',
|
|||||||
|
|
||||||
// Get initial value
|
// Get initial value
|
||||||
Currency.get({}, function(res) {
|
Currency.get({}, function(res) {
|
||||||
$rootScope.currency.bitstamp = res.data.bitstamp;
|
$rootScope.currency.factor = $rootScope.currency.bitstamp = res.data.bitstamp;
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
@ -11,5 +11,8 @@
|
|||||||
<li>
|
<li>
|
||||||
<a href="#" data-ng-click="setCurrency('mBTC')" data-ng-class="{active: currency.symbol == 'mBTC'}">mBTC</a>
|
<a href="#" data-ng-click="setCurrency('mBTC')" data-ng-class="{active: currency.symbol == 'mBTC'}">mBTC</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li>
|
||||||
|
<a href="#" data-ng-click="setCurrency('bits')" data-ng-class="{active: currency.symbol == 'bits'}">bits</a>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user