Commit f88817d9 authored by Daniel Friesel's avatar Daniel Friesel
Browse files

Add past option

parent 39746c14
Loading
Loading
Loading
Loading
+17 −4
Original line number Diff line number Diff line
@@ -268,6 +268,12 @@ sub handle_request {
		lookahead       => $self->config->{lookahead}
	);

	if ( $self->param('past') ) {
		$opt{datetime} = DateTime->now( time_zone => 'Europe/Berlin' )
		  ->subtract( minutes => 60 );
		$opt{lookahead} += 60;
	}

	my $api_version = $Travel::Status::DE::IRIS::VERSION;

	$self->stash( departures => [] );
@@ -320,7 +326,7 @@ sub handle_request {
		$opt{with_related} = 1;
	}

	if ( $self->param('train') ) {
	if ( $self->param('train') and not $opt{datetime} ) {

       # request results from twenty minutes ago to avoid train details suddenly
       # becoming unavailable when its scheduled departure is reached.
@@ -811,9 +817,16 @@ sub station_train_details {
	$self->stash( title      => 'DBF' );
	$self->stash( version    => $self->config->{version} );

	if ( $self->param('past') ) {
		$opt{datetime} = DateTime->now( time_zone => 'Europe/Berlin' )
		  ->subtract( minutes => 80 );
		$opt{lookahead} = $self->config->{lookahead} + 80;
	}
	else {
		$opt{datetime} = DateTime->now( time_zone => 'Europe/Berlin' )
		  ->subtract( minutes => 20 );
		$opt{lookahead} = $self->config->{lookahead} + 20;
	}

	my $data   = get_results_for( $station, %opt );
	my $errstr = $data->{errstr};
+5 −2
Original line number Diff line number Diff line
@@ -95,9 +95,12 @@ function dbf_reg_handlers() {
		const trainElem = $(this);
		const station = $('div.app').data('station');
		event.preventDefault();
		var suffix = '';
		var suffix = '?';
		if (window.location.href.includes('detailed=1')) {
			suffix = '?detailed=1';
			suffix += '&detailed=1';
		}
		if (window.location.href.includes('past=1')) {
			suffix += '&past=1';
		}
		history.pushState({'page':'traindetail','station':station,'train':trainElem.data('no')}, 'test', '/z/' + trainElem.data('train') + '/' + trainElem.data('station') + suffix);
		dbf_show_moreinfo(trainElem, false);
+1 −3

File changed.

Preview size limit exceeded, changes collapsed.

+1 −1
Original line number Diff line number Diff line
$(function(){var e=function(){$("div.candidatestatus").remove()},t=function(e,t,n){var r=$(document.createElement("div"));r.attr("class","error"),r.text(t);var o=$(document.createElement("strong"));if(o.text(e),r.prepend(o),n){var a=$(document.createElement("div"));a.attr("class","errcode"),a.text(n),r.append(a)}$("div.candidatelist").append(r)},n=function(n){e(),n.error?t("Backend-Fehler:",n.error,null):0==n.candidates.length?t("Keine Bahnhöfe in 70km Umkreis gefunden","",null):$.each(n.candidates,function(e,t){var n=t.ds100,r=t.name,o=t.distance;o=o.toFixed(1);var a=$(document.createElement("a"));a.attr("href",n),a.text(r);var i=$(document.createElement("div"));i.attr("class","distance"),i.text(o),a.append(i),$("div.candidatelist").append(a)})},r=function(r){$.post("/_geolocation",{lon:r.coords.longitude,lat:r.coords.latitude},n).fail(function(n,r,o){e(),t("Netzwerkfehler: ",r,o)}),$("div.candidatestatus").text("Suche Bahnhöfe…")},o=function(n){e(),n.code==n.PERMISSION_DENIED?t("Standortanfrage nicht möglich.","Vermutlich fehlen die Rechte im Browser oder der Android Location Service ist deaktiviert.","geolocation.error.PERMISSION_DENIED"):n.code==n.POSITION_UNAVAILABLE?t("Standort konnte nicht ermittelt werden","(Service nicht verfügbar)","geolocation.error.POSITION_UNAVAILABLE"):n.code==n.TIMEOUT?t("Standort konnte nicht ermittelt werden","(Timeout)","geolocation.error.TIMEOUT"):t("Standort konnte nicht ermittelt werden","(unbekannter Fehler)","unknown geolocation.error code")};navigator.geolocation?(navigator.geolocation.getCurrentPosition(r,o),$("div.candidatestatus").text("Position wird bestimmt…")):(e(),t("Standortanfragen werden von diesem Browser nicht unterstützt","",null))});
$(function(){function t(e){r(),e.error?o("Backend-Fehler:",e.error,null):0==e.candidates.length?o("Keine Bahnhöfe in 70km Umkreis gefunden","",null):$.each(e.candidates,function(e,t){var n=t.ds100,r=t.name,o=(o=t.distance).toFixed(1),t=$(document.createElement("a"));t.attr("href",n),t.text(r);r=$(document.createElement("div"));r.attr("class","distance"),r.text(o),t.append(r),$("div.candidatelist").append(t)})}var r=function(){$("div.candidatestatus").remove()},o=function(e,t,n){var r=$(document.createElement("div"));r.attr("class","error"),r.text(t);t=$(document.createElement("strong"));t.text(e),r.prepend(t),n&&((t=$(document.createElement("div"))).attr("class","errcode"),t.text(n),r.append(t)),$("div.candidatelist").append(r)};navigator.geolocation?(navigator.geolocation.getCurrentPosition(function(e){$.post("/_geolocation",{lon:e.coords.longitude,lat:e.coords.latitude},t).fail(function(e,t,n){r(),o("Netzwerkfehler: ",t,n)}),$("div.candidatestatus").text("Suche Bahnhöfe…")},function(e){r(),e.code==e.PERMISSION_DENIED?o("Standortanfrage nicht möglich.","Vermutlich fehlen die Rechte im Browser oder der Android Location Service ist deaktiviert.","geolocation.error.PERMISSION_DENIED"):e.code==e.POSITION_UNAVAILABLE?o("Standort konnte nicht ermittelt werden","(Service nicht verfügbar)","geolocation.error.POSITION_UNAVAILABLE"):e.code==e.TIMEOUT?o("Standort konnte nicht ermittelt werden","(Timeout)","geolocation.error.TIMEOUT"):o("Standort konnte nicht ermittelt werden","(unbekannter Fehler)","unknown geolocation.error code")}),$("div.candidatestatus").text("Position wird bestimmt…")):(r(),o("Standortanfragen werden von diesem Browser nicht unterstützt","",null))});
+1 −1
Original line number Diff line number Diff line
$(function(){var e=function(){$("div.candidatestatus").remove()},t=function(e,t,n){var r=$(document.createElement("div"));r.attr("class","error"),r.text(t);var o=$(document.createElement("strong"));if(o.text(e),r.prepend(o),n){var i=$(document.createElement("div"));i.attr("class","errcode"),i.text(n),r.append(i)}$("div.candidatelist").append(r)},n=function(n){e(),n.error?t("Backend-Fehler:",n.error,null):0==n.evas.length?t("Keine Bahnstrecke gefunden","",null):0==n.trains.length?t("Keine Züge auf der Strecke gefunden","",null):$.each(n.trains,function(e,t){const n=t.stops[0][1],r=t.stops[0][2],o=t.stops[1][0],i=t.stops[1][1],a=t.stops[1][2];var d=$(document.createElement("a"));d.attr("href","/z/"+t.train+"/"+o),d.text(t.line);var c=$(document.createElement("div"));c.attr("class","traininfo"),c.html(t.likelihood+"%<br/>"+r+" "+n+"<br/>"+a+" "+i),d.append(c),$("div.candidatelist").append(d)})},r=function(r){$.get("https://dbf.finalrewind.org/__geotrain/search",{lon:r.coords.longitude,lat:r.coords.latitude},n).fail(function(n,r,o){e(),t("Netzwerkfehler: ",r,o)}),$("div.candidatestatus").text("Suche Züge…")},o=function(n){e(),n.code==n.PERMISSION_DENIED?t("Standortanfrage nicht möglich.","Vermutlich fehlen die Rechte im Browser oder der Android Location Service ist deaktiviert.","geolocation.error.PERMISSION_DENIED"):n.code==n.POSITION_UNAVAILABLE?t("Standort konnte nicht ermittelt werden","(Service nicht verfügbar)","geolocation.error.POSITION_UNAVAILABLE"):n.code==n.TIMEOUT?t("Standort konnte nicht ermittelt werden","(Timeout)","geolocation.error.TIMEOUT"):t("Standort konnte nicht ermittelt werden","(unbekannter Fehler)","unknown geolocation.error code")};navigator.geolocation?(navigator.geolocation.getCurrentPosition(r,o),$("div.candidatestatus").text("Position wird bestimmt…")):(e(),t("Standortanfragen werden von diesem Browser nicht unterstützt","",null))});
$(function(){function t(e){r(),e.error?o("Backend-Fehler:",e.error,null):0==e.evas.length?o("Keine Bahnstrecke gefunden","",null):0==e.trains.length?o("Keine Züge auf der Strecke gefunden","",null):$.each(e.trains,function(e,t){var n=t.stops[0][1],r=t.stops[0][2],o=t.stops[1][0],i=t.stops[1][1],a=t.stops[1][2],d=$(document.createElement("a"));d.attr("href","/z/"+t.train+"/"+o),d.text(t.line);o=$(document.createElement("div"));o.attr("class","traininfo"),o.html(t.likelihood+"%<br/>"+r+" "+n+"<br/>"+a+" "+i),d.append(o),$("div.candidatelist").append(d)})}var r=function(){$("div.candidatestatus").remove()},o=function(e,t,n){var r=$(document.createElement("div"));r.attr("class","error"),r.text(t);t=$(document.createElement("strong"));t.text(e),r.prepend(t),n&&((t=$(document.createElement("div"))).attr("class","errcode"),t.text(n),r.append(t)),$("div.candidatelist").append(r)};navigator.geolocation?(navigator.geolocation.getCurrentPosition(function(e){$.get("https://dbf.finalrewind.org/__geotrain/search",{lon:e.coords.longitude,lat:e.coords.latitude},t).fail(function(e,t,n){r(),o("Netzwerkfehler: ",t,n)}),$("div.candidatestatus").text("Suche Züge…")},function(e){r(),e.code==e.PERMISSION_DENIED?o("Standortanfrage nicht möglich.","Vermutlich fehlen die Rechte im Browser oder der Android Location Service ist deaktiviert.","geolocation.error.PERMISSION_DENIED"):e.code==e.POSITION_UNAVAILABLE?o("Standort konnte nicht ermittelt werden","(Service nicht verfügbar)","geolocation.error.POSITION_UNAVAILABLE"):e.code==e.TIMEOUT?o("Standort konnte nicht ermittelt werden","(Timeout)","geolocation.error.TIMEOUT"):o("Standort konnte nicht ermittelt werden","(unbekannter Fehler)","unknown geolocation.error code")}),$("div.candidatestatus").text("Position wird bestimmt…")):(r(),o("Standortanfragen werden von diesem Browser nicht unterstützt","",null))});
Loading