Files: 3dc61399c268fbb5b29ef38c51da4440292694c3 / index.html
1608 bytesRaw
1 | |
2 | <html> |
3 | <head> |
4 | <title>---</title> |
5 | <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport" /> |
6 | <meta charset=utf-8></head> |
7 | <body></body> |
8 | <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){ |
10 | var pre = document.createElement('pre') |
11 | document.body.appendChild(pre) |
12 | |
13 | function flatten (p) { |
14 | var o = {} |
15 | for(var k in p) |
16 | if(p[k] && 'object' === typeof p[k]) |
17 | o[k] = flatten(p[k]) |
18 | else |
19 | o[k] = p[k] |
20 | return o |
21 | } |
22 | |
23 | var positions = [] |
24 | |
25 | pre.textContent = 'waiting for position...' |
26 | |
27 | navigator.geolocation.watchPosition(function (e) { |
28 | console.log(e.coords, e.timestamp) |
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) |
42 | }) |
43 | |
44 | |
45 | },{}]},{},[1]); |
46 | </script> |
47 | </html> |
48 |
Built with git-ssb-web