From 650ace0edbed61c8f373364c57f5204a71064bd4 Mon Sep 17 00:00:00 2001 From: Matt Walsh Date: Tue, 1 Mar 2022 16:19:08 -0600 Subject: [PATCH] code cleanup --- .eslintrc.js | 6 +++++ server/scripts/modules/almanac.js | 42 +++++++++++++++---------------- server/scripts/modules/draw.js | 1 - server/scripts/modules/radar.js | 8 +++--- 4 files changed, 31 insertions(+), 26 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index faf84cc..6cf82f4 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -22,6 +22,12 @@ module.exports = { 'no-tabs': 0, 'no-console': 0, 'max-len': 0, + 'no-use-before-define': [ + 'error', + { + variables: false, + }, + ], 'no-mixed-operators': [ 'error', { diff --git a/server/scripts/modules/almanac.js b/server/scripts/modules/almanac.js index 74ec406..3bc80ee 100644 --- a/server/scripts/modules/almanac.js +++ b/server/scripts/modules/almanac.js @@ -247,6 +247,27 @@ class Almanac extends WeatherDisplay { const [FullMoonImage, LastMoonImage, NewMoonImage, FirstMoonImage] = await Promise.all(this.moonImages); switch (this.screenIndex) { + case 1: { + this.context.drawImage(await this.backgroundImage1, 0, 0); + draw.horizontalGradientSingle(this.context, 0, 30, 500, 90, draw.topColor1, draw.topColor2); + draw.triangle(this.context, 'rgb(28, 10, 87)', 500, 30, 450, 90, 500, 90); + draw.horizontalGradientSingle(this.context, 0, 90, 52, 399, draw.sideColor1, draw.sideColor2); + draw.horizontalGradientSingle(this.context, 584, 90, 640, 399, draw.sideColor1, draw.sideColor2); + + draw.titleText(this.context, 'Almanac', 'Outlook'); + + draw.text(this.context, 'Star4000', '24pt', '#FFFFFF', 320, 180, '30 Day Outlook', 2, 'center'); + + const DateRange = `MID-${info.outlook.thisMonth.toUpperCase()} TO MID-${info.outlook.nextMonth.toUpperCase()}`; + draw.text(this.context, 'Star4000', '24pt', '#FFFFFF', 320, 220, DateRange, 2, 'center'); + + const Temperature = info.outlook.temperature; + draw.text(this.context, 'Star4000', '24pt', '#FFFFFF', 70, 300, `Temperatures: ${Temperature}`, 2); + + const Precipitation = info.outlook.precipitation; + draw.text(this.context, 'Star4000', '24pt', '#FFFFFF', 70, 380, `Precipitation: ${Precipitation}`, 2); + break; + } case 0: default: // sun and moon data @@ -292,27 +313,6 @@ class Almanac extends WeatherDisplay { this.context.drawImage(image, 75 + Index * 130, 270); }); break; - - case 1: { - this.context.drawImage(await this.backgroundImage1, 0, 0); - draw.horizontalGradientSingle(this.context, 0, 30, 500, 90, draw.topColor1, draw.topColor2); - draw.triangle(this.context, 'rgb(28, 10, 87)', 500, 30, 450, 90, 500, 90); - draw.horizontalGradientSingle(this.context, 0, 90, 52, 399, draw.sideColor1, draw.sideColor2); - draw.horizontalGradientSingle(this.context, 584, 90, 640, 399, draw.sideColor1, draw.sideColor2); - - draw.titleText(this.context, 'Almanac', 'Outlook'); - - draw.text(this.context, 'Star4000', '24pt', '#FFFFFF', 320, 180, '30 Day Outlook', 2, 'center'); - - const DateRange = `MID-${info.outlook.thisMonth.toUpperCase()} TO MID-${info.outlook.nextMonth.toUpperCase()}`; - draw.text(this.context, 'Star4000', '24pt', '#FFFFFF', 320, 220, DateRange, 2, 'center'); - - const Temperature = info.outlook.temperature; - draw.text(this.context, 'Star4000', '24pt', '#FFFFFF', 70, 300, `Temperatures: ${Temperature}`, 2); - - const Precipitation = info.outlook.precipitation; - draw.text(this.context, 'Star4000', '24pt', '#FFFFFF', 70, 380, `Precipitation: ${Precipitation}`, 2); - } } this.finishDraw(); diff --git a/server/scripts/modules/draw.js b/server/scripts/modules/draw.js index a6631d3..1705217 100644 --- a/server/scripts/modules/draw.js +++ b/server/scripts/modules/draw.js @@ -74,7 +74,6 @@ const draw = (() => { context.strokeRect(x, y, width, height); }; - // TODO: implement full themes support const theme = 1; // classic const topColor1 = 'rgb(192, 91, 2)'; const topColor2 = 'rgb(72, 34, 64)'; diff --git a/server/scripts/modules/radar.js b/server/scripts/modules/radar.js index 38565c9..fa431d9 100644 --- a/server/scripts/modules/radar.js +++ b/server/scripts/modules/radar.js @@ -36,9 +36,9 @@ class Radar extends WeatherDisplay { this.backgroundImage = utils.image.load('images/BackGround4_1.png'); } - async getData(weatherParameters) { - super.getData(weatherParameters); - if (!weatherParameters) weatherParameters = this.weatherParameters; + async getData(_weatherParameters) { + super.getData(_weatherParameters); + const weatherParameters = _weatherParameters ?? this.weatherParameters; // ALASKA AND HAWAII AREN'T SUPPORTED! if (weatherParameters.state === 'AK' || weatherParameters.state === 'HI') { @@ -154,7 +154,7 @@ class Radar extends WeatherDisplay { minute, }, { zone: 'UTC', - }); + }).setZone(); } else { time = DateTime.fromHTTP(response.headers.get('last-modified')).setZone(); }