git ssb

0+

Dominic / %oZNumvaRdlZDV/jsRcA…



Commit 3dc61399c268fbb5b29ef38c51da4440292694c3

static

Dominic Tarr committed on 7/8/2017, 1:36:15 AM
Parent: 6ad452e049e6b44d559888128267bb109a3f1aad

Files changed

index.htmlchanged
index.htmlView
@@ -5,8 +5,9 @@
55 <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport" />
66 <meta charset=utf-8></head>
77 <body></body>
88 <script>
9 +(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
910 var pre = document.createElement('pre')
1011 document.body.appendChild(pre)
1112
1213 function flatten (p) {
@@ -18,12 +19,29 @@
1819 o[k] = p[k]
1920 return o
2021 }
2122
23 +var positions = []
24 +
25 +pre.textContent = 'waiting for position...'
26 +
2227 navigator.geolocation.watchPosition(function (e) {
2328 console.log(e.coords, e.timestamp)
24- pre.textContent = JSON.stringify(flatten(e), null, 2)
29 + position.push(flatten(e))
30 + //keep just one minute's worth of locations.
31 + if(e.timestamp < Date.now() - 60e3) // one minute
32 + positions.shift()
33 +
34 + var movement = position.map(function (_e) {
35 + return {
36 + distance: GreatCircle.distance(_e.latitude, _e.longitude, e.latitude, e.longitude, 'NM'),
37 + heading: GreatCircle.bearing(_e.latitude, _e.longitude, e.latitude, e.longitude)
38 + }
39 + })
40 +
41 + pre.textContent = JSON.stringify({current: flatten(e), movement: movement}, null, 2)
2542 })
2643
2744
45 +},{}]},{},[1]);
2846 </script>
2947 </html>

Built with git-ssb-web