From a6f765c6a1c0d5f53f1d9304b4a006dfdb8f2f64 Mon Sep 17 00:00:00 2001 From: Martin Donnelly Date: Tue, 4 Aug 2015 17:09:42 +0100 Subject: [PATCH] work --- app/app.js | 35 ++++ app/app.min.js | 2 +- app/app.min.js.map | 2 +- app/newslack.html | 418 +++++++++++++++++++++---------------------- lib/train.js | 110 +++++------- lib/train.min.js | 2 +- lib/train.min.js.map | 2 +- 7 files changed, 284 insertions(+), 287 deletions(-) diff --git a/app/app.js b/app/app.js index db9ccdb..d246c8b 100644 --- a/app/app.js +++ b/app/app.js @@ -248,6 +248,39 @@ }); }; + var getGLQDBE = function () { + + var url = '/glqdbe'; + + $.ajax({ + type: 'GET', + url: url, + data: '', + dataType: 'json', + + timeout: 10000, + + //contentType: ('application/json'), + headers: { + 'Access-Control-Allow-Origin': '*', + 'Access-Control-Allow-Methods': 'PUT, GET, POST, DELETE, OPTIONS', + 'Access-Control-Allow-Headers': 'Content-Type' + + }, + success: function (data) { + console.log(data); + + updateTrain('glqdbe',data); + //updateFX(fxdata); + }, + error: function (xhr, type) { + console.log("ajax error"); + console.log(xhr); + console.log(type); + } + }); + }; + var updateTrain = function (n, obj) { var elm = $('#'+n); @@ -268,12 +301,14 @@ btcValue(); getFX(); getDBEGLQ(); + getGLQDBE(); // start 15 minute timer _fastTimer = setInterval(function () { btcValue(); getDBEGLQ(); + getGLQDBE(); }, (60000)); _slowTimer = setInterval(function () { diff --git a/app/app.min.js b/app/app.min.js index 9f04c86..1deaeb2 100644 --- a/app/app.min.js +++ b/app/app.min.js @@ -1,2 +1,2 @@ -!function(){var e,t=0,o=0,n=3.49524333,a={gbp:0,usd:0},s={gbp:0,usd:0},r=function(e,t){return new Date(e.getTime()+24*t*60*60*1e3)},c=function(e,t){var o,n,a;return n=e.getTime(),a=t.getTime(),o=(a-n)/864e5},l=function(){var e=new Date,t=new Date,o=new Date,n=new Date,a=new Date;t.setFullYear(2013,9,24),o=r(t,1001),n.setFullYear(2015,4,10),a.setFullYear(2013,7,25),$("#one").text("101B ends: "+Math.ceil(c(e,o))+" days / "+Math.ceil(c(e,o)/7)+" weeks"),$("#two").text("Ends: "+Math.ceil(c(e,n))+" days / "+Math.ceil(c(e,n)/7)+" weeks"),$("#three").hide()},p=function(){navigator.geolocation.getCurrentPosition(i)},i=function(e){var t=e.coords.latitude,o=e.coords.longitude;$.ajax({type:"GET",url:"https://api.forecast.io/forecast/0657dc0d81c037cbc89ca88e383b6bbf/"+t.toString()+","+o.toString(),data:"",dataType:"jsonp",timeout:1e4,context:$("body"),contentType:"application/json",headers:{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"PUT, GET, POST, DELETE, OPTIONS","Access-Control-Allow-Headers":"Content-Type"},success:function(e){var t=5/9*(e.currently.temperature-32);$("#weather").html(e.currently.summary+" "+parseInt(t)+"°c "+e.daily.summary+"")},error:function(e,t){console.log("ajax error"),console.log(e),console.log(t)}})},u=function(e,r){var c,l,p=$("#btc");0!==t?(p.removeClass(),e>t?p.addClass("up"):t>e&&p.addClass("down")):(a.gbp=e,a.usd=r,s.gbp=e,s.usd=r),t=e,o=r,e"+e.daily.summary+"")},error:function(e,o){console.log("ajax error"),console.log(e),console.log(o)}})},u=function(e,r){var c,l,i=$("#btc");0!==o?(i.removeClass(),e>o?i.addClass("up"):o>e&&i.addClass("down")):(a.gbp=e,a.usd=r,s.gbp=e,s.usd=r),o=e,t=r,e
Starting Points/Metasites
+
  • Feedly
  • +
  • Reddit
  • +
  • Facebook
  • +
  • Yahoo!
  • +
  • Journal Editor
  • +
  • Slack Bookmarks
  • +
  • Paleo Mix
  • +
  • Hive Status
  • + @@ -234,97 +209,112 @@
    Travel
    - DBEGLQ: --- GLQDBE: --- + DBEGLQ: --- GLQDBE: --- + / + Advanced + +
  • + DBE Board + / + Advanced +
  • +
  • + GLQ Trains / + Adv / + GLQ->DBE +
  • +
  • Kayak
  • +
  • Travelocity
  • +
  • Travel.com
  • +
  • + Airlines +
  • +
  • Landings
  • +
  • + Maps +
  • +
  • Maps2
  • +
  • ITN
  • +
  • HAFAS
  • +
  • DieBahn
  • +
  • RailUSA +
  • +
  • + TrainWeb +
  • +
  • RailWorld +
  • +
  • Currency Converter +
  • +
  • + CIA +
  • +
  • GMaps
  • +
    @@ -389,6 +379,8 @@
  • Gear List
  • Emu Forum
  • Net 7 Wiki
  • +
  • Space Engineers Wiki
  • +
  • Space Engineers Forum
  • diff --git a/lib/train.js b/lib/train.js index ac3d5f8..a5f9ffd 100644 --- a/lib/train.js +++ b/lib/train.js @@ -8,103 +8,47 @@ var trainCache = { module.exports = { - dbe_glq: function(req, res) { - // http://huxley.apphb.com/all/dbe/to/glq/1?accessToken=215b99fe-b237-4a01-aadc-cf315d6756d8 - // http://huxley.apphb.com/all/dbe/from/glq/1?accessToken=215b99fe-b237-4a01-aadc-cf315d6756d8 + dbe_glq: function (req, res) { console.log('DBE:GLQ request'); - function Query(callback, r) { - var req = r; - var options = { - host: 'huxley.apphb.com', - // port: 80, - path: '/next/dbe/to/glq/1?accessToken=215b99fe-b237-4a01-aadc-cf315d6756d8', - //method: 'GET', - headers: { - } - }; - - try { - http.request(options).on('response', function(response) { - var data = ''; - response.on("data", function(chunk) { - data += chunk; - }); - response.on('end', function() { - callback(JSON.parse(data), r); - }); - }).end(); - } catch (e) { - console.log(e); - } - } - var now = new Date(); var nowSeconds = (now.getHours() * (60 * 60)) + (now.getMinutes() * 60); console.log('Now Seconds: ' + nowSeconds); if (trainCache.last.dbeglq == null || nowSeconds != trainCache.last.dbeglq) { - Query(function(a, b) { - //console.log(a); + Query(function (a, b) { + var ts = a.departures[0].service; var output = {}; - //GLOBAL.lastcheck = now; + console.log(ts); + console.log(ts.sta); - // console.log(toSeconds(ts.sta)); + output.sta = ts.sta; output.eta = ts.eta; trainCache.data.dbeglq = output; - // trainCache.last.dbeglq = toSeconds(ts.sta); - // console.log(ts); + res.setHeader('Content-Type', 'application/json'); res.end(JSON.stringify(trainCache.data.dbeglq)); - }, res); + }, res, 'huxley.apphb.com', '/next/dbe/to/glq/1?accessToken=215b99fe-b237-4a01-aadc-cf315d6756d8'); } }, - glq_dbe: function(req, res) { - - // http://huxley.apphb.com/all/dbe/to/glq/1?accessToken=215b99fe-b237-4a01-aadc-cf315d6756d8 - // http://huxley.apphb.com/all/dbe/from/glq/1?accessToken=215b99fe-b237-4a01-aadc-cf315d6756d8 + glq_dbe: function (req, res) { console.log('GLQ:DBE request'); - function Query(callback, r) { - var req = r; - var options = { - host: 'huxley.apphb.com', - // port: 80, - path: '/next/dbe/from/glq/1?accessToken=215b99fe-b237-4a01-aadc-cf315d6756d8', - //method: 'GET', - headers: { - } - }; - - try { - http.request(options).on('response', function(response) { - var data = ''; - response.on("data", function(chunk) { - data += chunk; - }); - response.on('end', function() { - callback(JSON.parse(data), r); - }); - }).end(); - } catch (e) { - console.log(e); - } - } - var now = new Date(); var nowSeconds = (now.getHours() * (60 * 60)) + (now.getMinutes() * 60); console.log('Now Seconds: ' + nowSeconds); if (trainCache.last.glqdbe == null || nowSeconds != trainCache.last.dbeglq) { - Query(function(a, b) { - //console.log(a); + Query(function (a, b) { + var ts = a.departures[0].service; var output = {}; + console.log(ts); //GLOBAL.lastcheck = now; console.log(ts.sta); console.log(toSeconds(ts.sta)); @@ -112,11 +56,11 @@ module.exports = { output.sta = ts.sta; output.eta = ts.eta; trainCache.data.glqdbe = output; - // trainCache.last.glqdbe = toSeconds(ts.sta); + // trainCache.last.glqdbe = toSeconds(ts.sta); // console.log(ts); res.setHeader('Content-Type', 'application/json'); res.end(JSON.stringify(trainCache.data.glqdbe)); - }, res); + }, res, 'huxley.apphb.com', '/next/glq/to/dbe/1?accessToken=215b99fe-b237-4a01-aadc-cf315d6756d8'); } } @@ -128,3 +72,29 @@ function toSeconds(inval) { return ((parseInt(a[0]) * (60 * 60)) + (parseInt(a[1]) * 60)); } + +function Query(callback, r, host, path) { + console.log(path); + var req = r; + var options = { + host: host, + // port: 80, + path: path, + //method: 'GET', + headers: {} + }; + + try { + http.request(options).on('response', function (response) { + var data = ''; + response.on("data", function (chunk) { + data += chunk; + }); + response.on('end', function () { + callback(JSON.parse(data), r); + }); + }).end(); + } catch (e) { + console.log(e); + } +} diff --git a/lib/train.min.js b/lib/train.min.js index 56916c8..d713118 100644 --- a/lib/train.min.js +++ b/lib/train.min.js @@ -1,2 +1,2 @@ -function toSeconds(e){var t=e.split(":");return 3600*parseInt(t[0])+60*parseInt(t[1])}var http=require("http"),trainCache={last:{},data:{}};module.exports={dbe_glq:function(e,t){function n(e,t){var n={host:"huxley.apphb.com",path:"/next/dbe/to/glq/1?accessToken=215b99fe-b237-4a01-aadc-cf315d6756d8",headers:{}};try{http.request(n).on("response",function(n){var o="";n.on("data",function(e){o+=e}),n.on("end",function(){e(JSON.parse(o),t)})}).end()}catch(o){console.log(o)}}console.log("DBE:GLQ request");var o=new Date,a=3600*o.getHours()+60*o.getMinutes();console.log("Now Seconds: "+a),(null==trainCache.last.dbeglq||a!=trainCache.last.dbeglq)&&n(function(e){var n=e.departures[0].service,o={};console.log(n.sta),o.sta=n.sta,o.eta=n.eta,trainCache.data.dbeglq=o,t.setHeader("Content-Type","application/json"),t.end(JSON.stringify(trainCache.data.dbeglq))},t)},glq_dbe:function(e,t){function n(e,t){var n={host:"huxley.apphb.com",path:"/next/dbe/from/glq/1?accessToken=215b99fe-b237-4a01-aadc-cf315d6756d8",headers:{}};try{http.request(n).on("response",function(n){var o="";n.on("data",function(e){o+=e}),n.on("end",function(){e(JSON.parse(o),t)})}).end()}catch(o){console.log(o)}}console.log("GLQ:DBE request");var o=new Date,a=3600*o.getHours()+60*o.getMinutes();console.log("Now Seconds: "+a),(null==trainCache.last.glqdbe||a!=trainCache.last.dbeglq)&&n(function(e){var n=e.departures[0].service,o={};console.log(n.sta),console.log(toSeconds(n.sta)),o.sta=n.sta,o.eta=n.eta,trainCache.data.glqdbe=o,t.setHeader("Content-Type","application/json"),t.end(JSON.stringify(trainCache.data.glqdbe))},t)}}; +function toSeconds(e){var t=e.split(":");return 3600*parseInt(t[0])+60*parseInt(t[1])}function Query(e,t,o,n){console.log(n);var a={host:o,path:n,headers:{}};try{http.request(a).on("response",function(o){var n="";o.on("data",function(e){n+=e}),o.on("end",function(){e(JSON.parse(n),t)})}).end()}catch(s){console.log(s)}}var http=require("http"),trainCache={last:{},data:{}};module.exports={dbe_glq:function(e,t){console.log("DBE:GLQ request");var o=new Date,n=3600*o.getHours()+60*o.getMinutes();console.log("Now Seconds: "+n),(null==trainCache.last.dbeglq||n!=trainCache.last.dbeglq)&&Query(function(e){var o=e.departures[0].service,n={};console.log(o),console.log(o.sta),n.sta=o.sta,n.eta=o.eta,trainCache.data.dbeglq=n,t.setHeader("Content-Type","application/json"),t.end(JSON.stringify(trainCache.data.dbeglq))},t,"huxley.apphb.com","/next/dbe/to/glq/1?accessToken=215b99fe-b237-4a01-aadc-cf315d6756d8")},glq_dbe:function(e,t){console.log("GLQ:DBE request");var o=new Date,n=3600*o.getHours()+60*o.getMinutes();console.log("Now Seconds: "+n),(null==trainCache.last.glqdbe||n!=trainCache.last.dbeglq)&&Query(function(e){var o=e.departures[0].service,n={};console.log(o),console.log(o.sta),console.log(toSeconds(o.sta)),n.sta=o.sta,n.eta=o.eta,trainCache.data.glqdbe=n,t.setHeader("Content-Type","application/json"),t.end(JSON.stringify(trainCache.data.glqdbe))},t,"huxley.apphb.com","/next/glq/to/dbe/1?accessToken=215b99fe-b237-4a01-aadc-cf315d6756d8")}}; //# sourceMappingURL=train.min.js.map diff --git a/lib/train.min.js.map b/lib/train.min.js.map index ac2d061..f33248a 100644 --- a/lib/train.min.js.map +++ b/lib/train.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["train.js"],"names":["toSeconds","inval","a","split","parseInt","http","require","trainCache","last","data","module","exports","dbe_glq","req","res","Query","callback","r","options","host","path","headers","request","on","response","chunk","JSON","parse","end","e","console","log","now","Date","nowSeconds","getHours","getMinutes","dbeglq","ts","departures","service","output","sta","eta","setHeader","stringify","glq_dbe","glqdbe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AG,MAAO,WACfP,EAASU,KAAKC,MAAMlB,GAAOQ,OAEhCW,MACL,MAAOC,GACLC,QAAQC,IAAIF,IAxBpBC,QAAQC,IAAI,kBA4BZ,IAAIC,GAAM,GAAIC,MACVC,EAA+B,KAAjBF,EAAIG,WAA8C,GAAnBH,EAAII,YACrDN,SAAQC,IAAI,gBAAkBG,IACA,MAA1B3B,WAAWC,KAAKuC,QAAkBb,GAAc3B,WAAWC,KAAK6B,SAChEtB,EAAM,SAASb,GAEX,GAAIoC,GAAKpC,EAAEqC,WAAW,GAAGC,QACrBC,IAEJX,SAAQC,IAAIO,EAAGI,KACfZ,QAAQC,IAAI/B,UAAUsC,EAAGI,MAEzBD,EAAOC,IAAMJ,EAAGI,IAChBD,EAAOE,IAAML,EAAGK,IAChBpC,WAAWE,KAAKsC,OAASN,EAGzB3B,EAAI8B,UAAU,eAAgB,oBAC9B9B,EAAIc,IAAIF,KAAKmB,UAAUtC,WAAWE,KAAKsC,UACxCjC"} \ No newline at end of file +{"version":3,"sources":["train.js"],"names":["toSeconds","inval","a","split","parseInt","Query","callback","r","host","path","console","log","options","headers","http","request","on","response","data","chunk","JSON","parse","end","e","require","trainCache","last","module","exports","dbe_glq","req","res","now","Date","nowSeconds","getHours","getMinutes","dbeglq","ts","departures","service","output","sta","eta","setHeader","stringify","glq_dbe","glqdbe"],"mappings":"AAqEA,QAASA,WAAUC,GACf,GAAIC,GAAID,EAAME,MAAM,IACpB,OAA0B,MAAjBC,SAASF,EAAE,IAAqC,GAAjBE,SAASF,EAAE,IAIvD,QAASG,OAAMC,EAAUC,EAAGC,EAAMC,GAC9BC,QAAQC,IAAIF,EACZ,IACIG,IACAJ,KAAMA,EAENC,KAAMA,EAENI,WAGJ,KACIC,KAAKC,QAAQH,GAASI,GAAG,WAAY,SAAUC,GAC3C,GAAIC,GAAO,EACXD,GAASD,GAAG,OAAQ,SAAUG,GAC1BD,GAAQC,IAEZF,EAASD,GAAG,MAAO,WACfV,EAASc,KAAKC,MA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