diff --git a/server/scripts/modules/almanac.mjs b/server/scripts/modules/almanac.mjs
index 92be74e..de39ace 100644
--- a/server/scripts/modules/almanac.mjs
+++ b/server/scripts/modules/almanac.mjs
@@ -21,7 +21,7 @@ class Almanac extends WeatherDisplay {
this.timing.totalScreens = 1;
}
- async getData(_weatherParameters) {
+ async getData(_weatherParameters, refresh) {
const superResponse = super.getData(_weatherParameters);
const weatherParameters = _weatherParameters ?? this.weatherParameters;
diff --git a/server/scripts/modules/currentweather.mjs b/server/scripts/modules/currentweather.mjs
index f4ecd89..ab2a95a 100644
--- a/server/scripts/modules/currentweather.mjs
+++ b/server/scripts/modules/currentweather.mjs
@@ -21,7 +21,7 @@ class CurrentWeather extends WeatherDisplay {
this.backgroundImage = loadImg('images/BackGround1_1.png');
}
- async getData(_weatherParameters) {
+ async getData(_weatherParameters, refresh) {
// always load the data for use in the lower scroll
const superResult = super.getData(_weatherParameters);
const weatherParameters = _weatherParameters ?? this.weatherParameters;
diff --git a/server/scripts/modules/extendedforecast.mjs b/server/scripts/modules/extendedforecast.mjs
index 8cbd103..d05d615 100644
--- a/server/scripts/modules/extendedforecast.mjs
+++ b/server/scripts/modules/extendedforecast.mjs
@@ -18,7 +18,7 @@ class ExtendedForecast extends WeatherDisplay {
this.timing.totalScreens = 2;
}
- async getData(_weatherParameters) {
+ async getData(_weatherParameters, refresh) {
if (!super.getData(_weatherParameters)) return;
const weatherParameters = _weatherParameters ?? this.weatherParameters;
diff --git a/server/scripts/modules/hazards.mjs b/server/scripts/modules/hazards.mjs
index a24c0a0..e77d8cd 100644
--- a/server/scripts/modules/hazards.mjs
+++ b/server/scripts/modules/hazards.mjs
@@ -26,7 +26,7 @@ class Hazards extends WeatherDisplay {
this.timing.totalScreens = 0;
}
- async getData(weatherParameters) {
+ async getData(weatherParameters, refresh) {
// super checks for enabled
const superResult = super.getData(weatherParameters);
diff --git a/server/scripts/modules/hourly-graph.mjs b/server/scripts/modules/hourly-graph.mjs
index a0609c4..c9201ee 100644
--- a/server/scripts/modules/hourly-graph.mjs
+++ b/server/scripts/modules/hourly-graph.mjs
@@ -23,7 +23,7 @@ class HourlyGraph extends WeatherDisplay {
this.elem.querySelector('.header .right').append(header);
}
- async getData() {
+ async getData(_weatherParameters, refresh) {
if (!super.getData()) return;
const data = await getHourlyData(() => this.stillWaiting());
diff --git a/server/scripts/modules/hourly.mjs b/server/scripts/modules/hourly.mjs
index 4aff36f..62cfae2 100644
--- a/server/scripts/modules/hourly.mjs
+++ b/server/scripts/modules/hourly.mjs
@@ -27,7 +27,7 @@ class Hourly extends WeatherDisplay {
this.timing.delay.push(150);
}
- async getData(weatherParameters) {
+ async getData(weatherParameters, refresh) {
// super checks for enabled
const superResponse = super.getData(weatherParameters);
let forecast;
diff --git a/server/scripts/modules/latestobservations.mjs b/server/scripts/modules/latestobservations.mjs
index 2d44c82..e6399ab 100644
--- a/server/scripts/modules/latestobservations.mjs
+++ b/server/scripts/modules/latestobservations.mjs
@@ -16,7 +16,7 @@ class LatestObservations extends WeatherDisplay {
this.MaximumRegionalStations = 7;
}
- async getData(_weatherParameters) {
+ async getData(_weatherParameters, refresh) {
if (!super.getData(_weatherParameters)) return;
const weatherParameters = _weatherParameters ?? this.weatherParameters;
diff --git a/server/scripts/modules/localforecast.mjs b/server/scripts/modules/localforecast.mjs
index 714e916..b1ef5a6 100644
--- a/server/scripts/modules/localforecast.mjs
+++ b/server/scripts/modules/localforecast.mjs
@@ -14,7 +14,7 @@ class LocalForecast extends WeatherDisplay {
this.timing.baseDelay = 5000;
}
- async getData(_weatherParameters) {
+ async getData(_weatherParameters, refresh) {
if (!super.getData(_weatherParameters)) return;
const weatherParameters = _weatherParameters ?? this.weatherParameters;
diff --git a/server/scripts/modules/radar.mjs b/server/scripts/modules/radar.mjs
index 7beac32..06880ae 100644
--- a/server/scripts/modules/radar.mjs
+++ b/server/scripts/modules/radar.mjs
@@ -42,7 +42,7 @@ class Radar extends WeatherDisplay {
];
}
- async getData(_weatherParameters) {
+ async getData(_weatherParameters, refresh) {
if (!super.getData(_weatherParameters)) return;
const weatherParameters = _weatherParameters ?? this.weatherParameters;
@@ -70,7 +70,7 @@ class Radar extends WeatherDisplay {
const lists = (await Promise.all(baseUrls.map(async (url) => {
try {
- // get a list of available radars
+ // get a list of available radars
return text(url, { cors: true });
} catch (error) {
console.log('Unable to get list of radars');
@@ -91,7 +91,7 @@ class Radar extends WeatherDisplay {
const anchors = xmlDoc.querySelectorAll('a');
const urls = [];
Array.from(anchors).forEach((elem) => {
- if (elem.innerHTML?.match(/n0r_\d{12}\.png/)) {
+ if (elem.innerHTML?.match(/n0r_\d{12}\.png/)) {
urls.push(elem.href);
}
});
diff --git a/server/scripts/modules/regionalforecast.mjs b/server/scripts/modules/regionalforecast.mjs
index 82d5f27..97838f8 100644
--- a/server/scripts/modules/regionalforecast.mjs
+++ b/server/scripts/modules/regionalforecast.mjs
@@ -21,7 +21,7 @@ class RegionalForecast extends WeatherDisplay {
this.timing.totalScreens = 3;
}
- async getData(_weatherParameters) {
+ async getData(_weatherParameters, refresh) {
if (!super.getData(_weatherParameters)) return;
const weatherParameters = _weatherParameters ?? this.weatherParameters;
diff --git a/server/scripts/modules/settings.mjs b/server/scripts/modules/settings.mjs
index 2a5a7b0..06f0252 100644
--- a/server/scripts/modules/settings.mjs
+++ b/server/scripts/modules/settings.mjs
@@ -22,6 +22,13 @@ const init = () => {
['us', 'US'],
['si', 'Metric'],
]);
+ settings.refreshTime = new Setting('refreshTime', 'Refresh Time', 'select', 30_000, null, false, [
+ [30_000, 'TESTING'],
+ [300_000, '5 minutes'],
+ [600_000, '10 minutes'],
+ [900_000, '15 minutes'],
+ [1_800_000, '30 minutes'],
+ ]);
// generate html objects
const settingHtml = Object.values(settings).map((d) => d.generate());
diff --git a/server/scripts/modules/travelforecast.mjs b/server/scripts/modules/travelforecast.mjs
index 920ab2c..6b68fdf 100644
--- a/server/scripts/modules/travelforecast.mjs
+++ b/server/scripts/modules/travelforecast.mjs
@@ -28,9 +28,9 @@ class TravelForecast extends WeatherDisplay {
this.timing.delay.push(150);
}
- async getData() {
+ async getData(weatherParameters, refresh) {
// super checks for enabled
- if (!super.getData()) return;
+ if (!super.getData(this.weatherParameters)) return;
const forecastPromises = TravelCities.map(async (city) => {
try {
// get point then forecast
diff --git a/server/scripts/modules/weatherdisplay.mjs b/server/scripts/modules/weatherdisplay.mjs
index a1906d9..8f8ca59 100644
--- a/server/scripts/modules/weatherdisplay.mjs
+++ b/server/scripts/modules/weatherdisplay.mjs
@@ -22,6 +22,7 @@ class WeatherDisplay {
this.okToDrawCurrentConditions = true;
this.okToDrawCurrentDateTime = true;
this.showOnProgress = true;
+ this.autoRefreshHandle = null;
// default navigation timing
this.timing = {
@@ -129,9 +130,14 @@ class WeatherDisplay {
}
// get necessary data for this display
- getData(weatherParameters) {
- // clear current data
- this.data = undefined;
+ getData(weatherParameters, refresh) {
+ // refresh doesn't delete existing data, and is resued if the silent refresh fails
+ if (!refresh) {
+ this.data = undefined;
+ }
+ // clear any refresh timers
+ clearTimeout(this.autoRefreshHandle);
+ this.autoRefreshHandle = null;
// store weatherParameters locally in case we need them later
if (weatherParameters) this.weatherParameters = weatherParameters;
@@ -144,6 +150,9 @@ class WeatherDisplay {
return false;
}
+ // set up auto reload
+ this.autoRefreshHandle = setTimeout(() => this.getData(false, true), settings.refreshTime.value);
+
// recalculate navigation timing (in case it was modified in the constructor)
this.calcNavTiming();
return true;
diff --git a/views/index.ejs b/views/index.ejs
index ef4c78d..cca6680 100644
--- a/views/index.ejs
+++ b/views/index.ejs
@@ -14,7 +14,7 @@
-
+