From 95cbc500ae6841ff552a7b299c127c0754fb3a23 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sun, 21 Oct 2018 16:27:32 +0200 Subject: Minify JS --- public/static/js/geolocation.min.js | 1 + public/static/js/travelynx-actions.js | 6 +++--- public/static/js/travelynx-actions.min.js | 1 + templates/layouts/default.html.ep | 4 ++-- 4 files changed, 7 insertions(+), 5 deletions(-) create mode 100644 public/static/js/geolocation.min.js create mode 100644 public/static/js/travelynx-actions.min.js diff --git a/public/static/js/geolocation.min.js b/public/static/js/geolocation.min.js new file mode 100644 index 0000000..50cd010 --- /dev/null +++ b/public/static/js/geolocation.min.js @@ -0,0 +1 @@ +$(document).ready(function(){var e=$("p.geolocationhint"),t=$("div.geolocation div.progress"),o=function(o,a,n){e.remove(),t.remove()},a=function(e){e.error?o(0,e.error):0==e.candidates.length?o():(resultTable=$("
"),resultBody=resultTable.children(),$.each(e.candidates,function(e,t){var o=t.ds100,a=t.name,n=t.distance;n=n.toFixed(1);var r=$(document.createElement("a"));r.attr("href",o),r.text(a),resultBody.append(''+a+"")}),t.replaceWith(resultTable))},n=function(e){$.post("/x/geolocation",{lon:e.coords.longitude,lat:e.coords.latitude},a)},r=function(e){e.code==e.PERMISSION_DENIED?o():e.code==e.POSITION_UNAVAILABLE?o():(e.code,e.TIMEOUT,o())};navigator.geolocation?navigator.geolocation.getCurrentPosition(n,r):o()}); diff --git a/public/static/js/travelynx-actions.js b/public/static/js/travelynx-actions.js index 91953a6..70c5d39 100644 --- a/public/static/js/travelynx-actions.js +++ b/public/static/js/travelynx-actions.js @@ -1,4 +1,4 @@ -function travelynx_run_action(link, req, redir, err_callback) { +function tvly_run(link, req, redir, err_callback) { var error_icon = 'error'; var progressbar = $('
'); link.hide(); @@ -25,7 +25,7 @@ $(document).ready(function() { station: link.data('station'), train: link.data('train'), }; - travelynx_run_action(link, req, '/'); + tvly_run(link, req, '/'); }); $('.action-checkout').click(function() { var link = $(this); @@ -34,7 +34,7 @@ $(document).ready(function() { station: link.data('station'), force: link.data('force'), }; - travelynx_run_action(link, req, '/' + req.station, function() { + tvly_run(link, req, '/' + req.station, function() { link.append(' – Keine Echtzeitdaten vorhanden') link.data('force', true); }); diff --git a/public/static/js/travelynx-actions.min.js b/public/static/js/travelynx-actions.min.js new file mode 100644 index 0000000..2ecfe38 --- /dev/null +++ b/public/static/js/travelynx-actions.min.js @@ -0,0 +1 @@ +function tvly_run(t,a,n,i){var c='error',o=$('
');t.hide(),t.after(o),$.post("/action",a,function(a){a.success?$(location).attr("href",n):(M.toast({html:c+" "+a.error}),o.remove(),i&&i(),t.append(" "+c),t.show())})}$(document).ready(function(){$(".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,"/"+a.station,function(){t.append(" – Keine Echtzeitdaten vorhanden"),t.data("force",!0)})})}); diff --git a/templates/layouts/default.html.ep b/templates/layouts/default.html.ep index 19be177..ffbb5ef 100644 --- a/templates/layouts/default.html.ep +++ b/templates/layouts/default.html.ep @@ -10,9 +10,9 @@ %= stylesheet '/static/css/local.css' %= javascript '/static/js/jquery-2.2.4.min.js' %= javascript '/static/js/materialize.min.js' - %= javascript '/static/js/travelynx-actions.js' + %= javascript '/static/js/travelynx-actions.min.js' % if (stash('with_geolocation')) { - %= javascript '/static/js/geolocation.js' + %= javascript '/static/js/geolocation.min.js' % } -- cgit v1.2.3