summaryrefslogtreecommitdiff
path: root/public/static/js
diff options
context:
space:
mode:
Diffstat (limited to 'public/static/js')
-rw-r--r--public/static/js/geolocation.js22
-rw-r--r--public/static/js/travelynx-actions.js24
2 files changed, 30 insertions, 16 deletions
diff --git a/public/static/js/geolocation.js b/public/static/js/geolocation.js
index c428acd..1bb4b2b 100644
--- a/public/static/js/geolocation.js
+++ b/public/static/js/geolocation.js
@@ -24,7 +24,9 @@ $(document).ready(function() {
const res = $(document.createElement('p'));
$.each(stops, function(i, stop) {
const parts = stop.split(';');
- const node = $('<a class="tablerow" href="/s/' + parts[0] + '?dbris=' + parts[2] + '&amp;hafas=' + parts[3] + '"><span><i class="material-icons" aria-hidden="true">' + (parts[2] == '0' ? 'train' : 'directions') + '</i>' + parts[1] + '</span></a>');
+ const [ eva, name, dbris, motis, hafas ] = parts;
+
+ const node = $('<a class="tablerow" href="/s/' + eva + '?dbris=' + dbris + '&amp;motis=' + motis + '&amp;hafas=' + hafas + '"><span><i class="material-icons" aria-hidden="true">' + (dbris == '0' ? 'train' : 'directions') + '</i>' + name + '</span></a>');
node.click(function() {
$('nav .preloader-wrapper').addClass('active');
});
@@ -45,13 +47,21 @@ $(document).ready(function() {
} else {
const res = $(document.createElement('p'));
$.each(data.candidates, function(i, candidate) {
+ let node;
+
+ if (candidate.motis !== undefined) {
+ const { id, name, motis } = candidate;
+
+ node = $('<a class="tablerow" href="/s/' + id + '?motis=' + motis + '"><span><i class="material-icons" aria-hidden="true">train</i>' + name + '</span></a>');
+ } else {
+ const eva = candidate.eva,
+ name = candidate.name,
+ hafas = candidate.hafas,
+ distance = candidate.distance.toFixed(1);
- const eva = candidate.eva,
- name = candidate.name,
- hafas = candidate.hafas,
- distance = candidate.distance.toFixed(1);
+ node = $('<a class="tablerow" href="/s/' + eva + '?hafas=' + hafas + '"><span><i class="material-icons" aria-hidden="true">' + (hafas == '0' ? 'train' : 'directions') + '</i>' + name + '</span></a>');
+ }
- const node = $('<a class="tablerow" href="/s/' + eva + '?hafas=' + hafas + '"><span><i class="material-icons" aria-hidden="true">' + (hafas == '0' ? 'train' : 'directions') + '</i>' + name + '</span></a>');
node.click(function() {
$('nav .preloader-wrapper').addClass('active');
});
diff --git a/public/static/js/travelynx-actions.js b/public/static/js/travelynx-actions.js
index 3e02283..d2316af 100644
--- a/public/static/js/travelynx-actions.js
+++ b/public/static/js/travelynx-actions.js
@@ -196,6 +196,7 @@ function tvly_reg_handlers() {
action: 'checkin',
dbris: link.data('dbris'),
hafas: link.data('hafas'),
+ motis: link.data('motis'),
station: link.data('station'),
train: link.data('train'),
suffix: link.data('suffix'),
@@ -210,6 +211,7 @@ function tvly_reg_handlers() {
action: 'checkout',
dbris: link.data('dbris'),
hafas: link.data('hafas'),
+ motis: link.data('motis'),
station: link.data('station'),
force: link.data('force'),
};
@@ -242,6 +244,7 @@ function tvly_reg_handlers() {
action: 'cancelled_from',
dbris: link.data('dbris'),
hafas: link.data('hafas'),
+ motis: link.data('motis'),
station: link.data('station'),
ts: link.data('ts'),
train: link.data('train'),
@@ -254,6 +257,7 @@ function tvly_reg_handlers() {
action: 'cancelled_to',
dbris: link.data('dbris'),
hafas: link.data('hafas'),
+ motis: link.data('motis'),
station: link.data('station'),
force: true,
};
@@ -320,18 +324,18 @@ $(document).ready(function() {
$('nav .preloader-wrapper').addClass('active');
});
$('a[href="#now"]').keydown(function(event) {
- // also trigger click handler on keyboard enter
- if (event.keyCode == 13) {
- event.preventDefault();
- event.target.click();
- }
+ // also trigger click handler on keyboard enter
+ if (event.keyCode == 13) {
+ event.preventDefault();
+ event.target.click();
+ }
});
$('a[href="#now"]').click(function(event) {
- event.preventDefault();
- $('nav .preloader-wrapper').removeClass('active');
- now_el = $('#now')[0];
- now_el.previousElementSibling.querySelector(".dep-time").focus();
- now_el.scrollIntoView({behavior: "smooth", block: "center"});
+ event.preventDefault();
+ $('nav .preloader-wrapper').removeClass('active');
+ now_el = $('#now')[0];
+ now_el.previousElementSibling.querySelector(".dep-time").focus();
+ now_el.scrollIntoView({behavior: "smooth", block: "center"});
});
const elems = document.querySelectorAll('.carousel');
const instances = M.Carousel.init(elems, {