regional forecast/observation title close #11

This commit is contained in:
Matt Walsh
2022-08-04 20:12:44 -05:00
parent d34b0ca224
commit 902818d7a0
7 changed files with 16 additions and 6 deletions

View File

@@ -61,7 +61,7 @@ const currentWeatherScroll = (() => {
if (!data) return;
// clean up any old text
if (context) context.putImageData(blankDrawArea, 0, 405);
if (context && blankDrawArea) context.putImageData(blankDrawArea, 0, 405);
drawCondition(screens[screenIndex](data));
};

View File

@@ -30,6 +30,7 @@ class Hourly extends WeatherDisplay {
console.error('Get hourly forecast failed');
console.error(e.status, e.responseJSON);
this.setStatus(STATUS.failed);
return;
}
this.data = await Hourly.parseForecast(forecast.properties);

View File

@@ -343,17 +343,24 @@ class RegionalForecast extends WeatherDisplay {
draw.triangle(this.context, 'rgb(28, 10, 87)', 500, 30, 450, 90, 500, 90);
// draw the appropriate title
const titleTop = this.elem.querySelector('.title.dual .top');
const titleBottom = this.elem.querySelector('.title.dual .bottom');
if (this.screenIndex === 0) {
titleTop.innerHTML = 'Regional';
titleBottom.innerHTML = 'Observations';
draw.titleText(this.context, 'Regional', 'Observations');
} else {
const forecastDate = DateTime.fromISO(data[0][this.screenIndex].time);
// get the name of the day
const dayName = forecastDate.toLocaleString({ weekday: 'long' });
titleTop.innerHTML = 'Forecast for';
// draw the title
if (data[0][this.screenIndex].daytime) {
titleBottom.innerHTML = dayName;
draw.titleText(this.context, 'Forecast for', dayName);
} else {
titleBottom.innerHTML = `${dayName} Night`;
draw.titleText(this.context, 'Forecast for', `${dayName} Night`);
}
}