").css({position:"absolute",width:e.outerWidth(),height:e.outerHeight()}).appendTo(e.parent()).offset(e.offset())[0]})},_unblockFrames:function(){this.iframeBlocks&&(this.iframeBlocks.remove(),delete this.iframeBlocks)},_allowInteraction:function(e){return t(e.target).closest(".ui-dialog").length?!0:!!t(e.target).closest(".ui-datepicker").length},_createOverlay:function(){if(this.options.modal){var e=!0;this._delay(function(){e=!1}),this.document.data("ui-dialog-overlays")||this._on(this.document,{focusin:function(t){e||this._allowInteraction(t)||(t.preventDefault(),this._trackingInstances()[0]._focusTabbable())}}),this.overlay=t("
").appendTo(this._appendTo()),this._addClass(this.overlay,null,"ui-widget-overlay ui-front"),this._on(this.overlay,{mousedown:"_keepFocus"}),this.document.data("ui-dialog-overlays",(this.document.data("ui-dialog-overlays")||0)+1)}},_destroyOverlay:function(){if(this.options.modal&&this.overlay){var t=this.document.data("ui-dialog-overlays")-1;t?this.document.data("ui-dialog-overlays",t):(this._off(this.document,"focusin"),this.document.removeData("ui-dialog-overlays")),this.overlay.remove(),this.overlay=null}}}),t.uiBackCompat!==!1&&t.widget("ui.dialog",t.ui.dialog,{options:{dialogClass:""},_createWrapper:function(){this._super(),this.uiDialog.addClass(this.options.dialogClass)},_setOption:function(t,e){"dialogClass"===t&&this.uiDialog.removeClass(this.options.dialogClass).addClass(e),this._superApply(arguments)}}),t.ui.dialog});
\ No newline at end of file
diff --git a/src/main/resources/de/geofabrik/openrailrouting/maps/js/lib/jquery.autocomplete.js b/src/main/resources/de/geofabrik/openrailrouting/maps/js/lib/jquery.autocomplete.js
deleted file mode 100644
index bbacf00..0000000
--- a/src/main/resources/de/geofabrik/openrailrouting/maps/js/lib/jquery.autocomplete.js
+++ /dev/null
@@ -1,831 +0,0 @@
-/**
-* Ajax Autocomplete for jQuery, version 1.2.9
-* (c) 2013 Tomas Kirda
-*
-* Ajax Autocomplete for jQuery is freely distributable under the terms of an MIT-style license.
-* For details, see the web site: https://github.com/devbridge/jQuery-Autocomplete
-*
-*/
-
-/*jslint browser: true, white: true, plusplus: true */
-/*global define, window, document, jQuery */
-
-// Expose plugin as an AMD module if AMD loader is present:
-(function (factory) {
- 'use strict';
- if (typeof define === 'function' && define.amd) {
- // AMD. Register as an anonymous module.
- define(['jquery'], factory);
- } else {
- // Browser globals
- factory(jQuery);
- }
-}(function ($) {
- 'use strict';
-
- var
- utils = (function () {
- return {
- escapeRegExChars: function (value) {
- return value.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
- },
- createNode: function (containerClass) {
- var div = document.createElement('div');
- div.className = containerClass;
- div.style.position = 'absolute';
- div.style.display = 'none';
- div.style.cursor = 'pointer';
- return div;
- }
- };
- }()),
-
- keys = {
- ESC: 27,
- TAB: 9,
- RETURN: 13,
- LEFT: 37,
- UP: 38,
- RIGHT: 39,
- DOWN: 40
- };
-
- function Autocomplete(el, options) {
- var noop = function () { },
- that = this,
- defaults = {
- autoSelectFirst: false,
- appendTo: 'body',
- serviceUrl: null,
- lookup: null,
- onSelect: null,
- width: 'auto',
- minChars: 1,
- maxHeight: 300,
- deferRequestBy: 0,
- params: {},
- formatResult: Autocomplete.formatResult,
- onPreSelect: noop,
- delimiter: null,
- zIndex: 9999,
- type: 'GET',
- noCache: false,
- onSearchStart: noop,
- onSearchComplete: noop,
- onSearchError: noop,
- containerClass: 'autocomplete-suggestions',
- tabDisabled: false,
- dataType: 'text',
- currentRequest: null,
- triggerSelectOnValidInput: true,
- lookupFilter: function (suggestion, originalQuery, queryLowerCase) {
- return suggestion.value.toLowerCase().indexOf(queryLowerCase) !== -1;
- },
- paramName: 'query',
- transformResult: function (response) {
- return typeof response === 'string' ? $.parseJSON(response) : response;
- }
- };
-
- // Shared variables:
- that.element = el;
- that.el = $(el);
- that.suggestions = [];
- that.badQueries = [];
- that.selectedIndex = -1;
- that.currentValue = that.element.value;
- that.intervalId = 0;
- that.cachedResponse = {};
- that.onChangeInterval = null;
- that.onChange = null;
- that.isLocal = false;
- that.suggestionsContainer = null;
- that.options = $.extend({}, defaults, options);
- that.classes = {
- selected: 'autocomplete-selected',
- suggestion: 'autocomplete-suggestion'
- };
- that.hint = null;
- that.hintValue = '';
- that.selection = null;
-
- // Initialize and set options:
- that.initialize();
- that.setOptions(options);
- }
-
- Autocomplete.utils = utils;
-
- $.Autocomplete = Autocomplete;
-
- Autocomplete.formatResult = function (suggestion, currentValue) {
- var pattern = '(' + utils.escapeRegExChars(currentValue) + ')';
-
- return suggestion.value.replace(new RegExp(pattern, 'gi'), '
$1<\/strong>');
- };
-
- Autocomplete.prototype = {
-
- killerFn: null,
-
- initialize: function () {
- var that = this,
- suggestionSelector = '.' + that.classes.suggestion,
- selected = that.classes.selected,
- options = that.options,
- container;
-
- // Remove autocomplete attribute to prevent native suggestions:
- that.element.setAttribute('autocomplete', 'off');
-
- that.killerFn = function (e) {
- if ($(e.target).closest('.' + that.options.containerClass).length === 0) {
- that.killSuggestions();
- that.disableKillerFn();
- }
- };
-
- that.suggestionsContainer = Autocomplete.utils.createNode(options.containerClass);
-
- container = $(that.suggestionsContainer);
-
- container.appendTo(options.appendTo);
-
- // Only set width if it was provided:
- if (options.width !== 'auto') {
- container.width(options.width);
- }
-
- // special on() plugin code for 'autocomplete'
- // http://api.jquery.com/on/#on-events-selector-data
- // Listen for mouse over event on suggestions list:
-// container.on('mouseenter.autocomplete', suggestionSelector, function () {
-// that.activate($(this).data('index'));
-// });
-//
-// // Deselect active element when mouse leaves suggestions container:
-// container.on('mouseleave.autocomplete', suggestionSelector, function () {
-// that.selectedIndex = -1;
-// container.children('.' + selected).removeClass(selected);
-// });
-
- // Listen for click event on suggestions list:
- container.on('click.autocomplete', suggestionSelector, function () {
- that.select($(this).data('index'));
- });
-
- that.fixPosition();
-
- that.fixPositionCapture = function () {
- if (that.visible) {
- that.fixPosition();
- }
- };
-
- $(window).on('resize.autocomplete', that.fixPositionCapture);
-
- that.el.on('keydown.autocomplete', function (e) { that.onKeyPress(e); });
- that.el.on('keyup.autocomplete', function (e) { that.onKeyUp(e); });
- that.el.on('blur.autocomplete', function () { that.onBlur(); });
- that.el.on('focus.autocomplete', function () { that.onFocus(); });
- that.el.on('change.autocomplete', function (e) { that.onKeyUp(e); });
- },
-
- onFocus: function () {
- var that = this;
- that.fixPosition();
- if (that.options.minChars <= that.el.val().length) {
- // that.onValueChange();
- }
- },
-
- onBlur: function () {
- this.enableKillerFn();
- },
-
- setOptions: function (suppliedOptions) {
- var that = this,
- options = that.options;
-
- $.extend(options, suppliedOptions);
-
- that.isLocal = $.isArray(options.lookup);
-
- if (that.isLocal) {
- options.lookup = that.verifySuggestionsFormat(options.lookup);
- }
-
- // Adjust height, width and z-index:
- $(that.suggestionsContainer).css({
- 'max-height': options.maxHeight + 'px',
- 'width': options.width + 'px',
- 'z-index': options.zIndex
- });
- },
-
- clearCache: function () {
- this.cachedResponse = {};
- this.badQueries = [];
- },
-
- clear: function () {
- this.clearCache();
- this.currentValue = '';
- this.suggestions = [];
- },
-
- disable: function () {
- var that = this;
- that.disabled = true;
- if (that.currentRequest) {
- that.currentRequest.abort();
- }
- },
-
- enable: function () {
- this.disabled = false;
- },
-
- fixPosition: function () {
- var that = this,
- offset,
- styles;
-
- // Don't adjust position if custom container has been specified:
- if (that.options.appendTo !== 'body') {
- return;
- }
-
- offset = that.el.offset();
-
- styles = {
- top: (offset.top + that.el.outerHeight()) + 'px',
- left: offset.left + 'px'
- };
-
- if (that.options.width === 'auto') {
- styles.width = (that.el.outerWidth() - 2) + 'px';
- }
-
- $(that.suggestionsContainer).css(styles);
- },
-
- enableKillerFn: function () {
- var that = this;
- $(document).on('click.autocomplete', that.killerFn);
- },
-
- disableKillerFn: function () {
- var that = this;
- $(document).off('click.autocomplete', that.killerFn);
- },
-
- killSuggestions: function () {
- var that = this;
- that.stopKillSuggestions();
- that.intervalId = window.setInterval(function () {
- that.hide();
- that.stopKillSuggestions();
- }, 50);
- },
-
- stopKillSuggestions: function () {
- window.clearInterval(this.intervalId);
- },
-
- isCursorAtEnd: function () {
- var that = this,
- valLength = that.el.val().length,
- selectionStart = that.element.selectionStart,
- range;
-
- if (typeof selectionStart === 'number') {
- return selectionStart === valLength;
- }
- if (document.selection) {
- range = document.selection.createRange();
- range.moveStart('character', -valLength);
- return valLength === range.text.length;
- }
- return true;
- },
-
- onKeyPress: function (e) {
- var that = this;
-
- // If suggestions are hidden and user presses arrow down, display suggestions:
- if (!that.disabled && !that.visible && e.which === keys.DOWN && that.currentValue) {
- that.suggest();
- return;
- }
-
- if (that.disabled || !that.visible) {
- return;
- }
-
- switch (e.which) {
- case keys.ESC:
- that.el.val(that.currentValue);
- that.hide();
- break;
- case keys.RIGHT:
- if (that.hint && that.options.onHint && that.isCursorAtEnd()) {
- that.selectHint();
- break;
- }
- return;
- case keys.TAB:
- if (that.hint && that.options.onHint) {
- that.selectHint();
- return;
- }
- // Fall through to RETURN
- case keys.RETURN:
- if (that.selectedIndex === -1) {
- that.hide();
- return;
- }
- that.select(that.selectedIndex);
- if (e.which === keys.TAB && that.options.tabDisabled === false) {
- return;
- }
- break;
- case keys.UP:
- that.moveUp();
- break;
- case keys.DOWN:
- that.moveDown();
- break;
- default:
- return;
- }
-
- // Cancel event if function did not return:
- e.stopImmediatePropagation();
- e.preventDefault();
- },
-
- onKeyUp: function (e) {
- var that = this;
-
- if (that.disabled) {
- return;
- }
-
- switch (e.which) {
- case keys.UP:
- case keys.DOWN:
- return;
- }
-
- clearInterval(that.onChangeInterval);
-
- if (that.currentValue !== that.el.val()) {
- that.findBestHint();
- if (that.options.deferRequestBy > 0) {
- // Defer lookup in case when value changes very quickly:
- that.onChangeInterval = setInterval(function () {
- that.onValueChange();
- }, that.options.deferRequestBy);
- } else {
- that.onValueChange();
- }
- }
- },
-
- onValueChange: function () {
- var that = this,
- options = that.options,
- value = that.el.val(),
- query = that.getQuery(value),
- index;
-
- if (that.selection) {
- that.selection = null;
- (options.onInvalidateSelection || $.noop).call(that.element);
- }
-
- clearInterval(that.onChangeInterval);
- that.currentValue = value;
- that.selectedIndex = -1;
-
- // Check existing suggestion for the match before proceeding:
- if (options.triggerSelectOnValidInput) {
- index = that.findSuggestionIndex(query);
- if (index !== -1) {
- that.select(index);
- return;
- }
- }
-
- if (query.length < options.minChars) {
- that.hide();
- } else {
- that.getSuggestions(query);
- }
- },
-
- findSuggestionIndex: function (query) {
- var that = this,
- index = -1,
- queryLowerCase = query.toLowerCase();
-
- $.each(that.suggestions, function (i, suggestion) {
- if (suggestion.value.toLowerCase() === queryLowerCase) {
- index = i;
- return false;
- }
- });
-
- return index;
- },
-
- getQuery: function (value) {
- var delimiter = this.options.delimiter,
- parts;
-
- if (!delimiter) {
- return value;
- }
- parts = value.split(delimiter);
- return $.trim(parts[parts.length - 1]);
- },
-
- getSuggestionsLocal: function (query) {
- var that = this,
- options = that.options,
- queryLowerCase = query.toLowerCase(),
- filter = options.lookupFilter,
- limit = parseInt(options.lookupLimit, 10),
- data;
-
- data = {
- suggestions: $.grep(options.lookup, function (suggestion) {
- return filter(suggestion, query, queryLowerCase);
- })
- };
-
- if (limit && data.suggestions.length > limit) {
- data.suggestions = data.suggestions.slice(0, limit);
- }
-
- return data;
- },
-
- getSuggestions: function (q) {
- var response,
- that = this,
- options = that.options,
- serviceUrl = options.serviceUrl,
- data,
- cacheKey;
-
- options.params[options.paramName] = q;
- data = options.ignoreParams ? null : options.params;
-
- if (that.isLocal) {
- response = that.getSuggestionsLocal(q);
- } else {
- if ($.isFunction(serviceUrl)) {
- serviceUrl = serviceUrl.call(that.element, q);
- }
- cacheKey = serviceUrl + '?' + $.param(data || {});
- response = that.cachedResponse[cacheKey];
- }
-
- if (response && $.isArray(response.suggestions)) {
- that.suggestions = response.suggestions;
- that.suggest();
- } else if (!that.isBadQuery(q)) {
- if (options.onSearchStart.call(that.element, options.params) === false) {
- return;
- }
- if (that.currentRequest) {
- that.currentRequest.abort();
- }
- that.currentRequest = $.ajax({
- url: serviceUrl,
- data: data,
- type: options.type,
- dataType: options.dataType
- }).done(function (data) {
- that.currentRequest = null;
- that.processResponse(data, q, cacheKey);
- options.onSearchComplete.call(that.element, q);
- }).fail(function (jqXHR, textStatus, errorThrown) {
- options.onSearchError.call(that.element, q, jqXHR, textStatus, errorThrown);
- });
- }
- },
-
- isBadQuery: function (q) {
- var badQueries = this.badQueries,
- i = badQueries.length;
-
- while (i--) {
- if (q.indexOf(badQueries[i]) === 0) {
- return true;
- }
- }
-
- return false;
- },
-
- hide: function () {
- var that = this;
- that.visible = false;
- that.selectedIndex = -1;
- $(that.suggestionsContainer).hide();
- that.signalHint(null);
- },
-
- suggest: function () {
- if (this.suggestions.length === 0) {
- this.hide();
- return;
- }
-
- var that = this,
- options = that.options,
- formatResult = options.formatResult,
- value = that.getQuery(that.currentValue),
- className = that.classes.suggestion,
- classSelected = that.classes.selected,
- container = $(that.suggestionsContainer),
- beforeRender = options.beforeRender,
- html = '',
- index,
- width;
-
- if (options.triggerSelectOnValidInput) {
- index = that.findSuggestionIndex(value);
- if (index !== -1) {
- that.select(index);
- return;
- }
- }
-
- // Build suggestions inner HTML:
- $.each(that.suggestions, function (i, suggestion) {
- html += '' + formatResult(suggestion, value) + '
';
- });
-
- // If width is auto, adjust width before displaying suggestions,
- // because if instance was created before input had width, it will be zero.
- // Also it adjusts if input width has changed.
- // -2px to account for suggestions border.
- if (options.width === 'auto') {
- width = that.el.outerWidth() - 2;
- container.width(width > 0 ? width : 300);
- }
-
- container.html(html);
-
- // Select first value by default:
- if (options.autoSelectFirst) {
- that.selectedIndex = 0;
- container.children().first().addClass(classSelected);
- }
-
- if ($.isFunction(beforeRender)) {
- beforeRender.call(that.element, container);
- }
-
- container.show();
- that.visible = true;
-
- that.findBestHint();
- },
-
- findBestHint: function () {
- var that = this,
- value = that.el.val().toLowerCase(),
- bestMatch = null;
-
- if (!value) {
- return;
- }
-
- $.each(that.suggestions, function (i, suggestion) {
- var foundMatch = suggestion.value.toLowerCase().indexOf(value) === 0;
- if (foundMatch) {
- bestMatch = suggestion;
- }
- return !foundMatch;
- });
-
- that.signalHint(bestMatch);
- },
-
- signalHint: function (suggestion) {
- var hintValue = '',
- that = this;
- if (suggestion) {
- hintValue = that.currentValue + suggestion.value.substr(that.currentValue.length);
- }
- if (that.hintValue !== hintValue) {
- that.hintValue = hintValue;
- that.hint = suggestion;
- (this.options.onHint || $.noop)(hintValue);
- }
- },
-
- verifySuggestionsFormat: function (suggestions) {
- // If suggestions is string array, convert them to supported format:
- if (suggestions.length && typeof suggestions[0] === 'string') {
- return $.map(suggestions, function (value) {
- return { value: value, data: null };
- });
- }
-
- return suggestions;
- },
-
- processResponse: function (response, originalQuery, cacheKey) {
- var that = this,
- options = that.options,
- result = options.transformResult(response, originalQuery);
-
- result.suggestions = that.verifySuggestionsFormat(result.suggestions);
-
- // Cache results if cache is not disabled:
- if (!options.noCache) {
- that.cachedResponse[cacheKey] = result;
- if (result.suggestions.length === 0) {
- that.badQueries.push(cacheKey);
- }
- }
-
- // Return if originalQuery is not matching current query:
- if (originalQuery !== that.getQuery(that.currentValue)) {
- return;
- }
-
- that.suggestions = result.suggestions;
- that.suggest();
- },
-
- activate: function (index) {
- var that = this,
- activeItem,
- selected = that.classes.selected,
- container = $(that.suggestionsContainer),
- children = container.children();
-
- if(that.selectedIndex === index)
- return null;
-
- container.children('.' + selected).removeClass(selected);
-
- that.selectedIndex = index;
-
- if (that.selectedIndex !== -1 && children.length > that.selectedIndex) {
- activeItem = children.get(that.selectedIndex);
- $(activeItem).addClass(selected);
- that.options.onPreSelect(that.suggestions[index], activeItem);
- return activeItem;
- }
-
- return null;
- },
-
- selectHint: function () {
- var that = this,
- i = $.inArray(that.hint, that.suggestions);
-
- that.select(i);
- },
-
- select: function (i) {
- var that = this;
- that.hide();
- that.onSelect(i);
- },
-
- moveUp: function () {
- var that = this;
-
- if (that.selectedIndex === -1) {
- return;
- }
-
- if (that.selectedIndex === 0) {
- $(that.suggestionsContainer).children().first().removeClass(that.classes.selected);
- that.selectedIndex = -1;
- that.el.val(that.currentValue);
- that.findBestHint();
- return;
- }
-
- that.adjustScroll(that.selectedIndex - 1);
- },
-
- moveDown: function () {
- var that = this;
-
- if (that.selectedIndex === (that.suggestions.length - 1)) {
- return;
- }
-
- that.adjustScroll(that.selectedIndex + 1);
- },
-
- adjustScroll: function (index) {
- var that = this,
- activeItem = that.activate(index),
- offsetTop,
- upperBound,
- lowerBound,
- heightDelta = 25;
-
- if (!activeItem) {
- return;
- }
-
- offsetTop = activeItem.offsetTop;
- upperBound = $(that.suggestionsContainer).scrollTop();
- lowerBound = upperBound + that.options.maxHeight - heightDelta;
-
- if (offsetTop < upperBound) {
- $(that.suggestionsContainer).scrollTop(offsetTop);
- } else if (offsetTop > lowerBound) {
- $(that.suggestionsContainer).scrollTop(offsetTop - that.options.maxHeight + heightDelta);
- }
-
- that.el.val(that.getValue(that.suggestions[index].value));
- that.signalHint(null);
- },
-
- onSelect: function (index) {
- var that = this,
- onSelectCallback = that.options.onSelect,
- suggestion = that.suggestions[index];
-
- that.currentValue = that.getValue(suggestion.value);
- that.el.val(that.currentValue);
- that.signalHint(null);
- that.suggestions = [];
- that.selection = suggestion;
-
- if ($.isFunction(onSelectCallback)) {
- onSelectCallback.call(that.element, suggestion);
- }
- },
-
- getValue: function (value) {
- var that = this,
- delimiter = that.options.delimiter,
- currentValue,
- parts;
-
- if (!delimiter) {
- return value;
- }
-
- currentValue = that.currentValue;
- parts = currentValue.split(delimiter);
-
- if (parts.length === 1) {
- return value;
- }
-
- return currentValue.substr(0, currentValue.length - parts[parts.length - 1].length) + value;
- },
-
- dispose: function () {
- var that = this;
- that.el.off('.autocomplete').removeData('autocomplete');
- that.disableKillerFn();
- $(window).off('resize.autocomplete', that.fixPositionCapture);
- $(that.suggestionsContainer).remove();
- }
- };
-
- // Create chainable jQuery plugin:
- $.fn.autocomplete = function (options, args) {
- var dataKey = 'autocomplete';
- // If function invoked without argument return
- // instance of the first matched element:
- if (arguments.length === 0) {
- return this.first().data(dataKey);
- }
-
- return this.each(function () {
- var inputElement = $(this),
- instance = inputElement.data(dataKey);
-
- if (typeof options === 'string') {
- if (instance && typeof instance[options] === 'function') {
- instance[options](args);
- }
- } else {
- // If instance already exists, destroy it:
- if (instance && instance.dispose) {
- instance.dispose();
- }
- instance = new Autocomplete(this, options);
- inputElement.data(dataKey, instance);
- }
- });
- };
-}));
diff --git a/src/main/resources/de/geofabrik/openrailrouting/maps/js/lib/jquery.history.js b/src/main/resources/de/geofabrik/openrailrouting/maps/js/lib/jquery.history.js
deleted file mode 100644
index caeb7aa..0000000
--- a/src/main/resources/de/geofabrik/openrailrouting/maps/js/lib/jquery.history.js
+++ /dev/null
@@ -1 +0,0 @@
-(function(e,t){"use strict";var n=e.History=e.History||{},r=e.jQuery;if(typeof n.Adapter!="undefined")throw new Error("History.js Adapter has already been loaded...");n.Adapter={bind:function(e,t,n){r(e).bind(t,n)},trigger:function(e,t,n){r(e).trigger(t,n)},extractEventData:function(e,n,r){var i=n&&n.originalEvent&&n.originalEvent[e]||r&&r[e]||t;return i},onDomLoad:function(e){r(e)}},typeof n.init!="undefined"&&n.init()})(window),function(e,t){"use strict";var n=e.console||t,r=e.document,i=e.navigator,s=e.sessionStorage||!1,o=e.setTimeout,u=e.clearTimeout,a=e.setInterval,f=e.clearInterval,l=e.JSON,c=e.alert,h=e.History=e.History||{},p=e.history;try{s.setItem("TEST","1"),s.removeItem("TEST")}catch(d){s=!1}l.stringify=l.stringify||l.encode,l.parse=l.parse||l.decode;if(typeof h.init!="undefined")throw new Error("History.js Core has already been loaded...");h.init=function(e){return typeof h.Adapter=="undefined"?!1:(typeof h.initCore!="undefined"&&h.initCore(),typeof h.initHtml4!="undefined"&&h.initHtml4(),!0)},h.initCore=function(d){if(typeof h.initCore.initialized!="undefined")return!1;h.initCore.initialized=!0,h.options=h.options||{},h.options.hashChangeInterval=h.options.hashChangeInterval||100,h.options.safariPollInterval=h.options.safariPollInterval||500,h.options.doubleCheckInterval=h.options.doubleCheckInterval||500,h.options.disableSuid=h.options.disableSuid||!1,h.options.storeInterval=h.options.storeInterval||1e3,h.options.busyDelay=h.options.busyDelay||250,h.options.debug=h.options.debug||!1,h.options.initialTitle=h.options.initialTitle||r.title,h.options.html4Mode=h.options.html4Mode||!1,h.options.delayInit=h.options.delayInit||!1,h.intervalList=[],h.clearAllIntervals=function(){var e,t=h.intervalList;if(typeof t!="undefined"&&t!==null){for(e=0;e")&&n[0]);return e>4?e:!1}();return e},h.isInternetExplorer=function(){var e=h.isInternetExplorer.cached=typeof h.isInternetExplorer.cached!="undefined"?h.isInternetExplorer.cached:Boolean(h.getInternetExplorerMajorVersion());return e},h.options.html4Mode?h.emulated={pushState:!0,hashChange:!0}:h.emulated={pushState:!Boolean(e.history&&e.history.pushState&&e.history.replaceState&&!/ Mobile\/([1-7][a-z]|(8([abcde]|f(1[0-8]))))/i.test(i.userAgent)&&!/AppleWebKit\/5([0-2]|3[0-2])/i.test(i.userAgent)),hashChange:Boolean(!("onhashchange"in e||"onhashchange"in r)||h.isInternetExplorer()&&h.getInternetExplorerMajorVersion()<8)},h.enabled=!h.emulated.pushState,h.bugs={setHash:Boolean(!h.emulated.pushState&&i.vendor==="Apple Computer, Inc."&&/AppleWebKit\/5([0-2]|3[0-3])/.test(i.userAgent)),safariPoll:Boolean(!h.emulated.pushState&&i.vendor==="Apple Computer, Inc."&&/AppleWebKit\/5([0-2]|3[0-3])/.test(i.userAgent)),ieDoubleCheck:Boolean(h.isInternetExplorer()&&h.getInternetExplorerMajorVersion()<8),hashEscape:Boolean(h.isInternetExplorer()&&h.getInternetExplorerMajorVersion()<7)},h.isEmptyObject=function(e){for(var t in e)if(e.hasOwnProperty(t))return!1;return!0},h.cloneObject=function(e){var t,n;return e?(t=l.stringify(e),n=l.parse(t)):n={},n},h.getRootUrl=function(){var e=r.location.protocol+"//"+(r.location.hostname||r.location.host);if(r.location.port||!1)e+=":"+r.location.port;return e+="/",e},h.getBaseHref=function(){var e=r.getElementsByTagName("base"),t=null,n="";return e.length===1&&(t=e[0],n=t.href.replace(/[^\/]+$/,"")),n=n.replace(/\/+$/,""),n&&(n+="/"),n},h.getBaseUrl=function(){var e=h.getBaseHref()||h.getBasePageUrl()||h.getRootUrl();return e},h.getPageUrl=function(){var e=h.getState(!1,!1),t=(e||{}).url||h.getLocationHref(),n;return n=t.replace(/\/+$/,"").replace(/[^\/]+$/,function(e,t,n){return/\./.test(e)?e:e+"/"}),n},h.getBasePageUrl=function(){var e=h.getLocationHref().replace(/[#\?].*/,"").replace(/[^\/]+$/,function(e,t,n){return/[^\/]$/.test(e)?"":e}).replace(/\/+$/,"")+"/";return e},h.getFullUrl=function(e,t){var n=e,r=e.substring(0,1);return t=typeof t=="undefined"?!0:t,/[a-z]+\:\/\//.test(e)||(r==="/"?n=h.getRootUrl()+e.replace(/^\/+/,""):r==="#"?n=h.getPageUrl().replace(/#.*/,"")+e:r==="?"?n=h.getPageUrl().replace(/[\?#].*/,"")+e:t?n=h.getBaseUrl()+e.replace(/^(\.\/)+/,""):n=h.getBasePageUrl()+e.replace(/^(\.\/)+/,"")),n.replace(/\#$/,"")},h.getShortUrl=function(e){var t=e,n=h.getBaseUrl(),r=h.getRootUrl();return h.emulated.pushState&&(t=t.replace(n,"")),t=t.replace(r,"/"),h.isTraditionalAnchor(t)&&(t="./"+t),t=t.replace(/^(\.\/)+/g,"./").replace(/\#$/,""),t},h.getLocationHref=function(e){return e=e||r,e.URL===e.location.href?e.location.href:e.location.href===decodeURIComponent(e.URL)?e.URL:e.location.hash&&decodeURIComponent(e.location.href.replace(/^[^#]+/,""))===e.location.hash?e.location.href:e.URL.indexOf("#")==-1&&e.location.href.indexOf("#")!=-1?e.location.href:e.URL||e.location.href},h.store={},h.idToState=h.idToState||{},h.stateToId=h.stateToId||{},h.urlToId=h.urlToId||{},h.storedStates=h.storedStates||[],h.savedStates=h.savedStates||[],h.normalizeStore=function(){h.store.idToState=h.store.idToState||{},h.store.urlToId=h.store.urlToId||{},h.store.stateToId=h.store.stateToId||{}},h.getState=function(e,t){typeof e=="undefined"&&(e=!0),typeof t=="undefined"&&(t=!0);var n=h.getLastSavedState();return!n&&t&&(n=h.createStateObject()),e&&(n=h.cloneObject(n),n.url=n.cleanUrl||n.url),n},h.getIdByState=function(e){var t=h.extractId(e.url),n;if(!t){n=h.getStateString(e);if(typeof h.stateToId[n]!="undefined")t=h.stateToId[n];else if(typeof h.store.stateToId[n]!="undefined")t=h.store.stateToId[n];else{for(;;){t=(new Date).getTime()+String(Math.random()).replace(/\D/g,"");if(typeof h.idToState[t]=="undefined"&&typeof h.store.idToState[t]=="undefined")break}h.stateToId[n]=t,h.idToState[t]=e}}return t},h.normalizeState=function(e){var t,n;if(!e||typeof e!="object")e={};if(typeof e.normalized!="undefined")return e;if(!e.data||typeof e.data!="object")e.data={};return t={},t.normalized=!0,t.title=e.title||"",t.url=h.getFullUrl(e.url?e.url:h.getLocationHref()),t.hash=h.getShortUrl(t.url),t.data=h.cloneObject(e.data),t.id=h.getIdByState(t),t.cleanUrl=t.url.replace(/\??\&_suid.*/,""),t.url=t.cleanUrl,n=!h.isEmptyObject(t.data),(t.title||n)&&h.options.disableSuid!==!0&&(t.hash=h.getShortUrl(t.url).replace(/\??\&_suid.*/,""),/\?/.test(t.hash)||(t.hash+="?"),t.hash+="&_suid="+t.id),t.hashedUrl=h.getFullUrl(t.hash),(h.emulated.pushState||h.bugs.safariPoll)&&h.hasUrlDuplicate(t)&&(t.url=t.hashedUrl),t},h.createStateObject=function(e,t,n){var r={data:e,title:t,url:n};return r=h.normalizeState(r),r},h.getStateById=function(e){e=String(e);var n=h.idToState[e]||h.store.idToState[e]||t;return n},h.getStateString=function(e){var t,n,r;return t=h.normalizeState(e),n={data:t.data,title:e.title,url:e.url},r=l.stringify(n),r},h.getStateId=function(e){var t,n;return t=h.normalizeState(e),n=t.id,n},h.getHashByState=function(e){var t,n;return t=h.normalizeState(e),n=t.hash,n},h.extractId=function(e){var t,n,r,i;return e.indexOf("#")!=-1?i=e.split("#")[0]:i=e,n=/(.*)\&_suid=([0-9]+)$/.exec(i),r=n?n[1]||e:e,t=n?String(n[2]||""):"",t||!1},h.isTraditionalAnchor=function(e){var t=!/[\/\?\.]/.test(e);return t},h.extractState=function(e,t){var n=null,r,i;return t=t||!1,r=h.extractId(e),r&&(n=h.getStateById(r)),n||(i=h.getFullUrl(e),r=h.getIdByUrl(i)||!1,r&&(n=h.getStateById(r)),!n&&t&&!h.isTraditionalAnchor(e)&&(n=h.createStateObject(null,null,i))),n},h.getIdByUrl=function(e){var n=h.urlToId[e]||h.store.urlToId[e]||t;return n},h.getLastSavedState=function(){return h.savedStates[h.savedStates.length-1]||t},h.getLastStoredState=function(){return h.storedStates[h.storedStates.length-1]||t},h.hasUrlDuplicate=function(e){var t=!1,n;return n=h.extractState(e.url),t=n&&n.id!==e.id,t},h.storeState=function(e){return h.urlToId[e.url]=e.id,h.storedStates.push(h.cloneObject(e)),e},h.isLastSavedState=function(e){var t=!1,n,r,i;return h.savedStates.length&&(n=e.id,r=h.getLastSavedState(),i=r.id,t=n===i),t},h.saveState=function(e){return h.isLastSavedState(e)?!1:(h.savedStates.push(h.cloneObject(e)),!0)},h.getStateByIndex=function(e){var t=null;return typeof e=="undefined"?t=h.savedStates[h.savedStates.length-1]:e<0?t=h.savedStates[h.savedStates.length+e]:t=h.savedStates[e],t},h.getCurrentIndex=function(){var e=null;return h.savedStates.length<1?e=0:e=h.savedStates.length-1,e},h.getHash=function(e){var t=h.getLocationHref(e),n;return n=h.getHashByUrl(t),n},h.unescapeHash=function(e){var t=h.normalizeHash(e);return t=decodeURIComponent(t),t},h.normalizeHash=function(e){var t=e.replace(/[^#]*#/,"").replace(/#.*/,"");return t},h.setHash=function(e,t){var n,i;return t!==!1&&h.busy()?(h.pushQueue({scope:h,callback:h.setHash,args:arguments,queue:t}),!1):(h.busy(!0),n=h.extractState(e,!0),n&&!h.emulated.pushState?h.pushState(n.data,n.title,n.url,!1):h.getHash()!==e&&(h.bugs.setHash?(i=h.getPageUrl(),h.pushState(null,null,i+"#"+e,!1)):r.location.hash=e),h)},h.escapeHash=function(t){var n=h.normalizeHash(t);return n=e.encodeURIComponent(n),h.bugs.hashEscape||(n=n.replace(/\%21/g,"!").replace(/\%26/g,"&").replace(/\%3D/g,"=").replace(/\%3F/g,"?")),n},h.getHashByUrl=function(e){var t=String(e).replace(/([^#]*)#?([^#]*)#?(.*)/,"$2");return t=h.unescapeHash(t),t},h.setTitle=function(e){var t=e.title,n;t||(n=h.getStateByIndex(0),n&&n.url===e.url&&(t=n.title||h.options.initialTitle));try{r.getElementsByTagName("title")[0].innerHTML=t.replace("<","<").replace(">",">").replace(" & "," & ")}catch(i){}return r.title=t,h},h.queues=[],h.busy=function(e){typeof e!="undefined"?h.busy.flag=e:typeof h.busy.flag=="undefined"&&(h.busy.flag=!1);if(!h.busy.flag){u(h.busy.timeout);var t=function(){var e,n,r;if(h.busy.flag)return;for(e=h.queues.length-1;e>=0;--e){n=h.queues[e];if(n.length===0)continue;r=n.shift(),h.fireQueueItem(r),h.busy.timeout=o(t,h.options.busyDelay)}};h.busy.timeout=o(t,h.options.busyDelay)}return h.busy.flag},h.busy.flag=!1,h.fireQueueItem=function(e){return e.callback.apply(e.scope||h,e.args||[])},h.pushQueue=function(e){return h.queues[e.queue||0]=h.queues[e.queue||0]||[],h.queues[e.queue||0].push(e),h},h.queue=function(e,t){return typeof e=="function"&&(e={callback:e}),typeof t!="undefined"&&(e.queue=t),h.busy()?h.pushQueue(e):h.fireQueueItem(e),h},h.clearQueue=function(){return h.busy.flag=!1,h.queues=[],h},h.stateChanged=!1,h.doubleChecker=!1,h.doubleCheckComplete=function(){return h.stateChanged=!0,h.doubleCheckClear(),h},h.doubleCheckClear=function(){return h.doubleChecker&&(u(h.doubleChecker),h.doubleChecker=!1),h},h.doubleCheck=function(e){return h.stateChanged=!1,h.doubleCheckClear(),h.bugs.ieDoubleCheck&&(h.doubleChecker=o(function(){return h.doubleCheckClear(),h.stateChanged||e(),!0},h.options.doubleCheckInterval)),h},h.safariStatePoll=function(){var t=h.extractState(h.getLocationHref()),n;if(!h.isLastSavedState(t))return n=t,n||(n=h.createStateObject()),h.Adapter.trigger(e,"popstate"),h;return},h.back=function(e){return e!==!1&&h.busy()?(h.pushQueue({scope:h,callback:h.back,args:arguments,queue:e}),!1):(h.busy(!0),h.doubleCheck(function(){h.back(!1)}),p.go(-1),!0)},h.forward=function(e){return e!==!1&&h.busy()?(h.pushQueue({scope:h,callback:h.forward,args:arguments,queue:e}),!1):(h.busy(!0),h.doubleCheck(function(){h.forward(!1)}),p.go(1),!0)},h.go=function(e,t){var n;if(e>0)for(n=1;n<=e;++n)h.forward(t);else{if(!(e<0))throw new Error("History.go: History.go requires a positive or negative integer passed.");for(n=-1;n>=e;--n)h.back(t)}return h};if(h.emulated.pushState){var v=function(){};h.pushState=h.pushState||v,h.replaceState=h.replaceState||v}else h.onPopState=function(t,n){var r=!1,i=!1,s,o;return h.doubleCheckComplete(),s=h.getHash(),s?(o=h.extractState(s||h.getLocationHref(),!0),o?h.replaceState(o.data,o.title,o.url,!1):(h.Adapter.trigger(e,"anchorchange"),h.busy(!1)),h.expectedStateId=!1,!1):(r=h.Adapter.extractEventData("state",t,n)||!1,r?i=h.getStateById(r):h.expectedStateId?i=h.getStateById(h.expectedStateId):i=h.extractState(h.getLocationHref()),i||(i=h.createStateObject(null,null,h.getLocationHref())),h.expectedStateId=!1,h.isLastSavedState(i)?(h.busy(!1),!1):(h.storeState(i),h.saveState(i),h.setTitle(i),h.Adapter.trigger(e,"statechange"),h.busy(!1),!0))},h.Adapter.bind(e,"popstate",h.onPopState),h.pushState=function(t,n,r,i){if(h.getHashByUrl(r)&&h.emulated.pushState)throw new Error("History.js does not support states with fragement-identifiers (hashes/anchors).");if(i!==!1&&h.busy())return h.pushQueue({scope:h,callback:h.pushState,args:arguments,queue:i}),!1;h.busy(!0);var s=h.createStateObject(t,n,r);return h.isLastSavedState(s)?h.busy(!1):(h.storeState(s),h.expectedStateId=s.id,p.pushState(s.id,s.title,s.url),h.Adapter.trigger(e,"popstate")),!0},h.replaceState=function(t,n,r,i){if(h.getHashByUrl(r)&&h.emulated.pushState)throw new Error("History.js does not support states with fragement-identifiers (hashes/anchors).");if(i!==!1&&h.busy())return h.pushQueue({scope:h,callback:h.replaceState,args:arguments,queue:i}),!1;h.busy(!0);var s=h.createStateObject(t,n,r);return h.isLastSavedState(s)?h.busy(!1):(h.storeState(s),h.expectedStateId=s.id,p.replaceState(s.id,s.title,s.url),h.Adapter.trigger(e,"popstate")),!0};if(s){try{h.store=l.parse(s.getItem("History.store"))||{}}catch(m){h.store={}}h.normalizeStore()}else h.store={},h.normalizeStore();h.Adapter.bind(e,"unload",h.clearAllIntervals),h.saveState(h.storeState(h.extractState(h.getLocationHref(),!0))),s&&(h.onUnload=function(){var e,t,n;try{e=l.parse(s.getItem("History.store"))||{}}catch(r){e={}}e.idToState=e.idToState||{},e.urlToId=e.urlToId||{},e.stateToId=e.stateToId||{};for(t in h.idToState){if(!h.idToState.hasOwnProperty(t))continue;e.idToState[t]=h.idToState[t]}for(t in h.urlToId){if(!h.urlToId.hasOwnProperty(t))continue;e.urlToId[t]=h.urlToId[t]}for(t in h.stateToId){if(!h.stateToId.hasOwnProperty(t))continue;e.stateToId[t]=h.stateToId[t]}h.store=e,h.normalizeStore(),n=l.stringify(e);try{s.setItem("History.store",n)}catch(i){if(i.code!==DOMException.QUOTA_EXCEEDED_ERR)throw i;s.length&&(s.removeItem("History.store"),s.setItem("History.store",n))}},h.intervalList.push(a(h.onUnload,h.options.storeInterval)),h.Adapter.bind(e,"beforeunload",h.onUnload),h.Adapter.bind(e,"unload",h.onUnload));if(!h.emulated.pushState){h.bugs.safariPoll&&h.intervalList.push(a(h.safariStatePoll,h.options.safariPollInterval));if(i.vendor==="Apple Computer, Inc."||(i.appCodeName||"")==="Mozilla")h.Adapter.bind(e,"hashchange",function(){h.Adapter.trigger(e,"popstate")}),h.getHash()&&h.Adapter.onDomLoad(function(){h.Adapter.trigger(e,"hashchange")})}},(!h.options||!h.options.delayInit)&&h.init()}(window)
\ No newline at end of file
diff --git a/src/main/resources/de/geofabrik/openrailrouting/maps/js/lib/leaflet_numbered_markers.js b/src/main/resources/de/geofabrik/openrailrouting/maps/js/lib/leaflet_numbered_markers.js
deleted file mode 100644
index 2ab1983..0000000
--- a/src/main/resources/de/geofabrik/openrailrouting/maps/js/lib/leaflet_numbered_markers.js
+++ /dev/null
@@ -1,30 +0,0 @@
-L.NumberedDivIcon = L.Icon.extend({
- options: {
- iconUrl: './img/marker_hole.png',
- number: '',
- shadowUrl: null,
- iconSize: new L.Point(25, 41),
- iconAnchor: new L.Point(12, 40),
- popupAnchor: new L.Point(0, -33),
- shadowSize: new L.Point(50, -64),
- shadowAnchor: new L.Point(4, -62),
- className: 'leaflet-div-icon'
- },
-
- createIcon: function () {
- var div = document.createElement('div');
- var img = this._createImg(this.options['iconUrl']);
- var numdiv = document.createElement('div');
- numdiv.setAttribute ( "class", "number" );
- numdiv.innerHTML = this.options['number'] || '';
- div.appendChild ( img );
- div.appendChild ( numdiv );
- this._setIconStyles(div, 'icon');
- return div;
- },
-
- //you could change this to add a shadow like in the normal marker if you really wanted
- createShadow: function () {
- return null;
- }
-});
\ No newline at end of file
diff --git a/src/main/resources/de/geofabrik/openrailrouting/maps/js/main-template.js b/src/main/resources/de/geofabrik/openrailrouting/maps/js/main-template.js
deleted file mode 100644
index 16a8dea..0000000
--- a/src/main/resources/de/geofabrik/openrailrouting/maps/js/main-template.js
+++ /dev/null
@@ -1,932 +0,0 @@
-global.d3 = require('d3');
-var YAML = require('js-yaml');
-var Flatpickr = require('flatpickr');
-require('flatpickr/dist/l10n');
-
-var L = require('leaflet');
-require('leaflet-contextmenu');
-require('leaflet-loading');
-require('leaflet.heightgraph');
-var moment = require('moment');
-require('./lib/leaflet_numbered_markers.js');
-
-global.jQuery = require('jquery');
-global.$ = global.jQuery;
-require('./lib/jquery-ui-custom-1.12.0.min.js');
-require('./lib/jquery.history.js');
-require('./lib/jquery.autocomplete.js');
-
-var ghenv = require("./config/options.js").options;
-console.log(ghenv.environment);
-
-var GHInput = require('./graphhopper/GHInput.js');
-var GHRequest = require('./graphhopper/GHRequest.js');
-var host = ghenv.routing.host;
-if (!host) {
- if (location.port === '') {
- host = location.protocol + '//' + location.hostname;
- } else {
- host = location.protocol + '//' + location.hostname + ":" + location.port;
- }
-}
-
-var AutoComplete = require('./autocomplete.js');
-if (ghenv.environment === 'development') {
- var autocomplete = AutoComplete.prototype.createStub();
-} else {
- var autocomplete = new AutoComplete(ghenv.geocoding.host, ghenv.geocoding.api_key);
-}
-
-var mapLayer = require('./map.js');
-var nominatim = require('./nominatim.js');
-var routeManipulation = require('./routeManipulation.js');
-var gpxExport = require('./gpxexport.js');
-var messages = require('./messages.js');
-var translate = require('./translate.js');
-
-var format = require('./tools/format.js');
-var urlTools = require('./tools/url.js');
-var tileLayers = require('./config/tileLayers.js');
-if(ghenv.with_tiles)
- tileLayers.enableVectorTiles();
-
-var debug = false;
-var ghRequest = new GHRequest(host, ghenv.routing.api_key);
-var bounds = {};
-var metaVersionInfo;
-
-// usage: log('inside coolFunc',this,arguments);
-// http://paulirish.com/2009/log-a-lightweight-wrapper-for-consolelog/
-if (global.window) {
- window.log = function () {
- log.history = log.history || []; // store logs to an array for reference
- log.history.push(arguments);
- if (this.console && debug) {
- console.log(Array.prototype.slice.call(arguments));
- }
- };
-}
-
-$(document).ready(function (e) {
- // fixing cross domain support e.g in Opera
- jQuery.support.cors = true;
-
- gpxExport.addGpxExport(ghRequest);
-
- $("#flex-input-link").click(function() {
- $("#regular-input").toggle();
- $("#flex-input").toggle();
- // avoid default action, so use a different search button
- $("#searchButton").toggle();
- mapLayer.adjustMapSize();
- });
- $("#flex-example").click(function() {
- $("#flex-input-text").val("speed_factor:\n road_class:\n motorway: 0.8\npriority:\n road_environment:\n tunnel: 0.0\n road_class:\n residential: 0.7\n max_weight:\n \">3\": 0.0");
- return false;
- });
-
- var sendCustomData = function() {
- mapLayer.clearElevation();
- mapLayer.clearLayers();
- flagAll();
-
- var infoDiv = $("#info");
- infoDiv.empty();
- infoDiv.show();
- var routeResultsDiv = $("");
- infoDiv.append(routeResultsDiv);
- routeResultsDiv.html('
Search Route ...');
- var inputText = $("#flex-input-text").val();
- if(inputText.length < 5) {
- routeResultsDiv.html("Routing configuration too short");
- return;
- }
-
- var points = [];
- for(var idx = 0; idx < ghRequest.route.size(); idx++) {
- var point = ghRequest.route.getIndex(idx);
- if (point.isResolved()) {
- points.push([point.lng, point.lat]);
- } else {
- routeResultsDiv.html("Unresolved points");
- return;
- }
- }
-
- var jsonModel = {'ch.disable': true};
- try {
- jsonModel.custom_model = inputText.indexOf("{") == 0? JSON.parse(inputText) : YAML.safeLoad(inputText);
- } catch(ex) {
- routeResultsDiv.html("Cannot parse " + inputText + " " + ex);
- return;
- }
-
- jsonModel.points = points;
- jsonModel.points_encoded = false;
- jsonModel.elevation = ghRequest.api_params.elevation;
- jsonModel.profile = ghRequest.api_params.profile;
- var request = JSON.stringify(jsonModel);
-
- $.ajax({
- url: "/route",
- type: "POST",
- contentType: 'application/json; charset=utf-8',
- dataType: "json",
- data: request,
- success: createRouteCallback(ghRequest, routeResultsDiv, "", true),
- error: function(err) {
- routeResultsDiv.html("Error response: cannot process input");
- var json = JSON.parse(err.responseText);
- createRouteCallback(ghRequest, routeResultsDiv, "", true)(json);
- }
- });
- };
-
- $("#flex-input-text").keydown(function (e) {
- // CTRL+Enter
- if (e.ctrlKey && e.keyCode == 13) sendCustomData();
- });
- $("#flex-search-button").click(sendCustomData);
-
- if (isProduction())
- $('#hosting').show();
-
- var History = window.History;
- if (History.enabled) {
- History.Adapter.bind(window, 'statechange', function () {
- // No need for workaround?
- // Chrome and Safari always emit a popstate event on page load, but Firefox doesn’t
- // https://github.com/defunkt/jquery-pjax/issues/143#issuecomment-6194330
-
- var state = History.getState();
- console.log(state);
- initFromParams(state.data, true);
- });
- }
-
- $('#locationform').submit(function (e) {
- // no page reload
- e.preventDefault();
- mySubmit();
- });
-
- var urlParams = urlTools.parseUrlWithHisto();
-
- if(urlParams.flex)
- $("#flex-input-link").click();
-
- var customURL = urlParams.load_custom;
- if(customURL && ghenv.environment === 'development')
- $.ajax(customURL).
- done(function(data) { $("#flex-input-text").val(data); $("#flex-input-link").click(); }).
- fail(function(err) { console.log("Cannot load custom URL " + customURL); });
-
- $.when(ghRequest.fetchTranslationMap(urlParams.locale), ghRequest.getInfo())
- .then(function (arg1, arg2) {
- // init translation retrieved from first call (fetchTranslationMap)
- var translations = arg1[0];
- autocomplete.setLocale(translations.locale);
- ghRequest.setLocale(translations.locale);
- translate.init(translations);
-
- // init bounding box from getInfo result
- var json = arg2[0];
- var tmp = json.bbox;
- bounds.initialized = true;
- bounds.minLon = tmp[0];
- bounds.minLat = tmp[1];
- bounds.maxLon = tmp[2];
- bounds.maxLat = tmp[3];
- nominatim.setBounds(bounds);
- var profilesDiv = $("#profiles");
-
- function createButton(profile, hide) {
- var profileName = profile.name;
- var button = $("");
- if (hide)
- button.hide();
-
- button.attr('id', profileName);
- button.html("
");
- button.click(function () {
- ghRequest.setProfile(profileName);
- ghRequest.removeLegacyParameters();
- resolveAll();
- if (ghRequest.route.isResolved())
- routeLatLng(ghRequest);
- });
- return button;
- }
-
- if (json.profiles) {
- var profiles = json.profiles;
- // first sort alphabetically to maintain a consistent order, then move certain elements to front/back
- profiles.sort(function (a, b) {
- return a.name < b.name ? -1 : a.name > b.name ? 1 : 0;
- });
- // the desired order is car,foot,bike,,motorcycle
- var firstVehicles = ["car", "foot", "bike"];
- for (var i=firstVehicles.length-1; i>=0; --i) {
- profiles = moveToFront(profiles, function(p) { return p.name === firstVehicles[i]; });
- }
- var lastVehicles = ["mtb", "motorcycle"];
- for (var i=0; i= 0;
- if (profiles.length > 0)
- ghRequest.setProfile(profiles[0].name);
-
- var numVehiclesWhenCollapsed = 3;
- var hiddenVehicles = [];
- for (var i = 0; i < profiles.length; ++i) {
- var btn = createButton(profiles[i], !showAllProfiles && i >= numVehiclesWhenCollapsed);
- profilesDiv.append(btn);
- if (i >= numVehiclesWhenCollapsed)
- hiddenVehicles.push(btn);
- }
-
- if (!showAllProfiles && profiles.length > numVehiclesWhenCollapsed) {
- var moreBtn = $(" ...").click(function () {
- moreBtn.hide();
- for (var i in hiddenVehicles) {
- hiddenVehicles[i].show();
- }
- });
- profilesDiv.append($("?"));
- profilesDiv.append(moreBtn);
- }
- }
- $("button#" + profiles[0].name).addClass("selectprofile");
-
- metaVersionInfo = messages.extractMetaVersionInfo(json);
- // a very simplistic helper system that shows the possible entries and encoded values
- if(json.encoded_values) {
- $('#flex-input-text').bind('keyup click', function() {
- var cleanedText = this.value.replace(/(\n|:)/gm, ' ');
- var startIndex = cleanedText.substring(0, this.selectionStart).lastIndexOf(" ");
- startIndex = startIndex < 0 ? 0 : startIndex + 1;
- var endIndex = cleanedText.indexOf(" ", this.selectionStart);
- endIndex = endIndex < 0 ? cleanedText.length : endIndex;
- var wordUnderCursor = cleanedText.substring(startIndex, endIndex);
- if(this.selectionStart == 0 || this.value.substr(this.selectionStart - 1, 1) === "\n") {
- document.getElementById("ev_value").innerHTML = "root: speed_factor, priority, max_speed, max_speed_fallback, distance_influence, areas";
- } else if(wordUnderCursor === "priority" || wordUnderCursor === "speed_factor" || wordUnderCursor === "max_speed") {
- document.getElementById("ev_value").innerHTML = "" + wordUnderCursor + ": " + Object.keys(json.encoded_values).join(", ");
- } else if(json.encoded_values[wordUnderCursor]) {
- document.getElementById("ev_value").innerHTML = "" + wordUnderCursor + ": " + json.encoded_values[wordUnderCursor].join(", ");
- }
- });
- }
-
- mapLayer.initMap(bounds, setStartCoord, setIntermediateCoord, setEndCoord, urlParams.layer, urlParams.use_miles);
-
- // execute query
- initFromParams(urlParams, true);
-
- checkInput();
- }, function (err) {
- console.log(err);
- $('#error').html('GraphHopper API offline? Refresh' + '
Status: ' + err.statusText + '
' + host);
-
- bounds = {
- "minLon": -180,
- "minLat": -90,
- "maxLon": 180,
- "maxLat": 90
- };
- nominatim.setBounds(bounds);
- mapLayer.initMap(bounds, setStartCoord, setIntermediateCoord, setEndCoord, urlParams.layer, urlParams.use_miles);
- });
-
- var language_code = urlParams.locale && urlParams.locale.split('-', 1)[0];
- if (language_code != 'en') {
- // A few language codes are different in GraphHopper and Flatpickr.
- var flatpickr_locale;
- switch (language_code) {
- case 'ca': // Catalan
- flatpickr_locale = 'cat';
- break;
- case 'el': // Greek
- flatpickr_locale = 'gr';
- break;
- default:
- flatpickr_locale = language_code;
- }
- if (Flatpickr.l10ns.hasOwnProperty(flatpickr_locale)) {
- Flatpickr.localize(Flatpickr.l10ns[flatpickr_locale]);
- }
- }
-
- $(window).resize(function () {
- mapLayer.adjustMapSize();
- });
- $("#locationpoints").sortable({
- items: ".pointDiv",
- cursor: "n-resize",
- containment: "parent",
- handle: ".pointFlag",
- update: function (event, ui) {
- var origin_index = $(ui.item[0]).data('index');
- sortable_items = $("#locationpoints > div.pointDiv");
- $(sortable_items).each(function (index) {
- var data_index = $(this).data('index');
- if (origin_index === data_index) {
- //log(data_index +'>'+ index);
- ghRequest.route.move(data_index, index);
- if (!routeIfAllResolved())
- checkInput();
- return false;
- }
- });
- }
- });
-
- $('#locationpoints > div.pointAdd').click(function () {
- ghRequest.route.add(new GHInput());
- checkInput();
- });
-
- checkInput();
-});
-
-function profileDisplayName(profileName) {
- // custom profile names like 'my_car' cannot be translated and will be returned like 'web.my_car', so we remove
- // the 'web.' prefix in this case
- return translate.tr(profileName).replace("web.", "");
-}
-
-/**
- * Takes an array and returns another array with the same elements but sorted such that all elements matching the given
- * condition come first.
- */
-function moveToFront(arr, condition) {
- return arr.filter(condition).concat(arr.filter(function (e) { return !condition(e); }))
-}
-
-function initFromParams(params, doQuery) {
- ghRequest.init(params);
-
- var flatpickr = new Flatpickr(document.getElementById("input_date_0"), {
- defaultDate: new Date(),
- allowInput: true, /* somehow then does not sync!? */
- minuteIncrement: 15,
- time_24hr: true,
- enableTime: true
- });
- if (ghRequest.isPublicTransit())
- $(".time_input").show();
- else
- $(".time_input").hide();
- if (ghRequest.getEarliestDepartureTime()) {
- flatpickr.setDate(ghRequest.getEarliestDepartureTime());
- }
-
- var count = 0;
- var singlePointIndex;
- if (params.point)
- for (var key = 0; key < params.point.length; key++) {
- if (params.point[key] !== "") {
- count++;
- singlePointIndex = key;
- }
- }
-
- var routeNow = params.point && count >= 2;
- if (routeNow) {
- resolveCoords(params.point, doQuery);
- } else if (params.point && count === 1) {
- ghRequest.route.set(params.point[singlePointIndex], singlePointIndex, true);
- resolveIndex(singlePointIndex).done(function () {
- mapLayer.focus(ghRequest.route.getIndex(singlePointIndex), 15, singlePointIndex);
- });
- }
-}
-
-function resolveCoords(pointsAsStr, doQuery) {
- for (var i = 0, l = pointsAsStr.length; i < l; i++) {
- var pointStr = pointsAsStr[i];
- var coords = ghRequest.route.getIndex(i);
- if (!coords || pointStr !== coords.input || !coords.isResolved())
- ghRequest.route.set(pointStr, i, true);
- }
-
- checkInput();
-
- if (ghRequest.route.isResolved()) {
- resolveAll();
- routeLatLng(ghRequest, doQuery);
- } else {
- // at least one text input from user -> wait for resolve as we need the coord for routing
- $.when.apply($, resolveAll()).done(function () {
- routeLatLng(ghRequest, doQuery);
- });
- }
-}
-
-var FROM = 'from', TO = 'to';
-function getToFrom(index) {
- if (index === 0)
- return FROM;
- else if (index === (ghRequest.route.size() - 1))
- return TO;
- return -1;
-}
-
-function checkInput() {
- var template = $('#pointTemplate').html(),
- len = ghRequest.route.size();
-
- // remove deleted points
- if ($('#locationpoints > div.pointDiv').length > len) {
- $('#locationpoints > div.pointDiv:gt(' + (len - 1) + ')').remove();
- }
-
- // properly unbind previously click handlers
- $("#locationpoints .pointDelete").off();
-
- var deleteClickHandler = function () {
- var index = $(this).parent().data('index');
- ghRequest.route.removeSingle(index);
- mapLayer.clearLayers();
- checkInput();
- routeLatLng(ghRequest, false);
- };
-
- // console.log("## new checkInput");
- for (var i = 0; i < len; i++) {
- var div = $('#locationpoints > div.pointDiv').eq(i);
- // console.log(div.length + ", index:" + i + ", len:" + len);
- if (div.length === 0) {
- $('#locationpoints > div.pointAdd').before(translate.nanoTemplate(template, {id: i}));
- div = $('#locationpoints > div.pointDiv').eq(i);
- }
-
- var toFrom = getToFrom(i);
- div.data("index", i);
- div.find(".pointFlag").attr("src",
- (toFrom === FROM) ? 'img/marker-small-green.png' :
- ((toFrom === TO) ? 'img/marker-small-red.png' : 'img/marker-small-blue.png'));
- if (len > 2) {
- div.find(".pointDelete").click(deleteClickHandler).prop('disabled', false).removeClass('ui-state-disabled');
- } else {
- div.find(".pointDelete").prop('disabled', true).addClass('ui-state-disabled');
- }
-
- autocomplete.showListForIndex(ghRequest, routeIfAllResolved, i);
- if (translate.isI18nIsInitialized()) {
- var input = div.find(".pointInput");
- if (i === 0)
- $(input).attr("placeholder", translate.tr("from_hint"));
- else if (i === (len - 1))
- $(input).attr("placeholder", translate.tr("to_hint"));
- else
- $(input).attr("placeholder", translate.tr("via_hint"));
- }
- }
-}
-
-function setToStart(e) {
- var latlng = e.relatedTarget.getLatLng(),
- index = ghRequest.route.getIndexByCoord(latlng);
- ghRequest.route.move(index, 0);
- routeIfAllResolved();
-}
-
-function setToEnd(e) {
- var latlng = e.relatedTarget.getLatLng(),
- index = ghRequest.route.getIndexByCoord(latlng);
- ghRequest.route.move(index, -1);
- routeIfAllResolved();
-}
-
-function setStartCoord(e) {
- ghRequest.route.set(e.latlng.wrap(), 0);
- resolveFrom();
- routeIfAllResolved();
-}
-
-function setIntermediateCoord(e) {
- var routeLayers = mapLayer.getSubLayers("route");
- var routeSegments = routeLayers.map(function (rl) {
- return {
- coordinates: rl.getLatLngs(),
- wayPoints: rl.feature.properties.snapped_waypoints.coordinates.map(function (wp) {
- return L.latLng(wp[1], wp[0]);
- })
- };
- });
- var index = routeManipulation.getIntermediatePointIndex(routeSegments, e.latlng);
- ghRequest.route.add(e.latlng.wrap(), index);
- ghRequest.do_zoom = false;
- resolveIndex(index);
- routeIfAllResolved();
-}
-
-function deleteCoord(e) {
- var latlng = e.relatedTarget.getLatLng();
- ghRequest.route.removeSingle(latlng);
- mapLayer.clearLayers();
- routeLatLng(ghRequest, false);
-}
-
-function setEndCoord(e) {
- var index = ghRequest.route.size() - 1;
- ghRequest.route.set(e.latlng.wrap(), index);
- resolveTo();
- routeIfAllResolved();
-}
-
-function routeIfAllResolved(doQuery) {
- if (ghRequest.route.isResolved()) {
- routeLatLng(ghRequest, doQuery);
- return true;
- }
- return false;
-}
-
-function setFlag(coord, index) {
- if (coord.lat) {
- var toFrom = getToFrom(index);
- // intercept openPopup
- var marker = mapLayer.createMarker(index, coord, setToEnd, setToStart, deleteCoord, ghRequest);
- marker._openPopup = marker.openPopup;
- marker.openPopup = function () {
- var latlng = this.getLatLng(),
- locCoord = ghRequest.route.getIndexFromCoord(latlng),
- content;
- if (locCoord.resolvedList && locCoord.resolvedList[0] && locCoord.resolvedList[0].locationDetails) {
- var address = locCoord.resolvedList[0].locationDetails;
- content = format.formatAddress(address);
- // at last update the content and update
- this._popup.setContent(content).update();
- }
- this._openPopup();
- };
- var _tempItem = {
- text: translate.tr('set_start'),
- icon: './img/marker-small-green.png',
- callback: setToStart,
- index: 1
- };
- if (toFrom === -1)
- marker.options.contextmenuItems.push(_tempItem); // because the Mixin.ContextMenu isn't initialized
- marker.on('dragend', function (e) {
- mapLayer.clearLayers();
- // inconsistent leaflet API: event.target.getLatLng vs. mouseEvent.latlng?
- var latlng = e.target.getLatLng();
- autocomplete.hide();
- ghRequest.route.getIndex(index).setCoord(latlng.lat, latlng.lng);
- resolveIndex(index);
- // do not wait for resolving and avoid zooming when dragging
- ghRequest.do_zoom = false;
- routeLatLng(ghRequest, false);
- });
- }
-}
-
-function resolveFrom() {
- return resolveIndex(0);
-}
-
-function resolveTo() {
- return resolveIndex((ghRequest.route.size() - 1));
-}
-
-function resolveIndex(index) {
- if(!ghRequest.route.getIndex(index))
- return;
- setFlag(ghRequest.route.getIndex(index), index);
- if (index === 0) {
- if (!ghRequest.to.isResolved())
- mapLayer.setDisabledForMapsContextMenu('start', true);
- else
- mapLayer.setDisabledForMapsContextMenu('start', false);
- } else if (index === (ghRequest.route.size() - 1)) {
- if (!ghRequest.from.isResolved())
- mapLayer.setDisabledForMapsContextMenu('end', true);
- else
- mapLayer.setDisabledForMapsContextMenu('end', false);
- }
-
- return nominatim.resolve(index, ghRequest.route.getIndex(index));
-}
-
-function resolveAll() {
- var ret = [];
- for (var i = 0, l = ghRequest.route.size(); i < l; i++) {
- ret[i] = resolveIndex(i);
- }
-
- if(ghRequest.isPublicTransit())
- ghRequest.setEarliestDepartureTime(
- moment($("#input_date_0").val(), 'YYYY-MM-DD HH:mm').toISOString());
-
- return ret;
-}
-
-function flagAll() {
- for (var i = 0, l = ghRequest.route.size(); i < l; i++) {
- setFlag(ghRequest.route.getIndex(i), i);
- }
-}
-
-function createRouteCallback(request, routeResultsDiv, urlForHistory, doZoom) {
- return function (json) {
- routeResultsDiv.html("");
- if (json.message) {
- var tmpErrors = json.message;
- console.log(tmpErrors);
- if (json.hints) {
- for (var m = 0; m < json.hints.length; m++) {
- routeResultsDiv.append("" + json.hints[m].message + "
");
- }
- } else {
- routeResultsDiv.append("" + tmpErrors + "
");
- }
- return;
- }
-
- function createClickHandler(geoJsons, currentLayerIndex, tabHeader, oneTab, hasElevation, details) {
- return function () {
-
- var currentGeoJson = geoJsons[currentLayerIndex];
- mapLayer.eachLayer(function (layer) {
- // skip markers etc
- if (!layer.setStyle)
- return;
-
- var doHighlight = layer.feature === currentGeoJson;
- layer.setStyle(doHighlight ? highlightRouteStyle : alternativeRouteStye);
- if (doHighlight) {
- if (!L.Browser.ie && !L.Browser.opera)
- layer.bringToFront();
- }
- });
-
- if (hasElevation) {
- mapLayer.clearElevation();
- mapLayer.addElevation(currentGeoJson, details);
- }
-
- headerTabs.find("li").removeClass("current");
- routeResultsDiv.find("div").removeClass("current");
-
- tabHeader.addClass("current");
- oneTab.addClass("current");
- };
- }
-
- var headerTabs = $("");
- if (json.paths.length > 1) {
- routeResultsDiv.append(headerTabs);
- routeResultsDiv.append("");
- }
-
- // the routing layer uses the geojson properties.style for the style, see map.js
- var defaultRouteStyle = {color: "#00cc33", "weight": 5, "opacity": 0.6};
- var highlightRouteStyle = {color: "#00cc33", "weight": 6, "opacity": 0.8};
- var alternativeRouteStye = {color: "darkgray", "weight": 6, "opacity": 0.8};
- var geoJsons = [];
- var firstHeader;
-
- // Create buttons to toggle between SI and imperial units.
- var createUnitsChooserButtonClickHandler = function (useMiles) {
- return function () {
- mapLayer.updateScale(useMiles);
- ghRequest.useMiles = useMiles;
- resolveAll();
- if (ghRequest.route.isResolved())
- routeLatLng(ghRequest);
- };
- };
-
- if(json.paths.length > 0 && json.paths[0].points_order) {
- mapLayer.clearLayers();
- var po = json.paths[0].points_order;
- for (var i = 0; i < po.length; i++) {
- setFlag(ghRequest.route.getIndex(po[i]), i);
- }
- }
-
- for (var pathIndex = 0; pathIndex < json.paths.length; pathIndex++) {
- var tabHeader = $("").append((pathIndex + 1) + "
");
- if (pathIndex === 0)
- firstHeader = tabHeader;
-
- headerTabs.append(tabHeader);
- var path = json.paths[pathIndex];
- var style = (pathIndex === 0) ? defaultRouteStyle : alternativeRouteStye;
-
- var geojsonFeature = {
- "type": "Feature",
- "geometry": path.points,
- "properties": {
- "style": style,
- name: "route",
- snapped_waypoints: path.snapped_waypoints
- }
- };
-
- geoJsons.push(geojsonFeature);
- mapLayer.addDataToRoutingLayer(geojsonFeature);
- var oneTab = $("");
- routeResultsDiv.append(oneTab);
- tabHeader.click(createClickHandler(geoJsons, pathIndex, tabHeader, oneTab, request.hasElevation(), path.details));
-
- var routeInfo = $("
");
- if (path.description && path.description.length > 0) {
- routeInfo.text(path.description);
- routeInfo.append("
");
- }
-
- var tempDistance = translate.createDistanceString(path.distance, request.useMiles);
- var tempRouteInfo;
- if(request.isPublicTransit()) {
- var tempArrTime = moment(ghRequest.getEarliestDepartureTime())
- .add(path.time, 'milliseconds')
- .format('LT');
- if(path.transfers >= 0)
- tempRouteInfo = translate.tr("pt_route_info", [tempArrTime, path.transfers, tempDistance]);
- else
- tempRouteInfo = translate.tr("pt_route_info_walking", [tempArrTime, tempDistance]);
- } else {
- var tmpDuration = translate.createTimeString(path.time);
- tempRouteInfo = translate.tr("route_info", [tempDistance, tmpDuration]);
- }
-
- routeInfo.append(tempRouteInfo);
-
- var kmButton = $("