current conditions ready for data

This commit is contained in:
Matt Walsh 2020-09-24 22:44:51 -05:00
parent 965cb29699
commit 0a6a31217b
12 changed files with 314 additions and 122 deletions

View file

@ -40,6 +40,7 @@ const js_sources = [
'server/scripts/modules/icons.js', 'server/scripts/modules/icons.js',
'server/scripts/modules/utilities.js', 'server/scripts/modules/utilities.js',
'server/scripts/modules/currentweather.js', 'server/scripts/modules/currentweather.js',
'server/scripts/modules/currentweatherscroll.js',
'server/scripts/modules/latestobservations.js', 'server/scripts/modules/latestobservations.js',
'server/scripts/modules/travelforecast.js', 'server/scripts/modules/travelforecast.js',
'server/scripts/modules/regionalforecast.js', 'server/scripts/modules/regionalforecast.js',

View file

@ -216,8 +216,6 @@ const index = (() => {
// Do not auto get the same city twice. // Do not auto get the same city twice.
if (this.previousSuggestionValue === suggestion.value) return; if (this.previousSuggestionValue === suggestion.value) return;
this.previousSuggestionValue = suggestion.value;
PreviousSuggestion = suggestion;
if (overrides[suggestion.value]) { if (overrides[suggestion.value]) {
doRedirectToGeometry(overrides[suggestion.value]); doRedirectToGeometry(overrides[suggestion.value]);

View file

@ -38,7 +38,6 @@ class Almanac extends WeatherDisplay {
// process images for outlook // process images for outlook
const [outlookTemp, outlookPrecip] = await Promise.all(imagePromises); const [outlookTemp, outlookPrecip] = await Promise.all(imagePromises);
console.log(outlookTemp,outlookPrecip);
const outlook = this.parseOutlooks(weatherParameters.latitude, weatherParameters.longitude, outlookTemp, outlookPrecip); const outlook = this.parseOutlooks(weatherParameters.latitude, weatherParameters.longitude, outlookTemp, outlookPrecip);
// store the data // store the data
@ -47,8 +46,8 @@ class Almanac extends WeatherDisplay {
moon, moon,
outlook, outlook,
}; };
// draw the canvas // update status
this.drawCanvas(); this.setStatus(STATUS.loaded);
} }
@ -295,7 +294,6 @@ class Almanac extends WeatherDisplay {
}); });
this.finishDraw(); this.finishDraw();
this.setStatus(STATUS.loaded);
break; break;
case 1: case 1:

View file

