Merge branch 'develop'

master
Keith Irwin 2019-02-21 20:07:57 -05:00
commit be7db6f3c1
No known key found for this signature in database
GPG Key ID: 7A2D6993A44010AA
3 changed files with 40 additions and 18 deletions

View File

@ -1,28 +1,14 @@
<html>
<head>
<title>Spedometer</title>
<link type="text/css" rel="stylesheet" href="style.css">
</head>
<body>
<div id="speedometer">
<span id="speed"></span>
</div>
<div id="speed">0.0</div>
<div id="units">m.p.h.</div>
<script type="application/javascript">
const speedometer = document.getElementById('speedometer')
const speedSpan = document.getElementById('speed')
// Check for API
if (!'geolocation' in navigator) {
alert('No geolocation API available')
speedometer.innerHTML = 'No API'
} else {
const WID = navigator.geolocation.watchPosition( function(loc) {
console.log(JSON.stringify(loc.coords.speed))
//alert('speed:',loc.coords.speed)
if (loc.coords.speed) speedSpan.innerHTML = loc.coords.speed
})
}
</script>
<script type="application/javascript" src="main.js"></script>
</body>
</html>

20
main.js Normal file
View File

@ -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'
}
})
}

16
style.css Normal file
View File

@ -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;
}