summaryrefslogtreecommitdiff
path: root/public/static/js/collapse.js
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2019-06-09 12:48:19 +0200
committerDaniel Friesel <derf@finalrewind.org>2019-06-09 12:48:19 +0200
commit0ebe2d78893a925874b86e038eac11acff70a251 (patch)
tree138f78fcea49aae0d28c65f052ce3ae3b85ab00a /public/static/js/collapse.js
parent15b98bd1ffec98d168c7eceef5d321333e32aad9 (diff)
move css and js assets to separate directories
Diffstat (limited to 'public/static/js/collapse.js')
-rw-r--r--public/static/js/collapse.js89
1 files changed, 89 insertions, 0 deletions
diff --git a/public/static/js/collapse.js b/public/static/js/collapse.js
new file mode 100644
index 0000000..e7d0fe0
--- /dev/null
+++ b/public/static/js/collapse.js
@@ -0,0 +1,89 @@
+function reload_app() {
+ $.get(window.location.href, {ajax: 1}, function(data) {
+ $('div.app > ul').html(data);
+ dbf_reg_handlers();
+ setTimeout(reload_app, 60000);
+ }).fail(function() {
+ setTimeout(reload_app, 10000);
+ });
+}
+
+function dbf_reg_handlers() {
+ $('div.app > ul > li').click(function() {
+ var trainElem = $(this);
+ $('.moreinfo').each(function() {
+ var infoElem = $(this);
+ $('.moreinfo .train-line').removeClass('bahn sbahn fern ext').addClass(trainElem.data('linetype'));
+ $('.moreinfo .train-line').text(trainElem.data('line'));
+ $('.moreinfo .train-no').text(trainElem.data('no'));
+ $('.moreinfo .train-origin').text(trainElem.data('from'));
+ $('.moreinfo .train-dest').text(trainElem.data('to'));
+ $('.moreinfo .minfo').text('');
+ $('.moreinfo .mfooter').html('<div style="text-align: center; width: 100%; color: #888888;">Lade Daten, bitte warten...</div>');
+ $('.moreinfo .verbose').html('');
+ $('.moreinfo .mroute').html('');
+ $('.moreinfo ul').html('');
+ $.get(window.location.href, {train: trainElem.data('train'), ajax: 1}, function(data) {
+ $('.moreinfo').html(data);
+ }).fail(function() {
+ $('.moreinfo .mfooter').html('Der Zug ist abgefahren (Zug nicht gefunden)');
+ });
+ infoElem.removeClass('collapsed-moreinfo');
+ infoElem.addClass('expanded-moreinfo');
+ });
+ });
+}
+
+$(function() {
+ if (document.location.hash.length > 1) {
+ var wanted = document.location.hash.replace('#', '');
+ $('div.app > ul > li > .moreinfo, div.infoscreen > ul > li > .moreinfo').each(function() {
+ if ($(this).data('train') == wanted) {
+ $(this).removeClass('collapsed-moreinfo');
+ $(this).addClass('expanded-moreinfo');
+ }
+ });
+ }
+ $('.moresettings-header').each(function() {
+ $(this).click(function() {
+ var moresettings = $('.moresettings');
+ if ($(this).hasClass('moresettings-header-collapsed')) {
+ $(this).removeClass('moresettings-header-collapsed');
+ $(this).addClass('moresettings-header-expanded');
+ moresettings.removeClass('moresettings-collapsed');
+ moresettings.addClass('moresettings-expanded');
+ }
+ else {
+ $(this).removeClass('moresettings-header-expanded');
+ $(this).addClass('moresettings-header-collapsed');
+ moresettings.removeClass('moresettings-expanded');
+ moresettings.addClass('moresettings-collapsed');
+ }
+ });
+ });
+ $('.developers-header').each(function() {
+ $(this).click(function() {
+ var developers = $('.developers');
+ if ($(this).hasClass('developers-header-collapsed')) {
+ $(this).removeClass('developers-header-collapsed');
+ $(this).addClass('developers-header-expanded');
+ developers.removeClass('developers-collapsed');
+ developers.addClass('developers-expanded');
+ }
+ else {
+ $(this).removeClass('developers-header-expanded');
+ $(this).addClass('developers-header-collapsed');
+ developers.removeClass('developers-expanded');
+ developers.addClass('developers-collapsed');
+ }
+ });
+ });
+ $('.moreinfo').click(function() {
+ $(this).removeClass('expanded-moreinfo');
+ $(this).addClass('collapsed-moreinfo');
+ });
+ dbf_reg_handlers();
+ if ($('.content .app').length) {
+ setTimeout(reload_app, 30000);
+ }
+});