node: don't show "Start follow position" button at all if browser does not support navigator.geolocation

This commit is contained in:
Oliver Gerlich 2018-07-19 22:53:30 +02:00
parent 3a18da51c8
commit d7e98625e2
1 changed files with 27 additions and 27 deletions

View File

@ -91,6 +91,7 @@ export class NodeView extends View {
this.btnGPS = domlib.newAt(this.el, 'span');
if (navigator.geolocation) {
this.btnGPS.classList.add('btn');
this.btnGPS.innerHTML = 'Start follow position';
this.btnGPS.addEventListener('click', () => {
@ -110,7 +111,6 @@ export class NodeView extends View {
this.gpsPosition = null;
this.btnGPS.innerHTML = 'Stop following';
this.gpsStatusText.innerHTML = "waiting for location...";
if (navigator.geolocation) {
this.editLocationGPS = navigator.geolocation.watchPosition((position) => {
this.gpsStatusText.innerHTML = "GPS location at " +
new Date(position.timestamp).toLocaleTimeString() + ": " +
@ -136,10 +136,10 @@ export class NodeView extends View {
'maximumAge': 30000,
'timeout': 27000
});
} else {
notify.send('error', 'Browser did not support Location');
}
});
} else {
this.btnGPS.innerHTML = '(Browser does not support geo-location)';
}
this.gpsStatusText = domlib.newAt(this.el, 'span');
this.gpsStatusText.classList.add('withTextMargins');
}