From d402554499b7a495f9172fd2789070aa189a07b9 Mon Sep 17 00:00:00 2001 From: Wesley Moore Date: Thu, 8 Dec 2011 07:55:07 +1100 Subject: [PATCH] Improved handling of missing info in weather.js --- output/js/weather.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) 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 = [];