forked from wezm/wezm.net
Improved handling of missing info in weather.js
This commit is contained in:
parent
bb940601eb
commit
d402554499
1 changed files with 10 additions and 3 deletions
|
@ -39,8 +39,9 @@
|
||||||
].join('')
|
].join('')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var months = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
|
||||||
function datetimeString(date) {
|
function datetimeString(date) {
|
||||||
var months = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
|
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
|
||||||
};
|
};
|
||||||
|
|
||||||
var current_div = currentTemplate(current);
|
if (current.temperature === undefined) {
|
||||||
$('.loading').replaceWith(current_div)
|
$('.loading').replaceWith($('<p>Unavailable</p>'));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
var current_div = currentTemplate(current);
|
||||||
|
$('.loading').replaceWith(current_div)
|
||||||
|
}
|
||||||
|
|
||||||
// Populate the extremes
|
// Populate the extremes
|
||||||
var extremes = [];
|
var extremes = [];
|
||||||
|
|
Loading…
Reference in a new issue