From 438c8a18fc6c4c49480ed7ace2ac8cbae977c11e Mon Sep 17 00:00:00 2001 From: Anton Khorev Date: Fri, 22 Nov 2024 18:57:33 +0300 Subject: [PATCH] Add josm scheme link to edit menu --- app/assets/javascripts/index.js | 28 ++++++++++++++++++---------- config/locales/en.yml | 3 +++ lib/editors.rb | 2 +- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/app/assets/javascripts/index.js b/app/assets/javascripts/index.js index 9df0f0ad5a..4a293418fa 100644 --- a/app/assets/javascripts/index.js +++ b/app/assets/javascripts/index.js @@ -238,16 +238,8 @@ $(document).ready(function () { function remoteEditHandler(bbox, object) { var remoteEditHost = "http://127.0.0.1:8111", - osmHost = location.protocol + "//" + location.host, - query = { - 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.select = object.type + object.id; // can't select notes - sendRemoteEditCommand(remoteEditHost + "/load_and_zoom?" + Qs.stringify(query), function () { + osmHost = location.protocol + "//" + location.host; + sendRemoteEditCommand(remoteEditHost + getLoadAndZoomPath(bbox, object), function () { if (object && object.type === "note") { var noteQuery = { url: osmHost + OSM.apiUrl(object) }; sendRemoteEditCommand(remoteEditHost + "/import?" + Qs.stringify(noteQuery)); @@ -265,12 +257,28 @@ $(document).ready(function () { return false; } + function getLoadAndZoomPath(bbox, object) { + var query = { + 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.select = object.type + object.id; // can't select notes + return "/load_and_zoom?" + Qs.stringify(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 c423de7666..c096dc471a 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -213,6 +213,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