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