diff options
-rw-r--r-- | lib/DBInfoscreen/Controller/Stationboard.pm | 27 | ||||
-rw-r--r-- | templates/layouts/app.html.ep | 11 |
2 files changed, 37 insertions, 1 deletions
diff --git a/lib/DBInfoscreen/Controller/Stationboard.pm b/lib/DBInfoscreen/Controller/Stationboard.pm index bf986d3..39b3a3d 100644 --- a/lib/DBInfoscreen/Controller/Stationboard.pm +++ b/lib/DBInfoscreen/Controller/Stationboard.pm @@ -456,6 +456,13 @@ sub handle_request { results => [ $status->results ], station_ds100 => ( $status->station ? $status->station->{ds100} : undef ), + station_eva => ( + $status->station + ? ( $status->station->{uic} // $status->station->{eva} ) + : undef + ), + station_evas => + ( $status->station ? $status->station->{evas} : [] ), station_name => ( $status->station ? $status->station->{name} : $station ), }; @@ -1650,8 +1657,28 @@ sub handle_result { } else { my $station_name = $data->{station_name} // $self->stash('station'); + my ( $api_link, $api_text, $api_icon ); + my $params = $self->req->params->clone; + $params->param( hafas => not $params->param('hafas') ); + if ( $params->param('hafas') ) { + $api_link = '/' . $data->{station_eva} . '?' . $params->to_string; + $api_text = 'lol'; + $api_icon = 'train'; + } + else { + my $iris_eva = List::Util::min grep { $_ >= 1000000 } + @{ $data->{station_evas} // [] }; + if ($iris_eva) { + $api_link = '/' . $iris_eva . '?' . $params->to_string; + $api_text = 'lol'; + $api_icon = 'directions_bus'; + } + } $self->render( $template, + api_link => $api_link, + api_text => $api_text, + api_icon => $api_icon, departures => \@departures, ice_type => $self->app->ice_type_map, station => $station_name, diff --git a/templates/layouts/app.html.ep b/templates/layouts/app.html.ep index 0992a43..e406570 100644 --- a/templates/layouts/app.html.ep +++ b/templates/layouts/app.html.ep @@ -83,6 +83,11 @@ </span> % } <ul id="nav-mobile" style="float: right;"> + % if (stash('api_link')) { + <li class="waves-effect waves-light"> + <a href="<%= $api_link %>"><span class="visually-hidden"><%= $api_text %></span><i class="material-icons" aria-hidden="true"><%= $api_icon %></i></a> + </li> + % } <li class="waves-effect waves-light"> <a onClick="javascript:toggleTheme()"><span class="visually-hidden">Farbschema invertieren</span><i class="material-icons" aria-hidden="true">invert_colors</i></a> </li> @@ -92,7 +97,6 @@ % else { <li><a href="#stationinput"><span class="visually-hidden">Menü</span><i class="material-icons" aria-hidden="true">edit</i></a></li> % } - <li><a href="/_autostop"><span class="visually-hidden">Stationen in der Umgebung suchen</span><i class="material-icons" aria-hidden="true">my_location</i></a></li> </ul> </div> </nav> @@ -140,6 +144,11 @@ Bitte eine Station aus der Liste auswählen</div> <div class="field"> %= submit_button 'Abfahrtsmonitor' </div> + % if (stash('input')) { + <div class="geolink"> + <a class="button" href="<%= url_for('_autostop')->to_abs->scheme('https') %>">Stationen in der Umgebung suchen</a> + </div> + % } <div class="break"></div> <div class="moresettings-header moresettings-header-collapsed button button-light">Weitere Einstellungen</div> <div class="moresettings moresettings-collapsed"> |