+ 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
+ });
+
+ if (object && object.type !== "note") query.set("select", object.type + object.id); // can't select notes
+ sendRemoteEditCommand(remoteEditHost + "/load_and_zoom?" + query, function () {
+ if (object && object.type === "note") {
+ const noteQuery = new URLSearchParams({ url: osmHost + OSM.apiUrl(object) });
+ sendRemoteEditCommand(remoteEditHost + "/import?" + noteQuery);
+ }
+ });
+
+ function sendRemoteEditCommand(url, callback) {
+ 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"));
+ });
+ }
+
+ return false;
+ }
+
+ $("a[data-editor=remote]").click(function (e) {