diff --git a/html/resources/js/alerts.mjs b/html/resources/js/alerts.mjs index 727f19e..7501975 100644 --- a/html/resources/js/alerts.mjs +++ b/html/resources/js/alerts.mjs @@ -125,14 +125,7 @@ const testActive = (data) => { }; // test for any active warnings -const testWarning = (categorized) => Object.values(categorized).reduce( - (prevType, type) => ( - prevType || type.reduce( - (prevAlert, alert) => prevAlert || !!(alert.isWarning && alert.isActive), - false, - )), - false, -); +const testWarning = (categorized) => Object.values(categorized).some((type) => (type.some((alert) => !!(alert.isWarning && alert.isActive)))); // show the alert dialog const alertButton = () => { diff --git a/html/resources/js/spcoutlook.mjs b/html/resources/js/spcoutlook.mjs index 7151965..86373bd 100644 --- a/html/resources/js/spcoutlook.mjs +++ b/html/resources/js/spcoutlook.mjs @@ -117,10 +117,7 @@ const showDetailOutlook = async (position, daysToGet) => { } // determine if all detail data is present - const allDataPresent = data.reduce( - (prevDay, day, dayIndex) => (!daysToGet[dayIndex] || Object.values(day).reduce((prevCategory, cur) => (cur !== undefined) && prevCategory, false)) && prevDay, - false, - ); + const allDataPresent = data.every((day, dayIndex) => (!daysToGet[dayIndex] || Object.values(day).every((cur) => (cur !== undefined)))); if (!allDataPresent) { await getRemainingData(daysToGet); } @@ -135,7 +132,7 @@ const analyzeDetailData = (position) => { const isModerate = testModerate(inside); // see if we're inside any areas - const isInside = inside.reduce((prev, day) => prev || day, false); + const isInside = inside.some((day) => day); // show the button updateButtonState(!isInside, isModerate); @@ -237,7 +234,7 @@ const labelSortAlgorithm = (a, b) => { return bDN - aDN; }; -const testModerate = (days) => days.reduce((prevDay, day) => prevDay || (day?.reduce?.((prevArea, area) => prevArea || redIconLabel.includes(area.LABEL), false) ?? false), false); +const testModerate = (days) => days.some((prevDay, day) => (day?.some?.((area) => redIconLabel.includes(area.LABEL)) ?? false)); // update button state const updateButtonState = (hide, isModerate) => { diff --git a/html/resources/js/utils.mjs b/html/resources/js/utils.mjs index a153b8f..a2f9c09 100644 --- a/html/resources/js/utils.mjs +++ b/html/resources/js/utils.mjs @@ -23,9 +23,6 @@ let isDark; const readDarkMode = () => { isDark = window.matchMedia('(prefers-color-scheme: dark)').matches; - // if (redraw) { - // formatData(formatData.fcst ?? false, formatData.obs ?? false); - // } }; readDarkMode();