display 'no rain' message if precip_accum_local_day == 0

This commit is contained in:
John Bowdre 2024-02-10 12:02:13 -06:00
parent 0a0d7d4f88
commit 048fb6c332

View file

@ -38,7 +38,7 @@
// weather code inspired by https://kris.omg.lol // weather code inspired by https://kris.omg.lol
// fetch from API proxy // fetch from API proxy
fetch('https://paste.jbowdre.lol/testest.json/raw') fetch('https://paste.jbowdre.lol/tempest.json/raw')
.then(res => res.json()) .then(res => res.json())
.then(function(res){ .then(function(res){
@ -60,7 +60,11 @@
humidity = `${res.relative_humidity}% humidity`; humidity = `${res.relative_humidity}% humidity`;
wind = `${res.wind_gust}mph (${(res.wind_gust*1.609344).toFixed(1)}kph) from ${(res.wind_direction_cardinal).toLowerCase()}`; wind = `${res.wind_gust}mph (${(res.wind_gust*1.609344).toFixed(1)}kph) from ${(res.wind_direction_cardinal).toLowerCase()}`;
precipLabel = (rainRanges.find(range => res.precip_accum_local_day < range.upper)).label; precipLabel = (rainRanges.find(range => res.precip_accum_local_day < range.upper)).label;
if (res.precip_accum_local_day == 0) {
precipToday = 'no rain today';
} else {
precipToday = `${res.precip_accum_local_day}" rain today`; precipToday = `${res.precip_accum_local_day}" rain today`;
}
pressureTrend = res.pressure_trend; pressureTrend = res.pressure_trend;
pressure = `${res.station_pressure}inhg and ${pressureTrend}`; pressure = `${res.station_pressure}inhg and ${pressureTrend}`;
icon = res.icon; icon = res.icon;