mirror of
https://github.com/netbymatt/ws4kp.git
synced 2026-04-17 09:09:30 -07:00
More icon options for hourly forecast
This commit is contained in:
@@ -108,6 +108,7 @@ const icons = (() => {
|
||||
case 'tsra_hi':
|
||||
case 'tsra_hi-n':
|
||||
case 'hurricane':
|
||||
case 'tropical_storm':
|
||||
return addPath('Thunderstorm.gif');
|
||||
|
||||
case 'wind_few':
|
||||
@@ -229,6 +230,7 @@ const icons = (() => {
|
||||
case 'tsra_hi':
|
||||
case 'tsra_hi-n':
|
||||
case 'hurricane':
|
||||
case 'tropical_storm':
|
||||
return addPath('CC_TStorm.gif');
|
||||
|
||||
case 'wind_few':
|
||||
@@ -256,19 +258,40 @@ const icons = (() => {
|
||||
// internal function to add path to returned icon
|
||||
const addPath = (icon) => `images/r/${icon}`;
|
||||
|
||||
// possible phenomenon
|
||||
let thunder = false;
|
||||
let snow = false;
|
||||
let ice = false;
|
||||
let fog = false;
|
||||
let wind = false;
|
||||
|
||||
// test the phenomenon for various value if it is provided.
|
||||
weather.forEach(phenomenon => {
|
||||
console.log(phenomenon.weather);
|
||||
if (!phenomenon.weather) return;
|
||||
if (phenomenon.weather.toLowerCase().includes('thunder')) thunder = true;
|
||||
if (phenomenon.weather.toLowerCase().includes('snow')) snow = true;
|
||||
if (phenomenon.weather.toLowerCase().includes('ice')) ice = true;
|
||||
if (phenomenon.weather.toLowerCase().includes('fog')) fog = true;
|
||||
if (phenomenon.weather.toLowerCase().includes('wind')) wind = true;
|
||||
});
|
||||
|
||||
// first item in list is highest priority, units are metric where applicable
|
||||
if (iceAccumulation > 0) return addPath('Freezing-Rain-1992.gif');
|
||||
if (iceAccumulation > 0 || ice) return addPath('Freezing-Rain-1992.gif');
|
||||
if (snowfallAmount > 10) {
|
||||
if (windSpeed > 30) return addPath('Blowing Snow.gif');
|
||||
if (windSpeed > 30 || wind) return addPath('Blowing Snow.gif');
|
||||
return addPath('Heavy-Snow-1994.gif');
|
||||
}
|
||||
if (snowfallAmount > 0) return addPath('Light-Snow.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');
|
||||
}
|
||||
if (fog) return addPath('Fog.gif');
|
||||
if (skyCover > 70) return addPath('Cloudy.gif');
|
||||
if (skyCover > 50) {
|
||||
if (!isNight) return addPath('Mostly-Cloudy-1994.gif');
|
||||
|
||||
Reference in New Issue
Block a user