Browse Source

Make GPS position API more generic. See https://github.com/la5nta/pat/pull/163#discussion_r329472257

blockmurder 1 month ago
parent
commit
9f3aade4b8
2 changed files with 8 additions and 8 deletions
  1. 1 1
      http.go
  2. 7 7
      res/js/index.js

+ 1 - 1
http.go

@@ -80,7 +80,7 @@ func ListenAndServe(addr string) error {
 	r.HandleFunc("/api/mailbox/{box}", postMessageHandler).Methods("POST")
 	r.HandleFunc("/api/posreport", postPositionHandler).Methods("POST")
 	r.HandleFunc("/api/status", statusHandler).Methods("GET")
-	r.HandleFunc("/api/gpsdPosition", positionHandler).Methods("GET")
+	r.HandleFunc("/api/current_gps_position", positionHandler).Methods("GET")
 	r.HandleFunc("/ws", wsHandler)
 	r.HandleFunc("/ui", uiHandler).Methods("GET")
 	r.HandleFunc("/", rootHandler).Methods("GET")

+ 7 - 7
res/js/index.js

@@ -52,19 +52,19 @@ function initFrontend(ws_url)
 
 		$('#posModal').on('shown.bs.modal', function (e) {
 			$.ajax({
-				url: '/api/gpsdPosition',
+				url: '/api/current_gps_position',
 				dataType: 'json',
 				beforeSend: function(){
-					statusPos.html("Checking if GPSd is available");
+					statusPos.html("Checking if GPS device is available");
 				},
-				success: function(gpsdData){
+				success: function(gpsData){
 					statusPos.html("GPS position received");
 
-					statusPos.html("<strong>Waiting for position (gpsd)...</strong>");
-					updatePositionGpsd(gpsdData);
+					statusPos.html("<strong>Waiting for position form GPS device...</strong>");
+					updatePositionGPS(gpsData);
 				},
 				error: function( jqXHR, textStatus, errorThrown ){
-					statusPos.html("GPSd not available!");
+					statusPos.html("GPS device not available!");
 
 					if (navigator.geolocation) {
 						statusPos.html("<strong>Waiting for position (geolocation)...</strong>");
@@ -354,7 +354,7 @@ function updatePositionGeolocation(pos) {
 	$('#pos_ts').val(pos.timestamp);
 }
 
-function updatePositionGpsd(pos) {
+function updatePositionGPS(pos) {
 	var d = new Date(pos.Time);
 	statusPos.html("Last position update " + dateFormat(d) + "...");
 	$('#pos_lat').val(pos.Lat);