Tidying other modules, fixing password and fx

This commit is contained in:
Martin Donnelly 2017-09-11 16:30:37 +01:00
parent 0a937198a4
commit 19c3711550

View File

@ -29,7 +29,8 @@ const BitcoinModel = Backbone.Model.extend({
const btcupdateFn = function() { const btcupdateFn = function() {
this.update(); this.update();
}; };
setTimeout(btcupdateFn.bind(this), mod + 10); console.log('>> btc timeout disabled');
// setTimeout(btcupdateFn.bind(this), mod + 10);
}, },
'updateHourly': function () { 'updateHourly': function () {
this.getBalance(); this.getBalance();
@ -37,9 +38,10 @@ const BitcoinModel = Backbone.Model.extend({
const mod = 3600000 - (now.getTime() % 3600000); const mod = 3600000 - (now.getTime() % 3600000);
const btcupdateFn = function() { const btcupdateFn = function() {
this.update(); this.updateHourly();
}; };
setTimeout(btcupdateFn.bind(this), mod + 10); console.log('>> balance timeout disabled');
// setTimeout(btcupdateFn.bind(this), mod + 10);
}, },
'recalc': function () { 'recalc': function () {
let data = this.get('btcdata'); let data = this.get('btcdata');
@ -95,6 +97,7 @@ const BitcoinModel = Backbone.Model.extend({
// total = myBTC * g; // total = myBTC * g;
}, },
'getBTC': function () { 'getBTC': function () {
console.log('>> getBTC');
const self = this; const self = this;
const url = this.get('url'); const url = this.get('url');
$.ajax({ $.ajax({
@ -154,6 +157,27 @@ const BitcoinModel = Backbone.Model.extend({
console.log(type); console.log(type);
} }
}); });
},
'btcFromSocket': function (data) {
let self = this;
console.log('>> btc from the socket', data);
const gbp = data.bpi.GBP.rate_float;
const usd = data.bpi.USD.rate_float;
const trend = data.trend;
const btcdata = self.get('btcdata');
btcdata.gbp = gbp;
btcdata.usd = usd;
btcdata.trend = trend;
self.set('btcdata', btcdata);
self.recalc();
},
'balanceFromSocket': function (data) {
let self = this;
console.log('>> balance from the socket', data);
const balance = data.balance;
self.set('balance', balance);
self.recalc();
} }
}); });
const Bitcoin = Backbone.View.extend({ const Bitcoin = Backbone.View.extend({