diff --git a/server/scripts/modules/navigation.js b/server/scripts/modules/navigation.js index 9d41431..71ac900 100644 --- a/server/scripts/modules/navigation.js +++ b/server/scripts/modules/navigation.js @@ -95,14 +95,14 @@ const navigation = (() => { // start loading canvases if necessary if (displays.length === 0) { displays = [ - new CurrentWeather(0,'currentWeather', weatherParameters), - new LatestObservations(1, 'latestObservations', weatherParameters), - new TravelForecast(2, 'travelForecast', weatherParameters), - new RegionalForecast(3, 'regionalForecast', weatherParameters), - new LocalForecast(4, 'localForecast', weatherParameters), - new ExtendedForecast(5, 'extendedForecast', weatherParameters), - new Almanac(6, 'almanac', weatherParameters), - new Radar(7, 'radar', weatherParameters), + new CurrentWeather(0,'currentWeather'), + new LatestObservations(1, 'latestObservations'), + new TravelForecast(2, 'travelForecast', false), // not active by default + new RegionalForecast(3, 'regionalForecast'), + new LocalForecast(4, 'localForecast'), + new ExtendedForecast(5, 'extendedForecast'), + new Almanac(6, 'almanac'), + new Radar(7, 'radar'), ]; } // call for new data on each display diff --git a/server/scripts/modules/progress.js b/server/scripts/modules/progress.js index bd2261e..629f2ee 100644 --- a/server/scripts/modules/progress.js +++ b/server/scripts/modules/progress.js @@ -67,6 +67,11 @@ class Progress extends WeatherDisplay { statusColor = '#C0C0C0'; draw.box(this.context, 'rgb(33, 40, 90)', 475, y - 15, 75, 15); break; + case STATUS.disabled: + statusText = 'Disabled'; + statusColor = '#C0C0C0'; + this.context.drawImage(backgroundImage, 470, y - 20, 45, 25, 470, y - 20, 45, 25); + break; default: } // Erase any dots that spill into the status text. diff --git a/server/scripts/modules/travelforecast.js b/server/scripts/modules/travelforecast.js index f79bedc..63dc7b5 100644 --- a/server/scripts/modules/travelforecast.js +++ b/server/scripts/modules/travelforecast.js @@ -3,9 +3,9 @@ // eslint-disable-next-line no-unused-vars class TravelForecast extends WeatherDisplay { - constructor(navId, elemId) { + constructor(navId, elemId, defaultActive) { // special height and width for scrolling - super(navId, elemId, 'Travel Forecast'); + super(navId, elemId, 'Travel Forecast', defaultActive); // pre-load background image (returns promise) this.backgroundImage = utils.image.load('images/BackGround6_1.png'); @@ -29,7 +29,8 @@ class TravelForecast extends WeatherDisplay { } async getData() { - super.getData(); + // super checks for enabled + if (!super.getData()) return; const forecastPromises = _TravelCities.map(async city => { try { // get point then forecast diff --git a/server/scripts/modules/weatherdisplay.js b/server/scripts/modules/weatherdisplay.js index 8cf39c5..dbefeec 100644 --- a/server/scripts/modules/weatherdisplay.js +++ b/server/scripts/modules/weatherdisplay.js @@ -7,11 +7,12 @@ const STATUS = { loaded: Symbol('loaded'), failed: Symbol('failed'), noData: Symbol('noData'), + disabled: Symbol('disabled'), }; // eslint-disable-next-line no-unused-vars class WeatherDisplay { - constructor(navId, elemId, name) { + constructor(navId, elemId, name, defaultEnabled) { // navId is used in messaging this.navId = navId; this.elemId = undefined; @@ -29,10 +30,39 @@ class WeatherDisplay { this.navBaseCount = 0; this.screenIndex = -1; // special starting condition - this.setStatus(STATUS.loading); + if (elemId !== 'progress') this.addCheckbox(elemId, defaultEnabled); + if (this.enabled) { + this.setStatus(STATUS.loading); + } else { + this.setStatus(STATUS.disabled); + } this.createCanvas(elemId); } + addCheckbox(elemId, defaultEnabled = true) { + // get the saved status of the checkbox + let savedStatus = window.localStorage.getItem(`${elemId}Enabled`); + if (savedStatus === null) savedStatus = defaultEnabled; + if (savedStatus === 'true' || savedStatus === true) { + this.enabled = true; + } else { + this.enabled = false; + } + + // create a checkbox in the selected displays area + const checkbox = ``; + const availableDisplays = document.getElementById('enabledDisplays'); + availableDisplays.innerHTML += checkbox; + const checkboxElem = document.getElementById(`${elemId}Enabled`); + checkboxElem.addEventListener('click', this.checkboxChange); + } + + checkboxChange(e) { + console.log(e); + } + // set data status and send update to navigation module setStatus(value) { this.status = value; @@ -63,10 +93,17 @@ class WeatherDisplay { // clear current data this.data = undefined; // set status - this.setStatus(STATUS.loading); + + if (this.enabled) { + this.setStatus(STATUS.loading); + } else { + this.setStatus(STATUS.disabled); + return false; + } // recalculate navigation timing (in case it was modified in the constructor) this.calcNavTiming(); + return true; } drawCanvas() { @@ -226,7 +263,7 @@ class WeatherDisplay { } isEnabled() { - return true; + return this.enabled; } // navigation timings diff --git a/server/styles/index.css b/server/styles/index.css index 8d35c60..833a038 100644 --- a/server/styles/index.css +++ b/server/styles/index.css @@ -261,4 +261,14 @@ jsgif #container canvas { position: absolute; +} +.heading { + font-weight: bold; + margin-top: 15px; +} +#enabledDisplays { + margin-bottom: 15px; +} +#enabledDisplays label { + display: block; } \ No newline at end of file diff --git a/server/styles/twc3.css b/server/styles/twc3.css deleted file mode 100644 index 5f28270..0000000 --- a/server/styles/twc3.css +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/views/index.ejs b/views/index.ejs index d4e13a8..1916c02 100644 --- a/views/index.ejs +++ b/views/index.ejs @@ -160,6 +160,11 @@ More information +