mirror of
https://git.wetfence.xyz/RandyTheSilly/Civic-Segments.git
synced 2026-09-03 17:47:15 -04:00
Light temperature warning indicator for GPS timeout, API timeout, and API failure
This commit is contained in:
+18
-3
@@ -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 }
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user