Improved handling of missing info in weather.js

This commit is contained in:
Wesley Moore 2011-12-08 07:55:07 +11:00
parent bb940601eb
commit d402554499

View file

@ -39,8 +39,9 @@
].join('') ].join('')
} }
function datetimeString(date) {
var months = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec']; var months = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
function datetimeString(date) {
if (!date) return '';
return [ return [
date.getDate(), date.getDate(),
months[date.getMonth()], months[date.getMonth()],
@ -49,6 +50,7 @@
} }
function timeString(date) { function timeString(date) {
if (!date) return '';
return [ return [
padNumber(date.getHours()), padNumber(date.getHours()),
padNumber(date.getMinutes()) padNumber(date.getMinutes())
@ -100,8 +102,13 @@
forecast: data.current.forecast forecast: data.current.forecast
}; };
if (current.temperature === undefined) {
$('.loading').replaceWith($('<p>Unavailable</p>'));
}
else {
var current_div = currentTemplate(current); var current_div = currentTemplate(current);
$('.loading').replaceWith(current_div) $('.loading').replaceWith(current_div)
}
// Populate the extremes // Populate the extremes
var extremes = []; var extremes = [];