diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 diff --git a/LICENSE.md b/LICENSE.md old mode 100644 new mode 100755 diff --git a/README.md b/README.md old mode 100644 new mode 100755 diff --git a/coordinates.js b/coordinates.js new file mode 100755 index 0000000..ea2a162 --- /dev/null +++ b/coordinates.js @@ -0,0 +1,47 @@ +'use strict' +/* global navigator $ */ + + +// Set units based on browser locale +const metric = !(window.navigator.language=='en-US'||window.navigator.language=='my') + +// Check for GPS capability +if (!navigator.geolocation) $('#no-gps').show() + +// Start tracking +else navigator.geolocation.watchPosition( + + // Got location callbackw + function(pos) { + let lat = pos.coords.latitude.toFixed(4) + let lon = pos.coords.longitude.toFixed(4) + $('#lat').text( + (lat.substring(0,1)=='-')? // Negative values are South + lat.substring(1)+' S' : lat+' N' + ) + $('#lon').text( + (lon.substring(0,1)=='-')? // Negative values are East + lon.substring(1)+' W' : lon+' E' + ) + + // Get altitude + if (pos.coords.altitude) { + $('#alt').show().text( + (metric)? // Convert to feet if needed + pos.coords.altitude.toFixed(1)+' m': + (pos.coords.altitude*3.28084).toFixed(1)+' ft' + ) + } + else $('#alt').hide() + }, + + // Got error + function() { + $('.coord').hide() + $('#no-gps').show() + }, + + // Options + { enableHighAccuracy:true } + +) diff --git a/direction.js b/direction.js new file mode 100644 index 0000000..d55ba75 --- /dev/null +++ b/direction.js @@ -0,0 +1,21 @@ +'use strict' +/* global $ window */ + + +window.addEventListener('deviceorientation', function(e){ + + // No orientation data + if(!e) $('#no-dir').show() + + // Set orientation + else { + $('#no-dir').hide() + const rot = 'rotate('+e.alpha.toString().substring(0,5)+'deg)' + $('#rose').css({ + '-ms-transform': rot, + '-webkit-transform': rot, + 'transform': rot + }) + } + +}, true) diff --git a/icons/apple-touch-icon-114x114.png b/icons/apple-touch-icon-114x114.png old mode 100644 new mode 100755 diff --git a/icons/apple-touch-icon-120x120.png b/icons/apple-touch-icon-120x120.png old mode 100644 new mode 100755 diff --git a/icons/apple-touch-icon-144x144.png b/icons/apple-touch-icon-144x144.png old mode 100644 new mode 100755 diff --git a/icons/apple-touch-icon-152x152.png b/icons/apple-touch-icon-152x152.png old mode 100644 new mode 100755 diff --git a/icons/apple-touch-icon-57x57.png b/icons/apple-touch-icon-57x57.png old mode 100644 new mode 100755 diff --git a/icons/apple-touch-icon-60x60.png b/icons/apple-touch-icon-60x60.png old mode 100644 new mode 100755 diff --git a/icons/apple-touch-icon-72x72.png b/icons/apple-touch-icon-72x72.png old mode 100644 new mode 100755 diff --git a/icons/apple-touch-icon-76x76.png b/icons/apple-touch-icon-76x76.png old mode 100644 new mode 100755 diff --git a/icons/favicon-128.png b/icons/favicon-128.png old mode 100644 new mode 100755 diff --git a/icons/favicon-16x16.png b/icons/favicon-16x16.png old mode 100644 new mode 100755 diff --git a/icons/favicon-196x196.png b/icons/favicon-196x196.png old mode 100644 new mode 100755 diff --git a/icons/favicon-32x32.png b/icons/favicon-32x32.png old mode 100644 new mode 100755 diff --git a/icons/favicon-96x96.png b/icons/favicon-96x96.png old mode 100644 new mode 100755 diff --git a/icons/favicon.ico b/icons/favicon.ico old mode 100644 new mode 100755 diff --git a/icons/mstile-144x144.png b/icons/mstile-144x144.png old mode 100644 new mode 100755 diff --git a/icons/mstile-150x150.png b/icons/mstile-150x150.png old mode 100644 new mode 100755 diff --git a/icons/mstile-310x150.png b/icons/mstile-310x150.png old mode 100644 new mode 100755 diff --git a/icons/mstile-310x310.png b/icons/mstile-310x310.png old mode 100644 new mode 100755 diff --git a/icons/mstile-70x70.png b/icons/mstile-70x70.png old mode 100644 new mode 100755 diff --git a/index.html b/index.html old mode 100644 new mode 100755 index c65c88b..a0f8beb --- a/index.html +++ b/index.html @@ -47,8 +47,8 @@
No GPS data available.
-
0.00000 N
-
0.00000 E
+
0.0000 N
+
0.0000 W
@@ -58,7 +58,6 @@
No direction available. Try this on a smartphone with an internal compass.
-
Note: the compass may be 90° off when used in landscape mode.
@@ -66,11 +65,12 @@ - + + diff --git a/manifest.webmanifest b/manifest.json old mode 100644 new mode 100755 similarity index 100% rename from manifest.webmanifest rename to manifest.json diff --git a/rose.svg b/rose.svg old mode 100644 new mode 100755 diff --git a/script.js b/script.js deleted file mode 100644 index 50ecb4e..0000000 --- a/script.js +++ /dev/null @@ -1,61 +0,0 @@ -'use strict'; -/* global navigator $ */ - -// Set units based on browser locale -const metric = !(window.navigator.language=='en-US'||window.navigator.language=='my'); - -// Track GPS location -if (!navigator.geolocation){ $('#no-gps').show(); } -else { navigator.geolocation.watchPosition( - - // Got location - function(pos) { - let lat = pos.coords.latitude.toFixed(4); - let lon = pos.coords.longitude.toFixed(4); - $('#lat').text((lat.substring(0,1)=='-')? lat.substring(1)+' S' : lat+' N'); - $('#lon').text((lon.substring(0,1)=='-')? lon.substring(1)+' E' : lon+' W'); - - // Get altitude - if (pos.coords.altitude){ - var alt = (metric)? pos.coords.altitude.toFixed(1)+' m':(pos.coords.altitude*0.3048).toFixed(1)+' ft'; - $('#alt').show().text(alt); - } - else { - $('#alt').hide(); - } - }, - - // Got error - function() { - $('.coord').hide(); - $('#rotated').hide(); - $('#no-gps').show(); - }, - - // Options - { enableHighAccuracy:true } - - ); -} - -// Set compass orientation -function setRose(e) { - - // No orientation data - if(!e.absolute) { - $('#rotated').hide(); - $('#no-dir').show(); - } - - // Set orientation - else { - var rot = 'rotate('+e.alpha.toString().substring(0,5)+'deg)'; - $('#rose').css({ - '-ms-transform': rot, - '-webkit-transform': rot, - 'transform': rot - }); - } - -} -window.addEventListener("deviceorientation", setRose, true); \ No newline at end of file diff --git a/style.css b/style.css old mode 100644 new mode 100755 index 35a25c4..01af430 --- a/style.css +++ b/style.css @@ -38,7 +38,7 @@ header, main, footer, .error, noscript { } @media (orientation:portrait) { - .error#rotated { display: none; } + /*.error#rotated { display: none; }*/ header, main, footer { width: 90vw; padding: 5vw; @@ -66,7 +66,7 @@ header, main, footer, .error, noscript { } } @media (orientation:landscape) { - .error#rotated { display: block; } + /*.error#rotated { display: block; }*/ header, main, footer { height: 90vh; padding: 5vh;