-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
35 lines (30 loc) · 881 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import './main.css';
import { Elm } from './Main.elm';
// import { PortFunnel } from './PortFunnel.js';
import registerServiceWorker from './registerServiceWorker';
if (navigator && navigator.geolocation) {
navigator.geolocation.getCurrentPosition(geolocationCallback, geolocationCallback);
} else {
geolocationCallback(); // fallback to init
}
function geolocationCallback(result) {
let flags = undefined;
if (result && !result.code) { // error
flags = {
longitude: result.coords.longitude,
latitude: result.coords.latitude
}
} else {
flags = null;
}
Elm.Main.init({
node: document.getElementById('root'),
flags
});
}
// const modules = ['Geolocation'];
// PortFunnel.subscribe(app, {modules: modules});
// ignore for none-browser environment (electron)
if (window.location.protocol !== 'file:') {
registerServiceWorker();
}