mirror of
https://gitlab.silvrtree.co.uk/martind2000/old-silvrgit.git
synced 2025-01-26 20:16:17 +00:00
tidying up and eventing the app
This commit is contained in:
parent
929904325f
commit
30b83278f1
22
app/app.js
22
app/app.js
@ -84,7 +84,6 @@
|
|||||||
'Access-Control-Allow-Origin': '*',
|
'Access-Control-Allow-Origin': '*',
|
||||||
'Access-Control-Allow-Methods': 'PUT, GET, POST, DELETE, OPTIONS',
|
'Access-Control-Allow-Methods': 'PUT, GET, POST, DELETE, OPTIONS',
|
||||||
'Access-Control-Allow-Headers': 'Content-Type'
|
'Access-Control-Allow-Headers': 'Content-Type'
|
||||||
|
|
||||||
},
|
},
|
||||||
success: function (data) {
|
success: function (data) {
|
||||||
self.trigger('displayWeather', data);
|
self.trigger('displayWeather', data);
|
||||||
@ -137,6 +136,11 @@
|
|||||||
elm.html("£1 = $" + parseFloat(data.gpbe.toFixed(2)) + " = " + parseFloat(data.sekex.toFixed(2)) + " SEK");
|
elm.html("£1 = $" + parseFloat(data.gpbe.toFixed(2)) + " = " + parseFloat(data.sekex.toFixed(2)) + " SEK");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.bind('updateFX', function (data) {
|
||||||
|
$('#fx').html("£1 = $" + parseFloat(data.gpbe.toFixed(2)) + " = " + parseFloat(data.sekex.toFixed(2)) + " SEK");
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
var btcValue = function () {
|
var btcValue = function () {
|
||||||
var url = '/btc';
|
var url = '/btc';
|
||||||
|
|
||||||
@ -193,7 +197,6 @@
|
|||||||
|
|
||||||
},
|
},
|
||||||
success: function (data) {
|
success: function (data) {
|
||||||
//console.log(data);
|
|
||||||
var gpbex = (1 / data.rates.GBP);
|
var gpbex = (1 / data.rates.GBP);
|
||||||
var sekex = (gpbex * data.rates.SEK);
|
var sekex = (gpbex * data.rates.SEK);
|
||||||
var fxdata = {
|
var fxdata = {
|
||||||
@ -203,10 +206,7 @@
|
|||||||
gpbe: gpbex,
|
gpbe: gpbex,
|
||||||
sekex: sekex
|
sekex: sekex
|
||||||
};
|
};
|
||||||
// console.log(fxdata);
|
self.trigger('updateFX', fxdata);
|
||||||
//var fxdata = data.bpi.GBP.rate_float, usd = data.bpi.USD.rate_float;
|
|
||||||
|
|
||||||
updateFX(fxdata);
|
|
||||||
},
|
},
|
||||||
error: function (xhr, type) {
|
error: function (xhr, type) {
|
||||||
console.log("ajax error");
|
console.log("ajax error");
|
||||||
@ -216,6 +216,10 @@
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.bind('getFX', function () {
|
||||||
|
getFX();
|
||||||
|
});
|
||||||
|
|
||||||
var getNextTrainTime = function (toStation, fromStation) {
|
var getNextTrainTime = function (toStation, fromStation) {
|
||||||
var url = '/getnexttraintimes?from=' + fromStation + '&to=' + toStation;
|
var url = '/getnexttraintimes?from=' + fromStation + '&to=' + toStation;
|
||||||
var target = fromStation + toStation;
|
var target = fromStation + toStation;
|
||||||
@ -227,7 +231,6 @@
|
|||||||
|
|
||||||
timeout: 10000,
|
timeout: 10000,
|
||||||
|
|
||||||
//contentType: ('application/json'),
|
|
||||||
headers: {
|
headers: {
|
||||||
'Access-Control-Allow-Origin': '*',
|
'Access-Control-Allow-Origin': '*',
|
||||||
'Access-Control-Allow-Methods': 'PUT, GET, POST, DELETE, OPTIONS',
|
'Access-Control-Allow-Methods': 'PUT, GET, POST, DELETE, OPTIONS',
|
||||||
@ -313,7 +316,6 @@
|
|||||||
|
|
||||||
timeout: 10000,
|
timeout: 10000,
|
||||||
|
|
||||||
//contentType: ('application/json'),
|
|
||||||
headers: {
|
headers: {
|
||||||
'Access-Control-Allow-Origin': '*',
|
'Access-Control-Allow-Origin': '*',
|
||||||
'Access-Control-Allow-Methods': 'PUT, GET, POST, DELETE, OPTIONS',
|
'Access-Control-Allow-Methods': 'PUT, GET, POST, DELETE, OPTIONS',
|
||||||
@ -334,7 +336,7 @@
|
|||||||
tick();
|
tick();
|
||||||
get_weather();
|
get_weather();
|
||||||
self.trigger('getBTC');
|
self.trigger('getBTC');
|
||||||
getFX();
|
self.trigger('getFX');
|
||||||
getNextTrainTime('dbe', 'glq');
|
getNextTrainTime('dbe', 'glq');
|
||||||
getNextTrainTime('glq', 'dbe');
|
getNextTrainTime('glq', 'dbe');
|
||||||
|
|
||||||
@ -348,7 +350,7 @@
|
|||||||
|
|
||||||
_slowTimer = setInterval(function () {
|
_slowTimer = setInterval(function () {
|
||||||
|
|
||||||
getFX();
|
self.trigger('getFX');
|
||||||
get_weather();
|
get_weather();
|
||||||
}, (60000 * 15));
|
}, (60000 * 15));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user