From 374da8718236a3a1ad624ffbd63813b9cc8fd9fb Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Thu, 9 May 2019 18:14:16 +0200 Subject: [PATCH] hide status countdown when offline --- public/service-worker.js | 18 +++++++++--------- public/static/css/material-icons.css | 8 ++++---- public/static/js/travelynx-actions.js | 2 ++ public/static/js/travelynx-actions.min.js | 2 +- public/static/manifest.json | 12 ++++++------ public/static/{v14 => v16} | 0 templates/_checked_in.html.ep | 2 +- templates/_public_status_card.html.ep | 2 +- templates/layouts/default.html.ep | 2 +- 9 files changed, 25 insertions(+), 23 deletions(-) rename public/static/{v14 => v16} (100%) diff --git a/public/service-worker.js b/public/service-worker.js index 0374101..09dca86 100644 --- a/public/service-worker.js +++ b/public/service-worker.js @@ -1,14 +1,14 @@ -const CACHE_NAME = 'static-cache-v15'; +const CACHE_NAME = 'static-cache-v16'; const FILES_TO_CACHE = [ '/offline.html', - '/static/v15/css/materialize.min.css', - '/static/v15/css/material-icons.css', - '/static/v15/css/local.css', - '/static/v15/js/jquery-3.4.1.min.js', - '/static/v15/js/materialize.min.js', - '/static/v15/js/travelynx-actions.min.js', - '/static/v15/js/autocomplete.min.js', - '/static/v15/js/geolocation.min.js', + '/static/v16/css/materialize.min.css', + '/static/v16/css/material-icons.css', + '/static/v16/css/local.css', + '/static/v16/js/jquery-3.4.1.min.js', + '/static/v16/js/materialize.min.js', + '/static/v16/js/travelynx-actions.min.js', + '/static/v16/js/autocomplete.min.js', + '/static/v16/js/geolocation.min.js', ]; self.addEventListener('install', (evt) => { diff --git a/public/static/css/material-icons.css b/public/static/css/material-icons.css index f6adb7c..9404262 100644 --- a/public/static/css/material-icons.css +++ b/public/static/css/material-icons.css @@ -2,12 +2,12 @@ font-family: 'Material Icons'; font-style: normal; font-weight: 400; - src: url(/static/v15/fonts/MaterialIcons-Regular.eot); /* For IE6-8 */ + src: url(/static/v16/fonts/MaterialIcons-Regular.eot); /* For IE6-8 */ src: local('Material Icons'), local('MaterialIcons-Regular'), - url(/static/v15/fonts/MaterialIcons-Regular.woff2) format('woff2'), - url(/static/v15/fonts/MaterialIcons-Regular.woff) format('woff'), - url(/static/v15/fonts/MaterialIcons-Regular.ttf) format('truetype'); + url(/static/v16/fonts/MaterialIcons-Regular.woff2) format('woff2'), + url(/static/v16/fonts/MaterialIcons-Regular.woff) format('woff'), + url(/static/v16/fonts/MaterialIcons-Regular.ttf) format('truetype'); } .material-icons { diff --git a/public/static/js/travelynx-actions.js b/public/static/js/travelynx-actions.js index 7d91dbd..d3e2a7d 100644 --- a/public/static/js/travelynx-actions.js +++ b/public/static/js/travelynx-actions.js @@ -24,6 +24,7 @@ function tvly_update() { setTimeout(tvly_update, 20000); }).fail(function() { $('.sync-failed-marker').css('display', 'block'); + $('.countdown').html(' '); setTimeout(tvly_update, 5000); }); } @@ -37,6 +38,7 @@ function tvly_update_public() { setTimeout(tvly_update_public, 20000); }).fail(function() { $('.sync-failed-marker').css('display', 'block'); + $('.countdown').html(' '); setTimeout(tvly_update_public, 5000); }); } diff --git a/public/static/js/travelynx-actions.min.js b/public/static/js/travelynx-actions.min.js index 1c91823..376f348 100644 --- a/public/static/js/travelynx-actions.min.js +++ b/public/static/js/travelynx-actions.min.js @@ -1 +1 @@ -function tvly_run(a,t,e){var c='error',n=$('
');a.hide(),a.after(n),$.post("/action",t,function(t){t.success?$(location).attr("href",t.redirect_to):(M.toast({html:c+" "+t.error}),n.remove(),e&&e(),a.append(" "+c),a.show())})}function tvly_update(){$.get("/ajax/status_card.html",function(t){$(".statuscol").html(t),tvly_reg_handlers(),setTimeout(tvly_update,2e4)}).fail(function(){$(".sync-failed-marker").css("display","block"),setTimeout(tvly_update,5e3)})}function tvly_update_public(){var t;$(".publicstatuscol").each(function(){t=$(this).data("user")}),$.get("/ajax/status/"+t+".html",function(t){$(".publicstatuscol").html(t),setTimeout(tvly_update_public,2e4)}).fail(function(){$(".sync-failed-marker").css("display","block"),setTimeout(tvly_update_public,5e3)})}function tvly_reg_handlers(){$(".action-checkin").click(function(){var t=$(this);tvly_run(t,{action:"checkin",station:t.data("station"),train:t.data("train")})}),$(".action-checkout").click(function(){var t=$(this),a={action:"checkout",station:t.data("station"),force:t.data("force")};tvly_run(t,a,function(){t.append(" – Ohne Echtzeitdaten auschecken?"),t.data("force",!0)})}),$(".action-undo").click(function(){var t=$(this);tvly_run(t,{action:"undo",undo_id:t.data("id")})}),$(".action-cancelled-from").click(function(){var t=$(this);tvly_run(t,{action:"cancelled_from",station:t.data("station"),train:t.data("train")})}),$(".action-cancelled-to").click(function(){var t=$(this);tvly_run(t,{action:"cancelled_to",station:t.data("station"),force:!0})}),$(".action-delete").click(function(){var t=$(this),a={action:"delete",id:t.data("id"),checkin:t.data("checkin"),checkout:t.data("checkout")};really_delete=confirm("Diese Zugfahrt wirklich löschen? Der Eintrag wird sofort aus der Datenbank entfernt und kann nicht wiederhergestellt werden."),really_delete&&tvly_run(t,a)})}$(document).ready(function(){tvly_reg_handlers(),$(".statuscol .autorefresh").length&&setTimeout(tvly_update,2e4),$(".publicstatuscol .autorefresh").length&&setTimeout(tvly_update_public,2e4),$("a[href]").click(function(){$("nav .preloader-wrapper").addClass("active")})}); +function tvly_run(a,t,e){var n='error',c=$('
');a.hide(),a.after(c),$.post("/action",t,function(t){t.success?$(location).attr("href",t.redirect_to):(M.toast({html:n+" "+t.error}),c.remove(),e&&e(),a.append(" "+n),a.show())})}function tvly_update(){$.get("/ajax/status_card.html",function(t){$(".statuscol").html(t),tvly_reg_handlers(),setTimeout(tvly_update,2e4)}).fail(function(){$(".sync-failed-marker").css("display","block"),$(".countdown").html(" "),setTimeout(tvly_update,5e3)})}function tvly_update_public(){var t;$(".publicstatuscol").each(function(){t=$(this).data("user")}),$.get("/ajax/status/"+t+".html",function(t){$(".publicstatuscol").html(t),setTimeout(tvly_update_public,2e4)}).fail(function(){$(".sync-failed-marker").css("display","block"),$(".countdown").html(" "),setTimeout(tvly_update_public,5e3)})}function tvly_reg_handlers(){$(".action-checkin").click(function(){var t=$(this);tvly_run(t,{action:"checkin",station:t.data("station"),train:t.data("train")})}),$(".action-checkout").click(function(){var t=$(this),a={action:"checkout",station:t.data("station"),force:t.data("force")};tvly_run(t,a,function(){t.append(" – Ohne Echtzeitdaten auschecken?"),t.data("force",!0)})}),$(".action-undo").click(function(){var t=$(this);tvly_run(t,{action:"undo",undo_id:t.data("id")})}),$(".action-cancelled-from").click(function(){var t=$(this);tvly_run(t,{action:"cancelled_from",station:t.data("station"),train:t.data("train")})}),$(".action-cancelled-to").click(function(){var t=$(this);tvly_run(t,{action:"cancelled_to",station:t.data("station"),force:!0})}),$(".action-delete").click(function(){var t=$(this),a={action:"delete",id:t.data("id"),checkin:t.data("checkin"),checkout:t.data("checkout")};really_delete=confirm("Diese Zugfahrt wirklich löschen? Der Eintrag wird sofort aus der Datenbank entfernt und kann nicht wiederhergestellt werden."),really_delete&&tvly_run(t,a)})}$(document).ready(function(){tvly_reg_handlers(),$(".statuscol .autorefresh").length&&setTimeout(tvly_update,2e4),$(".publicstatuscol .autorefresh").length&&setTimeout(tvly_update_public,2e4),$("a[href]").click(function(){$("nav .preloader-wrapper").addClass("active")})}); diff --git a/public/static/manifest.json b/public/static/manifest.json index da3c185..c623123 100644 --- a/public/static/manifest.json +++ b/public/static/manifest.json @@ -3,27 +3,27 @@ "short_name": "Travelynx", "scope": "/", "icons": [{ - "src": "/static/v15/icons/icon-128x128.png", + "src": "/static/v16/icons/icon-128x128.png", "sizes": "128x128", "type": "image/png" }, { - "src": "/static/v15/icons/icon-144x144.png", + "src": "/static/v16/icons/icon-144x144.png", "sizes": "144x144", "type": "image/png" }, { - "src": "/static/v15/icons/icon-152x152.png", + "src": "/static/v16/icons/icon-152x152.png", "sizes": "152x152", "type": "image/png" }, { - "src": "/static/v15/icons/icon-192x192.png", + "src": "/static/v16/icons/icon-192x192.png", "sizes": "192x192", "type": "image/png" }, { - "src": "/static/v15/icons/icon-256x256.png", + "src": "/static/v16/icons/icon-256x256.png", "sizes": "256x256", "type": "image/png" }, { - "src": "/static/v15/icons/icon-512x512.png", + "src": "/static/v16/icons/icon-512x512.png", "sizes": "512x512", "type": "image/png" }], diff --git a/public/static/v14 b/public/static/v16 similarity index 100% rename from public/static/v14 rename to public/static/v16 diff --git a/templates/_checked_in.html.ep b/templates/_checked_in.html.ep index ffac3d6..43fda02 100644 --- a/templates/_checked_in.html.ep +++ b/templates/_checked_in.html.ep @@ -3,7 +3,7 @@ Eingecheckt in <%= $journey->{train_type} %> <%= $journey->{train_no} %>

-

+
% if ($journey->{departure_countdown} > 120) { Abfahrt in <%= sprintf('%.f', $journey->{departure_countdown} / 60) %> Minuten % } diff --git a/templates/_public_status_card.html.ep b/templates/_public_status_card.html.ep index 494ad43..4b3b787 100644 --- a/templates/_public_status_card.html.ep +++ b/templates/_public_status_card.html.ep @@ -4,7 +4,7 @@ <%= $name %> ist unterwegs

-

+
<%= $journey->{train_type} %> <%= $journey->{train_no} %>
% if ($journey->{departure_countdown} > 120) { Abfahrt in <%= sprintf('%.f', $journey->{departure_countdown} / 60) %> Minuten diff --git a/templates/layouts/default.html.ep b/templates/layouts/default.html.ep index fb77eec..98289f7 100644 --- a/templates/layouts/default.html.ep +++ b/templates/layouts/default.html.ep @@ -9,7 +9,7 @@ - % my $av = 'v15'; # asset version + % my $av = 'v16'; # asset version %= stylesheet "/static/${av}/css/materialize.min.css"