Minor cleanups
This commit is contained in:
parent
ec01086049
commit
c506f8d98e
@ -409,7 +409,7 @@ button > * {
|
||||
right: 8px;
|
||||
}
|
||||
.ol-popup-closer:after {
|
||||
content: "✖";
|
||||
content: "×";
|
||||
}
|
||||
|
||||
#switcher {
|
||||
|
@ -253,12 +253,9 @@ export default class OpenLayersApi {
|
||||
popupContent.id = 'popup-content';
|
||||
popupContainer.appendChild(popupContent);
|
||||
const popupCloser = document.createElement('a');
|
||||
popupCloser.id = 'popup-closer';
|
||||
popupCloser.className = 'ol-popup-closer';
|
||||
popupCloser.href = '#';
|
||||
popupContainer.appendChild(popupCloser);
|
||||
|
||||
|
||||
this.popup = new ol.Overlay({
|
||||
element: popupContainer,
|
||||
autoPan: true,
|
||||
@ -347,6 +344,9 @@ export default class OpenLayersApi {
|
||||
switcherContent.id = 'switcher-content';
|
||||
switcherContent.className = 'ol-layerswitcher';
|
||||
switcher.appendChild(switcherContent);
|
||||
const switcherCloser = document.createElement('a');
|
||||
switcherCloser.className = 'ol-popup-closer';
|
||||
switcher.appendChild(switcherCloser);
|
||||
|
||||
this.map.getLayers().forEach(/** @param {Layer} _layer */(_layer) => {
|
||||
const layerLabel = document.createElement('label');
|
||||
@ -387,6 +387,7 @@ export default class OpenLayersApi {
|
||||
}
|
||||
};
|
||||
|
||||
switcherCloser.addEventListener('click', switcherHandle, false);
|
||||
switcherButton.addEventListener('click', switcherHandle, false);
|
||||
switcherButton.addEventListener('touchstart', switcherHandle, false);
|
||||
|
||||
|
@ -83,4 +83,12 @@ export default class uPosition {
|
||||
hasImage() {
|
||||
return (this.image != null && this.image.length > 0);
|
||||
}
|
||||
|
||||
get calculatedSpeed() {
|
||||
return this.seconds ? this.meters / this.seconds : 0;
|
||||
}
|
||||
|
||||
get totalSpeed() {
|
||||
return this.totalSeconds ? this.totalMeters / this.totalSeconds : 0;
|
||||
}
|
||||
}
|
||||
|
@ -82,19 +82,33 @@ export default class uPositionSet extends uListItem {
|
||||
|
||||
/**
|
||||
* Fetch latest position of each user.
|
||||
* @return {Promise<uPositionSet, Error>}
|
||||
* @return {Promise<void, Error>}
|
||||
*/
|
||||
fetchLatest() {
|
||||
this.clear();
|
||||
return uPositionSet.fetch({ last: true }).then((_positions) => {
|
||||
this.fromJson(_positions);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch latest position of each user.
|
||||
* @return {Promise<?uPositionSet, Error>}
|
||||
*/
|
||||
static fetchLatest() {
|
||||
return this.fetch({ last: true }).then((_positions) => {
|
||||
if (_positions.length) {
|
||||
const set = new uPositionSet();
|
||||
set.fromJson(_positions);
|
||||
const set = new uPositionSet();
|
||||
return set.fetchLatest().then(() => {
|
||||
if (set.length) {
|
||||
return set;
|
||||
}
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param params
|
||||
* @return {Promise<Object[], Error>}
|
||||
*/
|
||||
static fetch(params) {
|
||||
return uAjax.get('utils/getpositions.php', params);
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ export default class uUser extends uListItem {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {Promise<uTrack, string>}
|
||||
* @return {Promise<uTrack, Error>}
|
||||
*/
|
||||
fetchLastPosition() {
|
||||
return uTrack.fetchLatest(this);
|
||||
@ -51,7 +51,7 @@ export default class uUser extends uListItem {
|
||||
|
||||
/**
|
||||
* @throws
|
||||
* @return {Promise<uUser[], string>}
|
||||
* @return {Promise<uUser[], Error>}
|
||||
*/
|
||||
static fetchList() {
|
||||
return uAjax.get('utils/getusers.php').then((_users) => {
|
||||
|
@ -294,24 +294,13 @@ export default class uUtils {
|
||||
static openUrl(url) {
|
||||
window.location.assign(url);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Error} e
|
||||
* @param {string} message
|
||||
*/
|
||||
static error(e, message) {
|
||||
console.error(`${e.name}: ${e.message} (${e.stack})`);
|
||||
alert(message);
|
||||
}
|
||||
}
|
||||
|
||||
// seconds to (d) H:M:S
|
||||
Number.prototype.toHMS = function () {
|
||||
let s = this;
|
||||
const d = Math.floor(s / 86400);
|
||||
const h = Math.floor((s % 86400) / 3600);
|
||||
const m = Math.floor(((s % 86400) % 3600) / 60);
|
||||
s = ((s % 86400) % 3600) % 60;
|
||||
return ((d > 0) ? (d + ' d ') : '') + (('00' + h).slice(-2)) + ':' + (('00' + m).slice(-2)) + ':' + (('00' + s).slice(-2)) + '';
|
||||
};
|
||||
|
||||
// meters to km
|
||||
Number.prototype.toKm = function () {
|
||||
return Math.round(this / 10) / 100;
|
||||
};
|
||||
|
||||
// m/s to km/h
|
||||
Number.prototype.toKmH = function () {
|
||||
return Math.round(this * 3600 / 10) / 100;
|
||||
};
|
||||
|
@ -70,22 +70,22 @@ describe('Track tests', () => {
|
||||
seconds = 0;
|
||||
|
||||
jsonPosition = {
|
||||
'id': posId,
|
||||
'latitude': latitude,
|
||||
'longitude': longitude,
|
||||
'altitude': altitude,
|
||||
'speed': speed,
|
||||
'bearing': bearing,
|
||||
'timestamp': timestamp,
|
||||
'accuracy': accuracy,
|
||||
'provider': provider,
|
||||
'comment': comment,
|
||||
'image': image,
|
||||
'username': username,
|
||||
'trackid': trackid,
|
||||
'trackname': trackname,
|
||||
'meters': meters,
|
||||
'seconds': seconds
|
||||
id: posId,
|
||||
latitude: latitude,
|
||||
longitude: longitude,
|
||||
altitude: altitude,
|
||||
speed: speed,
|
||||
bearing: bearing,
|
||||
timestamp: timestamp,
|
||||
accuracy: accuracy,
|
||||
provider: provider,
|
||||
comment: comment,
|
||||
image: image,
|
||||
username: username,
|
||||
trackid: trackid,
|
||||
trackname: trackname,
|
||||
meters: meters,
|
||||
seconds: seconds
|
||||
};
|
||||
});
|
||||
|
||||
|
@ -158,7 +158,7 @@ foreach ($gpxFiles as $i => $gpxFile) {
|
||||
$provider = "gps";
|
||||
if (!empty($point->extensions)) {
|
||||
// parse ulogger extensions
|
||||
$ext = $point->extensions->children('ulogger', TRUE);
|
||||
$ext = $point->extensions->children('ulogger', true);
|
||||
if (count($ext->speed)) { $speed = (double) $ext->speed; }
|
||||
if (count($ext->bearing)) { $bearing = (double) $ext->bearing; }
|
||||
if (count($ext->accuracy)) { $accuracy = (int) $ext->accuracy; }
|
||||
|
Loading…
x
Reference in New Issue
Block a user