From fe9dc6c86ae97554898fa9c8172cb6c043d2fcd1 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sat, 21 Jun 2014 14:58:46 +0200 Subject: IRIS backend: Use dropdown menu to narrow down stations --- cgi/index.pl | 12 ++++++++++++ cgi/templates/layouts/default.html.ep | 5 +++++ 2 files changed, 17 insertions(+) diff --git a/cgi/index.pl b/cgi/index.pl index 8558ec3..531ee5e 100644 --- a/cgi/index.pl +++ b/cgi/index.pl @@ -4,6 +4,7 @@ use Cache::File; use List::MoreUtils qw(any); use Travel::Status::DE::DeutscheBahn; use Travel::Status::DE::IRIS; +use Travel::Status::DE::IRIS::Stations; use 5.014; use utf8; @@ -79,6 +80,17 @@ sub handle_request { my @results = get_results_for( $backend, $station ); if ( not @results ) { + if ( $backend eq 'iris' ) { + my @candidates = map { [ "$_->[1] ($_->[0])", $_->[0] ] } + Travel::Status::DE::IRIS::Stations::get_station($station); + if (@candidates) { + $self->render( + 'multi', + stationlist => \@candidates, + hide_opts => 0 + ); + } + } $self->render( 'multi', error => "Got no results for '$station'", diff --git a/cgi/templates/layouts/default.html.ep b/cgi/templates/layouts/default.html.ep index 873def3..a9782ad 100644 --- a/cgi/templates/layouts/default.html.ep +++ b/cgi/templates/layouts/default.html.ep @@ -362,7 +362,12 @@
Station name
+% if (stash('stationlist')) { + %= select_field station => stash('stationlist') +% } +% else { %= text_field 'station' +% } %= submit_button 'Display'
-- cgit v1.2.3