I18n.fallbacks = true;
window.onload = function () {
- const args = Object.fromEntries(new URLSearchParams(window.location.search));
+ const args = Object.fromEntries(new URLSearchParams(location.search));
const tileOptions = {
mapnik: {
};
function addObject(type, id, version, center) {
- const hashParams = OSM.parseHash(window.location.hash);
+ const hashParams = OSM.parseHash(location.hash);
map.addObject({ type: type, id: parseInt(id, 10), version: version && parseInt(version, 10) }, function (bounds) {
if (!hashParams.center && bounds.isValid() &&
(center || !map.getBounds().contains(bounds))) {
"/account/home": OSM.Home(map)
});
- if (OSM.preferred_editor === "remote" && document.location.pathname === "/edit") {
+ if (OSM.preferred_editor === "remote" && location.pathname === "/edit") {
remoteEditHandler(map.getBounds(), params.object);
OSM.router.setCurrentPath("/");
}
const changesetData = content.find("[data-changeset]").data("changeset");
changesetData.type = "changeset";
- const hashParams = OSM.parseHash(window.location.hash);
+ const hashParams = OSM.parseHash(location.hash);
initialize();
map.addObject(changesetData, function (bounds) {
if (!hashParams.center && bounds.isValid()) {
});
})
.then(() => {
- OSM.loadSidebarContent(window.location.pathname, page.load);
+ OSM.loadSidebarContent(location.pathname, page.load);
})
.catch(error => {
content.find("button[data-method][data-url]").prop("disabled", false);
OSM.Directions.engines = [];
OSM.Directions.addEngine = function (engine, supportsHTTPS) {
- if (document.location.protocol === "http:" || supportsHTTPS) {
+ if (location.protocol === "http:" || supportsHTTPS) {
engine.id = engine.provider + "_" + engine.mode;
OSM.Directions.engines.push(engine);
}
function update() {
const data = new URLSearchParams();
- if (window.location.pathname === "/history") {
+ if (location.pathname === "/history") {
data.set("bbox", map.getBounds().wrap().toBBoxString());
const feedLink = $("link[type=\"application/atom+xml\"]"),
feedHref = feedLink.attr("href").split("?")[0];
data.set("list", "1");
- fetch(window.location.pathname + "?" + data)
+ fetch(location.pathname + "?" + data)
.then(response => response.text())
.then(function (html) {
displayFirstChangesets(html);
updateBounds();
- if (window.location.pathname !== "/history") {
+ if (location.pathname !== "/history") {
const bounds = group.getBounds();
if (bounds.isValid()) map.fitBounds(bounds);
}
page.load = function () {
map.addLayer(group);
- if (window.location.pathname === "/history") {
+ if (location.pathname === "/history") {
map.on("moveend", update);
}
const data = $(".details").data();
if (data) {
- const hashParams = OSM.parseHash(window.location.hash);
+ const hashParams = OSM.parseHash(location.hash);
map.addObject({
type: "note",
id: parseInt(id, 10),
const params = new URLSearchParams(path.substring(path.indexOf("?"))),
latlng = L.latLng(params.get("lat"), params.get("lon"));
- if (!window.location.hash && !noCentre && !map.getBounds().contains(latlng)) {
+ if (!location.hash && !noCentre && !map.getBounds().contains(latlng)) {
OSM.router.withoutMoveListener(function () {
map.setView(latlng, 15);
});
[params.mlat, params.mlon] = OSM.cropLocation(marker.getLatLng(), this.getZoom());
}
- let url = window.location.protocol + "//" + OSM.SERVER_URL + "/";
+ let url = location.protocol + "//" + OSM.SERVER_URL + "/";
const query = new URLSearchParams(params),
hash = OSM.formatHash(this);
// and drops the last 4 bits of the full 64 bit Morton code.
c1 = interlace(x >>> 17, y >>> 17),
c2 = interlace((x >>> 2) & 0x7fff, (y >>> 2) & 0x7fff);
- let str = window.location.protocol + "//" + window.location.hostname.replace(/^www\.openstreetmap\.org/i, "osm.org") + "/go/";
+ let str = location.protocol + "//" + location.hostname.replace(/^www\.openstreetmap\.org/i, "osm.org") + "/go/";
for (let i = 0; i < Math.ceil((zoom + 8) / 3.0) && i < 5; ++i) {
const digit = (c1 >> (24 - (6 * i))) & 0x3f;
$(document).ready(function () {
// Preserve location hash in referer
- if (window.location.hash) {
- $("#referer").val($("#referer").val() + window.location.hash);
+ if (location.hash) {
+ $("#referer").val($("#referer").val() + location.hash);
}
});
if (OSM.MATOMO) {
$(document).ready(function () {
- const base = document.location.protocol + "//" + OSM.MATOMO.location + "/";
+ const base = location.protocol + "//" + OSM.MATOMO.location + "/";
let matomoTracker;
const matomoLoader = $.ajax({
},
params: function (search) {
- const query = search || window.location.search;
+ const query = search || location.search;
return Object.fromEntries(new URLSearchParams(query));
},
}
};
- let currentPath = window.location.pathname.replace(/(.)\/$/, "$1") + window.location.search,
+ let currentPath = location.pathname.replace(/(.)\/$/, "$1") + location.search,
currentRoute = routes.recognize(currentPath),
currentHash = location.hash || OSM.formatHash(map);
function updateSecondaryNav() {
$("header nav.secondary > ul > li > a").each(function () {
- const active = $(this).attr("href") === window.location.pathname;
+ const active = $(this).attr("href") === location.pathname;
$(this)
.toggleClass("text-secondary", !active)
$(window).on("popstate", function (e) {
if (!e.originalEvent.state) return; // Is it a real popstate event or just a hash change?
- const path = window.location.pathname + window.location.search,
+ const path = location.pathname + location.search,
route = routes.recognize(path);
if (path === currentPath) return;
currentRoute.run("unload", null, route === currentRoute);
};
router.stateChange = function (state) {
- const url = state.center ? OSM.formatHash(state) : window.location;
+ const url = state.center ? OSM.formatHash(state) : location;
window.history.replaceState(state, document.title, url);
};
}
function geoSuccess(position) {
- window.location = "/edit" + OSM.formatHash({
+ location = "/edit" + OSM.formatHash({
zoom: 17,
lat: position.coords.latitude,
lon: position.coords.longitude
}
function manualEdit() {
- window.location = "/?edit_help=1";
+ location = "/?edit_help=1";
}
});
beforeEach(function () {
delete OSM.home;
delete OSM.location;
- document.location.hash = "";
+ location.hash = "";
document.cookie = "_osm_location=; expires=Thu, 01 Jan 1970 00:00:00 GMT";
// Test with another cookie set.
});
it("parses lat/lon/zoom from the hash", function () {
- document.location.hash = "#map=16/57.6247/-3.6845";
+ location.hash = "#map=16/57.6247/-3.6845";
const params = OSM.mapParams("?");
expect(params).to.have.property("lat", 57.6247);
expect(params).to.have.property("lon", -3.6845);
params = OSM.mapParams("?");
expect(params).to.have.property("layers", "C");
- document.location.hash = "#map=5/57.6247/-3.6845&layers=M";
+ location.hash = "#map=5/57.6247/-3.6845&layers=M";
params = OSM.mapParams("?");
expect(params).to.have.property("layers", "M");
});