From 7821ec9ba9a5e2a55e0e49267cc777cff339f1a3 Mon Sep 17 00:00:00 2001 From: Simon Poole Date: Tue, 7 Mar 2017 18:19:51 +0100 Subject: [PATCH] Support android intent uri for JOSM style remote control when on an android device. --- app/assets/javascripts/index.js | 38 +++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/app/assets/javascripts/index.js b/app/assets/javascripts/index.js index b30564a1ae6..4e8126edc6b 100644 --- a/app/assets/javascripts/index.js +++ b/app/assets/javascripts/index.js @@ -238,11 +238,37 @@ $(document).ready(function () { L.marker(center, {icon: OSM.getUserIcon()}).addTo(map); }); + var isMobile = { + Windows: function() { + return /IEMobile/i.test(navigator.userAgent); + }, + Android: function() { + return /Android/i.test(navigator.userAgent); + }, + BlackBerry: function() { + return /BlackBerry/i.test(navigator.userAgent); + }, + iOS: function() { + return /iPhone|iPad|iPod/i.test(navigator.userAgent); + }, + any: function() { + return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Windows()); + } + }; + + function url() { + if (isMobile.Android()) { + return "intent:/load_and_zoom?"; + } else { + return document.location.protocol === "https:" ? + "https://127.0.0.1:8112/load_and_zoom?" : + "http://127.0.0.1:8111/load_and_zoom?"; + } + } + function remoteEditHandler(bbox, object) { var loaded = false, - url = document.location.protocol === "https:" ? - "https://127.0.0.1:8112/load_and_zoom?" : - "http://127.0.0.1:8111/load_and_zoom?", + android = isMobile.Android(), query = { left: bbox.getWest() - 0.0001, top: bbox.getNorth() + 0.0001, @@ -255,17 +281,17 @@ $(document).ready(function () { var iframe = $('