larger icons for current conditions and extended forecast
This commit is contained in:
parent
06666c4ef9
commit
0e5d831f4a
|
@ -64,8 +64,7 @@ class CurrentWeather extends WeatherDisplay {
|
||||||
let WindChill = Math.round(observations.windChill.value);
|
let WindChill = Math.round(observations.windChill.value);
|
||||||
let WindGust = Math.round(observations.windGust.value);
|
let WindGust = Math.round(observations.windGust.value);
|
||||||
let Humidity = Math.round(observations.relativeHumidity.value);
|
let Humidity = Math.round(observations.relativeHumidity.value);
|
||||||
// TODO: switch to larger icon
|
const Icon = icons.getWeatherIconFromIconLink(observations.icon);
|
||||||
const Icon = icons.getWeatherRegionalIconFromIconLink(observations.icon);
|
|
||||||
let PressureDirection = '';
|
let PressureDirection = '';
|
||||||
const TextConditions = observations.textDescription;
|
const TextConditions = observations.textDescription;
|
||||||
|
|
||||||
|
|
|
@ -64,9 +64,7 @@ class ExtendedForecast extends WeatherDisplay {
|
||||||
// get the object to modify/populate
|
// get the object to modify/populate
|
||||||
const fDay = forecast[destIndex];
|
const fDay = forecast[destIndex];
|
||||||
// high temperature will always be last in the source array so it will overwrite the low values assigned below
|
// high temperature will always be last in the source array so it will overwrite the low values assigned below
|
||||||
// TODO: change to commented line when incons are matched up
|
fDay.icon = icons.getWeatherIconFromIconLink(period.icon);
|
||||||
// fDay.icon = icons.GetWeatherIconFromIconLink(period.icon);
|
|
||||||
fDay.icon = icons.getWeatherRegionalIconFromIconLink(period.icon);
|
|
||||||
fDay.text = this.shortenExtendedForecastText(period.shortForecast);
|
fDay.text = this.shortenExtendedForecastText(period.shortForecast);
|
||||||
fDay.dayName = dates[destIndex];
|
fDay.dayName = dates[destIndex];
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
/* spell-checker: disable */
|
||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
const icons = (() => {
|
const icons = (() => {
|
||||||
// internal function to add path to returned icon
|
|
||||||
const addPath = (icon) => `images/r/${icon}`;
|
|
||||||
|
|
||||||
const getWeatherRegionalIconFromIconLink = (link, isNightTime) => {
|
const getWeatherRegionalIconFromIconLink = (link, isNightTime) => {
|
||||||
// extract day or night if not provided
|
// extract day or night if not provided
|
||||||
if (isNightTime === undefined) isNightTime = link.indexOf('/night/') >=0;
|
if (isNightTime === undefined) 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: ?&,
|
// grab everything after the last slash ending at any of these: ?&,
|
||||||
const afterLastSlash = link.toLowerCase().match(/[^/]+$/)[0];
|
const afterLastSlash = link.toLowerCase().match(/[^/]+$/)[0];
|
||||||
|
@ -128,8 +128,13 @@ const icons = (() => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const getWeatherIconFromIconLink = function (link, OverrideIsDay = true) {
|
const getWeatherIconFromIconLink = function (link, isNightTime = false) {
|
||||||
// grab everything after the last slash ending at any of these: ?&,
|
// internal function to add path to returned icon
|
||||||
|
const addPath = (icon) => `images/${icon}`;
|
||||||
|
// extract day or night if not provided
|
||||||
|
if (isNightTime === undefined) isNightTime = link.indexOf('/night/') >=0;
|
||||||
|
|
||||||
|
// grab everything after the last slash ending at any of these: ?&,
|
||||||
const afterLastSlash = link.toLowerCase().match(/[^/]+$/)[0];
|
const afterLastSlash = link.toLowerCase().match(/[^/]+$/)[0];
|
||||||
let conditionName = afterLastSlash.match(/(.*?)[,?&.]/)[1];
|
let conditionName = afterLastSlash.match(/(.*?)[,?&.]/)[1];
|
||||||
|
|
||||||
|
@ -141,91 +146,105 @@ const icons = (() => {
|
||||||
|
|
||||||
|
|
||||||
// find the icon
|
// find the icon
|
||||||
switch (conditionName + (!OverrideIsDay?'-n':'')) {
|
switch (conditionName + (isNightTime?'-n':'')) {
|
||||||
|
|
||||||
|
|
||||||
case 'skc':
|
case 'skc':
|
||||||
return addPath('Sunny.gif');
|
case 'hot':
|
||||||
|
case 'haze':
|
||||||
|
return addPath('CC_Clear1.gif');
|
||||||
|
|
||||||
case 'skc-n':
|
case 'skc-n':
|
||||||
return addPath('Clear.gif');
|
case 'nskc':
|
||||||
|
case 'nskc-n':
|
||||||
|
return addPath('CC_Clear0.gif');
|
||||||
|
|
||||||
case 'cc_mostlycloudy1.gif':
|
case 'sct':
|
||||||
return addPath('Mostly-Cloudy.gif');
|
case 'few':
|
||||||
|
case 'bkn':
|
||||||
|
return addPath('CC_PartlyCloudy1.gif');
|
||||||
|
|
||||||
case 'cc_mostlycloudy0.gif':
|
case 'bkn-n':
|
||||||
return addPath('Partly-Clear.gif');
|
case 'few-n':
|
||||||
|
case 'nfew-n':
|
||||||
|
case 'nfew':
|
||||||
|
case 'sct-n':
|
||||||
|
case 'nsct':
|
||||||
|
case 'nsct-n':
|
||||||
|
return addPath('CC_PartlyCloudy0.gif');
|
||||||
|
|
||||||
case 'cc_partlycloudy1.gif':
|
case 'ovc':
|
||||||
return addPath('Partly-Cloudy.gif');
|
case 'novc':
|
||||||
|
case 'ovc-n':
|
||||||
|
return addPath('CC_Cloudy.gif');
|
||||||
|
|
||||||
case 'cc_partlycloudy0.gif':
|
case 'fog':
|
||||||
return addPath('Mostly-Clear.gif');
|
return addPath('CC_Fog.gif');
|
||||||
|
|
||||||
case 'cc_cloudy.gif':
|
case 'rain_sleet':
|
||||||
return addPath('Cloudy.gif');
|
|
||||||
|
|
||||||
case 'cc_fog.gif':
|
|
||||||
return addPath('Fog.gif');
|
|
||||||
|
|
||||||
case 'sleet.gif':
|
|
||||||
return addPath('Sleet.gif');
|
return addPath('Sleet.gif');
|
||||||
|
|
||||||
case 'ef_scatshowers.gif':
|
case 'rain_showers':
|
||||||
return addPath('Scattered-Showers.gif');
|
case 'rain_showers_high':
|
||||||
|
return addPath('CC_Showers.gif');
|
||||||
|
|
||||||
case 'cc_showers.gif':
|
case 'rain_showers-n':
|
||||||
return addPath('Shower.gif');
|
case 'rain_showers_high-n':
|
||||||
|
return addPath('CC_Showers.gif');
|
||||||
|
|
||||||
case 'cc_rain.gif':
|
case 'rain':
|
||||||
return addPath('Rain.gif');
|
return addPath('CC_Rain.gif');
|
||||||
|
|
||||||
//case "ef_scatsnowshowers.gif":
|
// case 'snow':
|
||||||
case 'light-snow.gif':
|
// return addPath('Light-Snow.gif');
|
||||||
return addPath('Light-Snow.gif');
|
// break;
|
||||||
|
|
||||||
case 'cc_snowshowers.gif':
|
// case 'cc_snowshowers.gif':
|
||||||
return addPath('Heavy-Snow.gif');
|
// //case "heavy-snow.gif":
|
||||||
|
// return addPath('AM-Snow-1994.gif');
|
||||||
|
// break;
|
||||||
|
|
||||||
case 'cc_snow.gif':
|
case 'snow':
|
||||||
case 'heavy-snow.gif':
|
return addPath('CC_Snow.gif');
|
||||||
return addPath('Heavy-Snow.gif');
|
|
||||||
|
|
||||||
case 'cc_rainsnow.gif':
|
case 'rain_snow':
|
||||||
//return addPath("Ice-Snow.gif");
|
return addPath('CC_RainSnow.gif');
|
||||||
return addPath('Rain-Snow.gif');
|
|
||||||
|
|
||||||
case 'cc_freezingrain.gif':
|
case 'snow_fzra':
|
||||||
return addPath('Freezing-Rain.gif');
|
case 'fzra':
|
||||||
|
return addPath('CC_FreezingRain.gif');
|
||||||
|
|
||||||
case 'cc_mix.gif':
|
case 'snow_sleet':
|
||||||
return addPath('Wintry-Mix.gif');
|
|
||||||
|
|
||||||
case 'freezing-rain-sleet.gif':
|
|
||||||
return addPath('Freezing-Rain-Sleet.gif');
|
|
||||||
|
|
||||||
case 'snow-sleet.gif':
|
|
||||||
return addPath('Snow-Sleet.gif');
|
return addPath('Snow-Sleet.gif');
|
||||||
|
|
||||||
case 'ef_scattstorms.gif':
|
case 'tsra_sct':
|
||||||
return addPath('Scattered-Tstorms.gif');
|
case 'tsra':
|
||||||
|
return addPath('EF_ScatTstorms.gif');
|
||||||
|
|
||||||
case 'ef_scatsnowshowers.gif':
|
case 'tsra_sct-n':
|
||||||
return addPath('Scattered-Snow-Showers.gif');
|
case 'tsra-n':
|
||||||
|
return addPath('CC_TStorm.gif');
|
||||||
|
|
||||||
case 'cc_tstorm.gif':
|
case 'tsra_hi':
|
||||||
case 'ef_isolatedtstorms.gif':
|
case 'tsra_hi-n':
|
||||||
return addPath('Thunderstorm.gif');
|
case 'hurricane':
|
||||||
|
return addPath('CC_TStorm');
|
||||||
|
|
||||||
case 'cc_windy.gif':
|
case 'wind_few':
|
||||||
case 'cc_windy2.gif':
|
case 'wind_sct':
|
||||||
return addPath('Windy.gif');
|
case 'wind_bkn':
|
||||||
|
case 'wind_ovc':
|
||||||
|
return addPath('CC_Windy.gif');
|
||||||
|
|
||||||
case 'blowing-snow.gif':
|
case 'wind_skc':
|
||||||
|
return addPath('CC_Windy.gif');
|
||||||
|
|
||||||
|
case 'wind_skc-n':
|
||||||
|
return addPath('CC_Windy.gif');
|
||||||
|
|
||||||
|
case 'blizzard':
|
||||||
return addPath('Blowing-Snow.gif');
|
return addPath('Blowing-Snow.gif');
|
||||||
|
|
||||||
default:
|
default:
|
||||||
console.error('Unable to locate icon for \'' + link + '\'');
|
console.log(`Unable to locate icon for ${link} ${isNightTime}`);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -342,8 +342,6 @@ const utils = (() => {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = -1, l = (r = str.split(/\r\n|\n|\r/)).length; ++i < l; r[i] += s) {
|
for (i = -1, l = (r = str.split(/\r\n|\n|\r/)).length; ++i < l; r[i] += s) {
|
||||||
// @todo: Split this up over many more lines and more semantic variable names
|
|
||||||
// so it becomes readable
|
|
||||||
for (s = r[i], r[i] = '';
|
for (s = r[i], r[i] = '';
|
||||||
s.length > m;
|
s.length > m;
|
||||||
r[i] += s.slice(0, j) + ((s = s.slice(j)).length ? b : '')) {
|
r[i] += s.slice(0, j) + ((s = s.slice(j)).length ? b : '')) {
|
||||||
|
|
Loading…
Reference in a new issue