From 72b2f275fa607c8d241b501b784704038c526ab4 Mon Sep 17 00:00:00 2001 From: Matt Walsh Date: Tue, 22 Nov 2022 16:29:10 -0600 Subject: [PATCH] remove window. references --- server/scripts/modules/almanac.mjs | 5 ++--- server/scripts/modules/currentweather.mjs | 5 ++--- server/scripts/modules/currentweatherscroll.mjs | 5 ----- server/scripts/modules/extendedforecast.mjs | 5 ++--- server/scripts/modules/hourly.mjs | 5 ++--- server/scripts/modules/icons.mjs | 6 ------ server/scripts/modules/latestobservations.mjs | 5 ++--- server/scripts/modules/localforecast.mjs | 5 ++--- server/scripts/modules/progress.mjs | 5 ++++- server/scripts/modules/radar.mjs | 4 ++-- server/scripts/modules/regionalforecast.mjs | 5 +++-- server/scripts/modules/travelforecast.mjs | 5 +++-- .../{weatherdisplay.js => weatherdisplay.mjs} | 14 +++++++++----- views/index.ejs | 3 +-- 14 files changed, 34 insertions(+), 43 deletions(-) rename server/scripts/modules/{weatherdisplay.js => weatherdisplay.mjs} (96%) diff --git a/server/scripts/modules/almanac.mjs b/server/scripts/modules/almanac.mjs index 7694e72..fc63967 100644 --- a/server/scripts/modules/almanac.mjs +++ b/server/scripts/modules/almanac.mjs @@ -2,8 +2,9 @@ import { loadImg, preloadImg } from './utils/image.mjs'; import { DateTime } from '../vendor/auto/luxon.mjs'; import STATUS from './status.mjs'; +import WeatherDisplay from './weatherdisplay.mjs'; -/* globals WeatherDisplay, SunCalc */ +/* globals SunCalc */ class Almanac extends WeatherDisplay { constructor(navId, elemId) { @@ -171,5 +172,3 @@ class Almanac extends WeatherDisplay { } export default Almanac; - -window.Almanac = Almanac; diff --git a/server/scripts/modules/currentweather.mjs b/server/scripts/modules/currentweather.mjs index 3dcf9aa..3af19f1 100644 --- a/server/scripts/modules/currentweather.mjs +++ b/server/scripts/modules/currentweather.mjs @@ -7,8 +7,9 @@ import { directionToNSEW } from './utils/calc.mjs'; import * as units from './utils/units.mjs'; import { locationCleanup } from './utils/string.mjs'; import { getWeatherIconFromIconLink } from './icons.mjs'; +import WeatherDisplay from './weatherdisplay.mjs'; -/* globals WeatherDisplay, navigation */ +/* globals navigation */ class CurrentWeather extends WeatherDisplay { constructor(navId, elemId) { @@ -191,5 +192,3 @@ class CurrentWeather extends WeatherDisplay { } export default CurrentWeather; - -window.CurrentWeather = CurrentWeather; diff --git a/server/scripts/modules/currentweatherscroll.mjs b/server/scripts/modules/currentweatherscroll.mjs index 29615e7..21404d9 100644 --- a/server/scripts/modules/currentweatherscroll.mjs +++ b/server/scripts/modules/currentweatherscroll.mjs @@ -98,8 +98,3 @@ export { start, stop, }; - -window.currentWeatherScroll = { - start, - stop, -}; diff --git a/server/scripts/modules/extendedforecast.mjs b/server/scripts/modules/extendedforecast.mjs index c137a12..904824d 100644 --- a/server/scripts/modules/extendedforecast.mjs +++ b/server/scripts/modules/extendedforecast.mjs @@ -8,8 +8,9 @@ import { DateTime } from '../vendor/auto/luxon.mjs'; import { fahrenheitToCelsius } from './utils/units.mjs'; import { getWeatherIconFromIconLink } from './icons.mjs'; import { preloadImg } from './utils/image.mjs'; +import WeatherDisplay from './weatherdisplay.mjs'; -/* globals WeatherDisplay, navigation */ +/* globals navigation */ class ExtendedForecast extends WeatherDisplay { constructor(navId, elemId) { @@ -167,5 +168,3 @@ class ExtendedForecast extends WeatherDisplay { } export default ExtendedForecast; - -window.ExtendedForecast = ExtendedForecast; diff --git a/server/scripts/modules/hourly.mjs b/server/scripts/modules/hourly.mjs index 8900871..7a174db 100644 --- a/server/scripts/modules/hourly.mjs +++ b/server/scripts/modules/hourly.mjs @@ -1,5 +1,5 @@ // hourly forecast list -/* globals WeatherDisplay, navigation */ +/* globals navigation */ import STATUS from './status.mjs'; import { DateTime, Interval, Duration } from '../vendor/auto/luxon.mjs'; @@ -8,6 +8,7 @@ import { UNITS } from './config.mjs'; import * as units from './utils/units.mjs'; import { getHourlyIcon } from './icons.mjs'; import { directionToNSEW } from './utils/calc.mjs'; +import WeatherDisplay from './weatherdisplay.mjs'; class Hourly extends WeatherDisplay { constructor(navId, elemId, defaultActive) { @@ -198,5 +199,3 @@ class Hourly extends WeatherDisplay { } export default Hourly; - -window.Hourly = Hourly; diff --git a/server/scripts/modules/icons.mjs b/server/scripts/modules/icons.mjs index 5d3e1c4..2e84ae0 100644 --- a/server/scripts/modules/icons.mjs +++ b/server/scripts/modules/icons.mjs @@ -331,9 +331,3 @@ export { getWeatherRegionalIconFromIconLink, getHourlyIcon, }; - -window.icons = { - getWeatherIconFromIconLink, - getWeatherRegionalIconFromIconLink, - getHourlyIcon, -}; diff --git a/server/scripts/modules/latestobservations.mjs b/server/scripts/modules/latestobservations.mjs index e836ac8..eab40bd 100644 --- a/server/scripts/modules/latestobservations.mjs +++ b/server/scripts/modules/latestobservations.mjs @@ -1,11 +1,12 @@ // current weather conditions display -/* globals WeatherDisplay, navigation, StationInfo */ +/* globals navigation, StationInfo */ import { distance as calcDistance, directionToNSEW } from './utils/calc.mjs'; import { json } from './utils/fetch.mjs'; import STATUS from './status.mjs'; import { locationCleanup } from './utils/string.mjs'; import { UNITS } from './config.mjs'; import * as units from './utils/units.mjs'; +import WeatherDisplay from './weatherdisplay.mjs'; class LatestObservations extends WeatherDisplay { constructor(navId, elemId) { @@ -131,5 +132,3 @@ class LatestObservations extends WeatherDisplay { return condition; } } - -window.LatestObservations = LatestObservations; diff --git a/server/scripts/modules/localforecast.mjs b/server/scripts/modules/localforecast.mjs index 5340ae6..e5b3931 100644 --- a/server/scripts/modules/localforecast.mjs +++ b/server/scripts/modules/localforecast.mjs @@ -1,9 +1,10 @@ // display text based local forecast -/* globals WeatherDisplay, navigation */ +/* globals navigation */ import STATUS from './status.mjs'; import { UNITS } from './config.mjs'; import { json } from './utils/fetch.mjs'; +import WeatherDisplay from './weatherdisplay.mjs'; class LocalForecast extends WeatherDisplay { constructor(navId, elemId) { @@ -96,5 +97,3 @@ class LocalForecast extends WeatherDisplay { })); } } - -window.LocalForecast = LocalForecast; diff --git a/server/scripts/modules/progress.mjs b/server/scripts/modules/progress.mjs index f14bfc8..3ff0458 100644 --- a/server/scripts/modules/progress.mjs +++ b/server/scripts/modules/progress.mjs @@ -1,7 +1,8 @@ // regional forecast and observations -/* globals WeatherDisplay, navigation */ +/* globals navigation */ import { loadImg } from './utils/image.mjs'; import STATUS from './status.mjs'; +import WeatherDisplay from './weatherdisplay.mjs'; class Progress extends WeatherDisplay { constructor(navId, elemId) { @@ -102,4 +103,6 @@ class Progress extends WeatherDisplay { } } +export default Progress; + window.Progress = Progress; diff --git a/server/scripts/modules/radar.mjs b/server/scripts/modules/radar.mjs index 0027228..1dc11e3 100644 --- a/server/scripts/modules/radar.mjs +++ b/server/scripts/modules/radar.mjs @@ -1,10 +1,10 @@ // current weather conditions display -/* globals WeatherDisplay */ import STATUS from './status.mjs'; import { DateTime } from '../vendor/auto/luxon.mjs'; import { loadImg } from './utils/image.mjs'; import { text } from './utils/fetch.mjs'; import { rewriteUrl } from './utils/cors.mjs'; +import WeatherDisplay from './weatherdisplay.mjs'; class Radar extends WeatherDisplay { constructor(navId, elemId) { @@ -397,4 +397,4 @@ class Radar extends WeatherDisplay { } } -window.Radar = Radar; +export default Radar; diff --git a/server/scripts/modules/regionalforecast.mjs b/server/scripts/modules/regionalforecast.mjs index fd12282..11b117a 100644 --- a/server/scripts/modules/regionalforecast.mjs +++ b/server/scripts/modules/regionalforecast.mjs @@ -1,7 +1,7 @@ // regional forecast and observations // type 0 = observations, 1 = first forecast, 2 = second forecast -/* globals WeatherDisplay, navigation, StationInfo, RegionalCities */ +/* globals navigation, StationInfo, RegionalCities */ import STATUS from './status.mjs'; import { UNITS } from './config.mjs'; import { distance as calcDistance } from './utils/calc.mjs'; @@ -10,6 +10,7 @@ import * as units from './utils/units.mjs'; import { getWeatherRegionalIconFromIconLink } from './icons.mjs'; import { preloadImg } from './utils/image.mjs'; import { DateTime } from '../vendor/auto/luxon.mjs'; +import WeatherDisplay from './weatherdisplay.mjs'; class RegionalForecast extends WeatherDisplay { constructor(navId, elemId) { @@ -389,4 +390,4 @@ class RegionalForecast extends WeatherDisplay { } } -window.RegionalForecast = RegionalForecast; +export default RegionalForecast; diff --git a/server/scripts/modules/travelforecast.mjs b/server/scripts/modules/travelforecast.mjs index d452e21..5499528 100644 --- a/server/scripts/modules/travelforecast.mjs +++ b/server/scripts/modules/travelforecast.mjs @@ -1,11 +1,12 @@ // travel forecast display -/* globals WeatherDisplay, navigation, TravelCities */ +/* globals navigation, TravelCities */ import STATUS from './status.mjs'; import { UNITS } from './config.mjs'; import { json } from './utils/fetch.mjs'; import { getWeatherRegionalIconFromIconLink } from './icons.mjs'; import { fahrenheitToCelsius } from './utils/units.mjs'; import { DateTime } from '../vendor/auto/luxon.mjs'; +import WeatherDisplay from './weatherdisplay.mjs'; class TravelForecast extends WeatherDisplay { constructor(navId, elemId, defaultActive) { @@ -165,4 +166,4 @@ class TravelForecast extends WeatherDisplay { } } -window.TravelForecast = TravelForecast; +export default TravelForecast; diff --git a/server/scripts/modules/weatherdisplay.js b/server/scripts/modules/weatherdisplay.mjs similarity index 96% rename from server/scripts/modules/weatherdisplay.js rename to server/scripts/modules/weatherdisplay.mjs index 149caf9..8892532 100644 --- a/server/scripts/modules/weatherdisplay.js +++ b/server/scripts/modules/weatherdisplay.mjs @@ -1,8 +1,11 @@ // base weather display class -/* globals navigation, utils, luxon, currentWeatherScroll, STATUS */ +/* globals navigation */ +import STATUS from './status.mjs'; +import * as currentWeatherScroll from './currentweatherscroll.mjs'; +import { DateTime } from '../vendor/auto/luxon.mjs'; +import { elemForEach } from './utils/elem.mjs'; -// eslint-disable-next-line no-unused-vars class WeatherDisplay { constructor(navId, elemId, name, defaultEnabled) { // navId is used in messaging @@ -166,7 +169,6 @@ class WeatherDisplay { drawCurrentDateTime() { // only draw if canvas is active to conserve battery if (!this.isActive()) return; - const { DateTime } = luxon; // Get the current date and time. const now = DateTime.local(); @@ -174,14 +176,14 @@ class WeatherDisplay { const time = now.toLocaleString(DateTime.TIME_WITH_SECONDS).padStart(11, ' '); if (this.lastTime !== time) { - utils.elem.forEach('.date-time.time', (elem) => { elem.innerHTML = time.toUpperCase(); }); + elemForEach('.date-time.time', (elem) => { elem.innerHTML = time.toUpperCase(); }); } this.lastTime = time; const date = now.toFormat(' ccc LLL ') + now.day.toString().padStart(2, ' '); if (this.lastDate !== date) { - utils.elem.forEach('.date-time.date', (elem) => { elem.innerHTML = date.toUpperCase(); }); + elemForEach('.date-time.date', (elem) => { elem.innerHTML = date.toUpperCase(); }); } this.lastDate = date; } @@ -408,3 +410,5 @@ class WeatherDisplay { return template; } } + +export default WeatherDisplay; diff --git a/views/index.ejs b/views/index.ejs index 85f9ad7..b6a7314 100644 --- a/views/index.ejs +++ b/views/index.ejs @@ -34,7 +34,6 @@ - @@ -43,6 +42,7 @@ + @@ -53,7 +53,6 @@ -