2018-10-21 14:27:32 +00:00
|
|
|
|
function tvly_run(link, req, redir, err_callback) {
|
2018-10-05 17:12:49 +00:00
|
|
|
|
var error_icon = '<i class="material-icons">error</i>';
|
2018-10-21 13:57:38 +00:00
|
|
|
|
var progressbar = $('<div class="progress"><div class="indeterminate"></div></div>');
|
|
|
|
|
link.hide();
|
|
|
|
|
link.after(progressbar);
|
|
|
|
|
$.post('/action', req, function(data) {
|
|
|
|
|
if (data.success) {
|
|
|
|
|
$(location).attr('href', redir);
|
|
|
|
|
} else {
|
|
|
|
|
M.toast({html: error_icon + ' ' + data.error});
|
|
|
|
|
progressbar.remove();
|
|
|
|
|
if (err_callback) {
|
|
|
|
|
err_callback();
|
|
|
|
|
}
|
|
|
|
|
link.append(' ' + error_icon);
|
|
|
|
|
link.show();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
$(document).ready(function() {
|
2018-10-05 14:33:59 +00:00
|
|
|
|
$('.action-checkin').click(function() {
|
|
|
|
|
var link = $(this);
|
2018-10-21 13:57:38 +00:00
|
|
|
|
var req = {
|
2018-10-05 14:33:59 +00:00
|
|
|
|
action: 'checkin',
|
|
|
|
|
station: link.data('station'),
|
|
|
|
|
train: link.data('train'),
|
|
|
|
|
};
|
2018-10-21 14:27:32 +00:00
|
|
|
|
tvly_run(link, req, '/');
|
2018-10-05 14:33:59 +00:00
|
|
|
|
});
|
|
|
|
|
$('.action-checkout').click(function() {
|
|
|
|
|
var link = $(this);
|
2018-10-21 13:57:38 +00:00
|
|
|
|
var req = {
|
2018-10-05 14:33:59 +00:00
|
|
|
|
action: 'checkout',
|
|
|
|
|
station: link.data('station'),
|
|
|
|
|
force: link.data('force'),
|
|
|
|
|
};
|
2018-10-21 14:27:32 +00:00
|
|
|
|
tvly_run(link, req, '/' + req.station, function() {
|
2018-10-21 13:57:38 +00:00
|
|
|
|
link.append(' – Keine Echtzeitdaten vorhanden')
|
|
|
|
|
link.data('force', true);
|
2018-10-05 14:33:59 +00:00
|
|
|
|
});
|
|
|
|
|
});
|
2018-11-02 20:35:53 +00:00
|
|
|
|
$('.action-undo').click(function() {
|
|
|
|
|
var link = $(this);
|
|
|
|
|
var req = {
|
|
|
|
|
action: 'undo',
|
|
|
|
|
};
|
|
|
|
|
tvly_run(link, req, window.location.href);
|
|
|
|
|
});
|
2018-10-05 14:33:59 +00:00
|
|
|
|
});
|