From c8f9fc901b440cb5f99fa531c6884af2b997ad97 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sat, 16 Mar 2019 21:33:19 +0100 Subject: allow manual input of station name Closes #1 --- index.pl | 7 +++++++ public/static/js/geolocation.js | 2 +- public/static/js/geolocation.min.js | 2 +- public/static/v1 | 1 - public/static/v3 | 1 + templates/landingpage.html.ep | 12 ++++++++++++ templates/layouts/default.html.ep | 2 +- 7 files changed, 23 insertions(+), 4 deletions(-) delete mode 120000 public/static/v1 create mode 120000 public/static/v3 diff --git a/index.pl b/index.pl index 066cf0b..467eed4 100755 --- a/index.pl +++ b/index.pl @@ -988,6 +988,13 @@ post '/geolocation' => sub { }; +post '/list_departures' => sub { + my ($self) = @_; + my $station = $self->param('station'); + + $self->redirect_to("/s/${station}"); +}; + get '/api/v0/:action/:token' => sub { my ($self) = @_; diff --git a/public/static/js/geolocation.js b/public/static/js/geolocation.js index 6e638e0..9cde56d 100644 --- a/public/static/js/geolocation.js +++ b/public/static/js/geolocation.js @@ -6,7 +6,7 @@ $(document).ready(function() { placeholder.remove(); var errnode = $(document.createElement('div')); errnode.attr('class', 'error'); - errnode.text(message + '. Alternativ kannst du unter „travelynx.de/s/Name der Station“ einchecken.'); + errnode.text(message); var headnode = $(document.createElement('strong')); headnode.text(header); diff --git a/public/static/js/geolocation.min.js b/public/static/js/geolocation.min.js index 6b4a790..11b5464 100644 --- a/public/static/js/geolocation.min.js +++ b/public/static/js/geolocation.min.js @@ -1 +1 @@ -$(document).ready(function(){var e=$("p.geolocationhint"),t=$("div.geolocation div.progress"),n=function(n,r,o){e.remove(),t.remove();var a=$(document.createElement("div"));a.attr("class","error"),a.text(r+". Alternativ kannst du unter „travelynx.de/s/Name der Station“ einchecken.");var i=$(document.createElement("strong"));i.text(n),a.prepend(i),$("div.geolocation").append(a)},r=function(e){e.error?n("Backend-Fehler:",e.error):0==e.candidates.length?n("Keine Bahnhöfe in 70km Umkreis gefunden",""):(resultTable=$("
"),resultBody=resultTable.children(),$.each(e.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),resultBody.append(''+r+"")}),t.replaceWith(resultTable))},o=function(e){$.post("/geolocation",{lon:e.coords.longitude,lat:e.coords.latitude},r)},a=function(e){e.code==e.PERMISSION_DENIED?n("Standortanfrage nicht möglich.","Vermutlich fehlen die Rechte im Browser oder der Android Location Service ist deaktiviert."):e.code==e.POSITION_UNAVAILABLE?n("Standort konnte nicht ermittelt werden","(Service nicht verfügbar)"):e.code==e.TIMEOUT?n("Standort konnte nicht ermittelt werden","(Timeout)"):n("Standort konnte nicht ermittelt werden","(unbekannter Fehler)")};navigator.geolocation?navigator.geolocation.getCurrentPosition(o,a):n("Standortanfragen werden von diesem Browser nicht unterstützt","")}); +$(document).ready(function(){var e=$("p.geolocationhint"),t=$("div.geolocation div.progress"),n=function(n,r,o){e.remove(),t.remove();var a=$(document.createElement("div"));a.attr("class","error"),a.text(r);var i=$(document.createElement("strong"));i.text(n),a.prepend(i),$("div.geolocation").append(a)},r=function(e){e.error?n("Backend-Fehler:",e.error):0==e.candidates.length?n("Keine Bahnhöfe in 70km Umkreis gefunden",""):(resultTable=$("
"),resultBody=resultTable.children(),$.each(e.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),resultBody.append(''+r+"")}),t.replaceWith(resultTable))},o=function(e){$.post("/geolocation",{lon:e.coords.longitude,lat:e.coords.latitude},r)},a=function(e){e.code==e.PERMISSION_DENIED?n("Standortanfrage nicht möglich.","Vermutlich fehlen die Rechte im Browser oder der Android Location Service ist deaktiviert."):e.code==e.POSITION_UNAVAILABLE?n("Standort konnte nicht ermittelt werden","(Service nicht verfügbar)"):e.code==e.TIMEOUT?n("Standort konnte nicht ermittelt werden","(Timeout)"):n("Standort konnte nicht ermittelt werden","(unbekannter Fehler)")};navigator.geolocation?navigator.geolocation.getCurrentPosition(o,a):n("Standortanfragen werden von diesem Browser nicht unterstützt","")}); diff --git a/public/static/v1 b/public/static/v1 deleted file mode 120000 index 945c9b4..0000000 --- a/public/static/v1 +++ /dev/null @@ -1 +0,0 @@ -. \ No newline at end of file diff --git a/public/static/v3 b/public/static/v3 new file mode 120000 index 0000000..945c9b4 --- /dev/null +++ b/public/static/v3 @@ -0,0 +1 @@ +. \ No newline at end of file diff --git a/templates/landingpage.html.ep b/templates/landingpage.html.ep index ece52df..fe3cd52 100644 --- a/templates/landingpage.html.ep +++ b/templates/landingpage.html.ep @@ -34,6 +34,18 @@
+ %= form_for 'list_departures' => begin +
+ %= text_field 'station', id => 'station', class => 'white-text', require => undef + +
+
+ +
+ %= end % } diff --git a/templates/layouts/default.html.ep b/templates/layouts/default.html.ep index 90af0a4..36995ba 100644 --- a/templates/layouts/default.html.ep +++ b/templates/layouts/default.html.ep @@ -5,7 +5,7 @@ - % my $av = 'v2'; # asset version + % my $av = 'v3'; # asset version %= stylesheet "/static/${av}/css/materialize.min.css" %= stylesheet "/static/${av}/css/material-icons.css" %= stylesheet "/static/${av}/css/local.css" -- cgit v1.2.3