@ -50,45 +50,55 @@ class CurrentWeather extends WeatherDisplay {
this.setStatus(STATUS.loaded); this.setStatus(STATUS.loaded);
} }
async drawCanvas () { // format the data for use outside this function
super.drawCanvas(); parseData() {
if (!this.data) return false;
const data = {};
const observations = this.data.features[0].properties; const observations = this.data.features[0].properties;
// values from api are provided in metric // values from api are provided in metric
let Temperature = Math.round(observations.temperature.value); data.observations = observations;
let DewPoint = Math.round(observations.dewpoint.value); data.Temperature = Math.round(observations.temperature.value);
let Ceiling = Math.round(observations.cloudLayers[0].base.value); data.DewPoint = Math.round(observations.dewpoint.value);
let CeilingUnit = 'm.'; data.Ceiling = Math.round(observations.cloudLayers[0].base.value);
let Visibility = Math.round(observations.visibility.value/1000); data.CeilingUnit = 'm.';
let VisibilityUnit = ' km.'; data.Visibility = Math.round(observations.visibility.value/1000);
let WindSpeed = Math.round(observations.windSpeed.value); data.VisibilityUnit = ' km.';
const WindDirection = utils.calc.directionToNSEW(observations.windDirection.value); data.WindSpeed = Math.round(observations.windSpeed.value);
let Pressure = Math.round(observations.barometricPressure.value); data.WindDirection = utils.calc.directionToNSEW(observations.windDirection.value);
let HeatIndex = Math.round(observations.heatIndex.value); data.Pressure = Math.round(observations.barometricPressure.value);
let WindChill = Math.round(observations.windChill.value); data.HeatIndex = Math.round(observations.heatIndex.value);
let WindGust = Math.round(observations.windGust.value); data.WindChill = Math.round(observations.windChill.value);
let Humidity = Math.round(observations.relativeHumidity.value); data.WindGust = Math.round(observations.windGust.value);
const Icon = icons.getWeatherIconFromIconLink(observations.icon); data.Humidity = Math.round(observations.relativeHumidity.value);
let PressureDirection = ''; data.Icon = icons.getWeatherIconFromIconLink(observations.icon);
const TextConditions = observations.textDescription; data.PressureDirection = '';
data.TextConditions = observations.textDescription;
// difference since last measurement (pascals, looking for difference of more than 150) // difference since last measurement (pascals, looking for difference of more than 150)
const pressureDiff = (observations.barometricPressure.value - this.data.features[1].properties.barometricPressure.value); const pressureDiff = (observations.barometricPressure.value - this.data.features[1].properties.barometricPressure.value);
if (pressureDiff > 150) PressureDirection = 'R'; if (pressureDiff > 150) data.PressureDirection = 'R';
if (pressureDiff < -150) PressureDirection = 'F'; if (pressureDiff < -150) data.PressureDirection = 'F';
if (navigation.units() === UNITS.english) { if (navigation.units() === UNITS.english) {
Temperature = utils.units.celsiusToFahrenheit(Temperature); data.Temperature = utils.units.celsiusToFahrenheit(data.Temperature);
DewPoint = utils.units.celsiusToFahrenheit(DewPoint); data.DewPoint = utils.units.celsiusToFahrenheit(data.DewPoint);
Ceiling = Math.round(utils.units.metersToFeet(Ceiling)/100)*100; data.Ceiling = Math.round(utils.units.metersToFeet(data.Ceiling)/100)*100;
CeilingUnit = 'ft.'; data.CeilingUnit = 'ft.';
Visibility = utils.units.kilometersToMiles(observations.visibility.value/1000); data.Visibility = utils.units.kilometersToMiles(observations.visibility.value/1000);
VisibilityUnit = ' mi.'; data.VisibilityUnit = ' mi.';
WindSpeed = utils.units.kphToMph(WindSpeed); data.WindSpeed = utils.units.kphToMph(data.WindSpeed);
Pressure = utils.units.pascalToInHg(Pressure); data.Pressure = utils.units.pascalToInHg(data.Pressure);
HeatIndex = utils.units.celsiusToFahrenheit(HeatIndex); data.HeatIndex = utils.units.celsiusToFahrenheit(data.HeatIndex);
WindChill = utils.units.celsiusToFahrenheit(WindChill); data.WindChill = utils.units.celsiusToFahrenheit(data.WindChill);
WindGust = utils.units.kphToMph(WindGust); data.WindGust = utils.units.kphToMph(data.WindGust);
} }
return data;
}
async drawCanvas () {
super.drawCanvas();
// parse each time to deal with a change in units if necessary
const data = this.parseData();
this.context.drawImage(await this.backgroundImage, 0, 0); this.context.drawImage(await this.backgroundImage, 0, 0);
draw.horizontalGradientSingle(this.context, 0, 30, 500, 90, draw.topColor1, draw.topColor2); draw.horizontalGradientSingle(this.context, 0, 30, 500, 90, draw.topColor1, draw.topColor2);
@ -98,37 +108,37 @@ class CurrentWeather extends WeatherDisplay {
draw.titleText(this.context, 'Current', 'Conditions'); draw.titleText(this.context, 'Current', 'Conditions');
draw.text(this.context, 'Star4000 Large', '24pt', '#FFFFFF', 170, 135, Temperature + String.fromCharCode(176), 2); draw.text(this.context, 'Star4000 Large', '24pt', '#FFFFFF', 170, 135, data.Temperature + String.fromCharCode(176), 2);
let Conditions = observations.textDescription; let Conditions = data.observations.textDescription;
if (TextConditions.length > 15) { if (Conditions.length > 15) {
Conditions = this.shortConditions(Conditions); Conditions = this.shortConditions(Conditions);
} }
draw.text(this.context, 'Star4000 Extended', '24pt', '#FFFFFF', 195, 170, Conditions, 2, 'center'); draw.text(this.context, 'Star4000 Extended', '24pt', '#FFFFFF', 195, 170, Conditions, 2, 'center');
draw.text(this.context, 'Star4000 Extended', '24pt', '#FFFFFF', 80, 330, 'Wind:', 2); draw.text(this.context, 'Star4000 Extended', '24pt', '#FFFFFF', 80, 330, 'Wind:', 2);
draw.text(this.context, 'Star4000 Extended', '24pt', '#FFFFFF', 300, 330, WindDirection + ' ' + WindSpeed, 2, 'right'); draw.text(this.context, 'Star4000 Extended', '24pt', '#FFFFFF', 300, 330, data.WindDirection + ' ' + data.WindSpeed, 2, 'right');
if (WindGust) draw.text(this.context, 'Star4000 Extended', '24pt', '#FFFFFF', 80, 375, 'Gusts to ' + WindGust, 2); if (data.WindGust) draw.text(this.context, 'Star4000 Extended', '24pt', '#FFFFFF', 80, 375, 'Gusts to ' + data.WindGust, 2);
draw.text(this.context, 'Star4000 Large', 'bold 16pt', '#FFFF00', 315, 120, this.data.station.properties.name.substr(0, 20), 2); draw.text(this.context, 'Star4000 Large', 'bold 16pt', '#FFFF00', 315, 120, this.data.station.properties.name.substr(0, 20), 2);
draw.text(this.context, 'Star4000 Large', 'bold 16pt', '#FFFFFF', 340, 165, 'Humidity:', 2); draw.text(this.context, 'Star4000 Large', 'bold 16pt', '#FFFFFF', 340, 165, 'Humidity:', 2);
draw.text(this.context, 'Star4000 Large', 'bold 16pt', '#FFFFFF', 560, 165, Humidity + '%', 2, 'right'); draw.text(this.context, 'Star4000 Large', 'bold 16pt', '#FFFFFF', 560, 165, data.Humidity + '%', 2, 'right');
draw.text(this.context, 'Star4000 Large', 'bold 16pt', '#FFFFFF', 340, 205, 'Dewpoint:', 2); draw.text(this.context, 'Star4000 Large', 'bold 16pt', '#FFFFFF', 340, 205, 'Dewpoint:', 2);
draw.text(this.context, 'Star4000 Large', 'bold 16pt', '#FFFFFF', 560, 205, DewPoint + String.fromCharCode(176), 2, 'right'); draw.text(this.context, 'Star4000 Large', 'bold 16pt', '#FFFFFF', 560, 205, data.DewPoint + String.fromCharCode(176), 2, 'right');
draw.text(this.context, 'Star4000 Large', 'bold 16pt', '#FFFFFF', 340, 245, 'Ceiling:', 2); draw.text(this.context, 'Star4000 Large', 'bold 16pt', '#FFFFFF', 340, 245, 'Ceiling:', 2);
draw.text(this.context, 'Star4000 Large', 'bold 16pt', '#FFFFFF', 560, 245, (Ceiling === '' ? 'Unlimited' : Ceiling + CeilingUnit), 2, 'right'); draw.text(this.context, 'Star4000 Large', 'bold 16pt', '#FFFFFF', 560, 245, (data.Ceiling === '' ? 'Unlimited' : data.Ceiling + data.CeilingUnit), 2, 'right');
draw.text(this.context, 'Star4000 Large', 'bold 16pt', '#FFFFFF', 340, 285, 'Visibility:', 2); draw.text(this.context, 'Star4000 Large', 'bold 16pt', '#FFFFFF', 340, 285, 'Visibility:', 2);
draw.text(this.context, 'Star4000 Large', 'bold 16pt', '#FFFFFF', 560, 285, Visibility + VisibilityUnit, 2, 'right'); draw.text(this.context, 'Star4000 Large', 'bold 16pt', '#FFFFFF', 560, 285, data.Visibility + data.VisibilityUnit, 2, 'right');
draw.text(this.context, 'Star4000 Large', 'bold 16pt', '#FFFFFF', 340, 325, 'Pressure:', 2); draw.text(this.context, 'Star4000 Large', 'bold 16pt', '#FFFFFF', 340, 325, 'Pressure:', 2);
draw.text(this.context, 'Star4000 Large', 'bold 16pt', '#FFFFFF', 535, 325, Pressure, 2, 'right'); draw.text(this.context, 'Star4000 Large', 'bold 16pt', '#FFFFFF', 535, 325, data.Pressure, 2, 'right');
switch (PressureDirection) { switch (data.PressureDirection) {
case 'R': case 'R':
// Shadow // Shadow
draw.triangle(this.context, '#000000', 552, 302, 542, 312, 562, 312); draw.triangle(this.context, '#000000', 552, 302, 542, 312, 562, 312);
@ -158,17 +168,17 @@ class CurrentWeather extends WeatherDisplay {
default: default:
} }
if (observations.heatIndex.value && HeatIndex !== Temperature) { if (data.observations.heatIndex.value && data.HeatIndex !== data.Temperature) {
draw.text(this.context, 'Star4000 Large', 'bold 16pt', '#FFFFFF', 340, 365, 'Heat Index:', 2); draw.text(this.context, 'Star4000 Large', 'bold 16pt', '#FFFFFF', 340, 365, 'Heat Index:', 2);
draw.text(this.context, 'Star4000 Large', 'bold 16pt', '#FFFFFF', 560, 365, HeatIndex + String.fromCharCode(176), 2, 'right'); draw.text(this.context, 'Star4000 Large', 'bold 16pt', '#FFFFFF', 560, 365, data.HeatIndex + String.fromCharCode(176), 2, 'right');
} else if (observations.windChill.value && WindChill !== '' && WindChill < Temperature) { } else if (data.observations.windChill.value && data.WindChill !== '' && data.WindChill < data.Temperature) {
draw.text(this.context, 'Star4000 Large', 'bold 16pt', '#FFFFFF', 340, 365, 'Wind Chill:', 2); draw.text(this.context, 'Star4000 Large', 'bold 16pt', '#FFFFFF', 340, 365, 'Wind Chill:', 2);
draw.text(this.context, 'Star4000 Large', 'bold 16pt', '#FFFFFF', 560, 365, WindChill + String.fromCharCode(176), 2, 'right'); draw.text(this.context, 'Star4000 Large', 'bold 16pt', '#FFFFFF', 560, 365, data.WindChill + String.fromCharCode(176), 2, 'right');
} }
// get main icon // get main icon
this.gifs.push(await utils.image.superGifAsync({ this.gifs.push(await utils.image.superGifAsync({
src: Icon, src: data.Icon,
auto_play: true, auto_play: true,
canvas: this.canvas, canvas: this.canvas,
x: 140, x: 140,
@ -179,6 +189,11 @@ class CurrentWeather extends WeatherDisplay {
this.finishDraw(); this.finishDraw();
} }
// return the latest gathered information if available
getCurrentWeather() {
return this.parseData();
}
shortConditions(condition) { shortConditions(condition) {
condition = condition.replace(/Light/g, 'L'); condition = condition.replace(/Light/g, 'L');
condition = condition.replace(/Heavy/g, 'H'); condition = condition.replace(/Heavy/g, 'H');

View file

@ -0,0 +1,96 @@
'use strict';
/* globals draw, navigation */
// eslint-disable-next-line no-unused-vars
const currentWeatherScroll = (() => {
// local variables
let context; // currently active context
let blankDrawArea; // original state of context
let station;
let interval;
let screenIndex = 0;
// start drawing conditions
// reset starts from the first item in the text scroll list
const start = (_context) => {
// see if there is a context available
if (!_context) return;
// store see if the context is new
if (_context !== context) {
// clean the outgoing context
cleanLastContext();
// store the new blank context
blankDrawArea = _context.getImageData(0, 405, 640, 75);
}
// store the context locally
context = _context;
// set up the interval if needed
if (!interval) {
interval = setInterval(incrementInterval, 700);
}
// draw the data
drawScreen();
};
const stop = (reset) => {
cleanLastContext();
if (interval) interval = clearInterval(interval);
if (reset) screenIndex = 0;
};
const cleanLastContext = () => {
if (blankDrawArea) context.putImageData(blankDrawArea, 0, 405);
blankDrawArea = undefined;
context = undefined;
};
// increment interval, roll over
const incrementInterval = () => {
screenIndex = (screenIndex+1)%2;
// draw new text
drawScreen();
};
const drawScreen = () => {
// get the conditions
const data = navigation.getCurrentWeather();
// nothing to do if there's no data yet
if (!data) return;
if (!station) return;
// clean up any old text
context.putImageData(blankDrawArea, 0, 405);
switch (screenIndex) {
case 0:
default:
drawCondition(`Conditions at ${station.name.substr(0,20)}`);
break;
case 1:
drawCondition(`Page 2`);
break;
}
};
// internal draw function with preset parameters
const drawCondition = (text) => {
draw.text(context, 'Star4000', '24pt', '#ffffff', 70, 430, text, 2);
};
// store the latest station data
const setStation = (weatherParameters) => {
station = weatherParameters.stations[0].properties;
};
// return the api
return {
start,
stop,
setStation,
};
})();

View file

@ -1,7 +1,7 @@
'use strict'; 'use strict';
// navigation handles progress, next/previous and initial load messages from the parent frame // navigation handles progress, next/previous and initial load messages from the parent frame
/* globals index, utils, _StationInfo, STATUS */ /* globals index, utils, _StationInfo, STATUS */
/* globals CurrentWeather, LatestObservations, TravelForecast, RegionalForecast, LocalForecast, ExtendedForecast, Almanac, Radar, Progress */ /* globals CurrentWeather, LatestObservations, TravelForecast, RegionalForecast, LocalForecast, ExtendedForecast, Almanac, Radar, Progress, currentWeatherScroll */
document.addEventListener('DOMContentLoaded', () => { document.addEventListener('DOMContentLoaded', () => {
navigation.init(); navigation.init();
@ -19,6 +19,9 @@ const navigation = (() => {
let playing = false; let playing = false;
let progress; let progress;
// current conditions are made available from the display below
let currentWeather;
const init = async () => { const init = async () => {
// nothing to do // nothing to do
}; };
@ -94,8 +97,9 @@ const navigation = (() => {
// start loading canvases if necessary // start loading canvases if necessary
if (displays.length === 0) { if (displays.length === 0) {
currentWeather = new CurrentWeather(0,'currentWeather');
displays = [ displays = [
new CurrentWeather(0,'currentWeather'), currentWeather,
new LatestObservations(1, 'latestObservations'), new LatestObservations(1, 'latestObservations'),
new TravelForecast(2, 'travelForecast', false), // not active by default new TravelForecast(2, 'travelForecast', false), // not active by default
new RegionalForecast(3, 'regionalForecast'), new RegionalForecast(3, 'regionalForecast'),
@ -107,6 +111,8 @@ const navigation = (() => {
} }
// call for new data on each display // call for new data on each display
displays.forEach(display => display.getData(weatherParameters)); displays.forEach(display => display.getData(weatherParameters));
// pass the information to the bottom scroll
currentWeatherScroll.setStation(weatherParameters);
// GetMonthPrecipitation(this.weatherParameters); // GetMonthPrecipitation(this.weatherParameters);
// GetAirQuality3(this.weatherParameters); // GetAirQuality3(this.weatherParameters);
@ -256,6 +262,12 @@ const navigation = (() => {
// return the specificed display // return the specificed display
const getDisplay = (index) => displays[index]; const getDisplay = (index) => displays[index];
// get current conditions
const getCurrentWeather = () => {
if (!currentWeather) return false;
return currentWeather.getCurrentWeather();
};
return { return {
init, init,
message, message,
@ -265,5 +277,6 @@ const navigation = (() => {
displayNavMessage, displayNavMessage,
msg, msg,
getDisplay, getDisplay,
getCurrentWeather,
}; };
})(); })();

View file

@ -386,7 +386,6 @@ class RegionalForecast extends WeatherDisplay {
})); }));
this.finishDraw(); this.finishDraw();
this.setStatus(STATUS.loaded);
} }
} }

View file

@ -56,7 +56,6 @@ const utils = (() => {
const img = new Image(); const img = new Image();
img.scr = src; img.scr = src;
cachedImages.push(src); cachedImages.push(src);
console.log(cachedImages);
return true; return true;
}; };

View file

@ -1,6 +1,6 @@
// base weather display class // base weather display class
/* globals navigation, utils, draw, UNITS, luxon */ /* globals navigation, utils, draw, UNITS, luxon, currentWeatherScroll */
const STATUS = { const STATUS = {
loading: Symbol('loading'), loading: Symbol('loading'),
@ -150,6 +150,10 @@ class WeatherDisplay {
if (this.elemId === 'almanac') OkToDrawNoaaImage = false; if (this.elemId === 'almanac') OkToDrawNoaaImage = false;
if (this.elemId === 'travelForecast') OkToDrawNoaaImage = false; if (this.elemId === 'travelForecast') OkToDrawNoaaImage = false;
if (this.elemId === 'regionalForecast') OkToDrawNoaaImage = false; if (this.elemId === 'regionalForecast') OkToDrawNoaaImage = false;
if (this.elemId === 'progress') {
OkToDrawCurrentConditions = false;
OkToDrawNoaaImage = false;
}
if (this.elemId === 'radar') { if (this.elemId === 'radar') {
OkToDrawCurrentConditions = false; OkToDrawCurrentConditions = false;
OkToDrawCurrentDateTime = false; OkToDrawCurrentDateTime = false;
@ -171,8 +175,12 @@ class WeatherDisplay {
} }
if (OkToDrawLogoImage) this.drawLogoImage(); if (OkToDrawLogoImage) this.drawLogoImage();
if (OkToDrawNoaaImage) this.drawNoaaImage(); if (OkToDrawNoaaImage) this.drawNoaaImage();
// TODO: fix current conditions scroll if (OkToDrawCurrentConditions) {
// if (OkToDrawCurrentConditions) DrawCurrentConditions(WeatherParameters, this.context); currentWeatherScroll.start(this.context);
} else {
// cause a reset if the progress screen is displayed
currentWeatherScroll.stop(this.elemId === 'progress');
}
// TODO: add custom scroll text // TODO: add custom scroll text
// if (OkToDrawCustomScrollText) DrawCustomScrollText(WeatherParameters, context); // if (OkToDrawCustomScrollText) DrawCustomScrollText(WeatherParameters, context);
} }

View file

@ -1,5 +1,4 @@
/* globals _StationInfo, luxon, _RegionalCities, utils, icons, _TravelCities, SunCalc */ /* globals luxon, _TravelCities */
const _DayShortNames = { 'Sunday': 'Sun', 'Monday': 'Mon', 'Tuesday': 'Tue', 'Wednesday': 'Wed', 'Thursday': 'Thu', 'Friday': 'Fri', 'Saturday': 'Sat' };
var canvasRegionalObservations; var canvasRegionalObservations;
@ -28,9 +27,7 @@ var canvasAirQuality;
var canvasTravelForecast; var canvasTravelForecast;
var divOutlookTemp; var divOutlookTemp;
var cnvOutlookTemp;
var divOutlookPrcp; var divOutlookPrcp;
var cnvOutlookPrcp;
var canvasLatestObservations; var canvasLatestObservations;
@ -83,16 +80,6 @@ const GetMonthPrecipitation = async (WeatherParameters) => {
}; };
Date.prototype.stdTimezoneOffset = function () {
var jan = new Date(this.getFullYear(), 0, 1);
var jul = new Date(this.getFullYear(), 6, 1);
return Math.max(jan.getTimezoneOffset(), jul.getTimezoneOffset());
};
Date.prototype.dst = function () {
return this.getTimezoneOffset() < this.stdTimezoneOffset();
};
var GetWeatherHazards3 = function (WeatherParameters) { var GetWeatherHazards3 = function (WeatherParameters) {
var ZoneId = WeatherParameters.ZoneId; var ZoneId = WeatherParameters.ZoneId;
var HazardUrls = []; var HazardUrls = [];
@ -260,53 +247,6 @@ $(() => {
}); });
}); });
var NavigateMenu = function () {
if (_IsPlaying) {
NavigatePlayToggle();
}
Navigate(0);
_PlayMs = 0;
};
$.fn.scrollIntoView = function () {
const $self = this;
const OkToFadeOut = true;
_WeatherParameters.WeatherCanvases.forEach($WeatherCanvas => {
if (!$WeatherCanvas.is($self)) {
if ($WeatherCanvas.is(':visible')) {
$WeatherCanvas.css('z-index', '9999');
if (!OkToFadeOut) {
$WeatherCanvas.hide();
} else {
$WeatherCanvas.fadeOut({
progress: () => {
UpdateWeatherCanvas(_WeatherParameters, $WeatherCanvas);
UpdateWeatherCanvas(_WeatherParameters, $self);
},
});
}
}
} else {
if (!$WeatherCanvas.is(':visible')) {
$WeatherCanvas.css('z-index', '');
$WeatherCanvas.show();
}
$WeatherCanvas.stop();
$WeatherCanvas.css('opacity', '');
UpdateWeatherCanvas(_WeatherParameters, $WeatherCanvas);
}
});
_RefreshGifs = true;
window.setTimeout(function () { _RefreshGifs = false; }, 200);
};
var canvasProgress_mousemove = function (e) { var canvasProgress_mousemove = function (e) {
canvasProgress.css('cursor', ''); canvasProgress.css('cursor', '');
@ -517,7 +457,7 @@ const WeatherMonthlyTotalsParser = (text) => {
const Progress = function (e) {
const DrawCustomScrollText = (WeatherParameters, context) => { const DrawCustomScrollText = (WeatherParameters, context) => {
const font = 'Star4000'; const font = 'Star4000';
const size = '24pt'; const size = '24pt';
@ -554,3 +494,116 @@ const AssignScrollText = (e) => {
_UpdateWeatherCurrentConditionCounterMs = 0; _UpdateWeatherCurrentConditionCounterMs = 0;
}; };
var DrawCurrentConditions = function (WeatherParameters, context) {
var Humidity;
var DewPoint;
var Temperature;
var TemperatureUnit;
var HeatIndex;
var WindChill;
var Pressure;
var PressureDirection;
var WindSpeed;
var WindDirection;
var WindGust;
var WindUnit;
var Visibility;
var VisibilityUnit;
var Ceiling;
var CeilingUnit;
var PrecipitationTotal;
var PrecipitationTotalUnit;
var text;
if (WeatherParameters.Progress.GetTotalPercentage() != 100) {
return;
}
// Clear the date and time area.
context.drawImage(canvasBackGroundCurrentConditions[0], 0, 0, 640, 75, 0, 405, 640, 75);
var WeatherCurrentConditions = WeatherParameters.WeatherCurrentConditions;
var WeatherMonthlyTotals = WeatherParameters.WeatherMonthlyTotals;
if (_UpdateWeatherCurrentConditionCounterMs >= 4000) {
_UpdateWeatherCurrentConditionCounterMs = 0;
_UpdateWeatherCurrentConditionType++;
if (_UpdateWeatherCurrentConditionType > CurrentConditionTypes.MonthPrecipitation) {
_UpdateWeatherCurrentConditionType = CurrentConditionTypes.Title;
}
}
switch(_UpdateWeatherCurrentConditionType) {
case CurrentConditionTypes.Title:
// mjb 06/01/19 text = "Conditions at " + WeatherCurrentConditions.StationName;
text = 'Conditions at ' + WeatherCurrentConditions.StationName.substr(0, 20); // mjb 06/01/19
break;
case CurrentConditionTypes.Conditions:
text = WeatherCurrentConditions.Conditions;
break;
case CurrentConditionTypes.Temperature:
text = 'Temp: ' + Temperature + String.fromCharCode(176) + TemperatureUnit;
if (HeatIndex != Temperature) {
text += ' ';
text += 'Heat Index: ' + HeatIndex + String.fromCharCode(176) + TemperatureUnit;
} else if (WindChill != '' && WindChill < Temperature) {
text += ' ';
text += 'Wind Chill: ' + WindChill + String.fromCharCode(176) + TemperatureUnit;
}
break;
case CurrentConditionTypes.HumidityDewpoint:
text = 'Humidity: ' + Humidity + '%';
text += ' ';
text += 'Dewpoint: ' + DewPoint + String.fromCharCode(176) + TemperatureUnit;
break;
case CurrentConditionTypes.BarometricPressure:
text = 'Barometric Pressure: ' + Pressure + ' ' + PressureDirection;
break;
case CurrentConditionTypes.Wind:
if (WindSpeed > 0) {
text = 'Wind: ' + WindDirection + ' ' + WindSpeed + WindUnit;
} else if (WindSpeed == 'NA') {
text = 'Wind: NA';
} else {
text = 'Wind: Calm';
}
if (WindGust != '') {
text += ' ';
text += 'Gusts to ' + WindGust;
}
break;
case CurrentConditionTypes.VisibilityCeiling:
text = 'Visib: ' + parseInt(Visibility).toString() + VisibilityUnit;
text += ' ';
text += 'Ceiling: ' + (Ceiling == '' ? 'Unlimited' : Ceiling + CeilingUnit);
break;
case CurrentConditionTypes.MonthPrecipitation:
if (PrecipitationTotal.toString() == '') {
_UpdateWeatherCurrentConditionCounterMs += 4000;
DrawCurrentConditions(WeatherParameters, context);
return;
}
// mjb 10/02/19 Begin
//text = WeatherMonthlyTotals.MonthName + " Precipitation: " + PrecipitationTotal.toString() + PrecipitationTotalUnit;
if (PrecipitationTotal.toString() == 'T') {
text = WeatherMonthlyTotals.MonthName + ' Precipitation: Trace';
} else {
text = WeatherMonthlyTotals.MonthName + ' Precipitation: ' + PrecipitationTotal.toString() + PrecipitationTotalUnit;
}
// mjb 10/02/19 End
break;
default:
}
// Draw the current condition.
DrawText(context, font, size, color, x, y, text, shadow);
//_UpdateWeatherCurrentConditionCounterMs += _UpdateWeatherUpdateMs;
//console.log(_UpdateWeatherUpdateMs);
};

View file

@ -46,6 +46,7 @@
<script type="text/javascript" src="scripts/modules/icons.js"></script> <script type="text/javascript" src="scripts/modules/icons.js"></script>
<script type="text/javascript" src="scripts/modules/utilities.js"></script> <script type="text/javascript" src="scripts/modules/utilities.js"></script>
<script type="text/javascript" src="scripts/modules/currentweather.js"></script> <script type="text/javascript" src="scripts/modules/currentweather.js"></script>
<script type="text/javascript" src="scripts/modules/currentweatherscroll.js"></script>
<script type="text/javascript" src="scripts/modules/latestobservations.js"></script> <script type="text/javascript" src="scripts/modules/latestobservations.js"></script>
<script type="text/javascript" src="scripts/modules/travelforecast.js"></script> <script type="text/javascript" src="scripts/modules/travelforecast.js"></script>
<script type="text/javascript" src="scripts/modules/regionalforecast.js"></script> <script type="text/javascript" src="scripts/modules/regionalforecast.js"></script>

View file

@ -11,6 +11,7 @@
"**/*.code-search": true, "**/*.code-search": true,
"dist/**": true, "dist/**": true,
"**/*.min.js": true, "**/*.min.js": true,
"**/vendor": true,
}, },
"cSpell.enabled": true, "cSpell.enabled": true,
"cSpell.words": [ "cSpell.words": [
@ -23,5 +24,15 @@
"devbridge", "devbridge",
"nosleep" "nosleep"
], ],
"cSpell.ignorePaths": [
"**/package-lock.json",
"**/node_modules/**",
"**/vscode-extension/**",
"**/.git/objects/**",
".vscode",
".vscode-insiders",
"**/vendor/auto/**",
"**/twc3.js",
],
}, },
} }