From b55e1f93d20c1d130587be0bbea37ab13ee2603a Mon Sep 17 00:00:00 2001 From: Skylar Ittner Date: Sat, 23 Nov 2019 22:37:21 -0700 Subject: [PATCH] Show max wind speed, "until" time, and location name --- www/assets/js/toolbox_track.js | 12 ------------ www/assets/js/toolbox_weather.js | 8 +++++++- www/assets/js/util.js | 30 ++++++++++++++++++++++++++++++ www/index.html | 1 + www/pages/toolbox/weather.html | 3 +++ 5 files changed, 41 insertions(+), 13 deletions(-) create mode 100644 www/assets/js/util.js diff --git a/www/assets/js/toolbox_track.js b/www/assets/js/toolbox_track.js index 5428bfc..3f9ee82 100644 --- a/www/assets/js/toolbox_track.js +++ b/www/assets/js/toolbox_track.js @@ -26,18 +26,6 @@ function locationArrayToString(location) { return locarray.join(", "); } -function timestampToDateTimeString(timestamp) { - var date = new Date(timestamp * 1000); - - var pm = date.getHours() >= 12; - var hours = date.getHours() > 12 ? date.getHours() - 12 : date.getHours(); - hours = (hours == 0 ? 12 : hours); - var minutes = date.getMinutes(); - var time = hours + ":" + (minutes < 10 ? "0" + minutes : minutes) + " " + (pm ? "PM" : "AM"); - - return date.toLocaleDateString() + " " + time; -} - function trackingStatusToNiceString(status, icon) { if (typeof icon == 'undefined' || icon !== true) { var icon = false; diff --git a/www/assets/js/toolbox_weather.js b/www/assets/js/toolbox_weather.js index 2c23bb3..cd8f4bc 100644 --- a/www/assets/js/toolbox_weather.js +++ b/www/assets/js/toolbox_weather.js @@ -45,12 +45,18 @@ function loadWeather(reload) { $("#lowtemp").html(mintemp); $("#hightemp").html(maxtemp); $("#precipchance").text(Math.round(resp.precipitation.chance * 100.0) + "% chance"); + if (localStorage.getItem("units") == "metric") { + $("#windspeed").text(Math.round(resp.windspeed * 1.609344) + " km/h"); + } else { + $("#windspeed").text(Math.round(resp.windspeed) + " mph"); + } if (SETTINGS.weathericons.includes(resp.icon)) { $("#weathericon").attr("src", "assets/images/weather-" + resp.icon + ".svg"); } else { $("#weathericon").attr("src", "assets/images/weather-none.svg"); } - $("#forecast-info").text("Forecast covers the next " + resp.forecast_hours + " hours."); + $("#forecast-location").text(resp.location_name); + $("#forecast-info").text("Forecast covers the next " + resp.forecast_hours + " hours (until " + timestampToTimeString(resp.forecast_until) + ")."); } else { app.dialog.alert(resp.message, "Error"); } diff --git a/www/assets/js/util.js b/www/assets/js/util.js new file mode 100644 index 0000000..064d4f2 --- /dev/null +++ b/www/assets/js/util.js @@ -0,0 +1,30 @@ +/* + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + + +function timestampToDateTimeString(timestamp) { + var date = new Date(timestamp * 1000); + + var pm = date.getHours() >= 12; + var hours = date.getHours() > 12 ? date.getHours() - 12 : date.getHours(); + hours = (hours == 0 ? 12 : hours); + var minutes = date.getMinutes(); + var time = hours + ":" + (minutes < 10 ? "0" + minutes : minutes) + " " + (pm ? "PM" : "AM"); + + return date.toLocaleDateString() + " " + time; +} + +function timestampToTimeString(timestamp) { + var date = new Date(timestamp * 1000); + + var pm = date.getHours() >= 12; + var hours = date.getHours() > 12 ? date.getHours() - 12 : date.getHours(); + hours = (hours == 0 ? 12 : hours); + var minutes = date.getMinutes(); + var time = hours + ":" + (minutes < 10 ? "0" + minutes : minutes) + " " + (pm ? "PM" : "AM"); + + return time; +} \ No newline at end of file diff --git a/www/index.html b/www/index.html index 1a827c8..4b07c63 100644 --- a/www/index.html +++ b/www/index.html @@ -43,6 +43,7 @@ + diff --git a/www/pages/toolbox/weather.html b/www/pages/toolbox/weather.html index 197f3fa..2364ae8 100644 --- a/www/pages/toolbox/weather.html +++ b/www/pages/toolbox/weather.html @@ -35,10 +35,13 @@

Precipitation: ...

+

Wind speed: ...