Browse Source

Add some error feedback

master
Skylar Ittner 12 months ago
parent
commit
5627f27562
  1. 15
      www/assets/js/home.js
  2. 3
      www/assets/js/map.js
  3. 4
      www/assets/js/map_maplibre.js

15
www/assets/js/home.js

@ -9,16 +9,9 @@ $("body").on("submit", "#wordbox-searchbar", function (e) {
dolookup($("#wordbox").val());
return false;
});
//
//$("body").on("keypress", "#wordbox", function (e) {
// if (e.which == 13) {
// dolookup($(this).val());
// }
// return false;
//});
function dolookup(words) {
//try {
try {
words = words.trim().toLowerCase().replace(/\s+/g, ' ');
if (!/^[a-z ]+?$/i.test(words)) {
@ -50,7 +43,7 @@ function dolookup(words) {
break;
}
map.animateMapIn(coords[0], coords[1], zoomlevel);
// } catch (e) {
// alert(e);
// }
} catch (e) {
app.dialog.alert(e, "Error");
}
}

3
www/assets/js/map.js

@ -13,7 +13,7 @@ function createMap() {
} else {
console.log("maplibre-gl not supported, disabling map");
$("#mapbox").css("display", "none");
// TODO: show error to user
app.dialog.alert("Your device does not support the 3D graphics needed to show the map.", "Unsupported Device");
}
}
@ -41,6 +41,7 @@ function reloadMap() {
// oh well ¯\(°_o)/¯
console.log(ex);
$("#mapbox").css("display", "none");
app.dialog.alert("There was a problem loading the map. Error message: " + ex, "Error");
}
}

4
www/assets/js/map_maplibre.js

@ -37,8 +37,8 @@ function maplibreMap() {
var latitude = (Math.round(coordinates.lat * 10000) / 10000);
var longitude = (Math.round(coordinates.lng * 10000) / 10000);
lookupAndShowCoords(latitude, longitude);
} catch (e) {
alert(e);
} catch (ex) {
alert(ex);
}
});

Loading…
Cancel
Save