console.log tidy

This commit is contained in:
martind2000 2016-02-01 10:23:47 +00:00
parent 258396c06f
commit 0531b14949
4 changed files with 22 additions and 15 deletions

View File

@ -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();

View File

@ -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": {

View File

@ -54,7 +54,9 @@
white-space: pre;
}
.mui--text-danger {
color: #F44336;
}
</style>
<script src="//cdnjs.cloudflare.com/ajax/libs/zepto/1.1.4/zepto.min.js"></script>
</head>

View File

@ -4,4 +4,19 @@
<h1>Weather</h1>
<div class="mui-row"><div class="mui-col-md-12">Currently: <%=data.weather.currently%></div></div>
<div class="mui-row"><div class="mui-col-md-12">Later: <%=data.weather.today%></div></div>
<% if (data.weather.alerts.length > 0) {
for (var i =0; i < data.weather.alerts.length; i++) {
%>
<div class="mui-row">
<div class="mui-col-md-12 mui--text-danger"><%=data.weather.alerts[i].title%></div>
<div class="mui-col-md-12"><%=data.weather.alerts[i].description%></div>
</div>
<%
}
}%>
</div>