Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions app/assets/javascripts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,16 +171,16 @@ $(function () {
map.getLayersCode(),
map._object);

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

if (Cookies.get("_osm_welcome") !== "hide") {
if (OSM.cookies.get("_osm_welcome") !== "hide") {
$(".welcome").removeAttr("hidden");
}

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

const bannerExpiry = new Date();
Expand All @@ -191,7 +191,7 @@ $(function () {
$("#banner").hide();
e.preventDefault();
if (cookieId) {
Cookies.set(cookieId, "hide", { secure: true, expires: bannerExpiry, path: "/", samesite: "lax" });
OSM.cookies.set(cookieId, "hide", { expires: bannerExpiry });
}
});

Expand Down
6 changes: 3 additions & 3 deletions app/assets/javascripts/index/directions.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,21 +133,21 @@
routeOutput.remove();
sidebarReadyPromise = null;
map.setSidebarOverlaid(true);
// TODO: collapse width of sidebar back to previous

Check warning on line 136 in app/assets/javascripts/index/directions.js

View workflow job for this annotation

GitHub Actions / ESLint

Unexpected 'todo' comment: 'TODO: collapse width of sidebar back to...'
}

setEngine("fossgis_osrm_car");
setEngine(Cookies.get("_osm_directions_engine"));
setEngine(OSM.cookies.get("_osm_directions_engine"));

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

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

Expand Down
4 changes: 2 additions & 2 deletions app/assets/javascripts/index/new_note.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ OSM.NewNote = function (map) {

createNote(location, text, (feature) => {
if (typeof OSM.user === "undefined") {
const anonymousNotesCount = Number(Cookies.get("_osm_anonymous_notes_count")) || 0;
Cookies.set("_osm_anonymous_notes_count", anonymousNotesCount + 1, { secure: true, expires: 30, path: "/", samesite: "lax" });
const anonymousNotesCount = Number(OSM.cookies.get("_osm_anonymous_notes_count")) || 0;
OSM.cookies.set("_osm_anonymous_notes_count", anonymousNotesCount + 1, { expires: 30 });
}
content.find("textarea").val("");
addCreatedNoteMarker(feature);
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/language_selector.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ $(document).on("click", "#select_language_dialog [data-language-code]", function
form.elements.language.value = code;
form.submit();
} else {
Cookies.set("_osm_locale", code, { secure: true, path: "/", samesite: "lax" });
OSM.cookies.set("_osm_locale", code);
location.reload();
}
});
4 changes: 3 additions & 1 deletion app/assets/javascripts/osm.js.erb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ OSM = {
end.to_json
%>,

cookies: Cookies.withAttributes({ path: "/", samesite: "lax", secure: <%= (Settings.server_protocol == "https").to_json %> }),

DEFAULT_LOCALE: <%= I18n.default_locale.to_json %>,

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

const hash = OSM.parseHash();

const loc = Cookies.get("_osm_location")?.split("|");
const loc = OSM.cookies.get("_osm_location")?.split("|");

function bboxToLatLngBounds({ minlon, minlat, maxlon, maxlat }) {
return L.latLngBounds([minlat, minlon], [maxlat, maxlon]);
Expand Down
Loading