diff --git a/app/assets/javascripts/index.js b/app/assets/javascripts/index.js index 4555553ee7..11701b6404 100644 --- a/app/assets/javascripts/index.js +++ b/app/assets/javascripts/index.js @@ -234,17 +234,10 @@ $(document).ready(function () { }); function remoteEditHandler(bbox, object) { - var remoteEditHost = "http://127.0.0.1:8111", - osmHost = location.protocol + "//" + location.host, - query = new URLSearchParams({ - left: bbox.getWest() - 0.0001, - top: bbox.getNorth() + 0.0001, - right: bbox.getEast() + 0.0001, - bottom: bbox.getSouth() - 0.0001 - }); + const remoteEditHost = "http://127.0.0.1:8111", + osmHost = location.protocol + "//" + location.host; - if (object && object.type !== "note") query.set("select", object.type + object.id); // can't select notes - sendRemoteEditCommand(remoteEditHost + "/load_and_zoom?" + query, function () { + sendRemoteEditCommand(remoteEditHost + getLoadAndZoomPath(bbox, object), () => { if (object && object.type === "note") { const noteQuery = new URLSearchParams({ url: osmHost + OSM.apiUrl(object) }); sendRemoteEditCommand(remoteEditHost + "/import?" + noteQuery); @@ -263,12 +256,29 @@ $(document).ready(function () { return false; } + function getLoadAndZoomPath(bbox, object) { + const query = new URLSearchParams({ + left: bbox.getWest() - 0.0001, + top: bbox.getNorth() + 0.0001, + right: bbox.getEast() + 0.0001, + bottom: bbox.getSouth() - 0.0001 + }); + + if (object && object.type !== "note") query.set("select", object.type + object.id); // can't select notes + return "/load_and_zoom?" + query; + } + $("a[data-editor=remote]").click(function (e) { var params = OSM.mapParams(this.search); remoteEditHandler(map.getBounds(), params.object); e.preventDefault(); }); + $("a[data-editor=josm_scheme]").click(function () { + var params = OSM.mapParams(this.search); + $(this).attr("href", "josm:" + getLoadAndZoomPath(map.getBounds(), params.object)); + }); + if (OSM.params().edit_help) { $("#editanchor") .removeAttr("title") diff --git a/config/locales/en.yml b/config/locales/en.yml index 7b2be6a0cb..90e8c5043d 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -210,6 +210,9 @@ en: remote: name: "Remote Control" description: "Remote Control (JOSM, Potlatch, Merkaartor)" + josm_scheme: + name: "josm: URI scheme" + description: "josm: URI scheme (Vespucci)" auth: providers: none: None diff --git a/lib/editors.rb b/lib/editors.rb index e1c4054f37..23e38ccc53 100644 --- a/lib/editors.rb +++ b/lib/editors.rb @@ -1,5 +1,5 @@ module Editors ALL_EDITORS = %w[potlatch potlatch2 id remote].freeze AVAILABLE_EDITORS = %w[id remote].freeze - RECOMMENDED_EDITORS = %w[id remote].freeze + RECOMMENDED_EDITORS = %w[id remote josm_scheme].freeze end