From 11ea0db3d6bd20e38b0eaab45d69c850256a0b5d Mon Sep 17 00:00:00 2001 From: Birte Kristina Friesel Date: Wed, 30 Aug 2023 22:06:53 +0200 Subject: remove geotrain assets --- public/static/js/geotrain.js | 89 ---------------------------------------- public/static/js/geotrain.min.js | 1 - scripts/asset-rebuild | 1 - templates/layouts/app.html.ep | 3 -- 4 files changed, 94 deletions(-) delete mode 100644 public/static/js/geotrain.js delete mode 100644 public/static/js/geotrain.min.js diff --git a/public/static/js/geotrain.js b/public/static/js/geotrain.js deleted file mode 100644 index b77c363..0000000 --- a/public/static/js/geotrain.js +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (C) 2020 Birte Kristina Friesel - * - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -$(function() { - var removeStatus = function() { - $('div.candidatestatus').remove(); - }; - var showError = function(header, message, code) { - var errnode = $(document.createElement('div')); - errnode.attr('class', 'error'); - errnode.text(message); - - var headnode = $(document.createElement('strong')); - headnode.text(header); - errnode.prepend(headnode); - - if (code) { - var shortnode = $(document.createElement('div')); - shortnode.attr('class', 'errcode'); - shortnode.text(code); - errnode.append(shortnode); - } - - $('div.candidatelist').append(errnode); - }; - - var processResult = function(data) { - removeStatus(); - if (data.error) { - showError('Backend-Fehler:', data.error, null); - } else if (data.evas.length == 0) { - showError('Keine Bahnstrecke gefunden', '', null); - } else if (data.trains.length == 0) { - showError('Keine Züge auf der Strecke gefunden', '', null); - } else { - $.each(data.trains, function(i, train) { - - const prev = train.stops[0][1] - const prev_time = train.stops[0][2] - const next_eva = train.stops[1][0] - const next = train.stops[1][1] - const next_time = train.stops[1][2] - - var stationlink = $(document.createElement('a')); - stationlink.attr('href', '/z/' + train.train + '/' + next_eva); - stationlink.text(train.line); - - var distancenode = $(document.createElement('div')); - distancenode.attr('class', 'traininfo'); - distancenode.html(train.likelihood + '%
' + prev_time + ' ' + prev + '
' + next_time + ' ' + next); - - stationlink.append(distancenode); - $('div.candidatelist').append(stationlink); - }); - } - }; - - var processLocation = function(loc) { - $.get('https://dbf.finalrewind.org/__geotrain/search', {lon: loc.coords.longitude, lat: loc.coords.latitude}, processResult).fail(function(jqXHR, textStatus, errorThrown) { - removeStatus(); - showError("Netzwerkfehler: ", textStatus, errorThrown); - }); - $('div.candidatestatus').text('Suche Züge…'); - }; - - var processError = function(error) { - removeStatus(); - if (error.code == error.PERMISSION_DENIED) { - showError('Standortanfrage nicht möglich.', 'Vermutlich fehlen die Rechte im Browser oder der Android Location Service ist deaktiviert.', 'geolocation.error.PERMISSION_DENIED'); - } else if (error.code == error.POSITION_UNAVAILABLE) { - showError('Standort konnte nicht ermittelt werden', '(Service nicht verfügbar)', 'geolocation.error.POSITION_UNAVAILABLE'); - } else if (error.code == error.TIMEOUT) { - showError('Standort konnte nicht ermittelt werden', '(Timeout)', 'geolocation.error.TIMEOUT'); - } else { - showError('Standort konnte nicht ermittelt werden', '(unbekannter Fehler)', 'unknown geolocation.error code'); - } - }; - - if (navigator.geolocation) { - navigator.geolocation.getCurrentPosition(processLocation, processError); - $('div.candidatestatus').text('Position wird bestimmt…'); - } else { - removeStatus(); - showError('Standortanfragen werden von diesem Browser nicht unterstützt', '', null); - } -}); diff --git a/public/static/js/geotrain.min.js b/public/static/js/geotrain.min.js deleted file mode 100644 index d58e8de..0000000 --- a/public/static/js/geotrain.min.js +++ /dev/null @@ -1 +0,0 @@ -$(function(){function t(e){r(),e.error?o("Backend-Fehler:",e.error,null):0==e.evas.length?o("Keine Bahnstrecke gefunden","",null):0==e.trains.length?o("Keine Züge auf der Strecke gefunden","",null):$.each(e.trains,function(e,t){var n=t.stops[0][1],r=t.stops[0][2],o=t.stops[1][0],i=t.stops[1][1],a=t.stops[1][2],d=$(document.createElement("a")),o=(d.attr("href","/z/"+t.train+"/"+o),d.text(t.line),$(document.createElement("div")));o.attr("class","traininfo"),o.html(t.likelihood+"%
"+r+" "+n+"
"+a+" "+i),d.append(o),$("div.candidatelist").append(d)})}var r=function(){$("div.candidatestatus").remove()},o=function(e,t,n){var r=$(document.createElement("div")),t=(r.attr("class","error"),r.text(t),$(document.createElement("strong")));t.text(e),r.prepend(t),n&&((e=$(document.createElement("div"))).attr("class","errcode"),e.text(n),r.append(e)),$("div.candidatelist").append(r)};navigator.geolocation?(navigator.geolocation.getCurrentPosition(function(e){$.get("https://dbf.finalrewind.org/__geotrain/search",{lon:e.coords.longitude,lat:e.coords.latitude},t).fail(function(e,t,n){r(),o("Netzwerkfehler: ",t,n)}),$("div.candidatestatus").text("Suche Züge…")},function(e){r(),e.code==e.PERMISSION_DENIED?o("Standortanfrage nicht möglich.","Vermutlich fehlen die Rechte im Browser oder der Android Location Service ist deaktiviert.","geolocation.error.PERMISSION_DENIED"):e.code==e.POSITION_UNAVAILABLE?o("Standort konnte nicht ermittelt werden","(Service nicht verfügbar)","geolocation.error.POSITION_UNAVAILABLE"):e.code==e.TIMEOUT?o("Standort konnte nicht ermittelt werden","(Timeout)","geolocation.error.TIMEOUT"):o("Standort konnte nicht ermittelt werden","(unbekannter Fehler)","unknown geolocation.error code")}),$("div.candidatestatus").text("Position wird bestimmt…")):(r(),o("Standortanfragen werden von diesem Browser nicht unterstützt","",null))}); diff --git a/scripts/asset-rebuild b/scripts/asset-rebuild index 98e5841..09597ad 100755 --- a/scripts/asset-rebuild +++ b/scripts/asset-rebuild @@ -10,6 +10,5 @@ sassc -t compressed sass/light.scss public/static/css/light.min.css uglifyjs public/static/js/collapse.js -c -m > public/static/js/dbf.min.js uglifyjs public/static/js/geostop.js -c -m > public/static/js/geostop.min.js -uglifyjs public/static/js/geotrain.js -c -m > public/static/js/geotrain.min.js uglifyjs public/static/js/map-refresh.js -c -m > public/static/js/map-refresh.min.js uglifyjs public/static/js/marquee.js -c -m > public/static/js/marquee.min.js diff --git a/templates/layouts/app.html.ep b/templates/layouts/app.html.ep index fda49d1..9b5e0b6 100644 --- a/templates/layouts/app.html.ep +++ b/templates/layouts/app.html.ep @@ -61,9 +61,6 @@ % if (stash('with_geostop')) { %= javascript "/static/${av}/js/geostop.min.js", defer => undef % } - % if (stash('with_geotrain')) { - %= javascript "/static/${av}/js/geotrain.min.js", defer => undef - % } % if (stash('with_map')) { %= stylesheet "/static/${av}/leaflet/leaflet.css" %= javascript "/static/${av}/leaflet/leaflet.js" -- cgit v1.2.3