Moved javascript to own file

master
Keith Irwin 2019-02-21 19:41:33 -05:00
parent 1ddea4bcb7
commit bf50194a10
No known key found for this signature in database
GPG Key ID: 7A2D6993A44010AA
2 changed files with 17 additions and 15 deletions

View File

@ -8,21 +8,7 @@
<span id="speed"></span>
</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>

16
main.js Normal file
View File

@ -0,0 +1,16 @@
'use strict';
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
})
}