Tweaks to allow hazard display to work on the local radar screen
This commit is contained in:
parent
5ed1eb2d2f
commit
67fa4d649a
4 changed files with 42 additions and 8 deletions
|
|
@ -28,6 +28,9 @@ let nextUpdate = DEFAULT_UPDATE;
|
||||||
let resetFlag;
|
let resetFlag;
|
||||||
let defaultScreensLoaded = true;
|
let defaultScreensLoaded = true;
|
||||||
|
|
||||||
|
const isRadarDisplay = (display) => display?.elemId === 'radar';
|
||||||
|
const isHazardsDisplay = (display) => display?.elemId === 'hazards';
|
||||||
|
|
||||||
// start drawing conditions
|
// start drawing conditions
|
||||||
// reset starts from the first item in the text scroll list
|
// reset starts from the first item in the text scroll list
|
||||||
const start = () => {
|
const start = () => {
|
||||||
|
|
@ -70,7 +73,7 @@ const incrementInterval = (force) => {
|
||||||
|
|
||||||
// test current screen
|
// test current screen
|
||||||
const display = currentDisplay();
|
const display = currentDisplay();
|
||||||
if (!display?.okToDrawCurrentConditions) {
|
if (!display || isHazardsDisplay(display) || (!display.okToDrawCurrentConditions && !isRadarDisplay(display))) {
|
||||||
stop(display?.elemId === 'progress');
|
stop(display?.elemId === 'progress');
|
||||||
hide();
|
hide();
|
||||||
return;
|
return;
|
||||||
|
|
@ -82,14 +85,20 @@ const incrementInterval = (force) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const drawScreen = async () => {
|
const drawScreen = async () => {
|
||||||
|
const display = currentDisplay();
|
||||||
|
if (!display || isHazardsDisplay(display) || (!display.okToDrawCurrentConditions && !isRadarDisplay(display))) {
|
||||||
|
hide();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// get the conditions
|
// get the conditions
|
||||||
const { data, parameters } = await getCurrentWeather();
|
const { data, parameters } = await getCurrentWeather();
|
||||||
|
|
||||||
// create a data object (empty if no valid current weather conditions)
|
// create a data object (empty if no valid current weather conditions)
|
||||||
const scrollData = data || {};
|
const scrollData = data || {};
|
||||||
|
|
||||||
// add the hazards if on screen 0
|
// add the hazards if on screen 0 or for Radar's hazard-only crawl
|
||||||
if (screenIndex === 0) {
|
if (screenIndex === 0 || isRadarDisplay(display)) {
|
||||||
const hazards = await getHazards();
|
const hazards = await getHazards();
|
||||||
if (hazards && hazards.length > 0) {
|
if (hazards && hazards.length > 0) {
|
||||||
scrollData.hazards = hazards;
|
scrollData.hazards = hazards;
|
||||||
|
|
@ -97,7 +106,24 @@ const drawScreen = async () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
// if we have no current weather and no hazards, there's nothing to display
|
// if we have no current weather and no hazards, there's nothing to display
|
||||||
if (!data && (!scrollData.hazards || scrollData.hazards.length === 0)) return;
|
if (!data && (!scrollData.hazards || scrollData.hazards.length === 0)) {
|
||||||
|
hide();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isRadarDisplay(display)) {
|
||||||
|
const radarHazard = hazards(scrollData);
|
||||||
|
if (!radarHazard) {
|
||||||
|
hide();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
mainScroll.classList.forEach((cls) => { if (cls !== 'scroll') mainScroll.classList.remove(cls); });
|
||||||
|
radarHazard.classes.forEach((cls) => mainScroll.classList.add(cls));
|
||||||
|
setHeader(radarHazard.header);
|
||||||
|
drawScrollCondition(radarHazard);
|
||||||
|
show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const thisScreen = workingScreens[screenIndex](scrollData, parameters);
|
const thisScreen = workingScreens[screenIndex](scrollData, parameters);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -171,9 +171,9 @@ class WeatherDisplay {
|
||||||
// clean up the first-run flag in screen index
|
// clean up the first-run flag in screen index
|
||||||
if (this.screenIndex < 0) this.screenIndex = 0;
|
if (this.screenIndex < 0) this.screenIndex = 0;
|
||||||
if (this.okToDrawCurrentDateTime) this.drawCurrentDateTime();
|
if (this.okToDrawCurrentDateTime) this.drawCurrentDateTime();
|
||||||
if (this.okToDrawCurrentConditions) postMessage({ type: 'current-weather-scroll', method: 'start' });
|
if (this.okToDrawCurrentConditions || this.elemId === 'radar') postMessage({ type: 'current-weather-scroll', method: 'start' });
|
||||||
if (!this.okToDrawCurrentConditions) postMessage({ type: 'current-weather-scroll', method: 'non-display' });
|
if (!this.okToDrawCurrentConditions && this.elemId !== 'radar') postMessage({ type: 'current-weather-scroll', method: 'non-display' });
|
||||||
if (this.okToDrawCurrentConditions === false) postMessage({ type: 'current-weather-scroll', method: 'hide' });
|
if (this.okToDrawCurrentConditions === false && this.elemId !== 'radar') postMessage({ type: 'current-weather-scroll', method: 'hide' });
|
||||||
}
|
}
|
||||||
|
|
||||||
finishDraw() {
|
finishDraw() {
|
||||||
|
|
|
||||||
|
|
@ -167,6 +167,14 @@
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.radar #container>.scroll {
|
||||||
|
z-index: 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
.radar #container>.scroll.hazard {
|
||||||
|
z-index: 1000 !important;
|
||||||
|
}
|
||||||
|
|
||||||
.wide #container>.scroll {
|
.wide #container>.scroll {
|
||||||
width: 854px;
|
width: 854px;
|
||||||
margin-left: -107px;
|
margin-left: -107px;
|
||||||
|
|
|
||||||
2
server/styles/ws.min.css
vendored
2
server/styles/ws.min.css
vendored
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue