mirror of
https://github.com/netbymatt/ws4kp.git
synced 2026-04-17 00:59:29 -07:00
regional forecast/observation title close #11
This commit is contained in:
@@ -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));
|
||||
};
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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`);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user