From 23ffdadb565be5ccc4ae9fad9647bdf0fa9b8683 Mon Sep 17 00:00:00 2001 From: Richard Fairhurst Date: Mon, 10 Mar 2014 18:02:28 +0000 Subject: [PATCH] Don't show http-only routers to users on https --- app/assets/javascripts/routing.js.erb | 5 ++++- app/assets/javascripts/routing_engines/graphhopper.js | 4 ++-- app/assets/javascripts/routing_engines/mapquest.js | 8 ++++---- app/assets/javascripts/routing_engines/osrm.js | 2 +- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/app/assets/javascripts/routing.js.erb b/app/assets/javascripts/routing.js.erb index 42e4ba2bc..84bf17832 100644 --- a/app/assets/javascripts/routing.js.erb +++ b/app/assets/javascripts/routing.js.erb @@ -18,7 +18,10 @@ var ROUTING_POLYLINE_HIGHLIGHT={ OSM.RoutingEngines={ - list: [] + list: [], + add: function(supportsHTTPS,engine) { + if (document.location.protocol=="http:" || supportsHTTPS) this.list.push(engine); + } }; OSM.Routing=function(map,name,jqSearch) { diff --git a/app/assets/javascripts/routing_engines/graphhopper.js b/app/assets/javascripts/routing_engines/graphhopper.js index 5e14ea0df..6d83e26e2 100644 --- a/app/assets/javascripts/routing_engines/graphhopper.js +++ b/app/assets/javascripts/routing_engines/graphhopper.js @@ -59,5 +59,5 @@ GraphHopperEngine.prototype.createConfig = function() { }; }; -OSM.RoutingEngines.list.push(new GraphHopperEngine("Bicycle", "vehicle=bike").createConfig()); -OSM.RoutingEngines.list.push(new GraphHopperEngine("Foot", "vehicle=foot").createConfig()); +OSM.RoutingEngines.add(false, new GraphHopperEngine("Bicycle", "vehicle=bike").createConfig()); +OSM.RoutingEngines.add(false, new GraphHopperEngine("Foot", "vehicle=foot").createConfig()); diff --git a/app/assets/javascripts/routing_engines/mapquest.js b/app/assets/javascripts/routing_engines/mapquest.js index fd17e5942..dc854ccdc 100644 --- a/app/assets/javascripts/routing_engines/mapquest.js +++ b/app/assets/javascripts/routing_engines/mapquest.js @@ -40,7 +40,7 @@ MapQuestEngine.prototype.createConfig = function() { 18: 1 // straight fork }, getRoute: function(isFinal,points) { - var url="http://open.mapquestapi.com/directions/v2/route?key=Fmjtd%7Cluur290anu%2Crl%3Do5-908a0y"; + var url=document.location.protocol+"//open.mapquestapi.com/directions/v2/route?key=Fmjtd%7Cluur290anu%2Crl%3Do5-908a0y"; var from=points[0]; var to=points[points.length-1]; url+="&from="+from.join(','); url+="&to="+to.join(','); @@ -88,7 +88,7 @@ MapQuestEngine.prototype.createConfig = function() { }; }; -OSM.RoutingEngines.list.push(new MapQuestEngine("Bicycle", "routeType=bicycle").createConfig()); -OSM.RoutingEngines.list.push(new MapQuestEngine("Foot", "routeType=pedestrian").createConfig()); -OSM.RoutingEngines.list.push(new MapQuestEngine("Car", "routeType=fastest").createConfig()); +OSM.RoutingEngines.add(true, new MapQuestEngine("Bicycle", "routeType=bicycle").createConfig()); +OSM.RoutingEngines.add(true, new MapQuestEngine("Foot", "routeType=pedestrian").createConfig()); +OSM.RoutingEngines.add(true, new MapQuestEngine("Car", "routeType=fastest").createConfig()); // can be: routeType=fastest|shortest|pedestrian|multimodal|bicycle diff --git a/app/assets/javascripts/routing_engines/osrm.js b/app/assets/javascripts/routing_engines/osrm.js index 5808fb7ee..660a306ea 100644 --- a/app/assets/javascripts/routing_engines/osrm.js +++ b/app/assets/javascripts/routing_engines/osrm.js @@ -57,4 +57,4 @@ OSRMEngine.prototype.createConfig = function() { }; }; -OSM.RoutingEngines.list.push(new OSRMEngine("Car", "http://router.project-osrm.org/viaroute").createConfig()); +OSM.RoutingEngines.add(false, new OSRMEngine("Car", "http://router.project-osrm.org/viaroute").createConfig()); -- 2.43.2