diff --git a/app/app.js b/app/app.js index 0504375..e627ea8 100644 --- a/app/app.js +++ b/app/app.js @@ -84,7 +84,6 @@ 'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Methods': 'PUT, GET, POST, DELETE, OPTIONS', 'Access-Control-Allow-Headers': 'Content-Type' - }, success: function (data) { self.trigger('displayWeather', data); @@ -137,6 +136,11 @@ 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 url = '/btc'; @@ -193,7 +197,6 @@ }, success: function (data) { - //console.log(data); var gpbex = (1 / data.rates.GBP); var sekex = (gpbex * data.rates.SEK); var fxdata = { @@ -203,10 +206,7 @@ gpbe: gpbex, sekex: sekex }; - // console.log(fxdata); - //var fxdata = data.bpi.GBP.rate_float, usd = data.bpi.USD.rate_float; - - updateFX(fxdata); + self.trigger('updateFX', fxdata); }, error: function (xhr, type) { console.log("ajax error"); @@ -216,6 +216,10 @@ }); }; + this.bind('getFX', function () { + getFX(); + }); + var getNextTrainTime = function (toStation, fromStation) { var url = '/getnexttraintimes?from=' + fromStation + '&to=' + toStation; var target = fromStation + toStation; @@ -227,7 +231,6 @@ timeout: 10000, - //contentType: ('application/json'), headers: { 'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Methods': 'PUT, GET, POST, DELETE, OPTIONS', @@ -313,7 +316,6 @@ timeout: 10000, - //contentType: ('application/json'), headers: { 'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Methods': 'PUT, GET, POST, DELETE, OPTIONS', @@ -334,7 +336,7 @@ tick(); get_weather(); self.trigger('getBTC'); - getFX(); + self.trigger('getFX'); getNextTrainTime('dbe', 'glq'); getNextTrainTime('glq', 'dbe'); @@ -348,7 +350,7 @@ _slowTimer = setInterval(function () { - getFX(); + self.trigger('getFX'); get_weather(); }, (60000 * 15));