From 0e97f9b3773585d8fb76659dc710726a888c4851 Mon Sep 17 00:00:00 2001 From: Jochen Topf Date: Fri, 6 Mar 2015 14:31:01 +0100 Subject: Make JOSM button work in https mode. The JOSM button now contacts JOSM on http://localhost:8111/ if the taginfo page is using http and https://localhost:8112/ if it is using https. This way we don't have a problem with mixed content. Also the way JOSM is called now works without the iframes which were a hack around the (then) missing CORS ability. --- web/public/js/taginfo.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'web/public') diff --git a/web/public/js/taginfo.js b/web/public/js/taginfo.js index 92e7f70..21a8563 100644 --- a/web/public/js/taginfo.js +++ b/web/public/js/taginfo.js @@ -743,6 +743,26 @@ function comparison_list_change(key, value) { /* ============================ */ +function activate_josm_button() { + if (window.location.protocol == "https:") { + var url = jQuery('#josm_button')[0].href.replace('http://localhost:8111/', 'https://localhost:8112/'); + jQuery('#josm_button')[0].href = url; + } + + jQuery('#josm_button').bind('click', function() { + var url = jQuery('#josm_button')[0].href; + jQuery.get(url, function(data) { + if (data.substring(0, 2) != 'OK') { + alert("Problem contacting JOSM. Is it running? Is remote control activated?"); + console.log("Answer from JOSM: [" + data + "]"); + } + }); + return false; + }); +} + +/* ============================ */ + function project_tag_desc(description, icon, url) { var out = ''; if (icon) { -- cgit v1.2.3