From: Dan Stowell Date: Tue, 11 Apr 2017 18:42:37 +0000 (+0100) Subject: Remember user's choice of directions engine X-Git-Tag: live~3396^2 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/5f35d37fee5a24a0f69ba375531e314eda85b573?hp=8f9a72c7f7b59092cb253054756a965d26421e8c Remember user's choice of directions engine --- diff --git a/app/assets/javascripts/index/directions.js b/app/assets/javascripts/index/directions.js index 11601c5b2..bb835f2fb 100644 --- a/app/assets/javascripts/index/directions.js +++ b/app/assets/javascripts/index/directions.js @@ -26,6 +26,9 @@ OSM.Directions = function (map) { Endpoint($("input[name='route_to']"), OSM.MARKER_RED) ]; + var expiry = new Date(); + expiry.setYear(expiry.getFullYear() + 10); + function Endpoint(input, iconUrl) { var endpoint = {}; @@ -292,10 +295,15 @@ OSM.Directions = function (map) { select.append(""); }); - setEngine('osrm_car'); + var chosenEngineId = $.cookie('_osm_directions_engine'); + if(!chosenEngineId) { + chosenEngineId = 'osrm_car'; + } + setEngine(chosenEngineId); select.on("change", function (e) { chosenEngine = engines[e.target.selectedIndex]; + $.cookie('_osm_directions_engine', chosenEngine.id, { expires: expiry, path: '/' }); if (map.hasLayer(polyline)) { getRoute(); }