Show max wind speed, "until" time, and location name
This commit is contained in:
parent
a90b3ef408
commit
b55e1f93d2
@ -26,18 +26,6 @@ function locationArrayToString(location) {
|
|||||||
return locarray.join(", ");
|
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) {
|
function trackingStatusToNiceString(status, icon) {
|
||||||
if (typeof icon == 'undefined' || icon !== true) {
|
if (typeof icon == 'undefined' || icon !== true) {
|
||||||
var icon = false;
|
var icon = false;
|
||||||
|
@ -45,12 +45,18 @@ function loadWeather(reload) {
|
|||||||
$("#lowtemp").html(mintemp);
|
$("#lowtemp").html(mintemp);
|
||||||
$("#hightemp").html(maxtemp);
|
$("#hightemp").html(maxtemp);
|
||||||
$("#precipchance").text(Math.round(resp.precipitation.chance * 100.0) + "% chance");
|
$("#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)) {
|
if (SETTINGS.weathericons.includes(resp.icon)) {
|
||||||
$("#weathericon").attr("src", "assets/images/weather-" + resp.icon + ".svg");
|
$("#weathericon").attr("src", "assets/images/weather-" + resp.icon + ".svg");
|
||||||
} else {
|
} else {
|
||||||
$("#weathericon").attr("src", "assets/images/weather-none.svg");
|
$("#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 {
|
} else {
|
||||||
app.dialog.alert(resp.message, "Error");
|
app.dialog.alert(resp.message, "Error");
|
||||||
}
|
}
|
||||||
|
30
www/assets/js/util.js
Normal file
30
www/assets/js/util.js
Normal file
@ -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;
|
||||||
|
}
|
@ -43,6 +43,7 @@
|
|||||||
|
|
||||||
<script src="assets/js/platform.js"></script>
|
<script src="assets/js/platform.js"></script>
|
||||||
|
|
||||||
|
<script src="assets/js/util.js"></script>
|
||||||
<script src="assets/js/audio.js"></script>
|
<script src="assets/js/audio.js"></script>
|
||||||
<script src="assets/js/autofill.js"></script>
|
<script src="assets/js/autofill.js"></script>
|
||||||
<script src="assets/js/packages.js"></script>
|
<script src="assets/js/packages.js"></script>
|
||||||
|
@ -35,10 +35,13 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="col-100">
|
<div class="col-100">
|
||||||
<h3>Precipitation: <span id="precipchance">...</span></h3>
|
<h3>Precipitation: <span id="precipchance">...</span></h3>
|
||||||
|
<h3>Wind speed: <span id="windspeed">...</span></h3>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="block-footer">
|
<div class="block-footer">
|
||||||
|
<span id="forecast-location"></span>
|
||||||
|
<br />
|
||||||
<span id="forecast-info"></span>
|
<span id="forecast-info"></span>
|
||||||
<br />
|
<br />
|
||||||
<a href="" onclick="openExternalBrowser('https://darksky.net/poweredby/')">Powered by Dark Sky</a>
|
<a href="" onclick="openExternalBrowser('https://darksky.net/poweredby/')">Powered by Dark Sky</a>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user