refact: use shorthand method and property syntax

This commit is contained in:
Simon Legner 2024-10-14 21:11:28 +02:00 committed by Gautier P
parent babd154596
commit 76f31aeb2b
44 changed files with 520 additions and 514 deletions

View file

@ -1,5 +1,5 @@
BR.Csv = {
format: function (geoJson) {
format(geoJson) {
const separator = '\t';
const newline = '\n';
const messages = geoJson.features[0].properties.messages;

View file

@ -1,5 +1,5 @@
BR.Fit = {
format: function (geoJson, turnInstructionMode = 0) {
format(geoJson, turnInstructionMode = 0) {
if (!geoJson?.features) return '';
function calcDistance(p1, p2) {

View file

@ -1,6 +1,6 @@
// derived from BRouter btools.router.OsmTrack.formatAsGpx
BR.Gpx = {
format: function (geoJson, turnInstructionMode = 0, transportMode = 'bike') {
format(geoJson, turnInstructionMode = 0, transportMode = 'bike') {
if (!geoJson?.features) return '';
class GpxTransform {
@ -55,9 +55,9 @@ BR.Gpx = {
let gpx = togpx(geoJson, {
creator: (BR.conf.appName || 'BRouter-Web') + ' ' + BR.version,
featureTitle: function () {},
featureDescription: function () {},
featureCoordTimes: function () {},
featureTitle() {},
featureDescription() {},
featureCoordTimes() {},
transform: gpxTransform,
});
const statsComment = BR.Gpx._statsComment(geoJson);
@ -67,7 +67,7 @@ BR.Gpx = {
},
// <!-- track-length = 319 filtered ascend = 2 plain-ascend = -1 cost=533 energy=.0kwh time=44s -->
_statsComment: function (geoJson) {
_statsComment(geoJson) {
const props = geoJson.features?.[0].properties;
if (!props) return '';

View file

@ -1,5 +1,5 @@
BR.Kml = {
format: function (geoJson) {
format(geoJson) {
// don't export properties as <ExtendedData>, probably no need for it
geoJson.features[0].properties = { name: geoJson.features[0].properties.name };
return BR.Xml.pretty(tokml(geoJson));

View file

@ -235,7 +235,7 @@
const wpt = {
ele: coord[2],
name: cmd.message,
extensions: extensions,
extensions,
};
if (wpt.ele === undefined || wpt.ele === null) {

View file

@ -2,7 +2,7 @@ BR.Xml = {
// modified version of
// https://gist.github.com/sente/1083506#gistcomment-2254622
// MIT License, Copyright (c) 2016 Stuart Powers, ES6 version by Jonathan Gruber
pretty: function (xml, indentSize = 1) {
pretty(xml, indentSize = 1) {
const PADDING = ' '.repeat(indentSize);
const newline = '\n';