Skip to content

Commit

Permalink
Add josm scheme link to edit menu
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonKhorev committed Nov 22, 2024
1 parent 257f467 commit 1a8a276
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 11 deletions.
28 changes: 18 additions & 10 deletions app/assets/javascripts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -275,12 +267,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 (e) {
var params = OSM.mapParams(this.search);
$(this).attr("href", "josm:" + getLoadAndZoomPath(map.getBounds(), params.object));
});

if (OSM.params().edit_help) {
$("#editanchor")
.removeAttr("title")
Expand Down
3 changes: 3 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,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
Expand Down
2 changes: 1 addition & 1 deletion lib/editors.rb
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 1a8a276

Please sign in to comment.