Increase prettier maxwidth to 120

This commit is contained in:
Gautier Pelloux-Prayer 2019-08-07 18:21:49 +02:00 committed by Gautier P
parent ce9e34283b
commit d31be926d2
27 changed files with 248 additions and 956 deletions

View file

@ -1,4 +1,5 @@
{ {
"singleQuote": true, "singleQuote": true,
"printWidth": 120,
"tabWidth": 4 "tabWidth": 4
} }

View file

@ -256,13 +256,11 @@ https://css-tricks.com/svg-line-animation-works/
width: 8px; width: 8px;
margin-left: 1px; margin-left: 1px;
background-image: linear-gradient(to right, #f0f0f0 0%, #e9e9e9 100%); background-image: linear-gradient(to right, #f0f0f0 0%, #e9e9e9 100%);
box-shadow: inset -1px -0px 1px rgba(55, 55, 55, 0.3), box-shadow: inset -1px -0px 1px rgba(55, 55, 55, 0.3), inset 1px 0px 1px rgba(230, 230, 230, 1);
inset 1px 0px 1px rgba(230, 230, 230, 1);
} }
.slider.slider-horizontal .slider-track { .slider.slider-horizontal .slider-track {
background-image: linear-gradient(to bottom, #f0f0f0 0%, #e9e9e9 100%); background-image: linear-gradient(to bottom, #f0f0f0 0%, #e9e9e9 100%);
box-shadow: inset -0px -1px 1px rgba(55, 55, 55, 0.3), box-shadow: inset -0px -1px 1px rgba(55, 55, 55, 0.3), inset 0px 1px 1px rgba(230, 230, 230, 1);
inset 0px 1px 1px rgba(230, 230, 230, 1);
} }
.control-slider:hover #route .slider-track, .control-slider:hover #route .slider-track,
@ -291,8 +289,7 @@ https://css-tricks.com/svg-line-animation-works/
/* bootstrap .btn-secondary */ /* bootstrap .btn-secondary */
background-image: linear-gradient(to bottom, #fff 0, #e0e0e0 100%); background-image: linear-gradient(to bottom, #fff 0, #e0e0e0 100%);
background-repeat: repeat-x; background-repeat: repeat-x;
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15), box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15), 0 1px 1px rgba(0, 0, 0, 0.075);
0 1px 1px rgba(0, 0, 0, 0.075);
border: 1px solid #adadad; border: 1px solid #adadad;
} }
@ -467,8 +464,7 @@ table.dataTable.display tbody tr.even:hover {
} }
.tree-code { .tree-code {
font-family: Menlo, Consolas, Monaco, Liberation Mono, Lucida Console, font-family: Menlo, Consolas, Monaco, Liberation Mono, Lucida Console, monospace;
monospace;
margin-right: 7px; margin-right: 7px;
color: #666; /* like root nodes, jstree-disabled */ color: #666; /* like root nodes, jstree-disabled */
} }
@ -497,8 +493,7 @@ table.dataTable.display tbody tr.even:hover {
border: 1px solid #ddd; border: 1px solid #ddd;
font-family: Menlo, Consolas, Monaco, Liberation Mono, Lucida Console, font-family: Menlo, Consolas, Monaco, Liberation Mono, Lucida Console, monospace;
monospace;
line-height: 1.2em; line-height: 1.2em;
} }

View file

