summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDerf Null <derf@finalrewind.org>2023-05-07 09:55:38 +0200
committerDerf Null <derf@finalrewind.org>2023-05-07 09:55:38 +0200
commite154a8aeb4fe69dcfa26ab091c874ca5c1d90809 (patch)
treeddf0f818c13bb75de04705d5471d0afb76fc27e8
parenteb5f4b06cdb7d2ac229758ade16f69acf70194dc (diff)
show loading icon when clicking on a stop in stop list
-rw-r--r--public/static/js/geolocation.js12
-rw-r--r--public/static/js/geolocation.min.js2
2 files changed, 11 insertions, 3 deletions
diff --git a/public/static/js/geolocation.js b/public/static/js/geolocation.js
index 5ef0a5c..6789730 100644
--- a/public/static/js/geolocation.js
+++ b/public/static/js/geolocation.js
@@ -24,7 +24,11 @@ $(document).ready(function() {
const res = $(document.createElement('p'));
$.each(stops, function(i, stop) {
const parts = stop.split(';');
- res.append($('<a class="tablerow" href="/s/' + parts[0] + '"><span>' + parts[1] + '</span></a>'));
+ const node = $('<a class="tablerow" href="/s/' + parts[0] + '"><span>' + parts[1] + '</span></a>');
+ node.click(function() {
+ $('nav .preloader-wrapper').addClass('active');
+ });
+ res.append(node);
});
$('p.geolocationhint').text('Letzte Ziele:');
getPlaceholder().replaceWith(res);
@@ -46,7 +50,11 @@ $(document).ready(function() {
name = candidate.name,
distance = candidate.distance.toFixed(1);
- res.append($('<a class="tablerow" href="/s/' + ds100 + '"><span>' + name + '</span></a>'));
+ const node = $('<a class="tablerow" href="/s/' + ds100 + '"><span>' + name + '</span></a>');
+ node.click(function() {
+ $('nav .preloader-wrapper').addClass('active');
+ });
+ res.append(node);
});
getPlaceholder().replaceWith(res);
}
diff --git a/public/static/js/geolocation.min.js b/public/static/js/geolocation.min.js
index 6ebb8f0..0752523 100644
--- a/public/static/js/geolocation.min.js
+++ b/public/static/js/geolocation.min.js
@@ -1 +1 @@
-$(document).ready(function(){function i(){return $("div.geolocation div.progress")}function e(e){$.post("/geolocation",{lon:e.coords.longitude,lat:e.coords.latitude},o)}function t(e){e.code==e.PERMISSION_DENIED?n("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?n("Standort konnte nicht ermittelt werden","(Service nicht verfügbar)","geolocation.error.POSITION_UNAVAILABLE"):e.code==e.TIMEOUT?n("Standort konnte nicht ermittelt werden","(Timeout)","geolocation.error.TIMEOUT"):n("Standort konnte nicht ermittelt werden","(unbekannter Fehler)","unknown geolocation.error code")}const n=function(e,t,n){var o=$(document.createElement("div")),t=(o.attr("class","error"),o.text(t),$(document.createElement("strong"))),e=(t.text(e+" "),o.prepend(t),$("div.geolocation").append(o),$("div.geolocation").data("recent"));if(e){t=e.split("|");const r=$(document.createElement("p"));$.each(t,function(e,t){t=t.split(";");r.append($('<a class="tablerow" href="/s/'+t[0]+'"><span>'+t[1]+"</span></a>"))}),$("p.geolocationhint").text("Letzte Ziele:"),i().replaceWith(r)}else i().remove()},o=function(e){if(e.error)n("Backend-Fehler:",e.error,null);else if(0==e.candidates.length)n("Keine Bahnhöfe in 70km Umkreis gefunden","",null);else{const r=$(document.createElement("p"));$.each(e.candidates,function(e,t){var n=t.ds100,o=t.name;t.distance.toFixed(1);r.append($('<a class="tablerow" href="/s/'+n+'"><span>'+o+"</span></a>"))}),i().replaceWith(r)}},r=$("div.geolocation > button");r.data("recent");function a(){r.replaceWith($('<p class="geolocationhint">Stationen in der Umgebung:</p><div class="progress"><div class="indeterminate"></div></div>')),navigator.geolocation.getCurrentPosition(e,t)}r.length&&(navigator.geolocation?navigator.permissions?navigator.permissions.query({name:"geolocation"}).then(function(e){"prompt"===e.state?r.on("click",a):a()}):r.on("click",a):n("Standortanfragen werden von diesem Browser nicht unterstützt","",null))});
+$(document).ready(function(){function i(){return $("div.geolocation div.progress")}function e(e){$.post("/geolocation",{lon:e.coords.longitude,lat:e.coords.latitude},o)}function n(e){e.code==e.PERMISSION_DENIED?t("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?t("Standort konnte nicht ermittelt werden","(Service nicht verfügbar)","geolocation.error.POSITION_UNAVAILABLE"):e.code==e.TIMEOUT?t("Standort konnte nicht ermittelt werden","(Timeout)","geolocation.error.TIMEOUT"):t("Standort konnte nicht ermittelt werden","(unbekannter Fehler)","unknown geolocation.error code")}const t=function(e,n,t){var o=$(document.createElement("div")),n=(o.attr("class","error"),o.text(n),$(document.createElement("strong"))),e=(n.text(e+" "),o.prepend(n),$("div.geolocation").append(o),$("div.geolocation").data("recent"));if(e){n=e.split("|");const r=$(document.createElement("p"));$.each(n,function(e,n){n=n.split(";"),n=$('<a class="tablerow" href="/s/'+n[0]+'"><span>'+n[1]+"</span></a>");n.click(function(){$("nav .preloader-wrapper").addClass("active")}),r.append(n)}),$("p.geolocationhint").text("Letzte Ziele:"),i().replaceWith(r)}else i().remove()},o=function(e){if(e.error)t("Backend-Fehler:",e.error,null);else if(0==e.candidates.length)t("Keine Bahnhöfe in 70km Umkreis gefunden","",null);else{const r=$(document.createElement("p"));$.each(e.candidates,function(e,n){var t=n.ds100,o=n.name,n=(n.distance.toFixed(1),$('<a class="tablerow" href="/s/'+t+'"><span>'+o+"</span></a>"));n.click(function(){$("nav .preloader-wrapper").addClass("active")}),r.append(n)}),i().replaceWith(r)}},r=$("div.geolocation > button");r.data("recent");function a(){r.replaceWith($('<p class="geolocationhint">Stationen in der Umgebung:</p><div class="progress"><div class="indeterminate"></div></div>')),navigator.geolocation.getCurrentPosition(e,n)}r.length&&(navigator.geolocation?navigator.permissions?navigator.permissions.query({name:"geolocation"}).then(function(e){"prompt"===e.state?r.on("click",a):a()}):r.on("click",a):t("Standortanfragen werden von diesem Browser nicht unterstützt","",null))});