]> git.openstreetmap.org Git - rails.git/commitdiff
Switch to using js-cookie to manage cookies from javascript
authorTom Hughes <tom@compton.nu>
Mon, 17 May 2021 17:57:48 +0000 (18:57 +0100)
committerTom Hughes <tom@compton.nu>
Mon, 17 May 2021 17:57:48 +0000 (18:57 +0100)
app/assets/javascripts/application.js
app/assets/javascripts/index.js
app/assets/javascripts/index/directions.js
app/assets/javascripts/osm.js.erb
package.json
yarn.lock

index cbb69119ced49a9406a6958508303092765bd6f8..8e6bf0790cb1383a1e6218eeadae9e28b09f3cde 100644 (file)
@@ -1,8 +1,8 @@
 //= require jquery3
 //= require jquery_ujs
 //= require jquery.timers
-//= require jquery.cookie/jquery.cookie
 //= require jquery.throttle-debounce
+//= require js-cookie/src/js.cookie
 //= require popper
 //= require bootstrap-sprockets
 //= require osm
index a2169643f37b8e99b3264fb895fab59f2903951f..9305a541595e321cdae3a2040f5b3f29902b17b2 100644 (file)
@@ -188,17 +188,17 @@ $(document).ready(function () {
       map.getLayersCode(),
       map._object);
 
-    $.removeCookie("_osm_location");
-    $.cookie("_osm_location", OSM.locationCookie(map), { secure: true, expires: expiry, path: "/" });
+    Cookies.remove("_osm_location");
+    Cookies.set("_osm_location", OSM.locationCookie(map), { secure: true, expires: expiry, path: "/" });
   });
 
-  if ($.cookie("_osm_welcome") !== "hide") {
+  if (Cookies.get("_osm_welcome") !== "hide") {
     $(".welcome").addClass("visible");
   }
 
   $(".welcome .close").on("click", function () {
     $(".welcome").removeClass("visible");
-    $.cookie("_osm_welcome", "hide", { secure: true, expires: expiry, path: "/" });
+    Cookies.set("_osm_welcome", "hide", { secure: true, expires: expiry, path: "/" });
   });
 
   var bannerExpiry = new Date();
@@ -209,7 +209,7 @@ $(document).ready(function () {
     $("#banner").hide();
     e.preventDefault();
     if (cookieId) {
-      $.cookie(cookieId, "hide", { secure: true, expires: bannerExpiry, path: "/" });
+      Cookies.set(cookieId, "hide", { secure: true, expires: bannerExpiry, path: "/" });
     }
   });
 
index a58b0af16abc956471170020435ab0c916a8c508..93024d0a90c4e71223cef1eb0aba7a6c17c2491c 100644 (file)
@@ -327,14 +327,14 @@ OSM.Directions = function (map) {
   }
 
   var chosenEngineIndex = findEngine("fossgis_osrm_car");
-  if ($.cookie("_osm_directions_engine")) {
-    chosenEngineIndex = findEngine($.cookie("_osm_directions_engine"));
+  if (Cookies.get("_osm_directions_engine")) {
+    chosenEngineIndex = findEngine(Cookies.get("_osm_directions_engine"));
   }
   setEngine(chosenEngineIndex);
 
   select.on("change", function (e) {
     chosenEngine = engines[e.target.selectedIndex];
-    $.cookie("_osm_directions_engine", chosenEngine.id, { secure: true, expires: expiry, path: "/" });
+    Cookies.set("_osm_directions_engine", chosenEngine.id, { secure: true, expires: expiry, path: "/" });
     getRoute(true, true);
   });
 
index 5c15e08e6f13d62654e47019a9b601eb6841443f..529ac3beadc18f2ef823b61404c730be7dbf9d98 100644 (file)
@@ -107,7 +107,7 @@ OSM = {
       mapParams.lon = parseFloat(params.mlon);
       mapParams.lat = parseFloat(params.mlat);
       mapParams.zoom = parseInt(params.zoom || 12);
-    } else if (loc = $.cookie('_osm_location')) {
+    } else if (loc = Cookies.get('_osm_location')) {
       loc = loc.split("|");
       mapParams.lon = parseFloat(loc[0]);
       mapParams.lat = parseFloat(loc[1]);
index 79f3241073e9c5c9bbd4e0fdfa12839c77dcee25..d5e2b7f347ff035158520b32f815b76f4570de24 100644 (file)
@@ -5,7 +5,7 @@
     "bs-custom-file-input": "^1.3.4",
     "html5shiv": "^3.7.3",
     "jquery-simulate": "^1.0.2",
-    "jquery.cookie": "^1.4.1",
+    "js-cookie": "^2.2.1",
     "leaflet": "^1.6.0",
     "leaflet.locatecontrol": "^0.73.0",
     "ohauth": "^1.0.0",
index 93e2a99c7215862d66c8ae046f6d55755523f5a0..3d22856b7a7e28cce7ed88711193baa3b04455d7 100644 (file)
--- a/yarn.lock
+++ b/yarn.lock
@@ -522,10 +522,10 @@ jquery-simulate@^1.0.2:
   resolved "https://registry.yarnpkg.com/jquery-simulate/-/jquery-simulate-1.0.2.tgz#2174b859b75123a0ac6d8ab3a9a6fb4ad7e82898"
   integrity sha512-Bq610fSrwTwvH5d06z5oskYaX/79s0BNrKiJZjZOiXRib3iL4ZkSn/wvLwzhf3P9KeXCEpk9wlIaGui/1arOpQ==
 
-jquery.cookie@^1.4.1:
-  version "1.4.1"
-  resolved "https://registry.yarnpkg.com/jquery.cookie/-/jquery.cookie-1.4.1.tgz#d63dce209eab691fe63316db08ca9e47e0f9385b"
-  integrity sha1-1j3OIJ6raR/mMxbbCMqeR+D5OFs=
+js-cookie@^2.2.1:
+  version "2.2.1"
+  resolved "https://registry.yarnpkg.com/js-cookie/-/js-cookie-2.2.1.tgz#69e106dc5d5806894562902aa5baec3744e9b2b8"
+  integrity sha512-HvdH2LzI/EAZcUwA8+0nKNtWHqS+ZmijLA30RwZA0bo7ToCckjK5MkGhjED9KoRcXO6BaGI3I9UIzSA1FKFPOQ==
 
 js-tokens@^4.0.0:
   version "4.0.0"