mirror of
https://github.com/netbymatt/ws4kp.git
synced 2026-04-17 09:09:30 -07:00
change to structured weather icon paths
This commit is contained in:
@@ -13,10 +13,10 @@ class Almanac extends WeatherDisplay {
|
||||
this.backgroundImage0 = loadImg('images/backgrounds/1.png');
|
||||
|
||||
// preload the moon images
|
||||
preloadImg('images/2/Full-Moon.gif');
|
||||
preloadImg('images/2/Last-Quarter.gif');
|
||||
preloadImg('images/2/New-Moon.gif');
|
||||
preloadImg('images/2/First-Quarter.gif');
|
||||
preloadImg(imageName('Full'));
|
||||
preloadImg(imageName('Last'));
|
||||
preloadImg(imageName('New'));
|
||||
preloadImg(imageName('First'));
|
||||
|
||||
this.timing.totalScreens = 1;
|
||||
}
|
||||
@@ -160,14 +160,14 @@ class Almanac extends WeatherDisplay {
|
||||
const imageName = (type) => {
|
||||
switch (type) {
|
||||
case 'Full':
|
||||
return 'images/2/Full-Moon.gif';
|
||||
return 'images/icons/moon-phases/Full-Moon.gif';
|
||||
case 'Last':
|
||||
return 'images/2/Last-Quarter.gif';
|
||||
return 'images/icons/moon-phases/Last-Quarter.gif';
|
||||
case 'New':
|
||||
return 'images/2/New-Moon.gif';
|
||||
return 'images/icons/moon-phases/New-Moon.gif';
|
||||
case 'First':
|
||||
default:
|
||||
return 'images/2/First-Quarter.gif';
|
||||
return 'images/icons/moon-phases/First-Quarter.gif';
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const hourlyIcon = (skyCover, weather, iceAccumulation, probabilityOfPrecipitation, snowfallAmount, windSpeed, isNight = false) => {
|
||||
// internal function to add path to returned icon
|
||||
const addPath = (icon) => `images/r/${icon}`;
|
||||
const addPath = (icon) => `images/icons/regional-maps/${icon}`;
|
||||
|
||||
// possible phenomenon
|
||||
let thunder = false;
|
||||
@@ -22,17 +22,16 @@ const hourlyIcon = (skyCover, weather, iceAccumulation, probabilityOfPrecipitati
|
||||
// first item in list is highest priority, units are metric where applicable
|
||||
if (iceAccumulation > 0 || ice) return addPath('Freezing-Rain-1992.gif');
|
||||
if (snowfallAmount > 10) {
|
||||
if (windSpeed > 30 || wind) return addPath('Blowing Snow.gif');
|
||||
if (windSpeed > 30 || wind) return addPath('Blowing-Snow.gif');
|
||||
return addPath('Heavy-Snow-1994.gif');
|
||||
}
|
||||
if ((snowfallAmount > 0 || snow) && thunder) return addPath('ThunderSnow.gif');
|
||||
if (snowfallAmount > 0 || snow) return addPath('Light-Snow.gif');
|
||||
if (thunder) return (addPath('Thunderstorm.gif'));
|
||||
if (probabilityOfPrecipitation > 70) return addPath('Rain-1992.gif');
|
||||
if (probabilityOfPrecipitation > 50) return addPath('Shower.gif');
|
||||
if (probabilityOfPrecipitation > 30) {
|
||||
if (!isNight) return addPath('Scattered-Showers-1994.gif');
|
||||
return addPath('Scattered-Showers-Night.gif');
|
||||
return addPath('Scattered-Showers-Night-1994.gif');
|
||||
}
|
||||
if (fog) return addPath('Fog.gif');
|
||||
if (skyCover > 70) return addPath('Cloudy.gif');
|
||||
@@ -42,7 +41,7 @@ const hourlyIcon = (skyCover, weather, iceAccumulation, probabilityOfPrecipitati
|
||||
}
|
||||
if (skyCover > 30) {
|
||||
if (!isNight) return addPath('Partly-Cloudy.gif');
|
||||
return addPath('Mostly-Clear.gif');
|
||||
return addPath('Partly-Cloudy-Night.gif');
|
||||
}
|
||||
if (isNight) return addPath('Clear-1992.gif');
|
||||
return addPath('Sunny.gif');
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
/* spell-checker: disable */
|
||||
// internal function to add path to returned icon
|
||||
const addPath = (icon) => `images/icons/current-conditions/${icon}`;
|
||||
|
||||
const largeIcon = (link, _isNightTime) => {
|
||||
if (!link) return false;
|
||||
|
||||
// internal function to add path to returned icon
|
||||
const addPath = (icon) => `images/${icon}`;
|
||||
// extract day or night if not provided
|
||||
const isNightTime = _isNightTime ?? link.indexOf('/night/') >= 0;
|
||||
|
||||
@@ -24,18 +26,18 @@ const largeIcon = (link, _isNightTime) => {
|
||||
case 'hot':
|
||||
case 'haze':
|
||||
case 'cold':
|
||||
return addPath('CC_Clear1.gif');
|
||||
return addPath('Sunny.gif');
|
||||
|
||||
case 'skc-n':
|
||||
case 'nskc':
|
||||
case 'nskc-n':
|
||||
case 'cold-n':
|
||||
return addPath('CC_Clear0.gif');
|
||||
return addPath('Clear.gif');
|
||||
|
||||
case 'sct':
|
||||
case 'few':
|
||||
case 'bkn':
|
||||
return addPath('CC_PartlyCloudy1.gif');
|
||||
return addPath('Partly-Cloudy.gif');
|
||||
|
||||
case 'bkn-n':
|
||||
case 'few-n':
|
||||
@@ -44,68 +46,63 @@ const largeIcon = (link, _isNightTime) => {
|
||||
case 'sct-n':
|
||||
case 'nsct':
|
||||
case 'nsct-n':
|
||||
return addPath('CC_PartlyCloudy0.gif');
|
||||
return addPath('Mostly-Clear.gif');
|
||||
|
||||
case 'ovc':
|
||||
case 'novc':
|
||||
case 'ovc-n':
|
||||
return addPath('CC_Cloudy.gif');
|
||||
return addPath('Cloudy.gif');
|
||||
|
||||
case 'fog':
|
||||
case 'fog-n':
|
||||
return addPath('CC_Fog.gif');
|
||||
return addPath('Fog.gif');
|
||||
|
||||
case 'rain_sleet':
|
||||
case 'rain_sleet-n':
|
||||
return addPath('Rain-Sleet.gif');
|
||||
|
||||
case 'sleet':
|
||||
case 'sleet-n':
|
||||
return addPath('Sleet.gif');
|
||||
|
||||
case 'rain_showers':
|
||||
case 'rain_showers_high':
|
||||
return addPath('CC_Showers.gif');
|
||||
|
||||
case 'rain_showers-n':
|
||||
case 'rain_showers_high-n':
|
||||
return addPath('CC_Showers.gif');
|
||||
return addPath('Shower.gif');
|
||||
|
||||
case 'rain':
|
||||
case 'rain-n':
|
||||
return addPath('CC_Rain.gif');
|
||||
return addPath('Rain.gif');
|
||||
|
||||
// case 'snow':
|
||||
// return addPath('Light-Snow.gif');
|
||||
// break;
|
||||
// case 'cc_snowshowers.gif':
|
||||
// //case "heavy-snow.gif":
|
||||
// return addPath('AM-Snow-1994.gif');
|
||||
// break;
|
||||
case 'snow':
|
||||
case 'snow-n':
|
||||
if (value > 50) return addPath('CC_Snow.gif');
|
||||
return addPath('CC_SnowShowers.gif');
|
||||
if (value > 50) return addPath('Heavy-Snow.gif');
|
||||
return addPath('Light-Snow.gif');
|
||||
|
||||
case 'rain_snow':
|
||||
return addPath('CC_RainSnow.gif');
|
||||
return addPath('Rain-Snow.gif');
|
||||
|
||||
case 'snow_fzra':
|
||||
case 'snow_fzra-n':
|
||||
return addPath('Freezing-Rain-Snow.gif');
|
||||
|
||||
case 'fzra':
|
||||
case 'fzra-n':
|
||||
case 'rain_fzra':
|
||||
case 'rain_fzra-n':
|
||||
return addPath('CC_FreezingRain.gif');
|
||||
return addPath('Freezing-Rain.gif');
|
||||
|
||||
case 'snow_sleet':
|
||||
return addPath('Snow-Sleet.gif');
|
||||
|
||||
case 'tsra_sct':
|
||||
case 'tsra':
|
||||
return addPath('EF_ScatTstorms.gif');
|
||||
return addPath('Scattered-Thunderstorms-Day.gif');
|
||||
|
||||
case 'tsra_sct-n':
|
||||
case 'tsra-n':
|
||||
return addPath('CC_TStorm.gif');
|
||||
return addPath('Scattered-Thunderstorms-Night.gif');
|
||||
|
||||
case 'tsra_hi':
|
||||
case 'tsra_hi-n':
|
||||
@@ -113,7 +110,7 @@ const largeIcon = (link, _isNightTime) => {
|
||||
case 'tropical_storm':
|
||||
case 'hurricane-n':
|
||||
case 'tropical_storm-n':
|
||||
return addPath('CC_TStorm.gif');
|
||||
return addPath('Thunderstorm.gif');
|
||||
|
||||
case 'wind_few':
|
||||
case 'wind_sct':
|
||||
@@ -125,7 +122,7 @@ const largeIcon = (link, _isNightTime) => {
|
||||
case 'wind_ovc-n':
|
||||
case 'wind_skc-n':
|
||||
case 'wind_sct-n':
|
||||
return addPath('CC_Windy.gif');
|
||||
return addPath('Windy.gif');
|
||||
|
||||
case 'blizzard':
|
||||
case 'blizzard-n':
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/* spell-checker: disable */
|
||||
// internal function to add path to returned icon
|
||||
const addPath = (icon) => `images/icons/regional-maps/${icon}`;
|
||||
|
||||
const smallIcon = (link, _isNightTime) => {
|
||||
// extract day or night if not provided
|
||||
const isNightTime = _isNightTime ?? link.indexOf('/night/') >= 0;
|
||||
// internal function to add path to returned icon
|
||||
const addPath = (icon) => `images/r/${icon}`;
|
||||
|
||||
// grab everything after the last slash ending at any of these: ?&,
|
||||
const afterLastSlash = link.toLowerCase().match(/[^/]+$/)[0];
|
||||
@@ -20,8 +20,6 @@ const smallIcon = (link, _isNightTime) => {
|
||||
// find the icon
|
||||
switch (conditionName + (isNightTime ? '-n' : '')) {
|
||||
case 'skc':
|
||||
case 'hot':
|
||||
case 'haze':
|
||||
return addPath('Sunny.gif');
|
||||
|
||||
case 'skc-n':
|
||||
@@ -31,13 +29,13 @@ const smallIcon = (link, _isNightTime) => {
|
||||
return addPath('Clear-1992.gif');
|
||||
|
||||
case 'bkn':
|
||||
return addPath('Mostly-Cloudy-1994-2.gif');
|
||||
return addPath('Mostly-Cloudy-1994.gif');
|
||||
|
||||
case 'bkn-n':
|
||||
case 'few-n':
|
||||
case 'nfew-n':
|
||||
case 'nfew':
|
||||
return addPath('Partly-Clear-1994-2.gif');
|
||||
return addPath('Partly-Clear-1994.gif');
|
||||
|
||||
case 'sct':
|
||||
case 'few':
|
||||
@@ -46,7 +44,7 @@ const smallIcon = (link, _isNightTime) => {
|
||||
case 'sct-n':
|
||||
case 'nsct':
|
||||
case 'nsct-n':
|
||||
return addPath('Mostly-Clear.gif');
|
||||
return addPath('Partly-Cloudy-Night.gif');
|
||||
|
||||
case 'ovc':
|
||||
case 'ovc-n':
|
||||
@@ -57,30 +55,23 @@ const smallIcon = (link, _isNightTime) => {
|
||||
return addPath('Fog.gif');
|
||||
|
||||
case 'rain_sleet':
|
||||
return addPath('Sleet.gif');
|
||||
return addPath('Rain-Sleet.gif');
|
||||
|
||||
case 'rain_showers':
|
||||
case 'rain_showers_high':
|
||||
return addPath('Scattered-Showers-1994-2.gif');
|
||||
return addPath('Scattered-Showers-1994.gif');
|
||||
|
||||
case 'rain_showers-n':
|
||||
case 'rain_showers_high-n':
|
||||
return addPath('Scattered-Showers-Night-1994-2.gif');
|
||||
return addPath('Scattered-Showers-Night-1994.gif');
|
||||
|
||||
case 'rain':
|
||||
case 'rain-n':
|
||||
return addPath('Rain-1992.gif');
|
||||
|
||||
// case 'snow':
|
||||
// return addPath('Light-Snow.gif');
|
||||
// break;
|
||||
// case 'cc_snowshowers.gif':
|
||||
// //case "heavy-snow.gif":
|
||||
// return addPath('AM-Snow-1994.gif');
|
||||
// break;
|
||||
case 'snow':
|
||||
case 'snow-n':
|
||||
if (value > 50) return addPath('Heavy-Snow-1994-2.gif');
|
||||
if (value > 50) return addPath('Heavy-Snow-1994.gif');
|
||||
return addPath('Light-Snow.gif');
|
||||
|
||||
case 'rain_snow':
|
||||
@@ -89,7 +80,7 @@ const smallIcon = (link, _isNightTime) => {
|
||||
|
||||
case 'snow_fzra':
|
||||
case 'snow_fzra-n':
|
||||
return addPath('Freezing-Rain-Snow-1992.gif');
|
||||
return addPath('Freezing-Rain-Snow-1994.gif');
|
||||
|
||||
case 'fzra':
|
||||
case 'fzra-n':
|
||||
@@ -99,7 +90,7 @@ const smallIcon = (link, _isNightTime) => {
|
||||
|
||||
case 'snow_sleet':
|
||||
case 'snow_sleet-n':
|
||||
return addPath('Snow and Sleet.gif');
|
||||
return addPath('Snow-Sleet.gif');
|
||||
|
||||
case 'sleet':
|
||||
case 'sleet-n':
|
||||
@@ -107,11 +98,11 @@ const smallIcon = (link, _isNightTime) => {
|
||||
|
||||
case 'tsra_sct':
|
||||
case 'tsra':
|
||||
return addPath('Scattered-Tstorms-1994-2.gif');
|
||||
return addPath('Scattered-Tstorms-1994.gif');
|
||||
|
||||
case 'tsra_sct-n':
|
||||
case 'tsra-n':
|
||||
return addPath('Scattered-Tstorms-Night-1994-2.gif');
|
||||
return addPath('Scattered-Tstorms-Night-1994.gif');
|
||||
|
||||
case 'tsra_hi':
|
||||
case 'tsra_hi-n':
|
||||
@@ -124,13 +115,15 @@ const smallIcon = (link, _isNightTime) => {
|
||||
case 'wind':
|
||||
case 'wind_few':
|
||||
case 'wind_sct':
|
||||
case 'wind_bkn':
|
||||
case 'wind_ovc':
|
||||
case 'wind-n':
|
||||
case 'wind_few-n':
|
||||
return addPath('Wind.gif');
|
||||
|
||||
case 'wind_bkn':
|
||||
case 'wind_ovc':
|
||||
case 'wind_bkn-n':
|
||||
case 'wind_ovc-n':
|
||||
return addPath('Wind.gif');
|
||||
return addPath('Cloudy-Wind.gif');
|
||||
|
||||
case 'wind_skc':
|
||||
return addPath('Sunny-Wind-1994.gif');
|
||||
@@ -144,7 +137,17 @@ const smallIcon = (link, _isNightTime) => {
|
||||
return addPath('Blowing Snow.gif');
|
||||
|
||||
case 'cold':
|
||||
return addPath('cold.gif');
|
||||
return addPath('Cold.gif');
|
||||
|
||||
case 'smoke':
|
||||
case 'smoke-n':
|
||||
return addPath('Smoke.gif');
|
||||
|
||||
case 'hot':
|
||||
return addPath('Hot.gif');
|
||||
|
||||
case 'haze':
|
||||
return addPath('Haze.gif');
|
||||
|
||||
default:
|
||||
console.log(`Unable to locate regional icon for ${conditionName} ${link} ${isNightTime}`);
|
||||
|
||||
Reference in New Issue
Block a user