summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2019-03-16 21:33:19 +0100
committerDaniel Friesel <derf@finalrewind.org>2019-03-16 21:33:19 +0100
commitc8f9fc901b440cb5f99fa531c6884af2b997ad97 (patch)
tree3065e5d1c41f6cc0af61045b7b6468503b6d0c85
parent26da2b598c92e22b6c57a391acea26d08ff4f767 (diff)
allow manual input of station name
Closes #1
-rwxr-xr-xindex.pl7
-rw-r--r--public/static/js/geolocation.js2
-rw-r--r--public/static/js/geolocation.min.js2
l---------public/static/v3 (renamed from public/static/v1)0
-rw-r--r--templates/landingpage.html.ep12
-rw-r--r--templates/layouts/default.html.ep2
6 files changed, 22 insertions, 3 deletions
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=$("<table><tbody></tbody></table>"),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('<tr><td><a href="/s/'+n+'">'+r+"</a></td></tr>")}),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=$("<table><tbody></tbody></table>"),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('<tr><td><a href="/s/'+n+'">'+r+"</a></td></tr>")}),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/v3
index 945c9b4..945c9b4 120000
--- a/public/static/v1
+++ b/public/static/v3
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 @@
<div class="geolocation">
<div class="progress"><div class="indeterminate"></div></div>
</div>
+ %= form_for 'list_departures' => begin
+ <div class="input-field text-white">
+ %= text_field 'station', id => 'station', class => 'white-text', require => undef
+ <label for="station">Manuelle Eingabe (Name oder DS100)</label>
+ </div>
+ <div class="center-align">
+ <button class="btn waves-effect waves-light btn-flat white" type="submit" name="action" value="departures">
+ <i class="material-icons left">send</i>
+ Abfahrten
+ </button>
+ </div>
+ %= end
</div>
</div>
% }
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 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="theme-color" content="#673ab7">
- % 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"