From 970a34981f943db66ad4214d0a030ea5e4db9575 Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Thu, 16 May 2019 21:31:06 +0200 Subject: [PATCH] Add prettier and reformat code --- .prettierignore | 9 + .prettierrc | 4 + CHANGELOG.md | 140 ++-- README.md | 215 +++--- config.template.js | 6 - css/style.css | 59 +- gulpfile.js | 467 +++++++------ index.html | 1168 ++++++++++++++++++++++++--------- js/Browser.js | 25 +- js/LayersConfig.js | 81 ++- js/Map.js | 80 ++- js/Util.js | 12 +- js/control/Control.Layers.js | 32 +- js/control/Download.js | 8 +- js/control/Itinerary.js | 18 +- js/control/Layers.js | 81 ++- js/control/LayersTab.js | 129 ++-- js/control/Message.js | 37 +- js/control/OpacitySlider.js | 78 ++- js/control/Profile.js | 39 +- js/control/RoutingOptions.js | 63 +- js/control/TrackMessages.js | 57 +- js/control/TrackStats.js | 35 +- js/index.js | 246 ++++--- js/plugin/Bing.js | 12 +- js/plugin/Elevation.js | 59 +- js/plugin/NogoAreas.js | 298 +++++---- js/plugin/Routing.js | 446 +++++++------ js/plugin/Sidebar.js | 44 +- js/plugin/leaflet-fullHash.js | 432 ++++++------ js/plugin/stravaSegments.js | 32 +- js/router/BRouter.js | 151 +++-- js/router/brouterCgi.js | 11 +- keys.template.js | 2 - locales/keys.js | 10 +- package.json | 439 +++++++------ yarn.lock | 403 +++++++++++- 37 files changed, 3459 insertions(+), 1969 deletions(-) create mode 100644 .prettierignore create mode 100644 .prettierrc diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..54d938a --- /dev/null +++ b/.prettierignore @@ -0,0 +1,9 @@ +LICENSE +dist/ +*.zip +yarn.lock +.idea +.gitignore +.prettierignore +.tx/ +layers/ \ No newline at end of file diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..18815a1 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,4 @@ +{ + "singleQuote": true, + "tabWidth": 4 +} \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 7bafd4d..35044d2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,4 @@ -BRouter-Web Changelog -===================== +# BRouter-Web Changelog ## 0.8.0 (2019-05-04) @@ -7,25 +6,25 @@ See also [milestone 0.8.0](https://github.com/nrenner/brouter-web/milestone/6?cl ### New Features -* Optional layers tree ([#146](https://github.com/nrenner/brouter-web/issues/146)) -* Let user upload GeoJSON file of nogos - by [@Phyks](https://github.com/Phyks) ([#161](https://github.com/nrenner/brouter-web/pull/161)) -* Translations: make website localizable (i18n) - by [@bagage](https://github.com/bagage) ([#63](https://github.com/nrenner/brouter-web/issues/63)) -* Fix polygon edition - by [@Phyks](https://github.com/Phyks) ([#158](https://github.com/nrenner/brouter-web/pull/158)) -* Render polygons from URL hash and pass it to BRouter server - by [@Phyks](https://github.com/Phyks) ([#157](https://github.com/nrenner/brouter-web/pull/157)) -* Start support of nogos polylines/polygons - by [@Phyks](https://github.com/Phyks) ([#148](https://github.com/nrenner/brouter-web/pull/148)) +- Optional layers tree ([#146](https://github.com/nrenner/brouter-web/issues/146)) +- Let user upload GeoJSON file of nogos - by [@Phyks](https://github.com/Phyks) ([#161](https://github.com/nrenner/brouter-web/pull/161)) +- Translations: make website localizable (i18n) - by [@bagage](https://github.com/bagage) ([#63](https://github.com/nrenner/brouter-web/issues/63)) +- Fix polygon edition - by [@Phyks](https://github.com/Phyks) ([#158](https://github.com/nrenner/brouter-web/pull/158)) +- Render polygons from URL hash and pass it to BRouter server - by [@Phyks](https://github.com/Phyks) ([#157](https://github.com/nrenner/brouter-web/pull/157)) +- Start support of nogos polylines/polygons - by [@Phyks](https://github.com/Phyks) ([#148](https://github.com/nrenner/brouter-web/pull/148)) ### Improvements -* Show line numbers in profile editor to help locating error message line ([81f2c08](https://github.com/nrenner/brouter-web/commit/81f2c0863f2569fa9079e5c96f4c9b09ef4c26e2)) -* Hide StravaSegments control when layer is not active ([eaba5a0](https://github.com/nrenner/brouter-web/commit/eaba5a08217fd026fb7f83ec7beb7c1f1fdc2d69)) -* Show strava error + update translations - by [@bagage](https://github.com/bagage) ([#163](https://github.com/nrenner/brouter-web/pull/163)) -* Replace Bower with Yarn/npm - by [@bagage](https://github.com/bagage) ([#116](https://github.com/nrenner/brouter-web/issues/116)) -* Add strava layer in overlays - by [@bagage](https://github.com/bagage) ([#152](https://github.com/nrenner/brouter-web/pull/152)) -* Fix release script - by [@bagage](https://github.com/bagage) ([#150](https://github.com/nrenner/brouter-web/pull/150)) +- Show line numbers in profile editor to help locating error message line ([81f2c08](https://github.com/nrenner/brouter-web/commit/81f2c0863f2569fa9079e5c96f4c9b09ef4c26e2)) +- Hide StravaSegments control when layer is not active ([eaba5a0](https://github.com/nrenner/brouter-web/commit/eaba5a08217fd026fb7f83ec7beb7c1f1fdc2d69)) +- Show strava error + update translations - by [@bagage](https://github.com/bagage) ([#163](https://github.com/nrenner/brouter-web/pull/163)) +- Replace Bower with Yarn/npm - by [@bagage](https://github.com/bagage) ([#116](https://github.com/nrenner/brouter-web/issues/116)) +- Add strava layer in overlays - by [@bagage](https://github.com/bagage) ([#152](https://github.com/nrenner/brouter-web/pull/152)) +- Fix release script - by [@bagage](https://github.com/bagage) ([#150](https://github.com/nrenner/brouter-web/pull/150)) ### Bugfixes -* Overlays hidden under custom layer ([#143](https://github.com/nrenner/brouter-web/issues/143)) +- Overlays hidden under custom layer ([#143](https://github.com/nrenner/brouter-web/issues/143)) ## 0.7.0 (2018-10-10) @@ -33,34 +32,34 @@ See also [milestone 0.7.0](https://github.com/nrenner/brouter-web/milestone/4?cl ### New Features -* Redesign of the user interface to also support mobile devices - by [@bagage](https://github.com/bagage) and [@RoPP](https://github.com/RoPP) ([#34](https://github.com/nrenner/brouter-web/issues/34), [#66](https://github.com/nrenner/brouter-web/issues/66)) -* Permalink replaced with auto-updating URL address bar - by [@bagage](https://github.com/bagage) ([#62](https://github.com/nrenner/brouter-web/issues/62)) -* Allow user to add custom layers - by [@bagage](https://github.com/bagage) ([#77](https://github.com/nrenner/brouter-web/pull/77)) -* Profile and data table now in a collapsible, full-height sidebar ([#90](https://github.com/nrenner/brouter-web/issues/90), [#114](https://github.com/nrenner/brouter-web/issues/114)) -* No-go areas individually editable and deletable ([#100](https://github.com/nrenner/brouter-web/issues/100)) +- Redesign of the user interface to also support mobile devices - by [@bagage](https://github.com/bagage) and [@RoPP](https://github.com/RoPP) ([#34](https://github.com/nrenner/brouter-web/issues/34), [#66](https://github.com/nrenner/brouter-web/issues/66)) +- Permalink replaced with auto-updating URL address bar - by [@bagage](https://github.com/bagage) ([#62](https://github.com/nrenner/brouter-web/issues/62)) +- Allow user to add custom layers - by [@bagage](https://github.com/bagage) ([#77](https://github.com/nrenner/brouter-web/pull/77)) +- Profile and data table now in a collapsible, full-height sidebar ([#90](https://github.com/nrenner/brouter-web/issues/90), [#114](https://github.com/nrenner/brouter-web/issues/114)) +- No-go areas individually editable and deletable ([#100](https://github.com/nrenner/brouter-web/issues/100)) ### Improvements -* New gulp debug task and watch CSS folder - by [@bagage](https://github.com/bagage) ([#58](https://github.com/nrenner/brouter-web/pull/58)) -* Locate button not shown when no https ([#60](https://github.com/nrenner/brouter-web/issues/60)) -* Support Leaflet 1.0 ([#65](https://github.com/nrenner/brouter-web/issues/65), [#69](https://github.com/nrenner/brouter-web/issues/69)) -* Add a gulp command for release - by [@RoPP](https://github.com/RoPP) ([#85](https://github.com/nrenner/brouter-web/pull/85)) -* Use https scheme whenever possible, to avoid mixed content issues - by [@bagage](https://github.com/bagage) ([#87](https://github.com/nrenner/brouter-web/pull/87)) -* Add car-eco/fast profiles + display energy/time - by [@abrensch](https://github.com/abrensch) ([#95](https://github.com/nrenner/brouter-web/pull/95)) -* Improve error message if no route found - by [@bagage](https://github.com/bagage) ([#99](https://github.com/nrenner/brouter-web/issues/99)) -* Support zoom 19 for German style - by [@giggls](https://github.com/giggls) ([#128](https://github.com/nrenner/brouter-web/pull/128)) +- New gulp debug task and watch CSS folder - by [@bagage](https://github.com/bagage) ([#58](https://github.com/nrenner/brouter-web/pull/58)) +- Locate button not shown when no https ([#60](https://github.com/nrenner/brouter-web/issues/60)) +- Support Leaflet 1.0 ([#65](https://github.com/nrenner/brouter-web/issues/65), [#69](https://github.com/nrenner/brouter-web/issues/69)) +- Add a gulp command for release - by [@RoPP](https://github.com/RoPP) ([#85](https://github.com/nrenner/brouter-web/pull/85)) +- Use https scheme whenever possible, to avoid mixed content issues - by [@bagage](https://github.com/bagage) ([#87](https://github.com/nrenner/brouter-web/pull/87)) +- Add car-eco/fast profiles + display energy/time - by [@abrensch](https://github.com/abrensch) ([#95](https://github.com/nrenner/brouter-web/pull/95)) +- Improve error message if no route found - by [@bagage](https://github.com/bagage) ([#99](https://github.com/nrenner/brouter-web/issues/99)) +- Support zoom 19 for German style - by [@giggls](https://github.com/giggls) ([#128](https://github.com/nrenner/brouter-web/pull/128)) ## 0.6.3 (2017-03-16) -* Fix data tab showing only two rows (regression from v0.6.2) ([#72](https://github.com/nrenner/brouter-web/issues/72)) +- Fix data tab showing only two rows (regression from v0.6.2) ([#72](https://github.com/nrenner/brouter-web/issues/72)) ## 0.6.2 (2017-03-14) -* Fix "API Key Required" in OpenCycleMap & Outdoors by registering for Thunderforest "Hobby Project" plan ([#70](https://github.com/nrenner/brouter-web/issues/70)) +- Fix "API Key Required" in OpenCycleMap & Outdoors by registering for Thunderforest "Hobby Project" plan ([#70](https://github.com/nrenner/brouter-web/issues/70)) ## 0.6.1 (2016-12-12) -* Add Esri World Imagery layer (DigitalGlobe is now also blocked because monthly usage limit is exceeded) +- Add Esri World Imagery layer (DigitalGlobe is now also blocked because monthly usage limit is exceeded) ## 0.6.0 (2016-10-11) @@ -68,66 +67,65 @@ See also [milestone 0.6.0](https://github.com/nrenner/brouter-web/milestone/1?cl ### Features/Improvements -* Update OpenTopoMap zoom range to 0-17 -* [local installation] Option to remove default base layers ([#27](https://github.com/nrenner/brouter-web/issues/27)) -* Add tooltip to display length in meter precision (3 digits) ([#38](https://github.com/nrenner/brouter-web/issues/38)) -* Add "mean cost" to route statistics ([#39](https://github.com/nrenner/brouter-web/issues/39)) -* Set route transparency slider to partially transparent by default ([#36](https://github.com/nrenner/brouter-web/issues/36)) -* Show position in elevation diagram when hovering path on map ([#29](https://github.com/nrenner/brouter-web/issues/29)) -* [local installation] Added ability to specify custom overlays in configuration - by [@saesh](https://github.com/saesh) ([#46](https://github.com/nrenner/brouter-web/pull/46)) -* Add button to get/follow the current location (leaflet.locatecontrol plugin) - by [@bagage](https://github.com/bagage) ([#49](https://github.com/nrenner/brouter-web/pull/49)) -* Save and restore last map position (leaflet.restoreview.js plugin) - by [@bagage](https://github.com/bagage) ([#49](https://github.com/nrenner/brouter-web/pull/49)) -* Toggle drawing mode via panel button - by [@bagage](https://github.com/bagage) ([#50](https://github.com/nrenner/brouter-web/pull/50)) -* [local installation] add keys.js to configure API keys instead of bingkey request -* Switch to new icon set (Font Awesome) with more options +- Update OpenTopoMap zoom range to 0-17 +- [local installation] Option to remove default base layers ([#27](https://github.com/nrenner/brouter-web/issues/27)) +- Add tooltip to display length in meter precision (3 digits) ([#38](https://github.com/nrenner/brouter-web/issues/38)) +- Add "mean cost" to route statistics ([#39](https://github.com/nrenner/brouter-web/issues/39)) +- Set route transparency slider to partially transparent by default ([#36](https://github.com/nrenner/brouter-web/issues/36)) +- Show position in elevation diagram when hovering path on map ([#29](https://github.com/nrenner/brouter-web/issues/29)) +- [local installation] Added ability to specify custom overlays in configuration - by [@saesh](https://github.com/saesh) ([#46](https://github.com/nrenner/brouter-web/pull/46)) +- Add button to get/follow the current location (leaflet.locatecontrol plugin) - by [@bagage](https://github.com/bagage) ([#49](https://github.com/nrenner/brouter-web/pull/49)) +- Save and restore last map position (leaflet.restoreview.js plugin) - by [@bagage](https://github.com/bagage) ([#49](https://github.com/nrenner/brouter-web/pull/49)) +- Toggle drawing mode via panel button - by [@bagage](https://github.com/bagage) ([#50](https://github.com/nrenner/brouter-web/pull/50)) +- [local installation] add keys.js to configure API keys instead of bingkey request +- Switch to new icon set (Font Awesome) with more options ### Bugfixes -* Replace Bing (usage limit exceeded) with DigitalGlobe Recent Imagery layer (newer images, but sometimes cloudy) -* [local installation] Show error message for invalid server response with custom profiles on Windows (still needs to be fixed) ([#53](https://github.com/nrenner/brouter-web/issues/53)) -* Restrictive Cookie settings caused app to stop responding ([#47](https://github.com/nrenner/brouter-web/issues/47)) +- Replace Bing (usage limit exceeded) with DigitalGlobe Recent Imagery layer (newer images, but sometimes cloudy) +- [local installation] Show error message for invalid server response with custom profiles on Windows (still needs to be fixed) ([#53](https://github.com/nrenner/brouter-web/issues/53)) +- Restrictive Cookie settings caused app to stop responding ([#47](https://github.com/nrenner/brouter-web/issues/47)) ## 0.5.2 (2015-08-27) -* switch search from MapQuest to Nominatim (MapQuest licensing change) +- switch search from MapQuest to Nominatim (MapQuest licensing change) ## 0.5.1 (2015-07-24) -* config option ``baseLayers`` to add custom base layers locally (#24) -* reset slider on page load to minimum opacity (#22), - customizable locally with config setting ``minOpacity`` -* set OpenTopoMap max zoom back to z15 while on fallback server (#21), - also fix max zoom of other services -* overscale tiles to common max zoom (avoids gray screen when switching) +- config option `baseLayers` to add custom base layers locally (#24) +- reset slider on page load to minimum opacity (#22), + customizable locally with config setting `minOpacity` +- set OpenTopoMap max zoom back to z15 while on fallback server (#21), + also fix max zoom of other services +- overscale tiles to common max zoom (avoids gray screen when switching) ## 0.5.0 (2015-07-01) ### Features -* Load profile content for selected profile (needs extra server locally) -* Bing maps aerial layer (not working locally) -* track color magenta instead of blue + white casing, for better contrast - with background map (esp. OpenCycleMap) -* transparency slider for route track and markers -* button to delete route (#10) -* map scale -* download all dependencies in a bundle, instead using CDNs and separate files (#18) -* switch search plugin for result-dependent zoom -* "about" popup with a bit more infos and links -* closable error/warning messages, profile messages in place +- Load profile content for selected profile (needs extra server locally) +- Bing maps aerial layer (not working locally) +- track color magenta instead of blue + white casing, for better contrast + with background map (esp. OpenCycleMap) +- transparency slider for route track and markers +- button to delete route (#10) +- map scale +- download all dependencies in a bundle, instead using CDNs and separate files (#18) +- switch search plugin for result-dependent zoom +- "about" popup with a bit more infos and links +- closable error/warning messages, profile messages in place ### Bugfixes -* keys to enable/disable drawing (d, q/esc) now always work, not only when map is focused -* fix adding new waypoint after deleting the last (#11) -* fix profile/data scrolling on Firefox -* hide trailer over controls and outside map - +- keys to enable/disable drawing (d, q/esc) now always work, not only when map is focused +- fix adding new waypoint after deleting the last (#11) +- fix profile/data scrolling on Firefox +- hide trailer over controls and outside map ## BRouter 1.2 -* data/CSV aggregated over segments with same tags (for better performance) +- data/CSV aggregated over segments with same tags (for better performance) ## 0.4.0 (2015-03-08) -* data tab (slow with long routes, exp. on Firefox) +- data tab (slow with long routes, exp. on Firefox) diff --git a/README.md b/README.md index 225ba5c..d59390e 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ -brouter-web -=========== +# brouter-web -Web client (by [@nrenner](https://github.com/nrenner) and [contributors](https://github.com/nrenner/brouter-web/graphs/contributors)) for the BRouter routing engine (by [@abrensch](https://github.com/abrensch)). *Work in progress*. +Web client (by [@nrenner](https://github.com/nrenner) and [contributors](https://github.com/nrenner/brouter-web/graphs/contributors)) for the BRouter routing engine (by [@abrensch](https://github.com/abrensch)). _Work in progress_. -Instances: -* [brouter.de/brouter-web](http://brouter.de/brouter-web/) *(provided by [@abrensch](https://github.com/abrensch))* -* [brouter.damsy.net](http://brouter.damsy.net) *(provided by [@bagage](https://github.com/bagage))* +Instances: + +- [brouter.de/brouter-web](http://brouter.de/brouter-web/) _(provided by [@abrensch](https://github.com/abrensch))_ +- [brouter.damsy.net](http://brouter.damsy.net) _(provided by [@bagage](https://github.com/bagage))_ This repository is only about the frontend. For the server/backend, BRouter routing engine, Android app, profiles, brouter.de site, see: https://github.com/abrensch/brouter @@ -30,52 +30,53 @@ As an alternative to the above online version, the standalone server of BRouter ### Install BRouter (server with routing engine) -1. download and unzip latest [BRouter revision](http://brouter.de/brouter/revisions.html) -e.g. for Linux (replace ``~/opt/`` with your preferred install dir and ``1_4_11`` with latest version): +1. download and unzip latest [BRouter revision](http://brouter.de/brouter/revisions.html) + e.g. for Linux (replace `~/opt/` with your preferred install dir and `1_4_11` with latest version): - mkdir ~/opt/brouter - cd ~/opt/brouter - wget http://brouter.de/brouter_bin/brouter_1_4_11.zip - unzip brouter_1_4_11.zip - chmod +x ./standalone/server.sh + mkdir ~/opt/brouter + cd ~/opt/brouter + wget http://brouter.de/brouter_bin/brouter_1_4_11.zip + unzip brouter_1_4_11.zip + chmod +x ./standalone/server.sh -2. download one or more [data file(s)](http://brouter.de/brouter/segments4/) (rd5) into ``segments4`` dir +2. download one or more [data file(s)](http://brouter.de/brouter/segments4/) (rd5) into `segments4` dir ### Install BRouter-Web (client) -1. download BRouter-Web as subdirectory ``brouter-web`` of the ``brouter`` directory - * using the latest stable release - adjust to current version number - from - https://github.com/nrenner/brouter-web/releases: +1. download BRouter-Web as subdirectory `brouter-web` of the `brouter` directory - wget https://github.com/nrenner/brouter-web/releases/download/0.7.0/brouter-web-0.7.0.zip - unzip brouter-web-0.7.0.zip -d brouter-web + - using the latest stable release - adjust to current version number - from + https://github.com/nrenner/brouter-web/releases: - * OR the current development state (potentially instable and without runtime distributables): + wget https://github.com/nrenner/brouter-web/releases/download/0.7.0/brouter-web-0.7.0.zip + unzip brouter-web-0.7.0.zip -d brouter-web - wget https://github.com/nrenner/brouter-web/archive/master.zip - unzip master.zip - mv brouter-web-master brouter-web + - OR the current development state (potentially instable and without runtime distributables): - * build the distributable files required for runtime (only for development state), see section [Build](#build) + wget https://github.com/nrenner/brouter-web/archive/master.zip + unzip master.zip + mv brouter-web-master brouter-web -2. copy ``config.template.js`` to ``config.js`` -3. configure URL to ``profiles2`` directory -set ``BR.conf.profilesUrl`` in config.js, e.g. uncomment: + - build the distributable files required for runtime (only for development state), see section [Build](#build) - BR.conf.profilesUrl = 'http://localhost:8000/profiles2/'; +2. copy `config.template.js` to `config.js` +3. configure URL to `profiles2` directory + set `BR.conf.profilesUrl` in config.js, e.g. uncomment: -4. add your API keys (optional) -copy ``keys.template.js`` to ``keys.js`` and edit to add your keys + BR.conf.profilesUrl = 'http://localhost:8000/profiles2/'; + +4. add your API keys (optional) + copy `keys.template.js` to `keys.js` and edit to add your keys ### Run -1. start BRouter server in the ``standalone`` directory with ``./server.sh`` or ``server.cmd`` (Windows) -2. serve the ``brouter`` directory for BRouter-Web -This is needed for pre-loading the selected profile (unless you allowed local file access in the Browser). Depending on your setup (see [How to run things locally](https://github.com/mrdoob/three.js/wiki/How-to-run-things-locally)), start a web server in the ``brouter`` directory, e.g.: +1. start BRouter server in the `standalone` directory with `./server.sh` or `server.cmd` (Windows) +2. serve the `brouter` directory for BRouter-Web + This is needed for pre-loading the selected profile (unless you allowed local file access in the Browser). Depending on your setup (see [How to run things locally](https://github.com/mrdoob/three.js/wiki/How-to-run-things-locally)), start a web server in the `brouter` directory, e.g.: - python -m SimpleHTTPServer + python -m SimpleHTTPServer -2. open http://localhost:8000/brouter-web/ +3. open http://localhost:8000/brouter-web/ ## Build @@ -102,75 +103,75 @@ Copyright (c) 2018 Norbert Renner and [contributors](https://github.com/nrenner/ ## Credits and Licenses -* [BRouter](https://github.com/abrensch/brouter) (not included) -by abrensch; [GNU General Public License, version 3.0 (GPLv3)](https://github.com/abrensch/brouter/blob/master/LICENSE) -* [Leaflet](http://leafletjs.com/) -Copyright (c) 2010-2014, Vladimir Agafonkin; Copyright (c) 2010-2011, CloudMade; [2-clause BSD License](https://github.com/Leaflet/Leaflet/blob/master/LICENSE) -* [leaflet-routing](https://github.com/Turistforeningen/leaflet-routing) -Copyright (c) 2013, Turistforeningen, Hans Kristian Flaatten. All rights reserved. [2-clause BSD License](https://github.com/Turistforeningen/leaflet-routing/blob/gh-pages/LICENSE) -* [Leaflet.Elevation](https://github.com/MrMufflon/Leaflet.Elevation) -Copyright (c) 2013 Felix Bache; [MIT License](https://github.com/MrMufflon/Leaflet.Elevation/blob/master/LICENSE) -* [D3.js](https://github.com/mbostock/d3) -Copyright (c) 2013, Michael Bostock. All rights reserved.; [3-clause BSD License](https://github.com/mbostock/d3/blob/master/LICENSE) -* [Leaflet.Editable](https://github.com/Leaflet/Leaflet.Editable) -Yohan Boniface; WTFPL licence -* [Leaflet Control Geocoder](https://github.com/perliedman/leaflet-control-geocoder) -Copyright (c) 2012 [sa3m](https://github.com/sa3m), Copyright (c) 2013 Per Liedman; [2-clause BSD License](https://github.com/perliedman/leaflet-control-geocoder/blob/master/LICENSE) -* [leaflet-plugins](https://github.com/shramov/leaflet-plugins) -Copyright (c) 2011-2012, Pavel Shramov; [2-clause BSD License](https://github.com/shramov/leaflet-plugins/blob/master/LICENSE) -* [Async.js](https://github.com/caolan/async) -Copyright (c) 2010-2014 Caolan McMahon; [MIT License](https://github.com/caolan/async/blob/master/LICENSE) -* [Bootstrap](https://getbootstrap.com/) -Copyright (c) 2011-2014 Twitter, Inc; [MIT License](https://github.com/twbs/bootstrap/blob/master/LICENSE) -* [jQuery](https://github.com/jquery/jquery) -Copyright 2005, 2014 jQuery Foundation and other contributors; [MIT License](https://github.com/jquery/jquery/blob/master/LICENSE.txt) -* [DataTables](https://github.com/DataTables/DataTables) -Copyright (C) 2008-2014, SpryMedia Ltd.; [MIT License](https://www.datatables.net/license/MIT-LICENCE) -* [Leaflet.EasyButton](https://github.com/CliffCloud/Leaflet.EasyButton) -Copyright (C) 2014 Daniel Montague; [MIT License](https://github.com/CliffCloud/Leaflet.EasyButton/blob/master/LICENSE) -* [Bootbox](https://github.com/makeusabrew/bootbox) -Copyright (C) 2011-2014 by Nick Payne; [MIT License](https://github.com/makeusabrew/bootbox/blob/master/LICENSE.md) -* [bootstrap-slider](https://github.com/seiyria/bootstrap-slider) -Copyright (c) 2015 Kyle Kemp, Rohit Kalkur, and contributors; [MIT License](https://github.com/seiyria/bootstrap-slider/blob/master/LICENSE.md) -* [Leaflet.RestoreView](https://github.com/makinacorpus/Leaflet.RestoreView) -Copyright (c) 2012 Makina Corpus, [MIT License](https://github.com/makinacorpus/Leaflet.RestoreView/blob/master/LICENSE) -* [Leaflet.Locate](https://github.com/domoritz/leaflet-locatecontrol) -Copyright (c) 2014 Dominik Moritz, [MIT License](https://github.com/domoritz/leaflet-locatecontrol/blob/gh-pages/LICENSE) -* [Font Awesome](http://fontawesome.io/license/) -by Dave Gandy; [SIL OFL 1.1](https://scripts.sil.org/OFL) (Font), MIT License (Code), CC BY 3.0 (Documentation) -* [url-search-params](https://github.com/WebReflection/url-search-params) -Copyright (C) 2015-2017 Andrea Giammarchi - @WebReflection; [MIT License](https://github.com/WebReflection/url-search-params/blob/master/LICENSE.txt) -* [bootstrap-select](https://github.com/snapappointments/bootstrap-select) -Copyright (c) 2012-2018 SnapAppointments, LLC; [MIT License](https://github.com/snapappointments/bootstrap-select/blob/v1.13.0-dev/LICENSE) -* [leaflet-sidebar-v2](https://github.com/nickpeihl/leaflet-sidebar-v2) -Copyright (c) 2013 Tobias Bieniek; [MIT License](https://github.com/nickpeihl/leaflet-sidebar-v2/blob/master/LICENSE) -* [CodeMirror](https://github.com/codemirror/CodeMirror) -Copyright (C) 2017 by Marijn Haverbeke and others; [MIT License](https://github.com/codemirror/CodeMirror/blob/master/LICENSE) -* [Map BBCode](https://github.com/MapBBCode/mapbbcode) -Ilya Zverev; [Do What The F*ck You Want To Public License](https://github.com/MapBBCode/mapbbcode/blob/master/LICENSE) -* [Leafet.StravaSegments](https://gitlab.com/bagage/leaflet.stravasegments) -Copyright (c) 2018 Gautier Pelloux-Prayer; [MIT License](https://gitlab.com/bagage/leaflet.stravasegments/blob/master/LICENSE) -* [polyline](https://github.com/mapbox/polyline) -Copyright (c), Development Seed; [BSD 3-Clause License](https://github.com/mapbox/polyline/blob/master/LICENSE) -* [leaflet-fullHash](https://github.com/KoGor/leaflet-fullHash) -Copyright (c) 2014 KoGor; [MIT License](https://github.com/KoGor/leaflet-fullHash/blob/master/LICENSE) -* [Turf.js](https://github.com/Turfjs/turf) -Copyright (c) 2019 Morgan Herlocker; [MIT License](https://github.com/Turfjs/turf/blob/master/LICENSE) -* [i18next](https://github.com/i18next/i18next), [i18next-browser-languageDetector](https://github.com/i18next/i18next-browser-languageDetector), [i18next-xhr-backend](https://github.com/i18next/i18next-xhr-backend), [jquery-i18next](https://github.com/i18next/jquery-i18next/blob/master/LICENSE) -Copyright (c) 2017 i18next; [MIT License](https://github.com/i18next/i18next/blob/master/LICENSE) -* [Leaflet TriangleMarker](https://github.com/themeler/leaflet-triangle-marker) -Copyright (c) 2018 Przemysław Melnarowicz; [MIT License](https://github.com/themeler/leaflet-triangle-marker/blob/master/LICENSE) -* [jsTree ](https://github.com/vakata/jstree) -Copyright (c) 2014 Ivan Bozhanov; [MIT License](https://github.com/vakata/jstree/blob/master/LICENSE-MIT) -* [Leaflet.snogylop](https://github.com/ebrelsford/leaflet.snogylop) -Copyright (c) 2014 Eric Brelsford; [MIT License](https://github.com/ebrelsford/Leaflet.snogylop/blob/master/LICENSE) -* [JOSM maps](https://josm.openstreetmap.de/wiki/Maps) -imagery database is licensed under [CC-BY-SA](https://creativecommons.org/licenses/by-sa/3.0/) -* [LayersCollection](https://github.com/Edward17/LayersCollection/tree/gh-pages) -Copyright (c) 2016 Eduard <edward17>; [MIT License](https://github.com/Edward17/LayersCollection/blob/gh-pages/LICENSE.md) -* [Leaflet-providers](https://github.com/leaflet-extras/leaflet-providers) -Copyright (c) 2013 Leaflet Providers contributors All rights reserved.; [2-clause BSD License](https://github.com/leaflet-extras/leaflet-providers/blob/master/license.md) -* [Fetch polyfill](https://github.com/Github/fetch) -Copyright (c) 2014-2016 GitHub, Inc.; [MIT License](https://github.com/github/fetch/blob/master/LICENSE) -* [Promise Polyfill](https://github.com/taylorhakes/promise-polyfill) -Copyright (c) 2014 Taylor Hakes, Copyright (c) 2014 Forbes Lindesay; [MIT License](https://github.com/taylorhakes/promise-polyfill/blob/master/LICENSE) +- [BRouter](https://github.com/abrensch/brouter) (not included) + by abrensch; [GNU General Public License, version 3.0 (GPLv3)](https://github.com/abrensch/brouter/blob/master/LICENSE) +- [Leaflet](http://leafletjs.com/) + Copyright (c) 2010-2014, Vladimir Agafonkin; Copyright (c) 2010-2011, CloudMade; [2-clause BSD License](https://github.com/Leaflet/Leaflet/blob/master/LICENSE) +- [leaflet-routing](https://github.com/Turistforeningen/leaflet-routing) + Copyright (c) 2013, Turistforeningen, Hans Kristian Flaatten. All rights reserved. [2-clause BSD License](https://github.com/Turistforeningen/leaflet-routing/blob/gh-pages/LICENSE) +- [Leaflet.Elevation](https://github.com/MrMufflon/Leaflet.Elevation) + Copyright (c) 2013 Felix Bache; [MIT License](https://github.com/MrMufflon/Leaflet.Elevation/blob/master/LICENSE) +- [D3.js](https://github.com/mbostock/d3) + Copyright (c) 2013, Michael Bostock. All rights reserved.; [3-clause BSD License](https://github.com/mbostock/d3/blob/master/LICENSE) +- [Leaflet.Editable](https://github.com/Leaflet/Leaflet.Editable) + Yohan Boniface; WTFPL licence +- [Leaflet Control Geocoder](https://github.com/perliedman/leaflet-control-geocoder) + Copyright (c) 2012 [sa3m](https://github.com/sa3m), Copyright (c) 2013 Per Liedman; [2-clause BSD License](https://github.com/perliedman/leaflet-control-geocoder/blob/master/LICENSE) +- [leaflet-plugins](https://github.com/shramov/leaflet-plugins) + Copyright (c) 2011-2012, Pavel Shramov; [2-clause BSD License](https://github.com/shramov/leaflet-plugins/blob/master/LICENSE) +- [Async.js](https://github.com/caolan/async) + Copyright (c) 2010-2014 Caolan McMahon; [MIT License](https://github.com/caolan/async/blob/master/LICENSE) +- [Bootstrap](https://getbootstrap.com/) + Copyright (c) 2011-2014 Twitter, Inc; [MIT License](https://github.com/twbs/bootstrap/blob/master/LICENSE) +- [jQuery](https://github.com/jquery/jquery) + Copyright 2005, 2014 jQuery Foundation and other contributors; [MIT License](https://github.com/jquery/jquery/blob/master/LICENSE.txt) +- [DataTables](https://github.com/DataTables/DataTables) + Copyright (C) 2008-2014, SpryMedia Ltd.; [MIT License](https://www.datatables.net/license/MIT-LICENCE) +- [Leaflet.EasyButton](https://github.com/CliffCloud/Leaflet.EasyButton) + Copyright (C) 2014 Daniel Montague; [MIT License](https://github.com/CliffCloud/Leaflet.EasyButton/blob/master/LICENSE) +- [Bootbox](https://github.com/makeusabrew/bootbox) + Copyright (C) 2011-2014 by Nick Payne; [MIT License](https://github.com/makeusabrew/bootbox/blob/master/LICENSE.md) +- [bootstrap-slider](https://github.com/seiyria/bootstrap-slider) + Copyright (c) 2015 Kyle Kemp, Rohit Kalkur, and contributors; [MIT License](https://github.com/seiyria/bootstrap-slider/blob/master/LICENSE.md) +- [Leaflet.RestoreView](https://github.com/makinacorpus/Leaflet.RestoreView) + Copyright (c) 2012 Makina Corpus, [MIT License](https://github.com/makinacorpus/Leaflet.RestoreView/blob/master/LICENSE) +- [Leaflet.Locate](https://github.com/domoritz/leaflet-locatecontrol) + Copyright (c) 2014 Dominik Moritz, [MIT License](https://github.com/domoritz/leaflet-locatecontrol/blob/gh-pages/LICENSE) +- [Font Awesome](http://fontawesome.io/license/) + by Dave Gandy; [SIL OFL 1.1](https://scripts.sil.org/OFL) (Font), MIT License (Code), CC BY 3.0 (Documentation) +- [url-search-params](https://github.com/WebReflection/url-search-params) + Copyright (C) 2015-2017 Andrea Giammarchi - @WebReflection; [MIT License](https://github.com/WebReflection/url-search-params/blob/master/LICENSE.txt) +- [bootstrap-select](https://github.com/snapappointments/bootstrap-select) + Copyright (c) 2012-2018 SnapAppointments, LLC; [MIT License](https://github.com/snapappointments/bootstrap-select/blob/v1.13.0-dev/LICENSE) +- [leaflet-sidebar-v2](https://github.com/nickpeihl/leaflet-sidebar-v2) + Copyright (c) 2013 Tobias Bieniek; [MIT License](https://github.com/nickpeihl/leaflet-sidebar-v2/blob/master/LICENSE) +- [CodeMirror](https://github.com/codemirror/CodeMirror) + Copyright (C) 2017 by Marijn Haverbeke and others; [MIT License](https://github.com/codemirror/CodeMirror/blob/master/LICENSE) +- [Map BBCode](https://github.com/MapBBCode/mapbbcode) + Ilya Zverev; [Do What The F\*ck You Want To Public License](https://github.com/MapBBCode/mapbbcode/blob/master/LICENSE) +- [Leafet.StravaSegments](https://gitlab.com/bagage/leaflet.stravasegments) + Copyright (c) 2018 Gautier Pelloux-Prayer; [MIT License](https://gitlab.com/bagage/leaflet.stravasegments/blob/master/LICENSE) +- [polyline](https://github.com/mapbox/polyline) + Copyright (c), Development Seed; [BSD 3-Clause License](https://github.com/mapbox/polyline/blob/master/LICENSE) +- [leaflet-fullHash](https://github.com/KoGor/leaflet-fullHash) + Copyright (c) 2014 KoGor; [MIT License](https://github.com/KoGor/leaflet-fullHash/blob/master/LICENSE) +- [Turf.js](https://github.com/Turfjs/turf) + Copyright (c) 2019 Morgan Herlocker; [MIT License](https://github.com/Turfjs/turf/blob/master/LICENSE) +- [i18next](https://github.com/i18next/i18next), [i18next-browser-languageDetector](https://github.com/i18next/i18next-browser-languageDetector), [i18next-xhr-backend](https://github.com/i18next/i18next-xhr-backend), [jquery-i18next](https://github.com/i18next/jquery-i18next/blob/master/LICENSE) + Copyright (c) 2017 i18next; [MIT License](https://github.com/i18next/i18next/blob/master/LICENSE) +- [Leaflet TriangleMarker](https://github.com/themeler/leaflet-triangle-marker) + Copyright (c) 2018 Przemysław Melnarowicz; [MIT License](https://github.com/themeler/leaflet-triangle-marker/blob/master/LICENSE) +- [jsTree ](https://github.com/vakata/jstree) + Copyright (c) 2014 Ivan Bozhanov; [MIT License](https://github.com/vakata/jstree/blob/master/LICENSE-MIT) +- [Leaflet.snogylop](https://github.com/ebrelsford/leaflet.snogylop) + Copyright (c) 2014 Eric Brelsford; [MIT License](https://github.com/ebrelsford/Leaflet.snogylop/blob/master/LICENSE) +- [JOSM maps](https://josm.openstreetmap.de/wiki/Maps) + imagery database is licensed under [CC-BY-SA](https://creativecommons.org/licenses/by-sa/3.0/) +- [LayersCollection](https://github.com/Edward17/LayersCollection/tree/gh-pages) + Copyright (c) 2016 Eduard <edward17>; [MIT License](https://github.com/Edward17/LayersCollection/blob/gh-pages/LICENSE.md) +- [Leaflet-providers](https://github.com/leaflet-extras/leaflet-providers) + Copyright (c) 2013 Leaflet Providers contributors All rights reserved.; [2-clause BSD License](https://github.com/leaflet-extras/leaflet-providers/blob/master/license.md) +- [Fetch polyfill](https://github.com/Github/fetch) + Copyright (c) 2014-2016 GitHub, Inc.; [MIT License](https://github.com/github/fetch/blob/master/LICENSE) +- [Promise Polyfill](https://github.com/taylorhakes/promise-polyfill) + Copyright (c) 2014 Taylor Hakes, Copyright (c) 2014 Forbes Lindesay; [MIT License](https://github.com/taylorhakes/promise-polyfill/blob/master/LICENSE) diff --git a/config.template.js b/config.template.js index 6cdd571..2173a88 100644 --- a/config.template.js +++ b/config.template.js @@ -1,5 +1,4 @@ (function() { - var hostname = window.location.hostname; var params = new URLSearchParams(window.location.search.slice(1)); @@ -13,7 +12,6 @@ //BR.conf.transit = params.has('transit') && (params.get('transit') === 'true'); if (hostname === 'brouter.de' || hostname === 'h2096617.stratoserver.net') { - // online service (brouter.de) configuration BR.conf.profiles = [ @@ -39,9 +37,7 @@ BR.conf.host = 'http://h2096617.stratoserver.net:443'; BR.conf.profilesUrl = 'http://brouter.de/brouter/profiles2/'; - } else { - // desktop configuration BR.conf.profiles = [ @@ -114,7 +110,6 @@ // transit (intermodal routing) demo config if (BR.conf.transit) { - BR.conf.profiles = [ '../im/bike', '../im/foot', @@ -126,6 +121,5 @@ 'moped', 'car-test' ]; - } })(); diff --git a/css/style.css b/css/style.css index 1d4394d..fdcba2d 100644 --- a/css/style.css +++ b/css/style.css @@ -1,11 +1,14 @@ -html, body, #map { +html, +body, +#map { height: 100%; } /* This is important so that bootstrap-select list goes over leaflet buttons Since the list is in navbar and leaflet buttons within map, we create a stacking context on their common ancestor */ -body, #content { +body, +#content { position: relative; z-index: 1; } @@ -60,7 +63,7 @@ table.dataTable { .navbar { /* align with leaflet-control */ - padding: .5rem 10px; + padding: 0.5rem 10px; } .navbar-brand { float: right; @@ -118,7 +121,7 @@ footer { } .form-group { - margin-bottom: 0 + margin-bottom: 0; } /* @@ -133,18 +136,18 @@ footer { /* diagram colors lighter, less dominant */ .steelblue-theme.leaflet-control.elevation .background { - background-color: rgba(105, 155, 196, 0.2); + background-color: rgba(105, 155, 196, 0.2); } .steelblue-theme.leaflet-control.elevation .axis path, .steelblue-theme.leaflet-control.elevation .axis line { - stroke: #8398aa; - shape-rendering: crispEdges; + stroke: #8398aa; + shape-rendering: crispEdges; } .steelblue-theme.leaflet-control.elevation .axis text { - fill: #8398aa; + fill: #8398aa; } .steelblue-theme.leaflet-control.elevation .area { - fill: #699bc4; + fill: #699bc4; } #elevation-btn { @@ -152,7 +155,6 @@ footer { margin-right: 0.5rem; } - .routing-draw-enabled { cursor: crosshair; } @@ -182,7 +184,8 @@ footer { } /* track messages (data tab) */ -#tab_data, .CodeMirror { +#tab_data, +.CodeMirror { font-size: x-small; } @@ -237,7 +240,8 @@ https://css-tricks.com/svg-line-animation-works/ width: 8px; margin-left: 1px; background-image: linear-gradient(to right, #f0f0f0 0%, #e9e9e9 100%); - box-shadow: inset -1px -0px 1px rgba(55, 55, 55, 0.3), inset 1px 0px 1px rgba(230, 230, 230, 1); + box-shadow: inset -1px -0px 1px rgba(55, 55, 55, 0.3), + inset 1px 0px 1px rgba(230, 230, 230, 1); } .control-slider:hover .slider-track, @@ -246,7 +250,7 @@ https://css-tricks.com/svg-line-animation-works/ } .slider-selection { - background-color: #C6C6C6; + background-color: #c6c6c6; background-image: none; box-shadow: inset 1px 1px 3px rgba(0, 0, 0, 0.6); } @@ -259,17 +263,21 @@ https://css-tricks.com/svg-line-animation-works/ outline: none; /* bootstrap .btn-default */ - background-image: linear-gradient(to bottom,#fff 0,#e0e0e0 100%); + background-image: linear-gradient(to bottom, #fff 0, #e0e0e0 100%); background-repeat: repeat-x; - box-shadow: inset 0 1px 0 rgba(255,255,255,.15),0 1px 1px rgba(0,0,0,.075); + box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15), + 0 1px 1px rgba(0, 0, 0, 0.075); border: 1px solid #adadad; } /* activated Font Awesome icon and Bootstrap button (for EasyButton add ' active' to icon class property) */ -.fa.active, .btn.active, .btn.active:hover, .btn.active:focus { +.fa.active, +.btn.active, +.btn.active:hover, +.btn.active:focus { /* use same color as leaflet-locatecontrol */ - color: #2074B6; + color: #2074b6; } .leaflet-bar button { @@ -337,7 +345,7 @@ table.dataTable.hover tbody tr.even:hover, table.dataTable.display tbody tr:hover, table.dataTable.display tbody tr.odd:hover, table.dataTable.display tbody tr.even:hover { - background-color: rgba(255,255,0,0.2); + background-color: rgba(255, 255, 0, 0.2); } /* @@ -360,9 +368,9 @@ table.dataTable.display tbody tr.even:hover { .editing-tooltip, .editing-tooltip-create { color: #fff; - background-color: rgba(0,0,0,0.7); + background-color: rgba(0, 0, 0, 0.7); /* for direction arrows that inherit */ - border-color: rgba(0,0,0,0.7); + border-color: rgba(0, 0, 0, 0.7); /* no border but still set a color for direction arrows */ border-width: 0px; } @@ -371,7 +379,7 @@ table.dataTable.display tbody tr.even:hover { border-color: transparent; } .leaflet-tooltip-bottom:before { - border-bottom-color: inherit; + border-bottom-color: inherit; } .leaflet-tooltip-right:before { border-right-color: inherit; @@ -424,19 +432,19 @@ table.dataTable.display tbody tr.even:hover { } .tree-code { - font-family: Menlo, Consolas, Monaco, Liberation Mono, Lucida Console, monospace; + font-family: Menlo, Consolas, Monaco, Liberation Mono, Lucida Console, + monospace; margin-right: 7px; color: #666; /* like root nodes, jstree-disabled */ } - /* hide currently unused bottom tabs container because of touch border artefacts */ .leaflet-sidebar-tabs > ul:last-child { display: none; } /* layers svg icon not properly centered */ -.leaflet-sidebar-tabs > ul > li > a[href="#tab_layers_control"] { +.leaflet-sidebar-tabs > ul > li > a[href='#tab_layers_control'] { display: flex; align-items: center; justify-content: center; @@ -454,7 +462,8 @@ table.dataTable.display tbody tr.even:hover { border: 1px solid #ddd; - font-family: Menlo, Consolas, Monaco, Liberation Mono, Lucida Console, monospace; + font-family: Menlo, Consolas, Monaco, Liberation Mono, Lucida Console, + monospace; line-height: 1.2em; } diff --git a/gulpfile.js b/gulpfile.js index 6c35636..cf9b52c 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -24,284 +24,367 @@ var modifyCssUrls = require('gulp-modify-css-urls'); var sort = require('gulp-sort'); var scanner = require('i18next-scanner'); var jsonConcat = require('gulp-json-concat'); -var rename = require("gulp-rename"); +var rename = require('gulp-rename'); var debug = false; var paths = { - // see overrides in package.json - scriptsConfig: mainNpmFiles().filter(f => RegExp('url-search-params/.*\\.js', 'i').test(f)), - scripts: [ - 'node_modules/jquery/dist/jquery.js', - 'node_modules/tether/dist/js/tether.js', - 'node_modules/async/lib/async.js' - ].concat(mainNpmFiles().filter(f => - RegExp('.*\\.js', 'i').test(f) && - !RegExp('.*\\.min\\.js', 'i').test(f) && - !RegExp('url-search-params/.*\\.js', 'i').test(f) - )).concat([ - 'js/Browser.js', - 'js/Util.js', - 'js/Map.js', - 'js/LayersConfig.js', - 'js/router/BRouter.js', - 'js/plugin/*.js', - 'js/control/*.js', - 'js/index.js' - ]), - styles: mainNpmFiles().filter(f => - RegExp('.*\\.css', 'i').test(f) && - !RegExp('.*\\.min\\.css', 'i').test(f) - ).concat('css/*.css'), - images: mainNpmFiles().filter(f => RegExp('.*.+(png|gif|svg)', 'i').test(f)), - fonts: mainNpmFiles().filter(f => RegExp('font-awesome/fonts/.*', 'i').test(f)), - locales: 'locales/*.json', - layers: 'layers/**/*.geojson', - layersDestName: 'layers.js', - layersConfig: [ - 'layers/config/config.js', - 'layers/config/tree.js', - 'layers/config/overrides.js', - 'layers/config/geometry.js' - ], - layersConfigDestName: 'layersConf.js', - dest: 'dist', - destName: 'brouter-web' + // see overrides in package.json + scriptsConfig: mainNpmFiles().filter(f => + RegExp('url-search-params/.*\\.js', 'i').test(f) + ), + scripts: [ + 'node_modules/jquery/dist/jquery.js', + 'node_modules/tether/dist/js/tether.js', + 'node_modules/async/lib/async.js' + ] + .concat( + mainNpmFiles().filter( + f => + RegExp('.*\\.js', 'i').test(f) && + !RegExp('.*\\.min\\.js', 'i').test(f) && + !RegExp('url-search-params/.*\\.js', 'i').test(f) + ) + ) + .concat([ + 'js/Browser.js', + 'js/Util.js', + 'js/Map.js', + 'js/LayersConfig.js', + 'js/router/BRouter.js', + 'js/plugin/*.js', + 'js/control/*.js', + 'js/index.js' + ]), + styles: mainNpmFiles() + .filter( + f => + RegExp('.*\\.css', 'i').test(f) && + !RegExp('.*\\.min\\.css', 'i').test(f) + ) + .concat('css/*.css'), + images: mainNpmFiles().filter(f => + RegExp('.*.+(png|gif|svg)', 'i').test(f) + ), + fonts: mainNpmFiles().filter(f => + RegExp('font-awesome/fonts/.*', 'i').test(f) + ), + locales: 'locales/*.json', + layers: 'layers/**/*.geojson', + layersDestName: 'layers.js', + layersConfig: [ + 'layers/config/config.js', + 'layers/config/tree.js', + 'layers/config/overrides.js', + 'layers/config/geometry.js' + ], + layersConfigDestName: 'layersConf.js', + dest: 'dist', + destName: 'brouter-web' }; // libs that require loading before config.js gulp.task('scripts_config', ['clean'], function() { - // just copy for now - return gulp.src(paths.scriptsConfig) - .pipe(gulp.dest(paths.dest)); + // just copy for now + return gulp.src(paths.scriptsConfig).pipe(gulp.dest(paths.dest)); }); gulp.task('scripts', function() { - if (debug) - gutil.log( gutil.colors.yellow('Running in Debug mode') ); - else - gutil.log( gutil.colors.green('Running in Release mode') ); + if (debug) gutil.log(gutil.colors.yellow('Running in Debug mode')); + else gutil.log(gutil.colors.green('Running in Release mode')); - return gulp.src(paths.scripts, { base: '.' }) - .pipe(sourcemaps.init()) - .pipe(cached('scripts')) - .pipe(gulpif(!debug, uglify())) - .pipe(remember('scripts')) - .pipe(concat(paths.destName + '.js')) - .pipe(sourcemaps.write('.')) - .pipe(gulp.dest(paths.dest)); + return gulp + .src(paths.scripts, { base: '.' }) + .pipe(sourcemaps.init()) + .pipe(cached('scripts')) + .pipe(gulpif(!debug, uglify())) + .pipe(remember('scripts')) + .pipe(concat(paths.destName + '.js')) + .pipe(sourcemaps.write('.')) + .pipe(gulp.dest(paths.dest)); }); // separate, fallback task for debugging (switch manually in index.html) gulp.task('concat', function() { - return gulp.src(paths.scripts) - .pipe(concat(paths.destName + '.src.js')) - .pipe(gulp.dest(paths.dest)); + return gulp + .src(paths.scripts) + .pipe(concat(paths.destName + '.src.js')) + .pipe(gulp.dest(paths.dest)); }); gulp.task('styles', function() { - return gulp.src(paths.styles) - .pipe(modifyCssUrls({ - modify(url, filePath) { - var distUrl = url; - var imageExt = ['.png', '.gif', '.svg']; + return gulp + .src(paths.styles) + .pipe( + modifyCssUrls({ + modify(url, filePath) { + var distUrl = url; + var imageExt = ['.png', '.gif', '.svg']; - if (imageExt.indexOf(path.extname(url)) !== -1) { - distUrl = 'images/' + path.basename(url); - } else if (url.indexOf('font') !== -1) { - distUrl = 'fonts/' + path.basename(url); - } + if (imageExt.indexOf(path.extname(url)) !== -1) { + distUrl = 'images/' + path.basename(url); + } else if (url.indexOf('font') !== -1) { + distUrl = 'fonts/' + path.basename(url); + } - return distUrl; - } - })) - .pipe(concat(paths.destName + '.css')) - .pipe(cleanCSS({ - rebase: false - })) - .pipe(postcss([ autoprefixer({ remove: false }) ])) - .pipe(gulp.dest(paths.dest)); + return distUrl; + } + }) + ) + .pipe(concat(paths.destName + '.css')) + .pipe( + cleanCSS({ + rebase: false + }) + ) + .pipe(postcss([autoprefixer({ remove: false })])) + .pipe(gulp.dest(paths.dest)); }); gulp.task('images', ['clean'], function() { - return gulp.src(paths.images) - .pipe(gulp.dest(paths.dest + '/images')); + return gulp.src(paths.images).pipe(gulp.dest(paths.dest + '/images')); }); gulp.task('fonts', ['clean'], function() { - return gulp.src(paths.fonts) - .pipe(gulp.dest(paths.dest + '/fonts')); + return gulp.src(paths.fonts).pipe(gulp.dest(paths.dest + '/fonts')); }); gulp.task('locales', ['clean'], function() { - return gulp.src(paths.locales) - .pipe(gulp.dest(paths.dest + '/locales')); + return gulp.src(paths.locales).pipe(gulp.dest(paths.dest + '/locales')); }); gulp.task('clean', function(cb) { - del(paths.dest + '/**/*' , cb); + del(paths.dest + '/**/*', cb); }); gulp.task('watch', function() { - debug = true; - var watcher = gulp.watch(paths.scripts, ['scripts']); - watcher.on('change', function (event) { - if (event.type === 'deleted') { - delete cached.caches.scripts[event.path]; - remember.forget('scripts', event.path); - } - }); - gulp.watch(paths.styles, ['styles']); - gulp.watch(paths.layersConfig, ['layers_config']); + debug = true; + var watcher = gulp.watch(paths.scripts, ['scripts']); + watcher.on('change', function(event) { + if (event.type === 'deleted') { + delete cached.caches.scripts[event.path]; + remember.forget('scripts', event.path); + } + }); + gulp.watch(paths.styles, ['styles']); + gulp.watch(paths.layersConfig, ['layers_config']); }); // Print paths to console, for manually debugging the gulp build // (comment out corresponding line of paths to print) gulp.task('log', function() { - //return gulp.src(paths.scripts) - //return gulp.src(paths.styles) - //return gulp.src(paths.images) - // return gulp.src(paths.locales) - return gulp.src(paths.scripts.concat(paths.styles).concat(paths.images).concat(paths.locales)) - .pipe(gulpDebug()); - + //return gulp.src(paths.scripts) + //return gulp.src(paths.styles) + //return gulp.src(paths.images) + // return gulp.src(paths.locales) + return gulp + .src( + paths.scripts + .concat(paths.styles) + .concat(paths.images) + .concat(paths.locales) + ) + .pipe(gulpDebug()); }); -gulp.task('inject', function () { - var target = gulp.src('index.html'); - var sources = gulp.src(paths.scripts.concat(paths.styles), { base: '.', read: false }); +gulp.task('inject', function() { + var target = gulp.src('index.html'); + var sources = gulp.src(paths.scripts.concat(paths.styles), { + base: '.', + read: false + }); - return target.pipe(inject(sources, { relative: true })) - .pipe(gulp.dest('.')); + return target + .pipe(inject(sources, { relative: true })) + .pipe(gulp.dest('.')); }); -gulp.task('default', ['clean', 'scripts_config', 'layers', 'scripts', 'styles', 'images', 'fonts', 'locales']); +gulp.task('default', [ + 'clean', + 'scripts_config', + 'layers', + 'scripts', + 'styles', + 'images', + 'fonts', + 'locales' +]); gulp.task('debug', function() { - debug = true; - gulp.start('default'); + debug = true; + gulp.start('default'); }); var pkg = require('./package.json'); -var tags = {patch: 'patch', minor: 'minor', major: 'major'}; +var tags = { patch: 'patch', minor: 'minor', major: 'major' }; var nextVersion; var ghToken; gulp.task('release:init', function() { - var tag = gutil.env.tag; - if (!tag) { - gutil.log(gutil.colors.red('--tag is required')); - process.exit(1); - } - if (['major', 'minor', 'patch'].indexOf(tag) < 0) { - gutil.log(gutil.colors.red('--tag must be major, minor or patch')); - process.exit(2); - } - ghToken = gutil.env.token; - if (!ghToken) { - gutil.log(gutil.colors.red('--token is required (github personnal access token)')); - process.exit(3); - } - if (ghToken.length != 40) { - gutil.log(gutil.colors.red('--token length must be 40')); - process.exit(4); - } - git.status({args: '--porcelain', quiet: true}, function(err, stdout) { - if (err) throw err; - if (stdout.length > 0) { - gutil.log(gutil.colors.red('Repository is not clean. Please commit or stash your pending modification')); - process.exit(5); + var tag = gutil.env.tag; + if (!tag) { + gutil.log(gutil.colors.red('--tag is required')); + process.exit(1); } - }); - nextVersion = semver.inc(pkg.version, tag); - return; + if (['major', 'minor', 'patch'].indexOf(tag) < 0) { + gutil.log(gutil.colors.red('--tag must be major, minor or patch')); + process.exit(2); + } + ghToken = gutil.env.token; + if (!ghToken) { + gutil.log( + gutil.colors.red( + '--token is required (github personnal access token)' + ) + ); + process.exit(3); + } + if (ghToken.length != 40) { + gutil.log(gutil.colors.red('--token length must be 40')); + process.exit(4); + } + git.status({ args: '--porcelain', quiet: true }, function(err, stdout) { + if (err) throw err; + if (stdout.length > 0) { + gutil.log( + gutil.colors.red( + 'Repository is not clean. Please commit or stash your pending modification' + ) + ); + process.exit(5); + } + }); + nextVersion = semver.inc(pkg.version, tag); + return; }); gulp.task('bump', ['bump:json', 'bump:html']); gulp.task('bump:json', ['release:init'], function() { - gutil.log(gutil.colors.green('Bump to '+nextVersion)); - return(gulp.src(['./package.json']) - .pipe(bump({version: nextVersion})) - .pipe(gulp.dest('./'))); + gutil.log(gutil.colors.green('Bump to ' + nextVersion)); + return gulp + .src(['./package.json']) + .pipe(bump({ version: nextVersion })) + .pipe(gulp.dest('./')); }); gulp.task('bump:html', ['release:init'], function() { - return(gulp.src('./index.html') - .pipe(replace(/(.*)<\/sup>/, ''+nextVersion+'')) - .pipe(gulp.dest('.'))); + return gulp + .src('./index.html') + .pipe( + replace( + /(.*)<\/sup>/, + '' + nextVersion + '' + ) + ) + .pipe(gulp.dest('.')); }); gulp.task('release:commit', ['bump'], function() { - return gulp.src(['./index.html', './package.json']) - .pipe(git.commit('release: '+nextVersion)); + return gulp + .src(['./index.html', './package.json']) + .pipe(git.commit('release: ' + nextVersion)); }); gulp.task('release:tag', ['release:commit'], function() { - return(git.tag(nextVersion, '', function(err) { - if (err) throw err; - })); + return git.tag(nextVersion, '', function(err) { + if (err) throw err; + }); }); gulp.task('release:push', ['release:tag'], function() { - git.push('origin', 'master', {args: '--tags'}, function(err) { - if (err) throw err; - }); + git.push('origin', 'master', { args: '--tags' }, function(err) { + if (err) throw err; + }); }); gulp.task('release:zip', ['release:tag', 'default'], function() { - gutil.log(gutil.colors.green('Build brouter-web.'+nextVersion+'.zip')); - return(gulp.src(['dist/**', 'index.html', 'config.template.js', 'keys.template.js'], {'base': '.'}) - .pipe(zip('brouter-web.'+nextVersion+'.zip')) - .pipe(gulp.dest('.'))); + gutil.log(gutil.colors.green('Build brouter-web.' + nextVersion + '.zip')); + return gulp + .src( + ['dist/**', 'index.html', 'config.template.js', 'keys.template.js'], + { + base: '.' + } + ) + .pipe(zip('brouter-web.' + nextVersion + '.zip')) + .pipe(gulp.dest('.')); }); gulp.task('release:publish', ['release:zip'], function() { - gulp.src('./brouter-web.'+nextVersion+'.zip') - .pipe(release({ - tag: nextVersion, - token: ghToken, - manifest: pkg, - })) + gulp.src('./brouter-web.' + nextVersion + '.zip').pipe( + release({ + tag: nextVersion, + token: ghToken, + manifest: pkg + }) + ); }); -gulp.task('release', ['release:init', 'bump', 'release:commit', 'release:tag', - 'release:push', 'release:zip', 'release:publish']); +gulp.task('release', [ + 'release:init', + 'bump', + 'release:commit', + 'release:tag', + 'release:push', + 'release:zip', + 'release:publish' +]); gulp.task('i18next', function() { - return gulp.src(['index.html', 'locales/keys.js', 'layers/config/overrides.js', 'js/**/*.js']) - .pipe(sort()) - .pipe(scanner({ - lngs: ['en'], // we only generate English version, other languages are handled by transifex via yarn transifex-pull/push - removeUnusedKeys: true, - sort: true, - resource: { - // the source path is relative to current working directory - loadPath: 'locales/{{lng}}.json', + return gulp + .src([ + 'index.html', + 'locales/keys.js', + 'layers/config/overrides.js', + 'js/**/*.js' + ]) + .pipe(sort()) + .pipe( + scanner({ + lngs: ['en'], // we only generate English version, other languages are handled by transifex via yarn transifex-pull/push + removeUnusedKeys: true, + sort: true, + resource: { + // the source path is relative to current working directory + loadPath: 'locales/{{lng}}.json', - // the destination path is relative to your `gulp.dest()` path - savePath: 'locales/{{lng}}.json' - } - })) - .pipe(gulp.dest('.')); -}) + // the destination path is relative to your `gulp.dest()` path + savePath: 'locales/{{lng}}.json' + } + }) + ) + .pipe(gulp.dest('.')); +}); -gulp.task('layers_config', function () { - return gulp.src(paths.layersConfig) - .pipe(concat(paths.layersConfigDestName)) - .pipe(gulp.dest(paths.dest)); +gulp.task('layers_config', function() { + return gulp + .src(paths.layersConfig) + .pipe(concat(paths.layersConfigDestName)) + .pipe(gulp.dest(paths.dest)); }); // Bundles layer files. To download and extract run "yarn layers" -gulp.task('layers', ['layers_config'], function () { - return gulp.src(paths.layers) - // Workaround to get file extension removed from the dictionary key - .pipe(rename({ extname: ".json" })) - .pipe(jsonConcat(paths.layersDestName, function(data){ - var header = '// 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' - + '// see https://josm.openstreetmap.de/wiki/Maps#Otherimportantinformation\n'; - return Buffer.from(header + 'BR.layerIndex = ' + JSON.stringify(data, null, 2) + ';'); - })) - .pipe(gulp.dest(paths.dest)); +gulp.task('layers', ['layers_config'], function() { + return ( + gulp + .src(paths.layers) + // Workaround to get file extension removed from the dictionary key + .pipe(rename({ extname: '.json' })) + .pipe( + jsonConcat(paths.layersDestName, function(data) { + var header = + '// 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' + + '// see https://josm.openstreetmap.de/wiki/Maps#Otherimportantinformation\n'; + return Buffer.from( + header + + 'BR.layerIndex = ' + + JSON.stringify(data, null, 2) + + ';' + ); + }) + ) + .pipe(gulp.dest(paths.dest)) + ); }); diff --git a/index.html b/index.html index d854f35..07e5e67 100644 --- a/index.html +++ b/index.html @@ -1,346 +1,926 @@ - - - - + + + + - BRouter web client + BRouter web client - - - - - - - -