Unverified Commit 042a59c8 authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

EFA departure board: add JSON interface

parent 16d9f3a0
Loading
Loading
Loading
Loading
+33 −17
Original line number Diff line number Diff line
@@ -1695,6 +1695,11 @@ sub handle_efa {
	for my $result ( $efa->results ) {
		my $time;

		if ( $template eq 'json' ) {
			push( @departures, $result );
			next;
		}

		if ( $show_realtime and $result->rt_datetime ) {
			$time = $result->rt_datetime->strftime('%H:%M');
		}
@@ -1764,6 +1769,16 @@ sub handle_efa {
		);
	}

	if ( $template eq 'json' ) {
		$self->res->headers->access_control_allow_origin(q{*});
		my $json = {
			departures => \@departures,
		};
		$self->render(
			json => $json,
		);
	}
	else {
		$self->render(
			$template,
			description      => "Abfahrtstafel $station_name",
@@ -1782,6 +1797,7 @@ sub handle_efa {
			force_mobile => ( $template eq 'app' ),
		);
	}
}

sub handle_result {
	my ( $self, $data ) = @_;