Light temperature warning indicator for GPS timeout, API timeout, and API failure

This commit is contained in:
2026-06-13 17:48:15 -04:00
parent 0e44c32577
commit df3ec1cc72
2 changed files with 35 additions and 8 deletions
+18 -3
View File
@@ -1,7 +1,22 @@
function weatherFailure() {
Pebble.sendAppMessage({ PKJS_TEMP_BAR_COUNT: -1 });
}
var xhrRequest = function (url, type, callback) {
var xhr = new XMLHttpRequest();
xhr.timeout = 7500;
xhr.onload = function () {
callback(this.responseText);
if (xhr.status === 200) {
callback(this.responseText);
} else {
weatherFailure();
}
};
xhr.onerror = function () {
weatherFailure();
};
xhr.ontimeout = function () {
weatherFailure();
};
xhr.open(type, url);
xhr.send();
@@ -31,8 +46,8 @@ function locationSuccess(pos) {
function getWeather() {
navigator.geolocation.getCurrentPosition(
locationSuccess,
null,
{ timeout: 15000, maximumAge: 60000 }
weatherFailure,
{ timeout: 7500, maximumAge: 60000 }
);
}