diff --git a/lib/today.js b/lib/today.js index 52c4d53..9cc748a 100644 --- a/lib/today.js +++ b/lib/today.js @@ -1,7 +1,6 @@ /** * Created by marti on 30/01/2016. */ - var http = require('http'), request = require('request'), cheerio = require('cheerio'), Forecast = require('forecast.io'), util = require('util'); var todayCache = { @@ -81,8 +80,7 @@ module.exports = { // todayCache.data.trains.data = j; - } - , + }, updateTrains: function () { todayCache.data.trains.data = []; module.exports.getTrainUpdates(0); @@ -91,32 +89,23 @@ module.exports = { setTimeout(function () { module.exports.updateTrains(); }, todayCache.expire); - } - , + }, doGetWeatherOutlook: function () { console.log('Retrieving weather..'); var j = {}; var forecast = new Forecast(forecastOptions); -//55.8582846,-4.2593033 forecast.get(55.8582846, -4.2593033, {units: 'uk2'}, function (err, res, data) { if (err) throw err; - // console.log('data: ' + util.inspect(data)); - j.currently = data.currently.summary; j.today = data.daily.summary; j.alerts = data.alerts || {}; todayCache.data.weather = j; - - // console.log(j.currently); - // console.log(j.today); - // console.log(j.alerts); }); - } - , + }, preLoadToday: function () { try { module.exports.doGetWeatherOutlook(); diff --git a/package.json b/package.json index 31ac0f5..2df0db9 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "htmlparser": "^1.7.7", "mammoth": "^0.3.25-pre.1", "request": "^2.67.0", + "simple-weather": "^1.2.2", "wordsoap": "^0.2.0" }, "dependencies": { diff --git a/views/partials/head.ejs b/views/partials/head.ejs index 5b8651d..7d43d12 100644 --- a/views/partials/head.ejs +++ b/views/partials/head.ejs @@ -54,7 +54,9 @@ white-space: pre; } - + .mui--text-danger { + color: #F44336; + } diff --git a/views/partials/weather.ejs b/views/partials/weather.ejs index 07ede00..a3881fe 100644 --- a/views/partials/weather.ejs +++ b/views/partials/weather.ejs @@ -4,4 +4,19 @@

Weather

Currently: <%=data.weather.currently%>
Later: <%=data.weather.today%>
+ + <% 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%>
+
+ + <% + + } + }%> +