From b8254210a97e833fbf396f0af9aa9e49339d8284 Mon Sep 17 00:00:00 2001 From: Birte Kristina Friesel Date: Tue, 2 Apr 2024 21:40:18 +0200 Subject: Pass HAFAS service on to geostop --- lib/DBInfoscreen/Controller/Stationboard.pm | 16 +++++++++++++--- public/static/js/geostop.js | 3 ++- templates/landingpage.html.ep | 2 +- templates/layouts/app.html.ep | 2 +- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/lib/DBInfoscreen/Controller/Stationboard.pm b/lib/DBInfoscreen/Controller/Stationboard.pm index 305035c..60a15d5 100644 --- a/lib/DBInfoscreen/Controller/Stationboard.pm +++ b/lib/DBInfoscreen/Controller/Stationboard.pm @@ -1818,14 +1818,23 @@ sub handle_result { sub stations_by_coordinates { my $self = shift; - my $lon = $self->param('lon'); - my $lat = $self->param('lat'); + my $lon = $self->param('lon'); + my $lat = $self->param('lat'); + my $hafas = $self->param('hafas'); if ( not $lon or not $lat ) { $self->render( json => { error => 'Invalid lon/lat received' } ); return; } + my $service = 'DB'; + if ( $hafas + and $hafas ne '1' + and Travel::Status::DE::HAFAS::get_service($hafas) ) + { + $service = $hafas; + } + $self->render_later; my @iris = map { @@ -1846,6 +1855,7 @@ sub stations_by_coordinates { Travel::Status::DE::HAFAS->new_p( promise => 'Mojo::Promise', user_agent => $self->ua, + service => $service, geoSearch => { lat => $lat, lon => $lon @@ -1858,7 +1868,7 @@ sub stations_by_coordinates { name => $_->name, eva => $_->eva, distance => $_->distance_m / 1000, - hafas => 1 + hafas => $service, } } $hafas->results; if ( @hafas > 10 ) { diff --git a/public/static/js/geostop.js b/public/static/js/geostop.js index 80e8311..00699ec 100644 --- a/public/static/js/geostop.js +++ b/public/static/js/geostop.js @@ -61,7 +61,8 @@ $(function() { }; const processLocation = function(loc) { - $.post('/_geolocation', {lon: loc.coords.longitude, lat: loc.coords.latitude}, processResult).fail(function(jqXHR, textStatus, errorThrown) { + const param = new URLSearchParams(window.location.search); + $.post('/_geolocation', {lon: loc.coords.longitude, lat: loc.coords.latitude, hafas: param.get('hafas')}, processResult).fail(function(jqXHR, textStatus, errorThrown) { removeStatus(); showError("Netzwerkfehler: ", textStatus, errorThrown); }); diff --git a/templates/landingpage.html.ep b/templates/landingpage.html.ep index 82128ca..17bb2bb 100644 --- a/templates/landingpage.html.ep +++ b/templates/landingpage.html.ep @@ -21,7 +21,7 @@

% }

Oder hier angeben: diff --git a/templates/layouts/app.html.ep b/templates/layouts/app.html.ep index ae3a7a2..8c6715a 100644 --- a/templates/layouts/app.html.ep +++ b/templates/layouts/app.html.ep @@ -138,7 +138,7 @@ Bitte eine Station aus der Liste auswählen % if (stash('input')) {

% }
-- cgit v1.2.3