@ -30,9 +30,7 @@ var debug = false;
var paths = { var paths = {
// see overrides in package.json // see overrides in package.json
scriptsConfig: mainNpmFiles().filter(f => scriptsConfig: mainNpmFiles().filter(f => RegExp('url-search-params/.*\\.js', 'i').test(f)),
RegExp('url-search-params/.*\\.js', 'i').test(f)
),
scripts: [ scripts: [
'node_modules/jquery/dist/jquery.js', 'node_modules/jquery/dist/jquery.js',
'node_modules/tether/dist/js/tether.js', 'node_modules/tether/dist/js/tether.js',
@ -58,18 +56,10 @@ var paths = {
'js/index.js' 'js/index.js'
]), ]),
styles: mainNpmFiles() styles: mainNpmFiles()
.filter( .filter(f => RegExp('.*\\.css', 'i').test(f) && !RegExp('.*\\.min\\.css', 'i').test(f))
f =>
RegExp('.*\\.css', 'i').test(f) &&
!RegExp('.*\\.min\\.css', 'i').test(f)
)
.concat('css/*.css'), .concat('css/*.css'),
images: mainNpmFiles().filter(f => images: mainNpmFiles().filter(f => RegExp('.*.+(png|gif|svg)', 'i').test(f)),
RegExp('.*.+(png|gif|svg)', 'i').test(f) fonts: mainNpmFiles().filter(f => RegExp('font-awesome/fonts/.*', 'i').test(f)),
),
fonts: mainNpmFiles().filter(f =>
RegExp('font-awesome/fonts/.*', 'i').test(f)
),
locales: 'locales/*.json', locales: 'locales/*.json',
layers: 'layers/**/*.geojson', layers: 'layers/**/*.geojson',
layersDestName: 'layers.js', layersDestName: 'layers.js',
@ -195,9 +185,7 @@ gulp.task('inject', function() {
read: false read: false
}); });
return target return target.pipe(inject(sources, { relative: true })).pipe(gulp.dest('.'));
.pipe(inject(sources, { relative: true }))
.pipe(gulp.dest('.'));
}); });
var pkg = require('./package.json'); var pkg = require('./package.json');
@ -215,9 +203,7 @@ gulp.task('release:init', function(cb) {
} }
ghToken = gutil.env.token; ghToken = gutil.env.token;
if (!ghToken) { if (!ghToken) {
return cb( return cb(new Error('--token is required (github personnal access token'));
new Error('--token is required (github personnal access token')
);
} }
if (ghToken.length != 40) { if (ghToken.length != 40) {
return cb(new Error('--token length must be 40')); return cb(new Error('--token length must be 40'));
@ -228,11 +214,7 @@ gulp.task('release:init', function(cb) {
git.status({ args: '--porcelain', quiet: true }, function(err, stdout) { git.status({ args: '--porcelain', quiet: true }, function(err, stdout) {
if (err) return cb(err); if (err) return cb(err);
if (stdout.length > 0) { if (stdout.length > 0) {
return cb( return cb(new Error('Repository is not clean. Please commit or stash your pending modification'));
new Error(
'Repository is not clean. Please commit or stash your pending modification'
)
);
} }
cb(); cb();
@ -250,21 +232,14 @@ gulp.task('bump:json', function() {
gulp.task('bump:html', function() { gulp.task('bump:html', function() {
return gulp return gulp
.src('./index.html') .src('./index.html')
.pipe( .pipe(replace(/<sup class="version">(.*)<\/sup>/, '<sup class="version">' + nextVersion + '</sup>'))
replace(
/<sup class="version">(.*)<\/sup>/,
'<sup class="version">' + nextVersion + '</sup>'
)
)
.pipe(gulp.dest('.')); .pipe(gulp.dest('.'));
}); });
gulp.task('bump', gulp.series('bump:json', 'bump:html')); gulp.task('bump', gulp.series('bump:json', 'bump:html'));
gulp.task('release:commit', function() { gulp.task('release:commit', function() {
return gulp return gulp.src(['./index.html', './package.json']).pipe(git.commit('release: ' + nextVersion));
.src(['./index.html', './package.json'])
.pipe(git.commit('release: ' + nextVersion));
}); });
gulp.task('release:tag', function(cb) { gulp.task('release:tag', function(cb) {
@ -277,12 +252,7 @@ gulp.task('release:push', function(cb) {
gulp.task('i18next', function() { gulp.task('i18next', function() {
return gulp return gulp
.src([ .src(['index.html', 'locales/keys.js', 'layers/config/overrides.js', 'js/**/*.js'])
'index.html',
'locales/keys.js',
'layers/config/overrides.js',
'js/**/*.js'
])
.pipe(sort()) .pipe(sort())
.pipe( .pipe(
scanner({ scanner({
@ -321,12 +291,7 @@ gulp.task('layers', function() {
'// Licensed under the MIT License (https://github.com/nrenner/brouter-web#license + Credits and Licenses),\n' + '// Licensed under the MIT License (https://github.com/nrenner/brouter-web#license + Credits and Licenses),\n' +
'// except JOSM imagery database (dataSource=JOSM) is licensed under Creative Commons (CC-BY-SA),\n' + '// except JOSM imagery database (dataSource=JOSM) is licensed under Creative Commons (CC-BY-SA),\n' +
'// see https://josm.openstreetmap.de/wiki/Maps#Otherimportantinformation\n'; '// see https://josm.openstreetmap.de/wiki/Maps#Otherimportantinformation\n';
return Buffer.from( return Buffer.from(header + 'BR.layerIndex = ' + JSON.stringify(data, null, 2) + ';');
header +
'BR.layerIndex = ' +
JSON.stringify(data, null, 2) +
';'
);
}) })
) )
.pipe(gulp.dest(paths.dest)) .pipe(gulp.dest(paths.dest))
@ -335,17 +300,7 @@ gulp.task('layers', function() {
gulp.task( gulp.task(
'default', 'default',
gulp.series( gulp.series('clean', 'scripts_config', 'layers_config', 'layers', 'scripts', 'styles', 'images', 'fonts', 'locales')
'clean',
'scripts_config',
'layers_config',
'layers',
'scripts',
'styles',
'images',
'fonts',
'locales'
)
); );
gulp.task( gulp.task(
@ -359,12 +314,9 @@ gulp.task(
gulp.task('release:zip', function() { gulp.task('release:zip', function() {
gutil.log(gutil.colors.green('Build brouter-web.' + nextVersion + '.zip')); gutil.log(gutil.colors.green('Build brouter-web.' + nextVersion + '.zip'));
return gulp return gulp
.src( .src(['dist/**', 'index.html', 'config.template.js', 'keys.template.js'], {
['dist/**', 'index.html', 'config.template.js', 'keys.template.js'],
{
base: '.' base: '.'
} })
)
.pipe(zip('brouter-web.' + nextVersion + '.zip')) .pipe(zip('brouter-web.' + nextVersion + '.zip'))
.pipe(gulp.dest('.')); .pipe(gulp.dest('.'));
}); });

View file

@ -3,10 +3,7 @@
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
name="viewport"
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"
/>
<title data-i18n="title">BRouter web client</title> <title data-i18n="title">BRouter web client</title>
@ -27,32 +24,16 @@
> >
<span class="fa fa-bars"></span> <span class="fa fa-bars"></span>
</button> </button>
<a <a class="navbar-brand order-md-last" href="#" data-toggle="modal" data-target="#about"
class="navbar-brand order-md-last"
href="#"
data-toggle="modal"
data-target="#about"
>BRouter-Web <sup class="version">0.10.3</sup></a >BRouter-Web <sup class="version">0.10.3</sup></a
> >
<div class="collapse navbar-collapse" id="collapsingNavbar"> <div class="collapse navbar-collapse" id="collapsingNavbar">
<div class="navbar-nav"> <div class="navbar-nav">
<form class="form-inline"> <form class="form-inline">
<div class="form-group"> <div class="form-group">
<select <select class="selectpicker show-tick" data-width="250px" id="profile-alternative" multiple>
class="selectpicker show-tick" <optgroup label="Profile" data-max-options="1" data-icon="fa-bicycle" id="profile">
data-width="250px" <option data-i18n="navbar.profile.custom">Custom </option>
id="profile-alternative"
multiple
>
<optgroup
label="Profile"
data-max-options="1"
data-icon="fa-bicycle"
id="profile"
>
<option data-i18n="navbar.profile.custom"
>Custom
</option>
</optgroup> </optgroup>
<optgroup <optgroup
label="Alternative" label="Alternative"
@ -60,27 +41,12 @@
data-icon="fa-random" data-icon="fa-random"
id="alternative" id="alternative"
> >
<option <option data-i18n="navbar.alternative.original" value="0" selected
data-i18n="navbar.alternative.original"
value="0"
selected
>Original >Original
</option> </option>
<option <option data-i18n="navbar.alternative.first" value="1">1st alternative </option>
data-i18n="navbar.alternative.first" <option data-i18n="navbar.alternative.second" value="2">2nd alternative </option>
value="1" <option data-i18n="navbar.alternative.third" value="3">3rd alternative </option>
>1st alternative
</option>
<option
data-i18n="navbar.alternative.second"
value="2"
>2nd alternative
</option>
<option
data-i18n="navbar.alternative.third"
value="3"
>3rd alternative
</option>
</optgroup> </optgroup>
</select> </select>
</div> </div>
@ -96,11 +62,7 @@
aria-haspopup="true" aria-haspopup="true"
aria-expanded="false" aria-expanded="false"
> >
<span <span class="fa fa-lg fa-cloud-download" aria-hidden="true"> </span>
class="fa fa-lg fa-cloud-download"
aria-hidden="true"
>
</span>
<span data-i18n="navbar.export">Export</span> <span data-i18n="navbar.export">Export</span>
</a> </a>
</div> </div>
@ -115,17 +77,10 @@
aria-haspopup="true" aria-haspopup="true"
aria-expanded="false" aria-expanded="false"
> >
<span <span class="fa fa-lg fa-cloud-upload" aria-hidden="true"> </span>
class="fa fa-lg fa-cloud-upload"
aria-hidden="true"
>
</span>
<span data-i18n="navbar.load.title">Load</span> <span data-i18n="navbar.load.title">Load</span>
</a> </a>
<div <div class="dropdown-menu" aria-labelledby="navbarLoadDropdown">
class="dropdown-menu"
aria-labelledby="navbarLoadDropdown"
>
<a <a
class="dropdown-item" class="dropdown-item"
data-i18n="navbar.load.nogos" data-i18n="navbar.load.nogos"
@ -137,15 +92,8 @@
</div> </div>
</div> </div>
<div class="nav-item"> <div class="nav-item">
<a <a class="nav-link" href="#" data-toggle="modal" data-target="#about"
class="nav-link" ><span class="fa fa-lg fa-info-circle" aria-hidden="true"></span
href="#"
data-toggle="modal"
data-target="#about"
><span
class="fa fa-lg fa-info-circle"
aria-hidden="true"
></span
><span data-i18n="navbar.about">About</span></a ><span data-i18n="navbar.about">About</span></a
> >
</div> </div>
@ -166,12 +114,7 @@
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
<h4 class="modal-title" data-i18n="credits">Credits</h4> <h4 class="modal-title" data-i18n="credits">Credits</h4>
<button <button type="button" class="close" data-dismiss="modal" aria-label="Close">
type="button"
class="close"
data-dismiss="modal"
aria-label="Close"
>
<span aria-hidden="true">&times;</span> <span aria-hidden="true">&times;</span>
</button> </button>
</div> </div>
@ -179,35 +122,21 @@
<dl> <dl>
<dt data-i18n="credits.brouter">BRouter</dt> <dt data-i18n="credits.brouter">BRouter</dt>
<dd data-i18n="[html]credits.brouter-license"> <dd data-i18n="[html]credits.brouter-license">
<a <a target="_blank" href="http://brouter.de/brouter">BRouter</a>
target="_blank"
href="http://brouter.de/brouter"
>BRouter</a
>
&copy; Arndt Brenschede &copy; Arndt Brenschede
</dd> </dd>
<dt data-i18n="credits.map-data">Map data</dt> <dt data-i18n="credits.map-data">Map data</dt>
<dd data-i18n="[html]credits.openstreetmap"> <dd data-i18n="[html]credits.openstreetmap">
&copy; &copy;
<a <a target="_blank" href="https://www.openstreetmap.org/copyright"
target="_blank"
href="https://www.openstreetmap.org/copyright"
>OpenStreetMap contributors</a >OpenStreetMap contributors</a
> >
under under
<a <a target="_blank" href="https://opendatacommons.org/licenses/odbl/">ODbL</a>
target="_blank"
href="https://opendatacommons.org/licenses/odbl/"
>ODbL</a
>
</dd> </dd>
<dd data-i18n="[html]credits.nominatim"> <dd data-i18n="[html]credits.nominatim">
Search by Search by
<a <a href="https://wiki.openstreetmap.org/wiki/Nominatim" target="_blank">Nominatim</a>
href="https://wiki.openstreetmap.org/wiki/Nominatim"
target="_blank"
>Nominatim</a
>
</dd> </dd>
</dl> </dl>
<h5 data-i18n="credits.map-tiles">Map tiles</h5> <h5 data-i18n="credits.map-tiles">Map tiles</h5>
@ -232,12 +161,7 @@
<h4 class="modal-title" data-i18n="layers.customize"> <h4 class="modal-title" data-i18n="layers.customize">
Customize layers Customize layers
</h4> </h4>
<button <button type="button" class="close" data-dismiss="modal" aria-label="Close">
type="button"
class="close"
data-dismiss="modal"
aria-label="Close"
>
<span aria-hidden="true">&times;</span> <span aria-hidden="true">&times;</span>
</button> </button>
</div> </div>
@ -306,72 +230,43 @@
<h4 class="modal-title" data-i18n="about.title"> <h4 class="modal-title" data-i18n="about.title">
About About
</h4> </h4>
<button <button type="button" class="close" data-dismiss="modal" aria-label="Close">
type="button"
class="close"
data-dismiss="modal"
aria-label="Close"
>
<span aria-hidden="true">&times;</span> <span aria-hidden="true">&times;</span>
</button> </button>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<p data-i18n="[html]about.description"> <p data-i18n="[html]about.description">
Online service of the BRouter routing engine. For Online service of the BRouter routing engine. For the offline Android app and more
the offline Android app and more information see information see
<a href="http://brouter.de/" target="_blank" <a href="http://brouter.de/" target="_blank">brouter.de</a>.
>brouter.de</a
>.
</p> </p>
<p><i data-i18n="about.contact">Contact:</i><br /></p> <p><i data-i18n="about.contact">Contact:</i><br /></p>
<ul> <ul>
<li> <li>
<a <a href="https://groups.google.com/group/osm-android-bikerouting" target="_blank"
href="https://groups.google.com/group/osm-android-bikerouting" ><span data-i18n="about.support">General discussions/questions, support</span></a
target="_blank"
><span data-i18n="about.support"
>General discussions/questions,
support</span
></a
> >
</li> </li>
<li> <li>
<a <a href="https://webchat.oftc.net/?channels=#brouter" target="_blank"
href="https://webchat.oftc.net/?channels=#brouter" ><span data-i18n="about.chat">Chat with users and developers</span></a
target="_blank"
><span data-i18n="about.chat"
>Chat with users and developers</span
></a
> >
</li> </li>
<li> <li>
<span data-i18n="about.bug-reports" <span data-i18n="about.bug-reports">Bug reports and feature requests:</span>
>Bug reports and feature requests:</span
>
<ul> <ul>
<li> <li>
<a <a href="https://github.com/abrensch/brouter/issues" target="_blank">
href="https://github.com/abrensch/brouter/issues" <span data-i18n="about.bug-reports-back"
target="_blank" >server/backend, routing engine, Android app, profiles, brouter.de
> site</span
<span
data-i18n="about.bug-reports-back"
>server/backend, routing engine,
Android app, profiles,
brouter.de site</span
> >
</a> </a>
</li> </li>
<li> <li>
<a <a href="https://github.com/nrenner/brouter-web/issues" target="_blank">
href="https://github.com/nrenner/brouter-web/issues" <span data-i18n="about.bug-reports-front">web client/frontend.</span>
target="_blank"
>
<span
data-i18n="about.bug-reports-front"
>web client/frontend.</span
>
</a> </a>
</li> </li>
</ul> </ul>
@ -383,30 +278,15 @@
<div data-i18n="[html]about.data-description"> <div data-i18n="[html]about.data-description">
This is based on This is based on
<a <a href="https://www.openstreetmap.org" target="_blank">OpenStreetMap</a>. It is usually
href="https://www.openstreetmap.org" updated once a week when a new Planet file is available, see dates of
target="_blank" <a href="http://brouter.de/brouter/segments4/" target="_blank">data files</a>.
>OpenStreetMap</a
>. It is usually updated once a week when a new
Planet file is available, see dates of
<a
href="http://brouter.de/brouter/segments4/"
target="_blank"
>data files</a
>.
</div> </div>
<p data-i18n="[html]about.details"> <p data-i18n="[html]about.details">
<i <i><a href="http://brouter.de/privacypolicy.html" target="_blank">Privacy Policy</a></i
><a
href="http://brouter.de/privacypolicy.html"
target="_blank"
>Privacy Policy</a
></i
>, >,
<i <i
><a ><a href="https://github.com/nrenner/brouter-web#credits-and-licenses" target="_blank"
href="https://github.com/nrenner/brouter-web#credits-and-licenses"
target="_blank"
>Credits</a >Credits</a
></i ></i
>, >,
@ -418,13 +298,7 @@
></i ></i
> >
and and
<i <i><a href="https://github.com/nrenner/brouter-web#readme" target="_blank">more info</a></i>
><a
href="https://github.com/nrenner/brouter-web#readme"
target="_blank"
>more info</a
></i
>
on the client. on the client.
</p> </p>
</div> </div>
@ -447,49 +321,23 @@
<h4 class="modal-title" data-i18n="loadNogos.title"> <h4 class="modal-title" data-i18n="loadNogos.title">
Load no-go areas Load no-go areas
</h4> </h4>
<button <button type="button" class="close" data-dismiss="modal" aria-label="Close">
type="button"
class="close"
data-dismiss="modal"
aria-label="Close"
>
<span aria-hidden="true">&times;</span> <span aria-hidden="true">&times;</span>
</button> </button>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<p <p id="nogoError" class="invalid-feedback" style="display: none;"></p>
id="nogoError"
class="invalid-feedback"
style="display: none;"
></p>
<form> <form>
<fieldset> <fieldset>
<legend data-i18n="loadNogos.source"> <legend data-i18n="loadNogos.source">
Source Source
</legend> </legend>
<p> <p>
<label <label for="nogoURL" data-i18n="loadNogos.url">URL: </label>
for="nogoURL" <input type="text" name="nogoURL" id="nogoURL" /><br />
data-i18n="loadNogos.url"
>URL:
</label>
<input
type="text"
name="nogoURL"
id="nogoURL"
/><br />
or<br /> or<br />
<label <label for="nogoFile" data-i18n="loadNogos.file">File (.geojson): </label>
for="nogoFile" <input type="file" accept=".geojson" name="nogoFile" id="nogoFile" />
data-i18n="loadNogos.file"
>File (.geojson):
</label>
<input
type="file"
accept=".geojson"
name="nogoFile"
id="nogoFile"
/>
</p> </p>
</fieldset> </fieldset>
<fieldset> <fieldset>
@ -497,46 +345,22 @@
Default properties Default properties
</legend> </legend>
<p> <p>
<label <label for="nogoWeight" data-i18n="loadNogos.nogoWeight"
for="nogoWeight"
data-i18n="loadNogos.nogoWeight"
>No-go weight (-1 means impassable): >No-go weight (-1 means impassable):
</label> </label>
<input <input type="number" name="nogoWeight" id="nogoWeight" value="-1" min="-1" />
type="number"
name="nogoWeight"
id="nogoWeight"
value="-1"
min="-1"
/>
</p> </p>
<p> <p>
<label <label for="nogoRadius" data-i18n="loadNogos.nogoRadius"
for="nogoRadius"
data-i18n="loadNogos.nogoRadius"
>No-go radius for points (in meters): >No-go radius for points (in meters):
</label> </label>
<input <input type="number" name="nogoRadius" id="nogoRadius" value="20" min="0" />
type="number"
name="nogoRadius"
id="nogoRadius"
value="20"
min="0"
/>
</p> </p>
<p> <p>
<label <label for="nogoBuffer" data-i18n="loadNogos.nogoBuffer"
for="nogoBuffer"
data-i18n="loadNogos.nogoBuffer"
>Buffer no-go areas (in meters): >Buffer no-go areas (in meters):
</label> </label>
<input <input type="number" name="nogoBuffer" id="nogoBuffer" value="0" min="0" />
type="number"
name="nogoBuffer"
id="nogoBuffer"
value="0"
min="0"
/>
</p> </p>
</fieldset> </fieldset>
<div class="modal-footer"> <div class="modal-footer">
@ -579,41 +403,22 @@
<h4 class="modal-title" data-i18n="export.title"> <h4 class="modal-title" data-i18n="export.title">
Export route Export route
</h4> </h4>
<button <button type="button" class="close" data-dismiss="modal" aria-label="Close">
type="button"
class="close"
data-dismiss="modal"
aria-label="Close"
>
<span aria-hidden="true">&times;</span> <span aria-hidden="true">&times;</span>
</button> </button>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<form name="export"> <form name="export">
<div class="form-group row"> <div class="form-group row">
<label <label class="col-form-label col-sm-2" data-i18n="export.trackname">Name</label>
class="col-form-label col-sm-2"
data-i18n="export.trackname"
>Name</label
>
<div class="col-sm-10"> <div class="col-sm-10">
<input <input type="text" class="form-control" id="trackname" />
type="text" <span id="trackname-message" class="validation-warning"></span>
class="form-control"
id="trackname"
/>
<span
id="trackname-message"
class="validation-warning"
></span>
</div> </div>
</div> </div>
<fieldset id="export-format" class="form-group"> <fieldset id="export-format" class="form-group">
<div class="row"> <div class="row">
<legend <legend class="col-form-label col-sm-2" data-i18n="export.format">
class="col-form-label col-sm-2"
data-i18n="export.format"
>
Format Format
</legend> </legend>
<div class="col-sm-10"> <div class="col-sm-10">
@ -627,17 +432,11 @@
value="gpx" value="gpx"
checked checked
/> />
<span <span data-i18n="export.format_gpx">GPX</span>
data-i18n="export.format_gpx"
>GPX</span
>
</label> </label>
</div> </div>
<div class="form-check"> <div class="form-check">
<label <label class="form-check-label" for="format-kml">
class="form-check-label"
for="format-kml"
>
<input <input
class="form-check-input" class="form-check-input"
id="format-kml" id="format-kml"
@ -645,17 +444,11 @@
name="format" name="format"
value="kml" value="kml"
/> />
<span <span data-i18n="export.format_kml">KML</span>
data-i18n="export.format_kml"
>KML</span
>
</label> </label>
</div> </div>
<div class="form-check"> <div class="form-check">
<label <label class="form-check-label" for="format-geojson">
class="form-check-label"
for="format-geojson"
>
<input <input
class="form-check-input" class="form-check-input"
id="format-geojson" id="format-geojson"
@ -663,17 +456,11 @@
name="format" name="format"
value="geojson" value="geojson"
/> />
<span <span data-i18n="export.format_geojson">GeoJSON</span>
data-i18n="export.format_geojson"
>GeoJSON</span
>
</label> </label>
</div> </div>
<div class="form-check"> <div class="form-check">
<label <label class="form-check-label" for="format-csv">
class="form-check-label"
for="format-csv"
>
<input <input
class="form-check-input" class="form-check-input"
id="format-csv" id="format-csv"
@ -681,10 +468,7 @@
name="format" name="format"
value="csv" value="csv"
/> />
<span <span data-i18n="export.format_csv">CSV</span>
data-i18n="export.format_csv"
>CSV</span
>
</label> </label>
</div> </div>
</div> </div>
@ -692,10 +476,7 @@
</fieldset> </fieldset>
<fieldset id="export-includes" class="form-group"> <fieldset id="export-includes" class="form-group">
<div class="row"> <div class="row">
<legend <legend class="col-form-label col-sm-2" data-i18n="export.include">
class="col-form-label col-sm-2"
data-i18n="export.include"
>
Include Include
</legend> </legend>
<div class="col-sm-10"> <div class="col-sm-10">
@ -707,10 +488,7 @@
type="checkbox" type="checkbox"
name="include-waypoints" name="include-waypoints"
/> />
<span <span data-i18n="export.include_waypoints">Waypoints</span>
data-i18n="export.include_waypoints"
>Waypoints</span
>
</label> </label>
</div> </div>
</div> </div>
@ -744,12 +522,7 @@
<div id="sidebarTabs" class="leaflet-sidebar-tabs collapsed"> <div id="sidebarTabs" class="leaflet-sidebar-tabs collapsed">
<ul role="tablist"> <ul role="tablist">
<li> <li>
<a <a href="#tab_layers_control" role="tab" data-i18n="[title]sidebar.layers.title" title="Layers">
href="#tab_layers_control"
role="tab"
data-i18n="[title]sidebar.layers.title"
title="Layers"
>
<!-- <!--
https://github.com/feathericons/feather/blob/0dc2bf5c9d01759e47485d9498aefc02cac1d845/icons/layers.svg https://github.com/feathericons/feather/blob/0dc2bf5c9d01759e47485d9498aefc02cac1d845/icons/layers.svg
MIT License: https://github.com/feathericons/feather/blob/master/LICENSE MIT License: https://github.com/feathericons/feather/blob/master/LICENSE
@ -766,23 +539,14 @@
stroke-linecap="round" stroke-linecap="round"
stroke-linejoin="round" stroke-linejoin="round"
> >
<polygon <polygon style="fill: currentColor" points="12 2 2 7 12 12 22 7 12 2"></polygon>
style="fill: currentColor" <polyline points="2 11.5 12 16.5 22 11.5"></polyline>
points="12 2 2 7 12 12 22 7 12 2"
></polygon>
<polyline
points="2 11.5 12 16.5 22 11.5"
></polyline>
<polyline points="2 16 12 21 22 16"></polyline> <polyline points="2 16 12 21 22 16"></polyline>
</svg> </svg>
</a> </a>
</li> </li>
<li hidden> <li hidden>
<a <a href="#tab_itinerary" role="tab" data-i18n="[title]sidebar.itinerary.title" title="Itinerary"
href="#tab_itinerary"
role="tab"
data-i18n="[title]sidebar.itinerary.title"
title="Itinerary"
><i class="fa fa-map-signs"></i ><i class="fa fa-map-signs"></i
></a> ></a>
</li> </li>
@ -796,11 +560,7 @@
></a> ></a>
</li> </li>
<li> <li>
<a <a href="#tab_data" role="tab" data-i18n="[title]sidebar.data.title" title="Data"
href="#tab_data"
role="tab"
data-i18n="[title]sidebar.data.title"
title="Data"
><i class="fa fa-table"></i ><i class="fa fa-table"></i
></a> ></a>
</li> </li>
@ -814,18 +574,11 @@
<div id="sidebar" class="leaflet-sidebar collapsed"> <div id="sidebar" class="leaflet-sidebar collapsed">
<div class="leaflet-sidebar-content"> <div class="leaflet-sidebar-content">
<div <div class="leaflet-sidebar-pane" id="tab_layers_control">
class="leaflet-sidebar-pane"
id="tab_layers_control"
>
<h1 class="leaflet-sidebar-header"> <h1 class="leaflet-sidebar-header">
<span class="leaflet-sidebar-close" <span class="leaflet-sidebar-close"><i class="fa fa-caret-right"></i></span
><i class="fa fa-caret-right"></i></span ><span class="leaflet-sidebar-expand"><i class="fa fa-expand"></i></span
><span class="leaflet-sidebar-expand" ><span data-i18n="sidebar.layers.title">Layers</span>
><i class="fa fa-expand"></i></span
><span data-i18n="sidebar.layers.title"
>Layers</span
>
</h1> </h1>
<div id="layers-control-wrapper"></div> <div id="layers-control-wrapper"></div>
<div class="leaflet-control-layers-separator"></div> <div class="leaflet-control-layers-separator"></div>
@ -846,9 +599,7 @@
data-i18n="[title]sidebar.layers.expand" data-i18n="[title]sidebar.layers.expand"
title="Expand all" title="Expand all"
> >
<span <span class="fa fa-plus-square-o"></span>
class="fa fa-plus-square-o"
></span>
</button> </button>
<button <button
type="button" type="button"
@ -857,9 +608,7 @@
data-i18n="[title]sidebar.layers.collapse" data-i18n="[title]sidebar.layers.collapse"
title="Collapse all" title="Collapse all"
> >
<span <span class="fa fa-minus-square-o"></span>
class="fa fa-minus-square-o"
></span>
</button> </button>
</div> </div>
<!-- empty dummy to keep following buttons right-aligned when previous hidden --> <!-- empty dummy to keep following buttons right-aligned when previous hidden -->
@ -873,10 +622,7 @@
title="Add or remove optional layers" title="Add or remove optional layers"
> >
<span class="fa fa-cogs"></span> <span class="fa fa-cogs"></span>
<span <span data-i18n="sidebar.layers.optional-layers">More</span>
data-i18n="sidebar.layers.optional-layers"
>More</span
>
</button> </button>
<button <button
type="button" type="button"
@ -886,10 +632,7 @@
title="Add or remove custom layers" title="Add or remove custom layers"
> >
<span class="fa fa-plus-square"></span> <span class="fa fa-plus-square"></span>
<span <span data-i18n="sidebar.layers.custom-layers">Custom layers</span>
data-i18n="sidebar.layers.custom-layers"
>Custom layers</span
>
</button> </button>
</div> </div>
</div> </div>
@ -898,13 +641,9 @@
<div class="leaflet-sidebar-pane" id="tab_profile"> <div class="leaflet-sidebar-pane" id="tab_profile">
<h1 class="leaflet-sidebar-header"> <h1 class="leaflet-sidebar-header">
<span class="leaflet-sidebar-close" <span class="leaflet-sidebar-close"><i class="fa fa-caret-right"></i></span
><i class="fa fa-caret-right"></i></span ><span class="leaflet-sidebar-expand"><i class="fa fa-expand"></i></span
><span class="leaflet-sidebar-expand" ><span data-i18n="sidebar.custom-profile.title">Custom profile</span>
><i class="fa fa-expand"></i></span
><span data-i18n="sidebar.custom-profile.title"
>Custom profile</span
>
</h1> </h1>
<form class="flexcolumn flexgrow"> <form class="flexcolumn flexgrow">
<textarea <textarea
@ -924,28 +663,18 @@
data-uploading-text="Uploading…" data-uploading-text="Uploading…"
> >
<span class="fa fa-cloud-upload"></span> <span class="fa fa-cloud-upload"></span>
<span data-i18n="sidebar.profile.upload" <span data-i18n="sidebar.profile.upload">Upload</span>
>Upload</span
>
</button> </button>
<button <button id="clear" type="button" class="btn btn-secondary btn-sm">
id="clear"
type="button"
class="btn btn-secondary btn-sm"
>
<span class="fa fa-eraser"></span> <span class="fa fa-eraser"></span>
<span data-i18n="sidebar.profile.clear" <span data-i18n="sidebar.profile.clear">Clear</span>
>Clear</span
>
</button> </button>
<a <a
href="http://brouter.de/brouter/costfunctions.html" href="http://brouter.de/brouter/costfunctions.html"
target="_blank" target="_blank"
class="btn btn-info btn-sm pull-right" class="btn btn-info btn-sm pull-right"
><span class="fa fa-question"></span> ><span class="fa fa-question"></span>
<span data-i18n="sidebar.profile.help" <span data-i18n="sidebar.profile.help">Help</span></a
>Help</span
></a
> >
</div> </div>
</form> </form>
@ -953,34 +682,20 @@
<div class="leaflet-sidebar-pane" id="tab_data"> <div class="leaflet-sidebar-pane" id="tab_data">
<h1 class="leaflet-sidebar-header"> <h1 class="leaflet-sidebar-header">
<span class="leaflet-sidebar-close" <span class="leaflet-sidebar-close"><i class="fa fa-caret-right"></i></span
><i class="fa fa-caret-right"></i></span ><span class="leaflet-sidebar-expand"><i class="fa fa-expand"></i></span
><span class="leaflet-sidebar-expand" ><span data-i18n="sidebar.data.title">Data</span>
><i class="fa fa-expand"></i></span
><span data-i18n="sidebar.data.title"
>Data</span
>
</h1> </h1>
<table <table id="datatable" class="mini cell-border hover stripe"></table>
id="datatable"
class="mini cell-border hover stripe"
></table>
</div> </div>
<div class="leaflet-sidebar-pane" id="tab_itinerary"> <div class="leaflet-sidebar-pane" id="tab_itinerary">
<h1 class="leaflet-sidebar-header"> <h1 class="leaflet-sidebar-header">
<span data-i18n="sidebar.itinerary.title" <span data-i18n="sidebar.itinerary.title">Itinerary</span
>Itinerary</span ><span class="leaflet-sidebar-close"><i class="fa fa-caret-right"></i></span
><span class="leaflet-sidebar-close" ><span class="leaflet-sidebar-expand"><i class="fa fa-expand"></i></span>
><i class="fa fa-caret-right"></i></span
><span class="leaflet-sidebar-expand"
><i class="fa fa-expand"></i
></span>
</h1> </h1>
<div <div id="itinerary" class="flexcolumn flexgrow"></div>
id="itinerary"
class="flexcolumn flexgrow"
></div>
</div> </div>
</div> </div>
</div> </div>
@ -993,46 +708,30 @@
<div class="flexrow"> <div class="flexrow">
<ul id="stats"> <ul id="stats">
<li> <li>
<div <div class="text-muted small d-none d-sm-block" data-i18n="footer.distance">
class="text-muted small d-none d-sm-block"
data-i18n="footer.distance"
>
Distance Distance
</div> </div>
<p class="stats-label"> <p class="stats-label">
<span id="distance">-</span> <span id="distance">-</span>
<abbr <abbr data-i18n="[title]footer.kilometer;footer.kilometer-abbrev" title="kilometers"
data-i18n="[title]footer.kilometer;footer.kilometer-abbrev"
title="kilometers"
>km</abbr >km</abbr
> >
</p> </p>
</li> </li>
<li> <li>
<div <div class="text-muted small d-none d-sm-block" data-i18n="footer.travel-time">
class="text-muted small d-none d-sm-block"
data-i18n="footer.travel-time"
>
Travel time Travel time
</div> </div>
<p class="stats-label"> <p class="stats-label">
<span id="totaltime">-</span> <span id="totaltime">-</span>
<abbr <abbr data-i18n="[title]footer.hours;footer.hours-abbrev" title="hours">h</abbr>
data-i18n="[title]footer.hours;footer.hours-abbrev"
title="hours"
>h</abbr
>
</p> </p>
</li> </li>
<li> <li>
<div class="text-muted small d-none d-sm-block"> <div class="text-muted small d-none d-sm-block">
<span data-i18n="footer.total-energy" <span data-i18n="footer.total-energy">Total Energy</span>
>Total Energy</span
>
| |
<span data-i18n="footer.energy-per-100km" <span data-i18n="footer.energy-per-100km">Energy per 100 km</span>
>Energy per 100 km</span
>
</div> </div>
<p class="stats-label"> <p class="stats-label">
<span id="totalenergy">-</span> <span id="totalenergy">-</span>
@ -1052,31 +751,19 @@
<li> <li>
<div class="text-muted small d-none d-sm-block"> <div class="text-muted small d-none d-sm-block">
<span data-i18n="footer.ascend">Ascend</span> | <span data-i18n="footer.ascend">Ascend</span> |
<span data-i18n="footer.plain-ascend" <span data-i18n="footer.plain-ascend">Plain ascend</span>
>Plain ascend</span
>
</div> </div>
<p class="stats-label"> <p class="stats-label">
<span id="ascend">-</span> <span id="ascend">-</span>
<abbr <abbr data-i18n="[title]footer.meter;footer.meter-abbrev" title="meters">m</abbr>
data-i18n="[title]footer.meter;footer.meter-abbrev"
title="meters"
>m</abbr
>
| <span id="plainascend">-</span> | <span id="plainascend">-</span>
<abbr <abbr data-i18n="[title]footer.meter;footer.meter-abbrev" title="meters">m</abbr>
data-i18n="[title]footer.meter;footer.meter-abbrev"
title="meters"
>m</abbr
>
</p> </p>
</li> </li>
<li> <li>
<div class="text-muted small d-none d-sm-block"> <div class="text-muted small d-none d-sm-block">
<span data-i18n="footer.cost">Cost</span> | <span data-i18n="footer.cost">Cost</span> |
<span data-i18n="footer.mean-cost-factor" <span data-i18n="footer.mean-cost-factor">Mean cost factor</span>
>Mean cost factor</span
>
</div> </div>
<p class="stats-label"> <p class="stats-label">
<span id="cost">-</span> | <span id="cost">-</span> |

View file

@ -6,9 +6,7 @@
result = navigator.maxTouchPoints > 0; result = navigator.maxTouchPoints > 0;
} else if ( } else if (
window.matchMedia && window.matchMedia &&
window.matchMedia( window.matchMedia('(any-pointer:coarse),(any-pointer:fine),(any-pointer:none)').matches
'(any-pointer:coarse),(any-pointer:fine),(any-pointer:none)'
).matches
) { ) {
result = window.matchMedia('(any-pointer:coarse)').matches; result = window.matchMedia('(any-pointer:coarse)').matches;
} else if ('msMaxTouchPoints' in navigator) { } else if ('msMaxTouchPoints' in navigator) {

View file

@ -29,10 +29,7 @@ BR.LayersConfig = L.Class.extend({
baseLayers: baseLayers, baseLayers: baseLayers,
overlays: overlays overlays: overlays
}; };
localStorage.setItem( localStorage.setItem('map/defaultLayers', JSON.stringify(defaultLayers));
'map/defaultLayers',
JSON.stringify(defaultLayers)
);
} }
}, },
@ -75,8 +72,7 @@ BR.LayersConfig = L.Class.extend({
BR.layerIndex['MtbMap'].geometry = BR.confLayers.europeGeofabrik; BR.layerIndex['MtbMap'].geometry = BR.confLayers.europeGeofabrik;
BR.layerIndex['1069'].geometry = BR.confLayers.europeGeofabrik; BR.layerIndex['1069'].geometry = BR.confLayers.europeGeofabrik;
BR.layerIndex['OpenStreetMap.CH'].geometry = BR.layerIndex['OpenStreetMap.CH'].geometry = BR.confLayers.switzerlandPadded;
BR.confLayers.switzerlandPadded;
BR.layerIndex['1017'].geometry = BR.confLayers.osmapaPl; BR.layerIndex['1017'].geometry = BR.confLayers.osmapaPl;
}, },
@ -138,9 +134,7 @@ BR.LayersConfig = L.Class.extend({
// when key required only add if configured // when key required only add if configured
var keyObj = this.getKeyName(layerData.properties.url); var keyObj = this.getKeyName(layerData.properties.url);
if (!keyObj || (keyObj && BR.keys[keyObj.name])) { if (!keyObj || (keyObj && BR.keys[keyObj.name])) {
layers[layerData.properties.name] = this.createLayer( layers[layerData.properties.name] = this.createLayer(layerData);
layerData
);
} }
} else { } else {
console.error('Layer not found: ' + layerId); console.error('Layer not found: ' + layerId);
@ -208,12 +202,7 @@ BR.LayersConfig = L.Class.extend({
if (attr.html) { if (attr.html) {
result = attr.html; result = attr.html;
} else if (attr.url && attr.text) { } else if (attr.url && attr.text) {
result = result = '<a href="' + attr.url + '" target="_blank" rel="noopener">' + attr.text + '</a>';
'<a href="' +
attr.url +
'" target="_blank" rel="noopener">' +
attr.text +
'</a>';
} else if (attr.text) { } else if (attr.text) {
result = attr.text; result = attr.text;
} }
@ -227,18 +216,11 @@ BR.LayersConfig = L.Class.extend({
var options = { var options = {
maxZoom: this._map.getMaxZoom(), maxZoom: this._map.getMaxZoom(),
bounds: bounds: layerData.geometry && !props.worldTiles ? L.geoJson(layerData.geometry).getBounds() : null
layerData.geometry && !props.worldTiles
? L.geoJson(layerData.geometry).getBounds()
: null
}; };
if (props.mapUrl) { if (props.mapUrl) {
options.mapLink = options.mapLink =
'<a target="_blank" href="' + '<a target="_blank" href="' + props.mapUrl + '">' + (props.nameShort || props.name) + '</a>';
props.mapUrl +
'">' +
(props.nameShort || props.name) +
'</a>';
} }
if (props.attribution) { if (props.attribution) {
options.attribution = props.attribution; options.attribution = props.attribution;

View file

@ -52,9 +52,7 @@ BR.Map = {
var overlays = layersConfig.getOverlays(); var overlays = layersConfig.getOverlays();
if (BR.keys.bing) { if (BR.keys.bing) {
baseLayers[i18next.t('map.layer.bing')] = new BR.BingLayer( baseLayers[i18next.t('map.layer.bing')] = new BR.BingLayer(BR.keys.bing);
BR.keys.bing
);
} }
if (BR.keys.digitalGlobe) { if (BR.keys.digitalGlobe) {
@ -86,14 +84,9 @@ BR.Map = {
} }
} }
layersControl = BR.layersTab(layersConfig, baseLayers, overlays).addTo( layersControl = BR.layersTab(layersConfig, baseLayers, overlays).addTo(map);
map
);
var secureContext = var secureContext = 'isSecureContext' in window ? isSecureContext : location.protocol === 'https:';
'isSecureContext' in window
? isSecureContext
: location.protocol === 'https:';
if (secureContext) { if (secureContext) {
L.control L.control
.locate({ .locate({

View file

@ -8,19 +8,12 @@ BR.Export = L.Class.extend({
this.tracknameAllowedChars = BR.conf.tracknameAllowedChars; this.tracknameAllowedChars = BR.conf.tracknameAllowedChars;
if (this.tracknameAllowedChars) { if (this.tracknameAllowedChars) {
this.tracknameMessage = document.getElementById( this.tracknameMessage = document.getElementById('trackname-message');
'trackname-message' var patternRegex = new RegExp('[' + this.tracknameAllowedChars + ']+');
);
var patternRegex = new RegExp(
'[' + this.tracknameAllowedChars + ']+'
);
// warn about special characters getting removed by server quick fix (#194) // warn about special characters getting removed by server quick fix (#194)
trackname.pattern = patternRegex.toString().slice(1, -1); trackname.pattern = patternRegex.toString().slice(1, -1);
trackname.addEventListener( trackname.addEventListener('input', L.bind(this._validationMessage, this));
'input',
L.bind(this._validationMessage, this)
);
} }
this.exportButton.on('click', L.bind(this._generateTrackname, this)); this.exportButton.on('click', L.bind(this._generateTrackname, this));
@ -41,37 +34,14 @@ BR.Export = L.Class.extend({
_export: function() { _export: function() {
var exportForm = document.forms['export']; var exportForm = document.forms['export'];
var format = var format = exportForm['format'].value || $('#export-format input:radio:checked').val();
exportForm['format'].value ||
$('#export-format input:radio:checked').val();
var name = encodeURIComponent(exportForm['trackname'].value); var name = encodeURIComponent(exportForm['trackname'].value);
var includeWaypoints = exportForm['include-waypoints'].checked; var includeWaypoints = exportForm['include-waypoints'].checked;
var uri = this.router.getUrl( var uri = this.router.getUrl(this.latLngs, format, name, includeWaypoints);
this.latLngs,
format,
name,
includeWaypoints
);
var evt = document.createEvent('MouseEvents'); var evt = document.createEvent('MouseEvents');
evt.initMouseEvent( evt.initMouseEvent('click', true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
'click',
true,
true,
window,
0,
0,
0,
0,
0,
false,
false,
false,
false,
0,
null
);
var link = document.createElement('a'); var link = document.createElement('a');
link.href = uri; link.href = uri;
link.dispatchEvent(evt); link.dispatchEvent(evt);
@ -79,16 +49,12 @@ BR.Export = L.Class.extend({
_validationMessage: function() { _validationMessage: function() {
var trackname = this.trackname; var trackname = this.trackname;
var replaceRegex = new RegExp( var replaceRegex = new RegExp('[^' + this.tracknameAllowedChars + ']', 'g');
'[^' + this.tracknameAllowedChars + ']',
'g'
);
if (trackname.validity.patternMismatch) { if (trackname.validity.patternMismatch) {
var replaced = trackname.value.replace(replaceRegex, ''); var replaced = trackname.value.replace(replaceRegex, '');
var patternStr = this.tracknameAllowedChars.replace(/\\/g, ''); var patternStr = this.tracknameAllowedChars.replace(/\\/g, '');
this.tracknameMessage.textContent = this.tracknameMessage.textContent = '[' + patternStr + '] --> ' + replaced;
'[' + patternStr + '] --> ' + replaced;
} else { } else {
this.tracknameMessage.textContent = ''; this.tracknameMessage.textContent = '';
} }
@ -102,8 +68,7 @@ BR.Export = L.Class.extend({
this._getCityAtPosition( this._getCityAtPosition(
this.latLngs[this.latLngs.length - 1], this.latLngs[this.latLngs.length - 1],
L.bind(function(to) { L.bind(function(to) {
var distance = document.getElementById('distance') var distance = document.getElementById('distance').innerHTML;
.innerHTML;
if (this.tracknameAllowedChars) { if (this.tracknameAllowedChars) {
distance = distance.replace(',', '.'); // temp. fix (#202) distance = distance.replace(',', '.'); // temp. fix (#202)
} }
@ -115,17 +80,16 @@ BR.Export = L.Class.extend({
distance: distance distance: distance
}); });
} else { } else {
trackname.value = i18next.t( trackname.value = i18next.t('export.route-from-to', {
'export.route-from-to', from: from,
{ from: from, to: to, distance: distance } to: to,
); distance: distance
});
} }
if (this.tracknameAllowedChars) { if (this.tracknameAllowedChars) {
// temp. fix: replace and remove characters that will get removed by server quick fix (#194) // temp. fix: replace and remove characters that will get removed by server quick fix (#194)
trackname.value = trackname.value trackname.value = trackname.value.replace(/[>)]/g, '').replace(/ \(/g, ' - ');
.replace(/[>)]/g, '')
.replace(/ \(/g, ' - ');
this._validationMessage(); this._validationMessage();
} }
}, this) }, this)
@ -144,17 +108,9 @@ BR.Export = L.Class.extend({
L.bind(function(err, response) { L.bind(function(err, response) {
try { try {
var addr = JSON.parse(response).address; var addr = JSON.parse(response).address;
cb( cb(addr.village || addr.town || addr.hamlet || addr.city_district || addr.city);
addr.village ||
addr.town ||
addr.hamlet ||
addr.city_district ||
addr.city
);
} catch (err) { } catch (err) {
BR.message.showError( BR.message.showError('Error getting position city "' + lonlat + '": ' + err);
'Error getting position city "' + lonlat + '": ' + err
);
return cb(null); return cb(null);
} }
}) })

View file

@ -46,18 +46,9 @@ BR.Layers = L.Class.extend({
for (var l in overlays) this._layers[l] = [overlays[l], true]; for (var l in overlays) this._layers[l] = [overlays[l], true];
for (var l in baseLayers) this._layers[l] = [baseLayers[l], false]; for (var l in baseLayers) this._layers[l] = [baseLayers[l], false];
L.DomUtil.get('custom_layers_add_base').onclick = L.bind( L.DomUtil.get('custom_layers_add_base').onclick = L.bind(this._addBaseLayer, this);
this._addBaseLayer, L.DomUtil.get('custom_layers_add_overlay').onclick = L.bind(this._addOverlay, this);
this L.DomUtil.get('custom_layers_remove').onclick = L.bind(this._remove, this);
);
L.DomUtil.get('custom_layers_add_overlay').onclick = L.bind(
this._addOverlay,
this
);
L.DomUtil.get('custom_layers_remove').onclick = L.bind(
this._remove,
this
);
this._loadLayers(); this._loadLayers();
this._loadTable(); this._loadTable();
@ -95,8 +86,7 @@ BR.Layers = L.Class.extend({
_addFromInput: function(isOverlay) { _addFromInput: function(isOverlay) {
var layer_name = L.DomUtil.get('layer_name').value; var layer_name = L.DomUtil.get('layer_name').value;
var layer_url = L.DomUtil.get('layer_url').value; var layer_url = L.DomUtil.get('layer_url').value;
if (layer_name.length > 0 && layer_url.length > 0) if (layer_name.length > 0 && layer_url.length > 0) this._addLayer(layer_name, layer_url, isOverlay);
this._addLayer(layer_name, layer_url, isOverlay);
}, },
_addBaseLayer: function(evt) { _addBaseLayer: function(evt) {

View file

@ -4,12 +4,7 @@ BR.LayersTab = BR.ControlLayers.extend({
saveLayers: [], saveLayers: [],
initialize: function(layersConfig, baseLayers, overlays, options) { initialize: function(layersConfig, baseLayers, overlays, options) {
L.Control.Layers.prototype.initialize.call( L.Control.Layers.prototype.initialize.call(this, baseLayers, overlays, options);
this,
baseLayers,
overlays,
options
);
this.layersConfig = layersConfig; this.layersConfig = layersConfig;
}, },
@ -30,21 +25,13 @@ BR.LayersTab = BR.ControlLayers.extend({
onAdd: function(map) { onAdd: function(map) {
BR.ControlLayers.prototype.onAdd.call(this, map); BR.ControlLayers.prototype.onAdd.call(this, map);
map.on( map.on('baselayerchange overlayadd overlayremove', this.storeActiveLayers, this);
'baselayerchange overlayadd overlayremove',
this.storeActiveLayers,
this
);
}, },
onRemove: function(map) { onRemove: function(map) {
BR.ControlLayers.prototype.onRemove.call(this, map); BR.ControlLayers.prototype.onRemove.call(this, map);
map.off( map.off('baselayerchange overlayadd overlayremove', this.storeActiveLayers, this);
'baselayerchange overlayadd overlayremove',
this.storeActiveLayers,
this
);
}, },
initOpacitySlider: function(map) { initOpacitySlider: function(map) {
@ -57,19 +44,14 @@ BR.LayersTab = BR.ControlLayers.extend({
title: i18next.t('layers.opacity-slider'), title: i18next.t('layers.opacity-slider'),
callback: function(opacity) { callback: function(opacity) {
for (var i = 0; i < self._layers.length; i++) { for (var i = 0; i < self._layers.length; i++) {
if ( if (!self._layers[i].overlay || !map.hasLayer(self._layers[i].layer)) {
!self._layers[i].overlay ||
!map.hasLayer(self._layers[i].layer)
) {
continue; continue;
} }
self._layers[i].layer.setOpacity(opacity); self._layers[i].layer.setOpacity(opacity);
} }
} }
}); });
L.DomUtil.get( L.DomUtil.get('leaflet-control-layers-overlays-opacity-slider').appendChild(overlayOpacitySlider.getElement());
'leaflet-control-layers-overlays-opacity-slider'
).appendChild(overlayOpacitySlider.getElement());
}, },
initButtons: function() { initButtons: function() {
@ -95,15 +77,9 @@ BR.LayersTab = BR.ControlLayers.extend({
}; };
L.DomUtil.get('expand_tree_button').onclick = L.bind(expandTree, this); L.DomUtil.get('expand_tree_button').onclick = L.bind(expandTree, this);
L.DomUtil.get('collapse_tree_button').onclick = L.bind( L.DomUtil.get('collapse_tree_button').onclick = L.bind(collapseTree, this);
collapseTree,
this
);
L.DomUtil.get('optional_layers_button').onclick = L.bind( L.DomUtil.get('optional_layers_button').onclick = L.bind(toggleOptionalLayers, this);
toggleOptionalLayers,
this
);
}, },
initJsTree: function() { initJsTree: function() {
@ -225,10 +201,7 @@ BR.LayersTab = BR.ControlLayers.extend({
id: id, id: id,
text: getText(props, parent), text: getText(props, parent),
state: { state: {
checked: self.layersConfig.isDefaultLayer( checked: self.layersConfig.isDefaultLayer(id, props.overlay)
id,
props.overlay
)
} }
}; };
} }

View file

@ -12,10 +12,7 @@ BR.Message = L.Class.extend({
_show: function(msg, type) { _show: function(msg, type) {
var ele = L.DomUtil.get(this.id), var ele = L.DomUtil.get(this.id),
iconClass = iconClass = type === 'warning' ? 'fa-exclamation-triangle' : 'fa-times-circle',
type === 'warning'
? 'fa-exclamation-triangle'
: 'fa-times-circle',
alertClass = type === 'warning' ? 'alert-warning' : 'alert-danger'; alertClass = type === 'warning' ? 'alert-warning' : 'alert-danger';
L.DomEvent.disableClickPropagation(ele); L.DomEvent.disableClickPropagation(ele);

View file

@ -11,12 +11,8 @@ BR.OpacitySlider = L.Class.extend({
initialize: function(options) { initialize: function(options) {
L.setOptions(this, options); L.setOptions(this, options);
var input = (this.input = $( var input = (this.input = $('<input id="slider-' + this.options.id + '" type="text"/>')),
'<input id="slider-' + this.options.id + '" type="text"/>' item = BR.Util.localStorageAvailable() ? localStorage['opacitySliderValue' + this.options.id] : null,
)),
item = BR.Util.localStorageAvailable()
? localStorage['opacitySliderValue' + this.options.id]
: null,
value = item ? parseInt(item) : this.options.defaultValue * 100, value = item ? parseInt(item) : this.options.defaultValue * 100,
minOpacity = (BR.conf.minOpacity || 0) * 100; minOpacity = (BR.conf.minOpacity || 0) * 100;
@ -41,9 +37,7 @@ BR.OpacitySlider = L.Class.extend({
}) })
.on('slideStop', { self: this }, function(evt) { .on('slideStop', { self: this }, function(evt) {
if (BR.Util.localStorageAvailable()) { if (BR.Util.localStorageAvailable()) {
localStorage[ localStorage['opacitySliderValue' + evt.data.self.options.id] = evt.value;
'opacitySliderValue' + evt.data.self.options.id
] = evt.value;
} }
}); });

View file

@ -13,10 +13,7 @@ BR.OpacitySliderControl = L.Control.extend({
if (BR.Util.localStorageAvailable()) { if (BR.Util.localStorageAvailable()) {
var value = localStorage.getItem('opacitySliderValue'); var value = localStorage.getItem('opacitySliderValue');
if (value !== null) { if (value !== null) {
localStorage.setItem( localStorage.setItem('opacitySliderValue' + this.options.id, value);
'opacitySliderValue' + this.options.id,
value
);
localStorage.removeItem('opacitySliderValue'); localStorage.removeItem('opacitySliderValue');
} }
} }
@ -31,11 +28,7 @@ BR.OpacitySliderControl = L.Control.extend({
var removeStopClickListeners = function() { var removeStopClickListeners = function() {
document.removeEventListener('click', stopClickAfterSlide, true); document.removeEventListener('click', stopClickAfterSlide, true);
document.removeEventListener( document.removeEventListener('mousedown', removeStopClickListeners, true);
'mousedown',
removeStopClickListeners,
true
);
}; };
slider.input slider.input
@ -52,11 +45,7 @@ BR.OpacitySliderControl = L.Control.extend({
document.addEventListener('click', stopClickAfterSlide, true); document.addEventListener('click', stopClickAfterSlide, true);
// Firefox does not fire click event in this case, so make sure stop listener // Firefox does not fire click event in this case, so make sure stop listener
// is always removed on next mousedown. // is always removed on next mousedown.
document.addEventListener( document.addEventListener('mousedown', removeStopClickListeners, true);
'mousedown',
removeStopClickListeners,
true
);
}); });
return container; return container;

View file

@ -39,22 +39,14 @@ BR.Profile = L.Evented.extend({
profileUrl, profileUrl,
L.bind(function(err, profileText) { L.bind(function(err, profileText) {
if (err) { if (err) {
console.warn( console.warn('Error getting profile from "' + profileUrl + '": ' + err);
'Error getting profile from "' +
profileUrl +
'": ' +
err
);
return; return;
} }
this.cache[profileName] = profileText; this.cache[profileName] = profileText;
// don't set when option has changed while loading // don't set when option has changed while loading
if ( if (!this.profileName || this.profileName === profileName) {
!this.profileName ||
this.profileName === profileName
) {
this._setValue(profileText); this._setValue(profileText);
} }
}, this) }, this)

View file

@ -1,9 +1,6 @@
BR.RoutingOptions = L.Evented.extend({ BR.RoutingOptions = L.Evented.extend({
initialize: function() { initialize: function() {
$('#profile-alternative').on( $('#profile-alternative').on('changed.bs.select', this._getChangeHandler());
'changed.bs.select',
this._getChangeHandler()
);
// build option list from config // build option list from config
var profiles = BR.conf.profiles; var profiles = BR.conf.profiles;
@ -55,12 +52,8 @@ BR.RoutingOptions = L.Evented.extend({
setOptions: function(options) { setOptions: function(options) {
var values = [ var values = [
options.profile options.profile ? options.profile : $('#profile option:selected').val(),
? options.profile options.alternative ? options.alternative : $('#alternative option:selected').val()
: $('#profile option:selected').val(),
options.alternative
? options.alternative
: $('#alternative option:selected').val()
]; ];
$('.selectpicker').selectpicker('val', values); $('.selectpicker').selectpicker('val', values);
this.refreshUI(); this.refreshUI();

View file

@ -74,10 +74,7 @@ BR.TrackMessages = L.Class.extend({
// highlight track segment (graph edge) on row hover // highlight track segment (graph edge) on row hover
this._setEdges(polyline, segments); this._setEdges(polyline, segments);
$('#datatable tbody tr').hover( $('#datatable tbody tr').hover(L.bind(this._handleHover, this), L.bind(this._handleHoverOut, this));
L.bind(this._handleHover, this),
L.bind(this._handleHoverOut, this)
);
}, },
show: function() { show: function() {
@ -198,10 +195,7 @@ BR.TrackMessages = L.Class.extend({
endIndex = this._edges[row.index()], endIndex = this._edges[row.index()],
edgeLatLngs = trackLatLngs.slice(startIndex, endIndex + 1); edgeLatLngs = trackLatLngs.slice(startIndex, endIndex + 1);
this._selectedEdge = L.polyline( this._selectedEdge = L.polyline(edgeLatLngs, this.options.edgeStyle).addTo(this._map);
edgeLatLngs,
this.options.edgeStyle
).addTo(this._map);
}, },
_handleHoverOut: function(evt) { _handleHoverOut: function(evt) {

View file

@ -14,36 +14,19 @@ BR.TrackStats = L.Class.extend({
} }
var stats = this.calcStats(polyline, segments), var stats = this.calcStats(polyline, segments),
length1 = L.Util.formatNum( length1 = L.Util.formatNum(stats.trackLength / 1000, 1).toLocaleString(),
stats.trackLength / 1000, length3 = L.Util.formatNum(stats.trackLength / 1000, 3).toLocaleString(),
1
).toLocaleString(),
length3 = L.Util.formatNum(
stats.trackLength / 1000,
3
).toLocaleString(),
formattedAscend = stats.filteredAscend.toLocaleString(), formattedAscend = stats.filteredAscend.toLocaleString(),
formattedPlainAscend = stats.plainAscend.toLocaleString(), formattedPlainAscend = stats.plainAscend.toLocaleString(),
formattedCost = stats.cost.toLocaleString(), formattedCost = stats.cost.toLocaleString(),
meanCostFactor = stats.trackLength meanCostFactor = stats.trackLength
? L.Util.formatNum( ? L.Util.formatNum(stats.cost / stats.trackLength, 2).toLocaleString()
stats.cost / stats.trackLength,
2
).toLocaleString()
: '0', : '0',
formattedTime = formattedTime =
Math.trunc(stats.totalTime / 3600) + Math.trunc(stats.totalTime / 3600) + ':' + ('0' + Math.trunc((stats.totalTime % 3600) / 60)).slice(-2),
':' + formattedEnergy = L.Util.formatNum(stats.totalEnergy / 3600000, 2).toLocaleString(),
('0' + Math.trunc((stats.totalTime % 3600) / 60)).slice(-2),
formattedEnergy = L.Util.formatNum(
stats.totalEnergy / 3600000,
2
).toLocaleString(),
meanEnergy = stats.trackLength meanEnergy = stats.trackLength
? L.Util.formatNum( ? L.Util.formatNum(stats.totalEnergy / 36 / stats.trackLength, 2).toLocaleString()
stats.totalEnergy / 36 / stats.trackLength,
2
).toLocaleString()
: '0'; : '0';
$('#distance').html(length1); $('#distance').html(length1);

View file

@ -10,15 +10,8 @@
function verifyTouchStyle(mapContext) { function verifyTouchStyle(mapContext) {
// revert touch style (large icons) when touch screen detection is available and negative // revert touch style (large icons) when touch screen detection is available and negative
// see https://github.com/nrenner/brouter-web/issues/69 // see https://github.com/nrenner/brouter-web/issues/69
if ( if (L.Browser.touch && BR.Browser.touchScreenDetectable && !BR.Browser.touchScreen) {
L.Browser.touch && L.DomUtil.removeClass(mapContext.map.getContainer(), 'leaflet-touch');
BR.Browser.touchScreenDetectable &&
!BR.Browser.touchScreen
) {
L.DomUtil.removeClass(
mapContext.map.getContainer(),
'leaflet-touch'
);
} }
} }
@ -91,10 +84,7 @@
deletePointButton = L.easyButton( deletePointButton = L.easyButton(
'<span><i class="fa fa-caret-left"></i><i class="fa fa-map-marker" style="margin-left: 1px; color: gray;"></i></span>', '<span><i class="fa fa-caret-left"></i><i class="fa fa-map-marker" style="margin-left: 1px; color: gray;"></i></span>',
function() { function() {
routing.removeWaypoint(routing.getLast(), function( routing.removeWaypoint(routing.getLast(), function(err, data) {});
err,
data
) {});
}, },
i18next.t('map.delete-last-point') i18next.t('map.delete-last-point')
); );
@ -171,19 +161,14 @@
profile.on('update', function(evt) { profile.on('update', function(evt) {
BR.message.hide(); BR.message.hide();
var profileId = routingOptions.getCustomProfile(); var profileId = routingOptions.getCustomProfile();
router.uploadProfile(profileId, evt.profileText, function( router.uploadProfile(profileId, evt.profileText, function(err, profileId) {
err,
profileId
) {
if (!err) { if (!err) {
routingOptions.setCustomProfile(profileId, true); routingOptions.setCustomProfile(profileId, true);
updateRoute({ updateRoute({
options: routingOptions.getOptions() options: routingOptions.getOptions()
}); });
if (!saveWarningShown) { if (!saveWarningShown) {
profile.message.showWarning( profile.message.showWarning(i18next.t('warning.temporary-profile'));
i18next.t('warning.temporary-profile')
);
saveWarningShown = true; saveWarningShown = true;
} }
} else { } else {
@ -214,9 +199,7 @@
styles: BR.conf.routingStyles styles: BR.conf.routingStyles
}); });
routing.on('routing:routeWaypointEnd routing:setWaypointsEnd', function( routing.on('routing:routeWaypointEnd routing:setWaypointsEnd', function(evt) {
evt
) {
search.clear(); search.clear();
onUpdate(evt && evt.err); onUpdate(evt && evt.err);
}); });
@ -339,9 +322,7 @@
// do not initialize immediately // do not initialize immediately
urlHash = new L.Hash(null, null); urlHash = new L.Hash(null, null);
urlHash.additionalCb = function() { urlHash.additionalCb = function() {
var url = router var url = router.getUrl(routing.getWaypoints(), null).substr('brouter?'.length + 1);
.getUrl(routing.getWaypoints(), null)
.substr('brouter?'.length + 1);
url = url.replace(/\|/g, ';'); url = url.replace(/\|/g, ';');
return url.length > 0 ? '&' + url : null; return url.length > 0 ? '&' + url : null;
}; };
@ -401,11 +382,7 @@
.on('hidden.bs.collapse', onHide) .on('hidden.bs.collapse', onHide)
.on('shown.bs.collapse', onShow) .on('shown.bs.collapse', onShow)
.each(function() { .each(function() {
if ( if (this.id && BR.Util.localStorageAvailable() && localStorage[this.id] === 'true') {
this.id &&
BR.Util.localStorageAvailable() &&
localStorage[this.id] === 'true'
) {
$(this).collapse('show'); $(this).collapse('show');
} }
}); });

View file

@ -15,33 +15,19 @@ BR.Elevation = L.Control.Elevation.extend({
// revert registering touch events when touch screen detection is available and negative // revert registering touch events when touch screen detection is available and negative
// see https://github.com/MrMufflon/Leaflet.Elevation/issues/67 // see https://github.com/MrMufflon/Leaflet.Elevation/issues/67
if ( if (L.Browser.touch && BR.Browser.touchScreenDetectable && !BR.Browser.touchScreen) {
L.Browser.touch &&
BR.Browser.touchScreenDetectable &&
!BR.Browser.touchScreen
) {
this._background this._background
.on('touchmove.drag', null) .on('touchmove.drag', null)
.on('touchstart.drag', null) .on('touchstart.drag', null)
.on('touchstart.focus', null); .on('touchstart.focus', null);
L.DomEvent.off( L.DomEvent.off(this._container, 'touchend', this._dragEndHandler, this);
this._container,
'touchend',
this._dragEndHandler,
this
);
this._background this._background
.on('mousemove.focus', this._mousemoveHandler.bind(this)) .on('mousemove.focus', this._mousemoveHandler.bind(this))
.on('mouseout.focus', this._mouseoutHandler.bind(this)) .on('mouseout.focus', this._mouseoutHandler.bind(this))
.on('mousedown.drag', this._dragStartHandler.bind(this)) .on('mousedown.drag', this._dragStartHandler.bind(this))
.on('mousemove.drag', this._dragHandler.bind(this)); .on('mousemove.drag', this._dragHandler.bind(this));
L.DomEvent.on( L.DomEvent.on(this._container, 'mouseup', this._dragEndHandler, this);
this._container,
'mouseup',
this._dragEndHandler,
this
);
} }
return container; return container;
@ -61,10 +47,7 @@ BR.Elevation = L.Control.Elevation.extend({
} }
this.addTo(map); this.addTo(map);
// move elevation graph outside of the map // move elevation graph outside of the map
setParent( setParent(this.getContainer(), document.getElementById('elevation-chart'));
this.getContainer(),
document.getElementById('elevation-chart')
);
}, },
update: function(track, layer) { update: function(track, layer) {

View file

@ -143,9 +143,7 @@ BR.NogoAreas = L.Control.extend({
resolve(reader.result); resolve(reader.result);
}; };
reader.onerror = function() { reader.onerror = function() {
self.displayUploadError( self.displayUploadError('Could not load file: ' + reader.error.message);
'Could not load file: ' + reader.error.message
);
}; };
reader.readAsText(nogoFile); reader.readAsText(nogoFile);
@ -184,32 +182,22 @@ BR.NogoAreas = L.Control.extend({
var maybeBufferedFeature = feature; var maybeBufferedFeature = feature;
// Eventually buffer GeoJSON // Eventually buffer GeoJSON
if (nogoBuffer !== 0) { if (nogoBuffer !== 0) {
maybeBufferedFeature = turf.buffer( maybeBufferedFeature = turf.buffer(maybeBufferedFeature, nogoBuffer, { units: 'meters' });
maybeBufferedFeature,
nogoBuffer,
{ units: 'meters' }
);
} }
cleanedGeoJSONFeatures.push(maybeBufferedFeature); cleanedGeoJSONFeatures.push(maybeBufferedFeature);
} }
}); });
if (cleanedGeoJSONFeatures.length === 0) { if (cleanedGeoJSONFeatures.length === 0) {
self.displayUploadError( self.displayUploadError('No valid area found in provided input.');
'No valid area found in provided input.'
);
return false; return false;
} }
var geoJSON = L.geoJson( var geoJSON = L.geoJson(turf.featureCollection(cleanedGeoJSONFeatures), {
turf.featureCollection(cleanedGeoJSONFeatures),
{
onEachFeature: function(feature, layer) { onEachFeature: function(feature, layer) {
layer.options.nogoWeight = layer.options.nogoWeight = feature.properties.nogoWeight || nogoWeight;
feature.properties.nogoWeight || nogoWeight;
} }
} });
);
var nogosPoints = geoJSON.getLayers().filter(function(e) { var nogosPoints = geoJSON.getLayers().filter(function(e) {
return e.feature.geometry.type === 'Point'; return e.feature.geometry.type === 'Point';
}); });
@ -332,9 +320,7 @@ BR.NogoAreas = L.Control.extend({
BR.NogoAreas.include(L.Evented.prototype); BR.NogoAreas.include(L.Evented.prototype);
L.Editable.prototype.createVertexIcon = function(options) { L.Editable.prototype.createVertexIcon = function(options) {
return BR.Browser.touch return BR.Browser.touch ? new L.Editable.TouchVertexIcon(options) : new L.Editable.VertexIcon(options);
? new L.Editable.TouchVertexIcon(options)
: new L.Editable.VertexIcon(options);
}; };
BR.EditingTooltip = L.Handler.extend({ BR.EditingTooltip = L.Handler.extend({
@ -351,12 +337,7 @@ BR.EditingTooltip = L.Handler.extend({
addHooks: function() { addHooks: function() {
// hack: listen to EasyButton click (instead of editable:drawing:start), // hack: listen to EasyButton click (instead of editable:drawing:start),
// to get mouse position from event for initial tooltip location // to get mouse position from event for initial tooltip location
L.DomEvent.addListener( L.DomEvent.addListener(this.button.button, 'click', this._addCreate, this);
this.button.button,
'click',
this._addCreate,
this
);
this.editTools.featuresLayer.on('layeradd', this._bind, this); this.editTools.featuresLayer.on('layeradd', this._bind, this);
@ -366,12 +347,7 @@ BR.EditingTooltip = L.Handler.extend({
}, },
removeHooks: function() { removeHooks: function() {
L.DomEvent.removeListener( L.DomEvent.removeListener(this.button.button, 'click', this._addCreate, this);
this.button.button,
'click',
this._addCreate,
this
);
this.editTools.featuresLayer.off('layeradd', this._bind, this); this.editTools.featuresLayer.off('layeradd', this._bind, this);
@ -396,9 +372,7 @@ BR.EditingTooltip = L.Handler.extend({
if (!latlng && layer instanceof L.Layer) { if (!latlng && layer instanceof L.Layer) {
latlng = L.latLng( latlng = L.latLng(
layer.getBounds().getSouth(), layer.getBounds().getSouth(),
0.5 * 0.5 * (layer.getBounds().getWest() + layer.getBounds().getEast())
(layer.getBounds().getWest() +
layer.getBounds().getEast())
); );
} }
L.Layer.prototype.openTooltip.call(this, layer, latlng); L.Layer.prototype.openTooltip.call(this, layer, latlng);
@ -444,11 +418,7 @@ BR.EditingTooltip = L.Handler.extend({
var closeTooltip = function() { var closeTooltip = function() {
this.map.closeTooltip(tooltip); this.map.closeTooltip(tooltip);
}; };
this.editTools.once( this.editTools.once('editable:editing editable:drawing:cancel', closeTooltip, this);
'editable:editing editable:drawing:cancel',
closeTooltip,
this
);
if (BR.Browser.touch) { if (BR.Browser.touch) {
// can't move with cursor on touch devices, so show at start pos for a few seconds // can't move with cursor on touch devices, so show at start pos for a few seconds
@ -501,9 +471,7 @@ BR.EditingTooltip = L.Handler.extend({
BR.DeletableCircleEditor = L.Editable.CircleEditor.extend({ BR.DeletableCircleEditor = L.Editable.CircleEditor.extend({
_computeDeleteLatLng: function() { _computeDeleteLatLng: function() {
// While circle is not added to the map, _radius is not set. // While circle is not added to the map, _radius is not set.
var delta = var delta = (this.feature._radius || this.feature._mRadius) * Math.cos(Math.PI / 4),
(this.feature._radius || this.feature._mRadius) *
Math.cos(Math.PI / 4),
point = this.map.project(this.feature._latlng); point = this.map.project(this.feature._latlng);
return this.map.unproject([point.x - delta, point.y - delta]); return this.map.unproject([point.x - delta, point.y - delta]);
}, },
@ -530,12 +498,7 @@ BR.DeletableCircleEditor = L.Editable.CircleEditor.extend({
}, },
initialize: function(map, feature, options) { initialize: function(map, feature, options) {
L.Editable.CircleEditor.prototype.initialize.call( L.Editable.CircleEditor.prototype.initialize.call(this, map, feature, options);
this,
map,
feature,
options
);
this._deleteLatLng = this._computeDeleteLatLng(); this._deleteLatLng = this._computeDeleteLatLng();
// FeatureGroup instead of LayerGroup to propagate events to members // FeatureGroup instead of LayerGroup to propagate events to members
@ -584,9 +547,7 @@ BR.DeleteMarker = L.Marker.extend({
options: { options: {
draggable: false, draggable: false,
icon: L.divIcon({ icon: L.divIcon({
iconSize: BR.Browser.touch iconSize: BR.Browser.touch ? new L.Point(24, 24) : new L.Point(16, 16),
? new L.Point(24, 24)
: new L.Point(16, 16),
className: 'leaflet-div-icon fa fa-trash-o nogo-delete-marker' className: 'leaflet-div-icon fa fa-trash-o nogo-delete-marker'
}) })
}, },

View file

@ -94,11 +94,7 @@ BR.Routing = L.Routing.extend({
// intercept listener: only re-show draw trailer after marker hover // intercept listener: only re-show draw trailer after marker hover
// when edit is not active (i.e. wasn't also supended) // when edit is not active (i.e. wasn't also supended)
this._parent.off( this._parent.off('waypoint:mouseout', this._catchWaypointEvent, this);
'waypoint:mouseout',
this._catchWaypointEvent,
this
);
this.on( this.on(
'waypoint:mouseout', 'waypoint:mouseout',
function(e) { function(e) {
@ -134,12 +130,7 @@ BR.Routing = L.Routing.extend({
this._map.off('mouseout', hide, this); this._map.off('mouseout', hide, this);
this._map.off('mouseover', show, this); this._map.off('mouseover', show, this);
L.DomEvent.off(this._map._controlContainer, 'mouseout', show, this); L.DomEvent.off(this._map._controlContainer, 'mouseout', show, this);
L.DomEvent.off( L.DomEvent.off(this._map._controlContainer, 'mouseover', hide, this);
this._map._controlContainer,
'mouseover',
hide,
this
);
}); });
// Call show after deleting last waypoint, but hide trailer. // Call show after deleting last waypoint, but hide trailer.
@ -159,11 +150,7 @@ BR.Routing = L.Routing.extend({
); );
// keys not working when map container does not have focus, use document instead // keys not working when map container does not have focus, use document instead
L.DomEvent.removeListener( L.DomEvent.removeListener(this._container, 'keyup', this._keyupListener);
this._container,
'keyup',
this._keyupListener
);
L.DomEvent.addListener(document, 'keyup', this._keyupListener, this); L.DomEvent.addListener(document, 'keyup', this._keyupListener, this);
// enable drawing mode // enable drawing mode
@ -173,10 +160,7 @@ BR.Routing = L.Routing.extend({
}, },
_addSegmentCasing: function(e) { _addSegmentCasing: function(e) {
var casing = L.polyline( var casing = L.polyline(e.layer.getLatLngs(), this.options.styles.trackCasing);
e.layer.getLatLngs(),
this.options.styles.trackCasing
);
this._segmentsCasing.addLayer(casing); this._segmentsCasing.addLayer(casing);
e.layer._casing = casing; e.layer._casing = casing;
this._segments.bringToFront(); this._segments.bringToFront();
@ -335,10 +319,7 @@ BR.Routing = L.Routing.extend({
_keyupListener: function(e) { _keyupListener: function(e) {
// Suppress shortcut handling when a text input field is focussed // Suppress shortcut handling when a text input field is focussed
if ( if (document.activeElement.type == 'text' || document.activeElement.type == 'textarea') {
document.activeElement.type == 'text' ||
document.activeElement.type == 'textarea'
) {
return; return;
} }
// add 'esc' to disable drawing // add 'esc' to disable drawing

View file

@ -36,11 +36,7 @@ BR.Sidebar = L.Control.Sidebar.extend({
this._rememberTabState(); this._rememberTabState();
if ( if (L.Browser.touch && BR.Browser.touchScreenDetectable && !BR.Browser.touchScreen) {
L.Browser.touch &&
BR.Browser.touchScreenDetectable &&
!BR.Browser.touchScreen
) {
L.DomUtil.removeClass(this._container, 'leaflet-touch'); L.DomUtil.removeClass(this._container, 'leaflet-touch');
L.DomUtil.removeClass(this._tabContainer, 'leaflet-touch'); L.DomUtil.removeClass(this._tabContainer, 'leaflet-touch');
} }

View file

@ -1,9 +1,7 @@
(function(window) { (function(window) {
var HAS_HASHCHANGE = (function() { var HAS_HASHCHANGE = (function() {
var doc_mode = window.documentMode; var doc_mode = window.documentMode;
return ( return 'onhashchange' in window && (doc_mode === undefined || doc_mode > 7);
'onhashchange' in window && (doc_mode === undefined || doc_mode > 7)
);
})(); })();
L.Hash = function(map, options) { L.Hash = function(map, options) {
@ -47,12 +45,7 @@
precision = Math.max(0, Math.ceil(Math.log(zoom) / Math.LN2)), precision = Math.max(0, Math.ceil(Math.log(zoom) / Math.LN2)),
layers = this.formatLayers(); layers = this.formatLayers();
var params = [ var params = [zoom, center.lat.toFixed(precision), center.lng.toFixed(precision), layers];
zoom,
center.lat.toFixed(precision),
center.lng.toFixed(precision),
layers
];
url = '#map=' + params.join('/'); url = '#map=' + params.join('/');
if (this.additionalCb != null) { if (this.additionalCb != null) {
var additional = this.additionalCb(); var additional = this.additionalCb();
@ -92,9 +85,7 @@
var layerString = decodeURIComponent(layerEncoded); var layerString = decodeURIComponent(layerEncoded);
if (layerString) { if (layerString) {
obj = this.options.layersControl.getLayerFromString( obj = this.options.layersControl.getLayerFromString(layerString);
layerString
);
} }
return obj; return obj;
@ -112,10 +103,7 @@
return count; return count;
}; };
var layers = this._parseLayers( var layers = this._parseLayers(layersParam, this.options.layerSeparator);
layersParam,
this.options.layerSeparator
);
var found = layers.reduce(countFoundLayers, 0); var found = layers.reduce(countFoundLayers, 0);
if (found < layers.length) { if (found < layers.length) {
@ -158,9 +146,7 @@
var objList = this.options.layersControl.getActiveLayers(); var objList = this.options.layersControl.getActiveLayers();
var layerList = objList.map( var layerList = objList.map(
L.bind(function(obj) { L.bind(function(obj) {
return encodeURIComponent( return encodeURIComponent(this.options.layersControl.toLayerString(obj));
this.options.layersControl.toLayerString(obj)
);
}, this) }, this)
); );
@ -246,41 +232,22 @@
isListening: false, isListening: false,
hashChangeInterval: null, hashChangeInterval: null,
startListening: function() { startListening: function() {
this.map.on( this.map.on('moveend layeradd layerremove', this.onMapMove, this);
'moveend layeradd layerremove',
this.onMapMove,
this
);
if (HAS_HASHCHANGE) { if (HAS_HASHCHANGE) {
L.DomEvent.addListener( L.DomEvent.addListener(window, 'hashchange', this.onHashChange);
window,
'hashchange',
this.onHashChange
);
} else { } else {
clearInterval(this.hashChangeInterval); clearInterval(this.hashChangeInterval);
this.hashChangeInterval = setInterval( this.hashChangeInterval = setInterval(this.onHashChange, 50);
this.onHashChange,
50
);
} }
this.isListening = true; this.isListening = true;
}, },
stopListening: function() { stopListening: function() {
this.map.off( this.map.off('moveend layeradd layerremove', this.onMapMove, this);
'moveend layeradd layerremove',
this.onMapMove,
this
);
if (HAS_HASHCHANGE) { if (HAS_HASHCHANGE) {
L.DomEvent.removeListener( L.DomEvent.removeListener(window, 'hashchange', this.onHashChange);
window,
'hashchange',
this.onHashChange
);
} else { } else {
clearInterval(this.hashChangeInterval); clearInterval(this.hashChangeInterval);
} }

View file

@ -7,10 +7,7 @@ BR.stravaSegments = function(map, layersControl) {
stravaToken: BR.keys.strava stravaToken: BR.keys.strava
}) })
.addTo(map); .addTo(map);
layersControl.addOverlay( layersControl.addOverlay(stravaControl.stravaLayer, i18next.t('map.layer.strava-segments'));
stravaControl.stravaLayer,
i18next.t('map.layer.strava-segments')
);
stravaControl.onError = function(err) { stravaControl.onError = function(err) {
BR.message.showError( BR.message.showError(
i18next.t('warning.strava-error', { i18next.t('warning.strava-error', {

View file

@ -40,30 +40,16 @@ L.BRouter = L.Class.extend({
getUrlParams: function(latLngs, format) { getUrlParams: function(latLngs, format) {
params = {}; params = {};
if (this._getLonLatsString(latLngs) != null) if (this._getLonLatsString(latLngs) != null) params.lonlats = this._getLonLatsString(latLngs);
params.lonlats = this._getLonLatsString(latLngs);
if ( if (this.options.nogos && this._getNogosString(this.options.nogos).length > 0)
this.options.nogos &&
this._getNogosString(this.options.nogos).length > 0
)
params.nogos = this._getNogosString(this.options.nogos); params.nogos = this._getNogosString(this.options.nogos);
if ( if (this.options.polylines && this._getNogosPolylinesString(this.options.polylines).length > 0)
this.options.polylines && params.polylines = this._getNogosPolylinesString(this.options.polylines);
this._getNogosPolylinesString(this.options.polylines).length > 0
)
params.polylines = this._getNogosPolylinesString(
this.options.polylines
);
if ( if (this.options.polygons && this._getNogosPolygonsString(this.options.polygons).length > 0)
this.options.polygons && params.polygons = this._getNogosPolygonsString(this.options.polygons);
this._getNogosPolygonsString(this.options.polygons).length > 0
)
params.polygons = this._getNogosPolygonsString(
this.options.polygons
);
if (this.options.profile != null) params.profile = this.options.profile; if (this.options.profile != null) params.profile = this.options.profile;
@ -77,10 +63,7 @@ L.BRouter = L.Class.extend({
if (params.alternativeidx == 0) delete params.alternativeidx; if (params.alternativeidx == 0) delete params.alternativeidx;
// don't add custom profile, as these are only stored temporarily // don't add custom profile, as these are only stored temporarily
if ( if (params.profile && params.profile.substring(0, 7) === 'custom_') {
params.profile &&
params.profile.substring(0, 7) === 'custom_'
) {
delete params.profile; delete params.profile;
} }
} }
@ -117,20 +100,12 @@ L.BRouter = L.Class.extend({
var args = []; var args = [];
if (urlParams.lonlats != null && urlParams.lonlats.length > 0) if (urlParams.lonlats != null && urlParams.lonlats.length > 0)
args.push(L.Util.template('lonlats={lonlats}', urlParams)); args.push(L.Util.template('lonlats={lonlats}', urlParams));
if (urlParams.nogos != null) if (urlParams.nogos != null) args.push(L.Util.template('nogos={nogos}', urlParams));
args.push(L.Util.template('nogos={nogos}', urlParams)); if (urlParams.polylines != null) args.push(L.Util.template('polylines={polylines}', urlParams));
if (urlParams.polylines != null) if (urlParams.polygons != null) args.push(L.Util.template('polygons={polygons}', urlParams));
args.push(L.Util.template('polylines={polylines}', urlParams)); if (urlParams.profile != null) args.push(L.Util.template('profile={profile}', urlParams));
if (urlParams.polygons != null) if (urlParams.alternativeidx != null) args.push(L.Util.template('alternativeidx={alternativeidx}', urlParams));
args.push(L.Util.template('polygons={polygons}', urlParams)); if (urlParams.format != null) args.push(L.Util.template('format={format}', urlParams));
if (urlParams.profile != null)
args.push(L.Util.template('profile={profile}', urlParams));
if (urlParams.alternativeidx != null)
args.push(
L.Util.template('alternativeidx={alternativeidx}', urlParams)
);
if (urlParams.format != null)
args.push(L.Util.template('format={format}', urlParams));
if (trackname) if (trackname)
args.push( args.push(
L.Util.template('trackname={trackname}', { L.Util.template('trackname={trackname}', {
@ -141,9 +116,7 @@ L.BRouter = L.Class.extend({
var prepend_host = format != null; var prepend_host = format != null;
return ( return (prepend_host ? BR.conf.host : '') + '/brouter?' + args.join('&');
(prepend_host ? BR.conf.host : '') + '/brouter?' + args.join('&')
);
}, },
getRoute: function(latLngs, cb) { getRoute: function(latLngs, cb) {
@ -174,8 +147,7 @@ L.BRouter = L.Class.extend({
xhr.status === 200 && xhr.status === 200 &&
xhr.responseText && xhr.responseText &&
// application error when not GeoJSON format (text/plain for errors) // application error when not GeoJSON format (text/plain for errors)
xhr.getResponseHeader('Content-Type').split(';')[0] === xhr.getResponseHeader('Content-Type').split(';')[0] === 'application/vnd.geo+json'
'application/vnd.geo+json'
) { ) {
// leaflet.spin // leaflet.spin
//gpxLayer.fire('data:loaded'); //gpxLayer.fire('data:loaded');
@ -221,11 +193,7 @@ L.BRouter = L.Class.extend({
_handleProfileResponse: function(xhr, cb) { _handleProfileResponse: function(xhr, cb) {
var response; var response;
if ( if (xhr.status === 200 && xhr.responseText && xhr.responseText.length > 0) {
xhr.status === 200 &&
xhr.responseText &&
xhr.responseText.length > 0
) {
response = JSON.parse(xhr.responseText); response = JSON.parse(xhr.responseText);
cb(response.error, response.profileid); cb(response.error, response.profileid);
} else { } else {

View file

@ -4,8 +4,7 @@ var brouterCgi = (function() {
// http://brouter.de/cgi-bin/brouter.sh?coords=13.404681_52.520185_13.340278_52.512356_trekking_0 // http://brouter.de/cgi-bin/brouter.sh?coords=13.404681_52.520185_13.340278_52.512356_trekking_0
//var URL_TEMPLATE = '/cgi-bin/proxy.cgi?url=' + 'http://brouter.de/cgi-bin/brouter.sh?coords={fromLng}_{fromLat}_{toLng}_{toLat}_{profile}_{alt}'; //var URL_TEMPLATE = '/cgi-bin/proxy.cgi?url=' + 'http://brouter.de/cgi-bin/brouter.sh?coords={fromLng}_{fromLat}_{toLng}_{toLat}_{profile}_{alt}';
var URL_TEMPLATE = var URL_TEMPLATE =
'/proxy.php?url=' + '/proxy.php?url=' + 'cgi-bin/brouter.sh?coords={fromLng}_{fromLat}_{toLng}_{toLat}_{profile}_{alt}';
'cgi-bin/brouter.sh?coords={fromLng}_{fromLat}_{toLng}_{toLat}_{profile}_{alt}';
var PRECISION = 6; var PRECISION = 6;
function getUrl(polyline) { function getUrl(polyline) {

View file

@ -21,14 +21,8 @@ i18next.t('navbar.profile.vm-forum-liegerad-schnell');
i18next.t('navbar.profile.vm-forum-velomobil-schnell'); i18next.t('navbar.profile.vm-forum-velomobil-schnell');
i18next.t('sidebar.layers.category.base-layers', 'Base layers'); i18next.t('sidebar.layers.category.base-layers', 'Base layers');
i18next.t( i18next.t('sidebar.layers.category.worldwide-international', 'Worldwide international');
'sidebar.layers.category.worldwide-international', i18next.t('sidebar.layers.category.worldwide-monolingual', 'Worldwide monolingual');
'Worldwide international'
);
i18next.t(
'sidebar.layers.category.worldwide-monolingual',
'Worldwide monolingual'
);
i18next.t('sidebar.layers.category.europe', 'Europe'); i18next.t('sidebar.layers.category.europe', 'Europe');
i18next.t('sidebar.layers.category.europe-monolingual', 'Europe monolingual'); i18next.t('sidebar.layers.category.europe-monolingual', 'Europe monolingual');
i18next.t('sidebar.layers.category.country', 'Country'); i18next.t('sidebar.layers.category.country', 'Country');