Browse Source

bits support. using local storage to remember selected currency

generic-ui
Gustavo Maximiliano Cortez 10 years ago
parent
commit
8ea1d1e9c4
  1. 2
      public/js/angularjs-all.min.js
  2. 2
      public/js/main.min.js
  3. 2
      public/js/vendors.min.js
  4. 1
      public/src/js/app.js
  5. 9
      public/src/js/controllers/currency.js
  6. 3
      public/views/includes/currency.html

2
public/js/angularjs-all.min.js

File diff suppressed because one or more lines are too long

2
public/js/main.min.js

File diff suppressed because one or more lines are too long

2
public/js/vendors.min.js

File diff suppressed because one or more lines are too long

1
public/src/js/app.js

@ -1,6 +1,7 @@
'use strict';
var defaultLanguage = localStorage.getItem('insight-language') || 'en';
var defaultCurrency = localStorage.getItem('insight-currency') || 'BTC';
angular.module('insight',[
'ngAnimate',

9
public/src/js/controllers/currency.js

@ -2,6 +2,7 @@
angular.module('insight.currency').controller('CurrencyController',
function($scope, $rootScope, Currency) {
$rootScope.currency.symbol = defaultCurrency;
var _roundFloat = function(x, n) {
if(!parseInt(n, 10) || !parseFloat(x)) n = 0;
@ -22,6 +23,9 @@ angular.module('insight.currency').controller('CurrencyController',
} else if (this.symbol === 'mBTC') {
this.factor = 1000;
response = _roundFloat((value * this.factor), 5);
} else if (this.symbol === 'bits') {
this.factor = 1000000;
response = _roundFloat((value * this.factor), 2);
} else {
this.factor = 1;
response = value;
@ -37,6 +41,7 @@ angular.module('insight.currency').controller('CurrencyController',
$scope.setCurrency = function(currency) {
$rootScope.currency.symbol = currency;
localStorage.setItem('insight-currency', currency);
if (currency === 'USD') {
Currency.get({}, function(res) {
@ -44,6 +49,8 @@ angular.module('insight.currency').controller('CurrencyController',
});
} else if (currency === 'mBTC') {
$rootScope.currency.factor = 1000;
} else if (currency === 'bits') {
$rootScope.currency.factor = 1000000;
} else {
$rootScope.currency.factor = 1;
}
@ -51,7 +58,7 @@ angular.module('insight.currency').controller('CurrencyController',
// Get initial value
Currency.get({}, function(res) {
$rootScope.currency.bitstamp = res.data.bitstamp;
$rootScope.currency.factor = $rootScope.currency.bitstamp = res.data.bitstamp;
});
});

3
public/views/includes/currency.html

@ -11,5 +11,8 @@
<li>
<a href="#" data-ng-click="setCurrency('mBTC')" data-ng-class="{active: currency.symbol == 'mBTC'}">mBTC</a>
</li>
<li>
<a href="#" data-ng-click="setCurrency('bits')" data-ng-class="{active: currency.symbol == 'bits'}">bits</a>
</li>
</ul>

Loading…
Cancel
Save