Skip to content

Commit c943c3e

Browse files
committed
Merge remote-tracking branch 'upstream/pull/6430'
2 parents 02f458e + 8f7fadf commit c943c3e

5 files changed

Lines changed: 13 additions & 11 deletions

File tree

app/assets/javascripts/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,16 +171,16 @@ $(function () {
171171
map.getLayersCode(),
172172
map._object);
173173

174-
Cookies.set("_osm_location", OSM.locationCookie(map), { secure: true, expires: expiry, path: "/", samesite: "lax" });
174+
OSM.cookies.set("_osm_location", OSM.locationCookie(map), { expires: expiry });
175175
});
176176

177-
if (Cookies.get("_osm_welcome") !== "hide") {
177+
if (OSM.cookies.get("_osm_welcome") !== "hide") {
178178
$(".welcome").removeAttr("hidden");
179179
}
180180

181181
$(".welcome .btn-close").on("click", function () {
182182
$(".welcome").hide();
183-
Cookies.set("_osm_welcome", "hide", { secure: true, expires: expiry, path: "/", samesite: "lax" });
183+
OSM.cookies.set("_osm_welcome", "hide", { expires: expiry });
184184
});
185185

186186
const bannerExpiry = new Date();
@@ -191,7 +191,7 @@ $(function () {
191191
$("#banner").hide();
192192
e.preventDefault();
193193
if (cookieId) {
194-
Cookies.set(cookieId, "hide", { secure: true, expires: bannerExpiry, path: "/", samesite: "lax" });
194+
OSM.cookies.set(cookieId, "hide", { expires: bannerExpiry });
195195
}
196196
});
197197

app/assets/javascripts/index/directions.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,17 +137,17 @@ OSM.Directions = function (map) {
137137
}
138138

139139
setEngine("fossgis_osrm_car");
140-
setEngine(Cookies.get("_osm_directions_engine"));
140+
setEngine(OSM.cookies.get("_osm_directions_engine"));
141141

142142
modeGroup.on("change", "input[name='modes']", function (e) {
143143
setEngine(chosenEngine.provider + "_" + e.target.value);
144-
Cookies.set("_osm_directions_engine", chosenEngine.id, { secure: true, expires: expiry, path: "/", samesite: "lax" });
144+
OSM.cookies.set("_osm_directions_engine", chosenEngine.id, { expires: expiry });
145145
getRoute(true, true);
146146
});
147147

148148
select.on("change", function (e) {
149149
setEngine(e.target.value + "_" + chosenEngine.mode);
150-
Cookies.set("_osm_directions_engine", chosenEngine.id, { secure: true, expires: expiry, path: "/", samesite: "lax" });
150+
OSM.cookies.set("_osm_directions_engine", chosenEngine.id, { expires: expiry });
151151
getRoute(true, true);
152152
});
153153

app/assets/javascripts/index/new_note.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,8 @@ OSM.NewNote = function (map) {
146146

147147
createNote(location, text, (feature) => {
148148
if (typeof OSM.user === "undefined") {
149-
const anonymousNotesCount = Number(Cookies.get("_osm_anonymous_notes_count")) || 0;
150-
Cookies.set("_osm_anonymous_notes_count", anonymousNotesCount + 1, { secure: true, expires: 30, path: "/", samesite: "lax" });
149+
const anonymousNotesCount = Number(OSM.cookies.get("_osm_anonymous_notes_count")) || 0;
150+
OSM.cookies.set("_osm_anonymous_notes_count", anonymousNotesCount + 1, { expires: 30 });
151151
}
152152
content.find("textarea").val("");
153153
addCreatedNoteMarker(feature);

app/assets/javascripts/language_selector.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ $(document).on("click", "#select_language_dialog [data-language-code]", function
88
form.elements.language.value = code;
99
form.submit();
1010
} else {
11-
Cookies.set("_osm_locale", code, { secure: true, path: "/", samesite: "lax" });
11+
OSM.cookies.set("_osm_locale", code);
1212
location.reload();
1313
}
1414
});

app/assets/javascripts/osm.js.erb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ OSM = {
2727
end.to_json
2828
%>,
2929

30+
cookies: Cookies.withAttributes({ path: "/", samesite: "lax", secure: <%= (Settings.server_protocol == "https").to_json %> }),
31+
3032
DEFAULT_LOCALE: <%= I18n.default_locale.to_json %>,
3133

3234
LAYER_DEFINITIONS: <%= MapLayers::full_definitions("config/layers.yml", :legends => "config/legend.yml").to_json %>,
@@ -73,7 +75,7 @@ OSM = {
7375

7476
const hash = OSM.parseHash();
7577

76-
const loc = Cookies.get("_osm_location")?.split("|");
78+
const loc = OSM.cookies.get("_osm_location")?.split("|");
7779

7880
function bboxToLatLngBounds({ minlon, minlat, maxlon, maxlat }) {
7981
return L.latLngBounds([minlat, minlon], [maxlat, maxlon]);

0 commit comments

Comments
 (0)