diff --git a/index.html b/index.html index 56cf527..225d193 100644 --- a/index.html +++ b/index.html @@ -1,28 +1,14 @@ Spedometer + -
- -
+
0.0
+
m.p.h.
- + diff --git a/main.js b/main.js new file mode 100644 index 0000000..6137965 --- /dev/null +++ b/main.js @@ -0,0 +1,20 @@ +'use strict'; + +const speedDiv = document.getElementById('speed') + +// Check for API +if (!'geolocation' in navigator) { + alert('No geolocation API available') + speedDiv.innerHTML = 'No API' +} else { + + const WID = navigator.geolocation.watchPosition( function (loc) { + // got speed + if (loc.coords.speed) { + // convert to mph and display + speedDiv.innerHTML = (2.23693629205*loc.coords.speed).toFixed(1) + } else { + speedDiv.innerHTML = '0.0' + } + }) +} diff --git a/style.css b/style.css new file mode 100644 index 0000000..011a452 --- /dev/null +++ b/style.css @@ -0,0 +1,16 @@ +body { + margin: 0; + background: #080808; + color: #FFF; +} + +#speed, #units { + font-family: 'sans'; + text-align: center; +} +#units { + font-size: 10vw; +} +#speed { + font-size: 30vw; +}