diff --git a/MMM-covid19.js b/MMM-covid19.js index b6ef413..3c18de4 100644 --- a/MMM-covid19.js +++ b/MMM-covid19.js @@ -82,19 +82,15 @@ Module.register("MMM-covid19", { // determine trend: // calc this and last weeks cases and substract // result is the difference of new cases between this and last week - // +10: red (arrow up) - // +0: orange (arrow up) - // 0: normal (arrow right) - // -0: green (arrow down) currentToLastWeekDiff = (data[this.config.region]["last_7"] * 2) - data[this.config.region]["last_14"] if (currentToLastWeekDiff > 10) { - this.cases.trend = "↗"; + this.cases.trend = "bad"; } else if (currentToLastWeekDiff > 0) { - this.cases.trend = "↗"; + this.cases.trend = "warn"; } else if (currentToLastWeekDiff == 0) { - this.cases.trend = "→"; + this.cases.trend = "even"; } else if (currentToLastWeekDiff < 0) { - this.cases.trend = "↘"; + this.cases.trend = "good"; } }, }); diff --git a/MMM-covid19.njk b/MMM-covid19.njk index 8decfaf..27fa6fd 100644 --- a/MMM-covid19.njk +++ b/MMM-covid19.njk @@ -1,5 +1,24 @@ + +{% if cases.trend == "even" %} + {% set trend_class = "none" %} + {% set trend = "→" %} +{% elif cases.trend == "good" %} + {% set trend_class = cases.trend %} + {% set trend = "↘" %} +{% elif cases.trend == "warn" %} + {% set trend_class = cases.trend %} + {% set trend = "↗" %} +{% elif cases.trend == "bad" %} + {% set trend_class = cases.trend %} + {% set trend = "↗" %} +{% endif %} +