From: Anton Khorev Date: Thu, 6 Feb 2025 19:10:31 +0000 (+0300) Subject: Merge branch 'pull/5627' X-Git-Tag: live~146 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/a9dcb66e7b835a45902e1257f47be3f625389831?hp=cb51f46a4ff913985d535afed0fd8d7d1d955126 Merge branch 'pull/5627' --- diff --git a/app/assets/javascripts/edit/id.js.erb b/app/assets/javascripts/edit/id.js.erb index 3af6fd3dc..588aa1e86 100644 --- a/app/assets/javascripts/edit/id.js.erb +++ b/app/assets/javascripts/edit/id.js.erb @@ -2,6 +2,7 @@ $(document).ready(function () { const id = $("#id-embed"); if (id.data("configured") === false) { + // eslint-disable-next-line no-alert alert(I18n.t("site.edit.id_not_configured")); return; } diff --git a/app/assets/javascripts/index.js b/app/assets/javascripts/index.js index 8ef067740..4555553ee 100644 --- a/app/assets/javascripts/index.js +++ b/app/assets/javascripts/index.js @@ -255,6 +255,7 @@ $(document).ready(function () { fetch(url, { mode: "no-cors", signal: AbortSignal.timeout(5000) }) .then(callback) .catch(function () { + // eslint-disable-next-line no-alert alert(I18n.t("site.index.remote_failed")); }); } diff --git a/app/assets/javascripts/index/directions-endpoint.js b/app/assets/javascripts/index/directions-endpoint.js index 30d499ad7..3fdae7c54 100644 --- a/app/assets/javascripts/index/directions-endpoint.js +++ b/app/assets/javascripts/index/directions-endpoint.js @@ -108,6 +108,7 @@ OSM.DirectionsEndpoint = function Endpoint(map, input, iconUrl, dragCallback, ch delete endpoint.geocodeRequest; if (json.length === 0) { input.addClass("is-invalid"); + // eslint-disable-next-line no-alert alert(I18n.t("javascripts.directions.errors.no_place", { place: endpoint.value })); return; } diff --git a/app/assets/javascripts/index/directions/fossgis_osrm.js b/app/assets/javascripts/index/directions/fossgis_osrm.js index 3989ff2b6..bd44be662 100644 --- a/app/assets/javascripts/index/directions/fossgis_osrm.js +++ b/app/assets/javascripts/index/directions/fossgis_osrm.js @@ -1,212 +1,214 @@ // OSRM engine // Doesn't yet support hints -function FOSSGISOSRMEngine(id, vehicleType) { - var cachedHints = []; - - return { - id: id, - creditline: "OSRM (FOSSGIS)", - draggable: true, - - _transformSteps: function (input_steps, line) { - var INSTRUCTION_TEMPLATE = { - "continue": "javascripts.directions.instructions.continue", - "merge right": "javascripts.directions.instructions.merge_right", - "merge left": "javascripts.directions.instructions.merge_left", - "off ramp right": "javascripts.directions.instructions.offramp_right", - "off ramp left": "javascripts.directions.instructions.offramp_left", - "on ramp right": "javascripts.directions.instructions.onramp_right", - "on ramp left": "javascripts.directions.instructions.onramp_left", - "fork right": "javascripts.directions.instructions.fork_right", - "fork left": "javascripts.directions.instructions.fork_left", - "end of road right": "javascripts.directions.instructions.endofroad_right", - "end of road left": "javascripts.directions.instructions.endofroad_left", - "turn straight": "javascripts.directions.instructions.continue", - "turn slight right": "javascripts.directions.instructions.slight_right", - "turn right": "javascripts.directions.instructions.turn_right", - "turn sharp right": "javascripts.directions.instructions.sharp_right", - "turn uturn": "javascripts.directions.instructions.uturn", - "turn sharp left": "javascripts.directions.instructions.sharp_left", - "turn left": "javascripts.directions.instructions.turn_left", - "turn slight left": "javascripts.directions.instructions.slight_left", - "roundabout": "javascripts.directions.instructions.roundabout", - "rotary": "javascripts.directions.instructions.roundabout", - "exit roundabout": "javascripts.directions.instructions.exit_roundabout", - "exit rotary": "javascripts.directions.instructions.exit_roundabout", - "depart": "javascripts.directions.instructions.start", - "arrive": "javascripts.directions.instructions.destination" - }; - var ICON_MAP = { - "continue": 0, - "merge right": 21, - "merge left": 20, - "off ramp right": 24, - "off ramp left": 25, - "on ramp right": 2, - "on ramp left": 6, - "fork right": 18, - "fork left": 19, - "end of road right": 22, - "end of road left": 23, - "turn straight": 0, - "turn slight right": 1, - "turn right": 2, - "turn sharp right": 3, - "turn uturn": 4, - "turn slight left": 5, - "turn left": 6, - "turn sharp left": 7, - "roundabout": 10, - "rotary": 10, - "exit roundabout": 10, - "exit rotary": 10, - "depart": 8, - "arrive": 14 - }; - var numToWord = function (num) { - return ["first", "second", "third", "fourth", "fifth", "sixth", "seventh", "eighth", "ninth", "tenth"][num - 1]; - }; - var transformed_steps = input_steps.map(function (step, idx) { - var maneuver_id; - - // special case handling - switch (step.maneuver.type) { - case "on ramp": - case "off ramp": - case "merge": - case "end of road": - case "fork": - maneuver_id = step.maneuver.type + " " + (step.maneuver.modifier.indexOf("left") >= 0 ? "left" : "right"); - break; - case "depart": - case "arrive": - case "roundabout": - case "rotary": - case "exit roundabout": - case "exit rotary": - maneuver_id = step.maneuver.type; - break; - case "roundabout turn": - case "turn": - maneuver_id = "turn " + step.maneuver.modifier; - break; - // for unknown types the fallback is turn - default: - maneuver_id = "turn " + step.maneuver.modifier; - break; - } - var template = INSTRUCTION_TEMPLATE[maneuver_id]; - - // convert lat,lng pairs to LatLng objects - var step_geometry = L.PolylineUtil.decode(step.geometry, { precision: 5 }).map(function (a) { return L.latLng(a); }); - // append step_geometry on line - Array.prototype.push.apply(line, step_geometry); - - var instText = "" + (idx + 1) + ". "; - var destinations = "" + step.destinations + ""; - var namedRoad = true; - var name; - - if (step.name && step.ref) { - name = "" + step.name + " (" + step.ref + ")"; - } else if (step.name) { - name = "" + step.name + ""; - } else if (step.ref) { - name = "" + step.ref + ""; - } else { - name = I18n.t("javascripts.directions.instructions.unnamed"); - namedRoad = false; - } +(function () { + function FOSSGISOSRMEngine(id, vehicleType) { + var cachedHints = []; + + return { + id: id, + creditline: "OSRM (FOSSGIS)", + draggable: true, + + _transformSteps: function (input_steps, line) { + var INSTRUCTION_TEMPLATE = { + "continue": "javascripts.directions.instructions.continue", + "merge right": "javascripts.directions.instructions.merge_right", + "merge left": "javascripts.directions.instructions.merge_left", + "off ramp right": "javascripts.directions.instructions.offramp_right", + "off ramp left": "javascripts.directions.instructions.offramp_left", + "on ramp right": "javascripts.directions.instructions.onramp_right", + "on ramp left": "javascripts.directions.instructions.onramp_left", + "fork right": "javascripts.directions.instructions.fork_right", + "fork left": "javascripts.directions.instructions.fork_left", + "end of road right": "javascripts.directions.instructions.endofroad_right", + "end of road left": "javascripts.directions.instructions.endofroad_left", + "turn straight": "javascripts.directions.instructions.continue", + "turn slight right": "javascripts.directions.instructions.slight_right", + "turn right": "javascripts.directions.instructions.turn_right", + "turn sharp right": "javascripts.directions.instructions.sharp_right", + "turn uturn": "javascripts.directions.instructions.uturn", + "turn sharp left": "javascripts.directions.instructions.sharp_left", + "turn left": "javascripts.directions.instructions.turn_left", + "turn slight left": "javascripts.directions.instructions.slight_left", + "roundabout": "javascripts.directions.instructions.roundabout", + "rotary": "javascripts.directions.instructions.roundabout", + "exit roundabout": "javascripts.directions.instructions.exit_roundabout", + "exit rotary": "javascripts.directions.instructions.exit_roundabout", + "depart": "javascripts.directions.instructions.start", + "arrive": "javascripts.directions.instructions.destination" + }; + var ICON_MAP = { + "continue": 0, + "merge right": 21, + "merge left": 20, + "off ramp right": 24, + "off ramp left": 25, + "on ramp right": 2, + "on ramp left": 6, + "fork right": 18, + "fork left": 19, + "end of road right": 22, + "end of road left": 23, + "turn straight": 0, + "turn slight right": 1, + "turn right": 2, + "turn sharp right": 3, + "turn uturn": 4, + "turn slight left": 5, + "turn left": 6, + "turn sharp left": 7, + "roundabout": 10, + "rotary": 10, + "exit roundabout": 10, + "exit rotary": 10, + "depart": 8, + "arrive": 14 + }; + var numToWord = function (num) { + return ["first", "second", "third", "fourth", "fifth", "sixth", "seventh", "eighth", "ninth", "tenth"][num - 1]; + }; + var transformed_steps = input_steps.map(function (step, idx) { + var maneuver_id; + + // special case handling + switch (step.maneuver.type) { + case "on ramp": + case "off ramp": + case "merge": + case "end of road": + case "fork": + maneuver_id = step.maneuver.type + " " + (step.maneuver.modifier.indexOf("left") >= 0 ? "left" : "right"); + break; + case "depart": + case "arrive": + case "roundabout": + case "rotary": + case "exit roundabout": + case "exit rotary": + maneuver_id = step.maneuver.type; + break; + case "roundabout turn": + case "turn": + maneuver_id = "turn " + step.maneuver.modifier; + break; + // for unknown types the fallback is turn + default: + maneuver_id = "turn " + step.maneuver.modifier; + break; + } + var template = INSTRUCTION_TEMPLATE[maneuver_id]; + + // convert lat,lng pairs to LatLng objects + var step_geometry = L.PolylineUtil.decode(step.geometry, { precision: 5 }).map(function (a) { return L.latLng(a); }); + // append step_geometry on line + Array.prototype.push.apply(line, step_geometry); + + var instText = "" + (idx + 1) + ". "; + var destinations = "" + step.destinations + ""; + var namedRoad = true; + var name; + + if (step.name && step.ref) { + name = "" + step.name + " (" + step.ref + ")"; + } else if (step.name) { + name = "" + step.name + ""; + } else if (step.ref) { + name = "" + step.ref + ""; + } else { + name = I18n.t("javascripts.directions.instructions.unnamed"); + namedRoad = false; + } - if (step.maneuver.type.match(/^exit (rotary|roundabout)$/)) { - instText += I18n.t(template, { name: name }); - } else if (step.maneuver.type.match(/^(rotary|roundabout)$/)) { - if (step.maneuver.exit) { - if (step.maneuver.exit <= 10) { - instText += I18n.t(template + "_with_exit_ordinal", { exit: I18n.t("javascripts.directions.instructions.exit_counts." + numToWord(step.maneuver.exit)), name: name }); + if (step.maneuver.type.match(/^exit (rotary|roundabout)$/)) { + instText += I18n.t(template, { name: name }); + } else if (step.maneuver.type.match(/^(rotary|roundabout)$/)) { + if (step.maneuver.exit) { + if (step.maneuver.exit <= 10) { + instText += I18n.t(template + "_with_exit_ordinal", { exit: I18n.t("javascripts.directions.instructions.exit_counts." + numToWord(step.maneuver.exit)), name: name }); + } else { + instText += I18n.t(template + "_with_exit", { exit: step.maneuver.exit, name: name }); + } } else { - instText += I18n.t(template + "_with_exit", { exit: step.maneuver.exit, name: name }); + instText += I18n.t(template + "_without_exit", { name: name }); } + } else if (step.maneuver.type.match(/^(on ramp|off ramp)$/)) { + var params = {}; + if (step.exits && step.maneuver.type.match(/^(off ramp)$/)) params.exit = step.exits; + if (step.destinations) params.directions = destinations; + if (namedRoad) params.directions = name; + if (Object.keys(params).length > 0) { + template = template + "_with_" + Object.keys(params).join("_"); + } + instText += I18n.t(template, params); } else { instText += I18n.t(template + "_without_exit", { name: name }); } - } else if (step.maneuver.type.match(/^(on ramp|off ramp)$/)) { - var params = {}; - if (step.exits && step.maneuver.type.match(/^(off ramp)$/)) params.exit = step.exits; - if (step.destinations) params.directions = destinations; - if (namedRoad) params.directions = name; - if (Object.keys(params).length > 0) { - template = template + "_with_" + Object.keys(params).join("_"); - } - instText += I18n.t(template, params); - } else { - instText += I18n.t(template + "_without_exit", { name: name }); - } - return [[step.maneuver.location[1], step.maneuver.location[0]], ICON_MAP[maneuver_id], instText, step.distance, step_geometry]; - }); + return [[step.maneuver.location[1], step.maneuver.location[0]], ICON_MAP[maneuver_id], instText, step.distance, step_geometry]; + }); - return transformed_steps; - }, + return transformed_steps; + }, - getRoute: function (points, callback) { - var params = [ - { name: "overview", value: "false" }, - { name: "geometries", value: "polyline" }, - { name: "steps", value: true } - ]; + getRoute: function (points, callback) { + var params = [ + { name: "overview", value: "false" }, + { name: "geometries", value: "polyline" }, + { name: "steps", value: true } + ]; - if (cachedHints.length === points.length) { - params.push({ name: "hints", value: cachedHints.join(";") }); - } else { + if (cachedHints.length === points.length) { + params.push({ name: "hints", value: cachedHints.join(";") }); + } else { // invalidate cache - cachedHints = []; - } + cachedHints = []; + } - var encoded_coords = points.map(function (p) { - return p.lng + "," + p.lat; - }).join(";"); + var encoded_coords = points.map(function (p) { + return p.lng + "," + p.lat; + }).join(";"); - var req_url = OSM.FOSSGIS_OSRM_URL + "routed-" + vehicleType + "/route/v1/driving/" + encoded_coords; + var req_url = OSM.FOSSGIS_OSRM_URL + "routed-" + vehicleType + "/route/v1/driving/" + encoded_coords; - var onResponse = function (data) { - if (data.code !== "Ok") { - return callback(true); - } + var onResponse = function (data) { + if (data.code !== "Ok") { + return callback(true); + } - cachedHints = data.waypoints.map(function (wp) { - return wp.hint; - }); + cachedHints = data.waypoints.map(function (wp) { + return wp.hint; + }); - var line = []; - var transformLeg = function (leg) { - return this._transformSteps(leg.steps, line); - }; + var line = []; + var transformLeg = function (leg) { + return this._transformSteps(leg.steps, line); + }; - var steps = [].concat.apply([], data.routes[0].legs.map(transformLeg.bind(this))); + var steps = [].concat.apply([], data.routes[0].legs.map(transformLeg.bind(this))); - callback(false, { - line: line, - steps: steps, - distance: data.routes[0].distance, - time: data.routes[0].duration + callback(false, { + line: line, + steps: steps, + distance: data.routes[0].distance, + time: data.routes[0].duration + }); + }; + + return $.ajax({ + url: req_url, + data: params, + dataType: "json", + success: onResponse.bind(this), + error: function () { + callback(true); + } }); - }; - - return $.ajax({ - url: req_url, - data: params, - dataType: "json", - success: onResponse.bind(this), - error: function () { - callback(true); - } - }); - } - }; -} - -OSM.Directions.addEngine(new FOSSGISOSRMEngine("fossgis_osrm_car", "car"), true); -OSM.Directions.addEngine(new FOSSGISOSRMEngine("fossgis_osrm_bike", "bike"), true); -OSM.Directions.addEngine(new FOSSGISOSRMEngine("fossgis_osrm_foot", "foot"), true); + } + }; + } + + OSM.Directions.addEngine(new FOSSGISOSRMEngine("fossgis_osrm_car", "car"), true); + OSM.Directions.addEngine(new FOSSGISOSRMEngine("fossgis_osrm_bike", "bike"), true); + OSM.Directions.addEngine(new FOSSGISOSRMEngine("fossgis_osrm_foot", "foot"), true); +}()); diff --git a/app/assets/javascripts/index/directions/fossgis_valhalla.js b/app/assets/javascripts/index/directions/fossgis_valhalla.js index 619f8f1e3..bc093fea4 100644 --- a/app/assets/javascripts/index/directions/fossgis_valhalla.js +++ b/app/assets/javascripts/index/directions/fossgis_valhalla.js @@ -1,118 +1,120 @@ -function FOSSGISValhallaEngine(id, costing) { - var INSTR_MAP = [ - 0, // kNone = 0; - 8, // kStart = 1; - 8, // kStartRight = 2; - 8, // kStartLeft = 3; - 14, // kDestination = 4; - 14, // kDestinationRight = 5; - 14, // kDestinationLeft = 6; - 0, // kBecomes = 7; - 0, // kContinue = 8; - 1, // kSlightRight = 9; - 2, // kRight = 10; - 3, // kSharpRight = 11; - 4, // kUturnRight = 12; - 4, // kUturnLeft = 13; - 7, // kSharpLeft = 14; - 6, // kLeft = 15; - 5, // kSlightLeft = 16; - 0, // kRampStraight = 17; - 24, // kRampRight = 18; - 25, // kRampLeft = 19; - 24, // kExitRight = 20; - 25, // kExitLeft = 21; - 0, // kStayStraight = 22; - 1, // kStayRight = 23; - 5, // kStayLeft = 24; - 20, // kMerge = 25; - 10, // kRoundaboutEnter = 26; - 10, // kRoundaboutExit = 27; - 17, // kFerryEnter = 28; - 0, // kFerryExit = 29; - null, // kTransit = 30; - null, // kTransitTransfer = 31; - null, // kTransitRemainOn = 32; - null, // kTransitConnectionStart = 33; - null, // kTransitConnectionTransfer = 34; - null, // kTransitConnectionDestination = 35; - null, // kPostTransitConnectionDestination = 36; - 21, // kMergeRight = 37; - 20 // kMergeLeft = 38; - ]; +(function () { + function FOSSGISValhallaEngine(id, costing) { + var INSTR_MAP = [ + 0, // kNone = 0; + 8, // kStart = 1; + 8, // kStartRight = 2; + 8, // kStartLeft = 3; + 14, // kDestination = 4; + 14, // kDestinationRight = 5; + 14, // kDestinationLeft = 6; + 0, // kBecomes = 7; + 0, // kContinue = 8; + 1, // kSlightRight = 9; + 2, // kRight = 10; + 3, // kSharpRight = 11; + 4, // kUturnRight = 12; + 4, // kUturnLeft = 13; + 7, // kSharpLeft = 14; + 6, // kLeft = 15; + 5, // kSlightLeft = 16; + 0, // kRampStraight = 17; + 24, // kRampRight = 18; + 25, // kRampLeft = 19; + 24, // kExitRight = 20; + 25, // kExitLeft = 21; + 0, // kStayStraight = 22; + 1, // kStayRight = 23; + 5, // kStayLeft = 24; + 20, // kMerge = 25; + 10, // kRoundaboutEnter = 26; + 10, // kRoundaboutExit = 27; + 17, // kFerryEnter = 28; + 0, // kFerryExit = 29; + null, // kTransit = 30; + null, // kTransitTransfer = 31; + null, // kTransitRemainOn = 32; + null, // kTransitConnectionStart = 33; + null, // kTransitConnectionTransfer = 34; + null, // kTransitConnectionDestination = 35; + null, // kPostTransitConnectionDestination = 36; + 21, // kMergeRight = 37; + 20 // kMergeLeft = 38; + ]; - return { - id: id, - creditline: + return { + id: id, + creditline: "Valhalla (FOSSGIS)", - draggable: false, + draggable: false, - getRoute: function (points, callback) { - return $.ajax({ - url: OSM.FOSSGIS_VALHALLA_URL, - data: { - json: JSON.stringify({ - locations: points.map(function (p) { - return { lat: p.lat, lon: p.lng, radius: 5 }; - }), - costing: costing, - directions_options: { - units: "km", - language: I18n.currentLocale() - } - }) - }, - dataType: "json", - success: function (data) { - var trip = data.trip; + getRoute: function (points, callback) { + return $.ajax({ + url: OSM.FOSSGIS_VALHALLA_URL, + data: { + json: JSON.stringify({ + locations: points.map(function (p) { + return { lat: p.lat, lon: p.lng, radius: 5 }; + }), + costing: costing, + directions_options: { + units: "km", + language: I18n.currentLocale() + } + }) + }, + dataType: "json", + success: function (data) { + var trip = data.trip; - if (trip.status === 0) { - var line = []; - var steps = []; - var distance = 0; - var time = 0; + if (trip.status === 0) { + var line = []; + var steps = []; + var distance = 0; + var time = 0; - trip.legs.forEach(function (leg) { - var legLine = L.PolylineUtil.decode(leg.shape, { - precision: 6 - }); + trip.legs.forEach(function (leg) { + var legLine = L.PolylineUtil.decode(leg.shape, { + precision: 6 + }); - line = line.concat(legLine); + line = line.concat(legLine); - leg.maneuvers.forEach(function (manoeuvre, idx) { - var point = legLine[manoeuvre.begin_shape_index]; + leg.maneuvers.forEach(function (manoeuvre, idx) { + var point = legLine[manoeuvre.begin_shape_index]; - steps.push([ - { lat: point[0], lng: point[1] }, - INSTR_MAP[manoeuvre.type], - "" + (idx + 1) + ". " + manoeuvre.instruction, - manoeuvre.length * 1000, - [] - ]); - }); + steps.push([ + { lat: point[0], lng: point[1] }, + INSTR_MAP[manoeuvre.type], + "" + (idx + 1) + ". " + manoeuvre.instruction, + manoeuvre.length * 1000, + [] + ]); + }); - distance = distance + leg.summary.length; - time = time + leg.summary.time; - }); + distance = distance + leg.summary.length; + time = time + leg.summary.time; + }); - callback(false, { - line: line, - steps: steps, - distance: distance * 1000, - time: time - }); - } else { + callback(false, { + line: line, + steps: steps, + distance: distance * 1000, + time: time + }); + } else { + callback(true); + } + }, + error: function () { callback(true); } - }, - error: function () { - callback(true); - } - }); - } - }; -} + }); + } + }; + } -OSM.Directions.addEngine(new FOSSGISValhallaEngine("fossgis_valhalla_car", "auto"), true); -OSM.Directions.addEngine(new FOSSGISValhallaEngine("fossgis_valhalla_bicycle", "bicycle"), true); -OSM.Directions.addEngine(new FOSSGISValhallaEngine("fossgis_valhalla_foot", "pedestrian"), true); + OSM.Directions.addEngine(new FOSSGISValhallaEngine("fossgis_valhalla_car", "auto"), true); + OSM.Directions.addEngine(new FOSSGISValhallaEngine("fossgis_valhalla_bicycle", "bicycle"), true); + OSM.Directions.addEngine(new FOSSGISValhallaEngine("fossgis_valhalla_foot", "pedestrian"), true); +}()); diff --git a/app/assets/javascripts/index/directions/graphhopper.js b/app/assets/javascripts/index/directions/graphhopper.js index e72f6d75f..021fc7b64 100644 --- a/app/assets/javascripts/index/directions/graphhopper.js +++ b/app/assets/javascripts/index/directions/graphhopper.js @@ -1,90 +1,92 @@ -function GraphHopperEngine(id, vehicleType) { - var GH_INSTR_MAP = { - "-3": 7, // sharp left - "-2": 6, // left - "-1": 5, // slight left - "0": 0, // straight - "1": 1, // slight right - "2": 2, // right - "3": 3, // sharp right - "4": 14, // finish reached - "5": 14, // via reached - "6": 10, // roundabout - "-7": 19, // keep left - "7": 18, // keep right - "-98": 4, // unknown direction u-turn - "-8": 4, // left u-turn - "8": 4 // right u-turn - }; +(function () { + function GraphHopperEngine(id, vehicleType) { + var GH_INSTR_MAP = { + "-3": 7, // sharp left + "-2": 6, // left + "-1": 5, // slight left + "0": 0, // straight + "1": 1, // slight right + "2": 2, // right + "3": 3, // sharp right + "4": 14, // finish reached + "5": 14, // via reached + "6": 10, // roundabout + "-7": 19, // keep left + "7": 18, // keep right + "-98": 4, // unknown direction u-turn + "-8": 4, // left u-turn + "8": 4 // right u-turn + }; - return { - id: id, - creditline: "GraphHopper", - draggable: false, + return { + id: id, + creditline: "GraphHopper", + draggable: false, - getRoute: function (points, callback) { + getRoute: function (points, callback) { // GraphHopper Directions API documentation // https://graphhopper.com/api/1/docs/routing/ - return $.ajax({ - url: OSM.GRAPHHOPPER_URL, - data: { - vehicle: vehicleType, - locale: I18n.currentLocale(), - key: "LijBPDQGfu7Iiq80w3HzwB4RUDJbMbhs6BU0dEnn", - elevation: false, - instructions: true, - turn_costs: vehicleType === "car", - point: points.map(function (p) { return p.lat + "," + p.lng; }) - }, - traditional: true, - dataType: "json", - success: function (data) { - if (!data.paths || data.paths.length === 0) { - return callback(true); - } + return $.ajax({ + url: OSM.GRAPHHOPPER_URL, + data: { + vehicle: vehicleType, + locale: I18n.currentLocale(), + key: "LijBPDQGfu7Iiq80w3HzwB4RUDJbMbhs6BU0dEnn", + elevation: false, + instructions: true, + turn_costs: vehicleType === "car", + point: points.map(function (p) { return p.lat + "," + p.lng; }) + }, + traditional: true, + dataType: "json", + success: function (data) { + if (!data.paths || data.paths.length === 0) { + return callback(true); + } - var path = data.paths[0]; - var line = L.PolylineUtil.decode(path.points); + var path = data.paths[0]; + var line = L.PolylineUtil.decode(path.points); - var steps = []; - var len = path.instructions.length; - for (var i = 0; i < len; i++) { - var instr = path.instructions[i]; - var instrCode = (i === len - 1) ? 14 : GH_INSTR_MAP[instr.sign]; - var instrText = "" + (i + 1) + ". "; - instrText += instr.text; - var latLng = line[instr.interval[0]]; - var distInMeter = instr.distance; - var lineseg = []; - for (var j = instr.interval[0]; j <= instr.interval[1]; j++) { - lineseg.push({ lat: line[j][0], lng: line[j][1] }); + var steps = []; + var len = path.instructions.length; + for (var i = 0; i < len; i++) { + var instr = path.instructions[i]; + var instrCode = (i === len - 1) ? 14 : GH_INSTR_MAP[instr.sign]; + var instrText = "" + (i + 1) + ". "; + instrText += instr.text; + var latLng = line[instr.interval[0]]; + var distInMeter = instr.distance; + var lineseg = []; + for (var j = instr.interval[0]; j <= instr.interval[1]; j++) { + lineseg.push({ lat: line[j][0], lng: line[j][1] }); + } + steps.push([ + { lat: latLng[0], lng: latLng[1] }, + instrCode, + instrText, + distInMeter, + lineseg + ]); // TODO does graphhopper map instructions onto line indices? } - steps.push([ - { lat: latLng[0], lng: latLng[1] }, - instrCode, - instrText, - distInMeter, - lineseg - ]); // TODO does graphhopper map instructions onto line indices? - } - callback(false, { - line: line, - steps: steps, - distance: path.distance, - time: path.time / 1000, - ascend: path.ascend, - descend: path.descend - }); - }, - error: function () { - callback(true); - } - }); - } - }; -} + callback(false, { + line: line, + steps: steps, + distance: path.distance, + time: path.time / 1000, + ascend: path.ascend, + descend: path.descend + }); + }, + error: function () { + callback(true); + } + }); + } + }; + } -OSM.Directions.addEngine(new GraphHopperEngine("graphhopper_car", "car"), true); -OSM.Directions.addEngine(new GraphHopperEngine("graphhopper_bicycle", "bike"), true); -OSM.Directions.addEngine(new GraphHopperEngine("graphhopper_foot", "foot"), true); + OSM.Directions.addEngine(new GraphHopperEngine("graphhopper_car", "car"), true); + OSM.Directions.addEngine(new GraphHopperEngine("graphhopper_bicycle", "bike"), true); + OSM.Directions.addEngine(new GraphHopperEngine("graphhopper_foot", "foot"), true); +}()); diff --git a/app/assets/javascripts/social_share_button.js b/app/assets/javascripts/social_share_button.js index 34db84758..b118c1d3b 100644 --- a/app/assets/javascripts/social_share_button.js +++ b/app/assets/javascripts/social_share_button.js @@ -1,15 +1,15 @@ -function openShareUrl(url, initialWidth = 640, initialHeight = 480) { - const width = Math.max(100, Math.min(screen.width, initialWidth)); - const height = Math.max(100, Math.min(screen.height, initialHeight)); +$(document).ready(function () { + function openShareUrl(url, initialWidth = 640, initialHeight = 480) { + const width = Math.max(100, Math.min(screen.width, initialWidth)); + const height = Math.max(100, Math.min(screen.height, initialHeight)); - const left = screenLeft + ((outerWidth - width) / 2); - const top = screenTop + ((outerHeight - height) / 2); - const opts = `width=${width},height=${height},left=${left},top=${top},menubar=no,status=no,location=no`; + const left = screenLeft + ((outerWidth - width) / 2); + const top = screenTop + ((outerHeight - height) / 2); + const opts = `width=${width},height=${height},left=${left},top=${top},menubar=no,status=no,location=no`; - window.open(url, "popup", opts); -} + window.open(url, "popup", opts); + } -$(document).ready(function () { $(".ssb-icon").on("click", function (e) { const shareUrl = $(this).attr("href"); if (!shareUrl.startsWith("mailto:")) { @@ -18,4 +18,3 @@ $(document).ready(function () { } }); }); - diff --git a/config/eslint.js b/config/eslint.js index cb421a992..90040f7bf 100644 --- a/config/eslint.js +++ b/config/eslint.js @@ -86,7 +86,7 @@ module.exports = [ "curly": ["error", "multi-line", "consistent"], "dot-notation": "error", "eqeqeq": ["error", "smart"], - "no-alert": "warn", + "no-alert": "error", "no-array-constructor": "error", "no-caller": "error", "no-console": "warn", @@ -97,7 +97,7 @@ module.exports = [ "no-extra-bind": "error", "no-extra-label": "error", "no-implicit-coercion": "warn", - "no-implicit-globals": "warn", + "no-implicit-globals": "error", "no-implied-eval": "error", "no-invalid-this": "error", "no-iterator": "error", diff --git a/config/locales/en.yml b/config/locales/en.yml index 25794cc9f..7b2be6a0c 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -836,7 +836,7 @@ en: census: "Census Boundary" national_park: "National Park" political: "Electoral Boundary" - protected_area : "Protected Area" + protected_area: "Protected Area" "yes": "Boundary" bridge: aqueduct: "Aqueduct" @@ -987,7 +987,7 @@ en: turning_circle: "Turning Circle" turning_loop: "Turning Loop" unclassified: "Unclassified Road" - "yes" : "Road" + "yes": "Road" historic: aircraft: "Historic Aircraft" archaeological_site: "Archaeological Site" @@ -1167,7 +1167,7 @@ en: trench: "Trench" "yes": "Military" mountain_pass: - "yes" : "Mountain Pass" + "yes": "Mountain Pass" natural: atoll: "Atoll" bare_rock: "Bare Rock" diff --git a/vendor/assets/iD/iD.css.erb b/vendor/assets/iD/iD.css.erb index f10dc9ba1..e695dbb43 100644 --- a/vendor/assets/iD/iD.css.erb +++ b/vendor/assets/iD/iD.css.erb @@ -7919,7 +7919,8 @@ } } -.ideditor img.tile-removing { +.ideditor .layer-background img.tile-removing, +.ideditor .map-in-map-background img.tile-removing { opacity: 0; z-index: 1; mix-blend-mode: normal; diff --git a/vendor/assets/iD/iD.js b/vendor/assets/iD/iD.js index bd1f5a5dd..add1166ba 100644 --- a/vendor/assets/iD/iD.js +++ b/vendor/assets/iD/iD.js @@ -21616,7 +21616,7 @@ // package.json var package_default = { name: "iD", - version: "2.31.0", + version: "2.31.1", description: "A friendly editor for OpenStreetMap", main: "dist/iD.min.js", repository: "github:openstreetmap/iD",