diff --git a/app/app.js b/app/app.js index 1f11a60..0504375 100644 --- a/app/app.js +++ b/app/app.js @@ -1,476 +1,388 @@ (function () { - var lastGBP = 0.0, - lastUSD = 0.0, - _fasttimer, _slowTimer, myBTC =3.49524333; - var lows = { - gbp: 0, - usd: 0 - }, - highs = { - gbp: 0, - usd: 0 - }; - - - var list = [{ - title: '101B ends', - y: 2013, - m: 9, - d: 24, - add: 1001 - }, - { - title: 'Ends', - y: 2016, - m: 4, - d: 4 - }]; - var addDays = function (myDate, days) { - return new Date(myDate.getTime() + days * 24 * 60 * 60 * 1000); + var lastGBP = 0.0, + lastUSD = 0.0, + _fasttimer, _slowTimer, myBTC = 3.49524333; + var lows = { + gbp: 0, + usd: 0 + }, + highs = { + gbp: 0, + usd: 0 }; - var getDays = function (startdate, enddate) { - var r, s, e; - s = startdate.getTime(); - e = enddate.getTime(); - r = (e - s) / (24 * 60 * 60 * 1000); - return r; - }; - var tick = function () { - var today = new Date(); - var start101 = new Date(); - var end101 = new Date(); - var endContract = new Date(); - var third = new Date(); - start101.setFullYear(2013, 9, 24); - end101 = addDays(start101, 1001); - endContract.setFullYear(2016, 4, 4); - third.setFullYear(2013, 7, 25); - $('#one').text('101B ends: ' + Math.ceil(getDays(today, - end101)) + " days / " + Math.ceil(getDays(today, - end101) / 7) + " weeks"); - $('#two').text('Ends: ' + Math.ceil(getDays(today, - endContract)) + " days / " + Math.ceil(getDays(today, - endContract) / 7) + " weeks"); - $('#three').hide(); - }; - - var get_weather = function () { - navigator.geolocation.getCurrentPosition(show_weather); - }; - var show_weather = function (position) { - var latitude = position.coords.latitude; - var longitude = position.coords.longitude; - // let's show a map or do something interesting! - $.ajax({ - type: 'GET', - url: 'https://api.forecast.io/forecast/0657dc0d81c037cbc89ca88e383b6bbf/' + latitude.toString() + ',' + longitude.toString() + '?units=uk2', - data: '', - dataType: 'jsonp', - timeout: 10000, - 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 (data) { - // console.log(data); - - var calc = ((5.0 / 9.0 * (data.currently.temperature - 32))); - $('#weather').html(data.currently.summary + " " + parseInt(calc) + '°c ' + '' + data.daily.summary + ''); - - }, - error: function (xhr, type) { - console.log("ajax error"); - console.log(xhr); - console.log(type); - } - }); - }; - - var updateBTC = function (g, u) { - var title, total, elm = $('#btc'); - if (lastGBP !== 0) { - - elm.removeClass(); - if (g > lastGBP) { - elm.addClass('up'); - } else if (g < lastGBP) { - elm.addClass('down'); - } - - } else { - lows.gbp = g; - lows.usd = u; - - highs.gbp = g; - highs.usd = u; - } - - lastGBP = g; - lastUSD = u; - - if (g < lows.gbp) lows.gbp = g; - if (u < lows.usd) lows.usd = u; - - if (highs.gbp < g) highs.gbp = g; - if (highs.usd < u) highs.usd = u; - - total = myBTC * g; - - title = "High: $" + parseFloat(highs.usd.toFixed(2)) + " / Low $" + parseFloat(lows.usd.toFixed(2)); - elm.html("$" + parseFloat(u.toFixed(2)) + " / £" + parseFloat(g.toFixed(2)) + " (£" + parseFloat(total.toFixed(2)) + ")"); - - elm.prop('title', title); - }; - - - var updateFX = function (data) { - var title, total, elm = $('#fx'); - //title = "High: $" + parseFloat(highs.usd.toFixed(2)) + " / Low $" + parseFloat(lows.usd.toFixed(2)); - elm.html("£1 = $" + parseFloat(data.gpbe.toFixed(2)) + " = " + parseFloat(data.sekex.toFixed(2)) + " SEK"); - - // elm.prop('title', title); - }; - - - var btcValue = function () { - var url = '/btc'; - - $.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); - var gbp = data.bpi.GBP.rate_float, - usd = data.bpi.USD.rate_float; - - updateBTC(gbp, usd); - }, - error: function (xhr, type) { - console.log("ajax error"); - console.log(xhr); - console.log(type); - } - }); - }; - - - var getFX = function () { - var url = '/fx'; - - $.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); - var gpbex = (1 / data.rates.GBP); - var sekex = (gpbex * data.rates.SEK); - var fxdata = { - usd: 1, - gbp: data.rates.GBP, - sek: data.rates.SEK, - gpbe: gpbex, - sekex: sekex - }; - // console.log(fxdata); - //var fxdata = data.bpi.GBP.rate_float, usd = data.bpi.USD.rate_float; - - updateFX(fxdata); - }, - error: function (xhr, type) { - console.log("ajax error"); - console.log(xhr); - console.log(type); - } - }); - }; - - var getNextTrainTime = function(toStation,fromStation) + var list = [{ + title: '101B ends', + y: 2013, + m: 9, + d: 24, + add: 1001 + }, { - var url = '/getnexttraintimes?from=' + fromStation + '&to=' + toStation ; - var target = fromStation + toStation; - $.ajax({ - type: 'GET', - url: url, - data: '', - dataType: 'json', + title: 'Ends', + y: 2016, + m: 4, + d: 4 + }]; - timeout: 10000, + MicroEvent.mixin(this); + var self = this; - //contentType: ('application/json'), - headers: { - 'Access-Control-Allow-Origin': '*', - 'Access-Control-Allow-Methods': 'PUT, GET, POST, DELETE, OPTIONS', - 'Access-Control-Allow-Headers': 'Content-Type' + var addDays = function (myDate, days) { + return new Date(myDate.getTime() + days * 24 * 60 * 60 * 1000); + }; - }, - success: function (data) { - console.log(data); + var getDays = function (startdate, enddate) { + var r, s, e; + s = startdate.getTime(); + e = enddate.getTime(); + r = (e - s) / (24 * 60 * 60 * 1000); + return r; + }; - updateTrain(target,data); - //updateFX(fxdata); - }, - error: function (xhr, type) { - console.log("ajax error"); - console.log(xhr); - console.log(type); - } - }); + var tick = function () { + var today = new Date(); + var start101 = new Date(); + var end101; + var endContract = new Date(); + var third = new Date(); + start101.setFullYear(2013, 9, 24); + end101 = addDays(start101, 1001); + endContract.setFullYear(2016, 4, 4); + third.setFullYear(2013, 7, 25); + $('#one').text('101B ends: ' + Math.ceil(getDays(today, + end101)) + " days / " + Math.ceil(getDays(today, + end101) / 7) + " weeks"); + $('#two').text('Ends: ' + Math.ceil(getDays(today, + endContract)) + " days / " + Math.ceil(getDays(today, + endContract) / 7) + " weeks"); + $('#three').hide(); + }; - }; + var get_weather = function () { + navigator.geolocation.getCurrentPosition(show_weather); + }; + this.bind('displayWeather', function (data) { + $('#weather').html(data.currently.summary + ' ' + data.currently.temperature + '°c ' + data.daily.summary + ''); + }); + var show_weather = function (position) { + var latitude = position.coords.latitude; + var longitude = position.coords.longitude; + // let's show a map or do something interesting! + $.ajax({ + type: 'GET', + url: 'https://api.forecast.io/forecast/0657dc0d81c037cbc89ca88e383b6bbf/' + latitude.toString() + ',' + longitude.toString() + '?units=uk2', + data: '', + dataType: 'jsonp', + timeout: 10000, + 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' - var getDBEGLQ = function () { + }, + success: function (data) { + self.trigger('displayWeather', data); + }, + error: function (xhr, type) { + console.log("ajax error"); + console.log(xhr); + console.log(type); + } + }); + }; - // var url = '/dbeglq'; - var url = '/getnexttraintimes?from=dbe&to=glq'; - $.ajax({ - type: 'GET', - url: url, - data: '', - dataType: 'json', + var updateBTC = function (g, u) { + var title, total, elm = $('#btc'); + if (lastGBP !== 0) { - timeout: 10000, + elm.removeClass(); + if (g > lastGBP) { + elm.addClass('up'); + } else if (g < lastGBP) { + elm.addClass('down'); + } - //contentType: ('application/json'), - headers: { - 'Access-Control-Allow-Origin': '*', - 'Access-Control-Allow-Methods': 'PUT, GET, POST, DELETE, OPTIONS', - 'Access-Control-Allow-Headers': 'Content-Type' + } else { + lows.gbp = g; + lows.usd = u; - }, - success: function (data) { - console.log(data); + highs.gbp = g; + highs.usd = u; + } - updateTrain('dbeglq',data); - //updateFX(fxdata); - }, - error: function (xhr, type) { - console.log("ajax error"); - console.log(xhr); - console.log(type); - } - }); - }; + lastGBP = g; + lastUSD = u; - var getGLQDBE = function () { + if (g < lows.gbp) lows.gbp = g; + if (u < lows.usd) lows.usd = u; - //var url = '/glqdbe'; - var url = '/getnexttraintimes?from=glq&to=dbe'; + if (highs.gbp < g) highs.gbp = g; + if (highs.usd < u) highs.usd = u; - $.ajax({ - type: 'GET', - url: url, - data: '', - dataType: 'json', + total = myBTC * g; - timeout: 10000, + title = "High: $" + parseFloat(highs.usd.toFixed(2)) + " / Low $" + parseFloat(lows.usd.toFixed(2)); + elm.html("$" + parseFloat(u.toFixed(2)) + " / £" + parseFloat(g.toFixed(2)) + " (£" + parseFloat(total.toFixed(2)) + ")"); + elm.prop('title', title); + }; - //contentType: ('application/json'), - headers: { - 'Access-Control-Allow-Origin': '*', - 'Access-Control-Allow-Methods': 'PUT, GET, POST, DELETE, OPTIONS', - 'Access-Control-Allow-Headers': 'Content-Type' + var updateFX = function (data) { + var elm = $('#fx'); + elm.html("£1 = $" + parseFloat(data.gpbe.toFixed(2)) + " = " + parseFloat(data.sekex.toFixed(2)) + " SEK"); + }; - }, - success: function (data) { - console.log(data); + var btcValue = function () { + var url = '/btc'; - updateTrain('glqdbe',data); - //updateFX(fxdata); - }, - error: function (xhr, type) { - console.log("ajax error"); - console.log(xhr); - console.log(type); - } - }); - }; + $.ajax({ + type: 'GET', + url: url, + data: '', + dataType: 'json', - var updateTrain = function (n, obj) { - var elm = $('#'+n); + timeout: 10000, - var output, status; + //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); + var gbp = data.bpi.GBP.rate_float, + usd = data.bpi.USD.rate_float; - output = (obj.eta == "On Time") ? obj.eta : obj.sta; - status = (obj.eta == "On Time") ? 'delayed' : 'ontime'; + updateBTC(gbp, usd); + }, + error: function (xhr, type) { + console.log("ajax error"); + console.log(xhr); + console.log(type); + } + }); + }; - elm.html(output); - - elm.prop('class', status); - }; - - var getTrainsCB = function (results) { - var dest$ = $('#trainResults'); - var html = new EJS({url: '/template/trains.ejs'}).render(results); - - console.log(html); - dest$.empty(); - dest$.append(html); - dest$.toggle(); - - }; - - var getTrains = function(from, to) { - var url = '/gettrains?from=' + from + "&to=" + to; - - $.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); - getTrainsCB(data); - }, - error: function (xhr, type) { - console.log("ajax error"); - console.log(xhr); - console.log(type); - } - }); - }; - - var formatPassword = function (data) { - - - var dest$ = $('#passwordOut'); - var html = new EJS({url: '/template/password.ejs'}).render(data); - - console.log(html); - dest$.empty(); - dest$.append(html); - dest$.show(); - }; - - - var generatePassword = function(from, to) { - var url = '/generate'; - - $.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); - - formatPassword(data); - }, - error: function (xhr, type) { - console.log("ajax error"); - console.log(xhr); - console.log(type); - } - }); - }; - - - - tick(); - get_weather(); + this.bind('getBTC', function () { btcValue(); + }); + + var getFX = function () { + var url = '/fx'; + + $.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); + var gpbex = (1 / data.rates.GBP); + var sekex = (gpbex * data.rates.SEK); + var fxdata = { + usd: 1, + gbp: data.rates.GBP, + sek: data.rates.SEK, + gpbe: gpbex, + sekex: sekex + }; + // console.log(fxdata); + //var fxdata = data.bpi.GBP.rate_float, usd = data.bpi.USD.rate_float; + + updateFX(fxdata); + }, + error: function (xhr, type) { + console.log("ajax error"); + console.log(xhr); + console.log(type); + } + }); + }; + + var getNextTrainTime = function (toStation, fromStation) { + var url = '/getnexttraintimes?from=' + fromStation + '&to=' + toStation; + var target = fromStation + toStation; + $.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) { + updateTrain(target, data); + }, + error: function (xhr, type) { + console.log("ajax error"); + console.log(xhr); + console.log(type); + } + }); + + }; + + var updateTrain = function (n, obj) { + var elm = $('#' + n); + + var output, status; + + output = (obj.eta == "On Time") ? obj.eta : obj.sta; + status = (obj.eta == "On Time") ? 'delayed' : 'ontime'; + + elm.html(output); + elm.prop('class', status); + }; + + var getTrainsCB = function (results) { + var dest$ = $('#trainResults'); + var html = new EJS({url: '/template/trains.ejs'}).render(results); + + dest$.empty(); + dest$.append(html); + dest$.toggle(); + }; + + var getTrains = function (from, to) { + var url = '/gettrains?from=' + from + "&to=" + to; + + $.ajax({ + type: 'GET', + url: url, + data: '', + dataType: 'json', + + timeout: 10000, + headers: { + 'Access-Control-Allow-Origin': '*', + 'Access-Control-Allow-Methods': 'PUT, GET, POST, DELETE, OPTIONS', + 'Access-Control-Allow-Headers': 'Content-Type' + + }, + success: function (data) { + getTrainsCB(data); + }, + error: function (xhr, type) { + console.log("ajax error"); + console.log(xhr); + console.log(type); + } + }); + }; + + var formatPassword = function (data) { + + var dest$ = $('#passwordOut'); + var html = new EJS({url: '/template/password.ejs'}).render(data); + dest$.empty(); + dest$.append(html); + dest$.show(); + }; + + var generatePassword = function (from, to) { + var url = '/generate'; + + $.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) { + formatPassword(data); + }, + error: function (xhr, type) { + console.log("ajax error"); + console.log(xhr); + console.log(type); + } + }); + }; + + tick(); + get_weather(); + self.trigger('getBTC'); + getFX(); + getNextTrainTime('dbe', 'glq'); + getNextTrainTime('glq', 'dbe'); + + // start 15 minute timer + + _fastTimer = setInterval(function () { + self.trigger('getBTC'); + getNextTrainTime('dbe', 'glq'); + getNextTrainTime('glq', 'dbe'); + }, (60000)); + + _slowTimer = setInterval(function () { + getFX(); - //getDBEGLQ(); - //getGLQDBE(); - getNextTrainTime('dbe','glq'); - getNextTrainTime('glq','dbe'); + get_weather(); + }, (60000 * 15)); - // start 15 minute timer + $('#dbeglq').on('click', function () { + self.trigger('getTrains', 'dbe', 'glq'); + }); - _fastTimer = setInterval(function () { - btcValue(); - // getDBEGLQ(); - // getGLQDBE(); - getNextTrainTime('dbe','glq'); - getNextTrainTime('glq','dbe'); - }, (60000)); + $('#glqdbe').on('click', function () { + self.trigger('getTrains', 'glq', 'dbe'); + }); - _slowTimer = setInterval(function () { + $('#newPassword').on('click', function () { + generatePassword(); + }); - getFX(); - get_weather(); - }, (60000 * 15)); - - $('#dbeglq').on('click',function(){ - getTrains('dbe','glq'); - }); - - $('#glqdbe').on('click',function(){ - getTrains('glq','dbe'); - }); - - $('#newPassword').on('click', function() { - generatePassword(); - }); + this.bind('getTrains', function (start, end) { + getTrains(start, end); + }); + document.title = 'Slack'; })(); var popitout = function (url) { - newwindow = window.open(url, 'name', 'height=600,width=570'); - if (window.focus) { - newwindow.focus() - } - return false; + var newwindow = window.open(url, 'name', 'height=600,width=570'); + if (window.focus) { + newwindow.focus() + } + return false; }; var popitoutSmall = function (url) { - newwindow = window.open(url, 'name', 'height=400,width=520'); - if (window.focus) { - newwindow.focus() - } - return false; + var newwindow = window.open(url, 'name', 'height=400,width=520'); + if (window.focus) { + newwindow.focus() + } + return false; }; diff --git a/app/app.min.js b/app/app.min.js index 1deaeb2..02b9da6 100644 --- a/app/app.min.js +++ b/app/app.min.js @@ -1,2 +1,10 @@ -!function(){var e,o=0,t=0,n=3.49524333,a={gbp:0,usd:0},s={gbp:0,usd:0},r=function(e,o){return new Date(e.getTime()+24*o*60*60*1e3)},c=function(e,o){var t,n,a;return n=e.getTime(),a=o.getTime(),t=(a-n)/864e5},l=function(){var e=new Date,o=new Date,t=new Date,n=new Date,a=new Date;o.setFullYear(2013,9,24),t=r(o,1001),n.setFullYear(2015,4,10),a.setFullYear(2013,7,25),$("#one").text("101B ends: "+Math.ceil(c(e,t))+" days / "+Math.ceil(c(e,t)/7)+" weeks"),$("#two").text("Ends: "+Math.ceil(c(e,n))+" days / "+Math.ceil(c(e,n)/7)+" weeks"),$("#three").hide()},i=function(){navigator.geolocation.getCurrentPosition(p)},p=function(e){var o=e.coords.latitude,t=e.coords.longitude;$.ajax({type:"GET",url:"https://api.forecast.io/forecast/0657dc0d81c037cbc89ca88e383b6bbf/"+o.toString()+","+t.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 o=5/9*(e.currently.temperature-32);$("#weather").html(e.currently.summary+" "+parseInt(o)+"°c "+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"+a.daily.summary+"")});var p=function(a){$.ajax({type:"GET",url:"https://api.forecast.io/forecast/0657dc0d81c037cbc89ca88e383b6bbf/"+a.coords.latitude.toString()+","+a.coords.longitude.toString()+"?units=uk2", + 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(a){e.trigger("displayWeather",a)},error:function(a,d){console.log("ajax error");console.log(a);console.log(d)}})},t=function(){$.ajax({type:"GET",url:"/btc",data:"",dataType:"json",timeout:1E4,headers:{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"PUT, GET, POST, DELETE, OPTIONS", + "Access-Control-Allow-Headers":"Content-Type"},success:function(a){var b=a.bpi.GBP.rate_float;a=a.bpi.USD.rate_float;var d,q,f=$("#btc");0!==c?(f.removeClass(),b>c?f.addClass("up"):b <% include ../partials/trains %> + <% include ../partials/calendar %> + <% include ../partials/history %> + <% include ../partials/tv %> diff --git a/views/partials/calendar.ejs b/views/partials/calendar.ejs new file mode 100644 index 0000000..bebe3d5 --- /dev/null +++ b/views/partials/calendar.ejs @@ -0,0 +1,13 @@ +<% if (data.cal.entries.length > 0 ) {%> +
+

Calendar

+ <% + for (var i = 0; i < data.cal.entries.length; i++) { %> + +
<%- data.cal.entries[i].combined %>
+ + <% } %> + +
+ +<% } %> diff --git a/views/partials/head.ejs b/views/partials/head.ejs index 7d43d12..3ae3b28 100644 --- a/views/partials/head.ejs +++ b/views/partials/head.ejs @@ -59,6 +59,7 @@ } - - \ No newline at end of file + + + diff --git a/views/partials/history.ejs b/views/partials/history.ejs new file mode 100644 index 0000000..c5e0a75 --- /dev/null +++ b/views/partials/history.ejs @@ -0,0 +1,14 @@ +<% if (data.history.length > 0 ) {%> +
+

Today in history

+
+ <% + for (var i = 0; i < data.history.length; i++) { %> + +

<%- data.history[i] %>

+ + <% } %> +
+
+ +<% } %> diff --git a/views/partials/trains.ejs b/views/partials/trains.ejs index de4382d..c0394ef 100644 --- a/views/partials/trains.ejs +++ b/views/partials/trains.ejs @@ -1,6 +1,6 @@ <% if (data.trains.data.length > 0 ) {%>
- +

Travel

<% for (var i = 0; i < data.trains.data.length; i++) { %> diff --git a/views/partials/tv.ejs b/views/partials/tv.ejs new file mode 100644 index 0000000..55bfda7 --- /dev/null +++ b/views/partials/tv.ejs @@ -0,0 +1,13 @@ +<% if (data.tv.entries.length > 0 ) {%> +
+

TV

+ <% + for (var i = 0; i < data.tv.entries.length; i++) { %> + +
<%- data.tv.entries[i].combined %>
+ + <% } %> + +
+ +<% } %> diff --git a/views/partials/weather.ejs b/views/partials/weather.ejs index a3881fe..b7ff88a 100644 --- a/views/partials/weather.ejs +++ b/views/partials/weather.ejs @@ -1,22 +1,26 @@ - -
-

Weather

-
Currently: <%=data.weather.currently%>
-
Later: <%=data.weather.today%>
+

Weather

+
+
Currently: <%= data.weather.currently %>
+
+
+
Today: <%= data.weather.today %>
+
+
+
Later: <%= data.weather.later %>
+
- <% if (data.weather.alerts.length > 0) { - for (var i =0; i < data.weather.alerts.length; i++) { - %> + <% if (data.weather.alerts.length > 0) { + for (var i = 0; i < data.weather.alerts.length; i++) { + %> -
-
<%=data.weather.alerts[i].title%>
-
<%=data.weather.alerts[i].description%>
-
+
+
<%= data.weather.alerts[i].title %>
+
<%= data.weather.alerts[i].description %>
+
- <% - - } - }%> + <% + } + } %>