Don’t repeat header with every line
[rhynodge.git] / src / main / kotlin / net / pterodactylus / rhynodge / webpages / weather / WeatherTrigger.kt
index 0522b02..5374d4c 100644 (file)
@@ -63,37 +63,37 @@ class WeatherTrigger : Trigger {
                 val showFeltTemperature = state.any { it.feltTemperature != null }
                 val showGustSpeed = state.any { it.gustSpeed != null }
                 val showHumidity = state.any { it.humidity != null }
-                state.forEach {
-                    div("weather-states") {
-                        div("header") {
-                            div { +"Time" }
-                            div { +"Temperature" }
-                            if (showHumidity) {
-                                div { +"feels like" }
-                            }
-                            div { +"Chance of Rain" }
-                            div { +"Amount" }
-                            div { +"Wind from" }
-                            div { +"Speed" }
-                            if (showGustSpeed) {
-                                div { +"Gusts" }
-                            }
-                            if (showHumidity) {
-                                div { +"Humidity" }
-                            }
-                            div { +"Description" }
-                            div { +"Image" }
+                div("weather-states") {
+                    div("header") {
+                        div { +"Time" }
+                        div { +"Temperature" }
+                        if (showHumidity) {
+                            div { +"feels like" }
+                        }
+                        div { +"Chance of Rain" }
+                        div { +"Amount" }
+                        div { +"Wind from" }
+                        div { +"Speed" }
+                        if (showGustSpeed) {
+                            div { +"Gusts" }
                         }
+                        if (showHumidity) {
+                            div { +"Humidity" }
+                        }
+                        div { +"Description" }
+                        div { +"Image" }
+                    }
+                    state.forEach {
                         div("hour-state") {
                             div("time") { +"%tH:%<tM".format(startTime.plus(it.hourIndex.toLong(), ChronoUnit.HOURS).toEpochMilli()) }
-                            div("temperature") { +"%d °C".format(it.temperature) }
+                            div("temperature") { +"${it.temperature} °C" }
                             if (showFeltTemperature) {
                                 div("felt-temperature") { +if (it.feltTemperature != null) "(${it.feltTemperature} °C)" else "" }
                             }
-                            div("rain-probability") { +"%d%%".format((it.rainProbability * 100).toInt()) }
-                            div("rain-amount") { +"%s l/m²".format(it.rainAmount.minDigits()) }
+                            div("rain-probability") { +"${it.rainProbability.times(100).toInt()}%" }
+                            div("rain-amount") { +"${it.rainAmount.minDigits()} l/m²" }
                             div("wind-direction") { +it.windDirection.arrow }
-                            div("wind-speed") { +"%d km/h".format(it.windSpeed) }
+                            div("wind-speed") { +"${it.windSpeed} km/h" }
                             if (showGustSpeed) {
                                 div("gust-speed") { +if (it.gustSpeed != null) "(up to ${it.gustSpeed} km/h)" else "" }
                             }