Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add josm scheme link to edit menu #5351

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 All @@ -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")
Expand Down
3 changes: 3 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
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
Loading