geo.js fix

This commit is contained in:
NN Solex 2023-05-01 22:59:40 +03:00
parent 20c0224bc8
commit 4203301112
35 changed files with 556 additions and 23 deletions

View file

@ -4,12 +4,16 @@ const ios = ua.indexOf("ios") > -1;
const windows = ua.indexOf("windows") > -1;
const linux = ua.indexOf("linux") > -1;
const mac = ua.indexOf("macos") > -1;
var hashlinks = document.querySelectorAll(".geo a");
var hashlinks = document.querySelectorAll('[href*="geo:"]');
var hasharray = [...hashlinks];
if ( hasharray.length > 0 ) {
hasharray.forEach(hashlink => {
if ( windows || mac || linux ) hashlink.href = "https://maps.google.com/?q=" + hashlink.getAttribute("latlon");
else if ( android ) hashlink.href = "geo:0,0?q=" + hashlink.getAttribute("latlon");
else if ( ios ) hashlink.href = "http://maps.apple.com/?ll=" + hashlink.getAttribute("latlon") + "&q=" + hashlink.innerHTML;
const geolink = hashlink.getAttribute("href").match(/(-?\d+(\.\d+)?),\s*(-?\d+(\.\d+)?)/g);
var latlon;
if ( geolink.length > 1 && geolink[0] == '0,0') latlon = geolink[1];
else latlon = geolink[0];
if ( windows || mac || linux ) hashlink.href = "https://maps.google.com/?q=" + latlon;
else if ( android ) hashlink.href = "geo:0,0?q=" + latlon;
else if ( ios ) hashlink.href = "http://maps.apple.com/?ll=" + latlon + "&q=" + hashlink.innerHTML;
});
}