Fix some eslint errors (quotes, spacing and parseInt radix) on .js.erb files
These have been flagged by eslint-plugin-erb, and need to be fixed before that plugin can be enabled.
This commit is contained in:
parent
8cf77a2f36
commit
6b06be5e5d
3 changed files with 64 additions and 63 deletions
|
@ -10,15 +10,15 @@ $(document).ready(function () {
|
|||
var params = {};
|
||||
|
||||
if (mapParams.object) {
|
||||
params.id = mapParams.object.type + '/' + mapParams.object.id;
|
||||
params.id = mapParams.object.type + "/" + mapParams.object.id;
|
||||
mapParams = OSM.parseHash(location.hash);
|
||||
if (mapParams.center) {
|
||||
params.map = mapParams.zoom + '/' + mapParams.center.lat + '/' + mapParams.center.lng;
|
||||
params.map = mapParams.zoom + "/" + mapParams.center.lat + "/" + mapParams.center.lng;
|
||||
}
|
||||
} else if (id.data("lat") && id.data("lon")) {
|
||||
params.map = "16/" + id.data("lat") + "/" + id.data("lon");
|
||||
} else {
|
||||
params.map = (mapParams.zoom || 17) + '/' + mapParams.lat + '/' + mapParams.lon;
|
||||
params.map = (mapParams.zoom || 17) + "/" + mapParams.lat + "/" + mapParams.lon;
|
||||
}
|
||||
|
||||
if (hashParams.background) params.background = hashParams.background;
|
||||
|
|
|
@ -15,13 +15,13 @@ I18n.default_locale = <%= I18n.default_locale.to_json %>;
|
|||
I18n.fallbacks = true;
|
||||
|
||||
window.onload = function () {
|
||||
var query = (window.location.search || '?').slice(1),
|
||||
var query = (window.location.search || "?").slice(1),
|
||||
args = {};
|
||||
|
||||
var pairs = query.split('&');
|
||||
var pairs = query.split("&");
|
||||
for (var i = 0; i < pairs.length; i++) {
|
||||
var parts = pairs[i].split('=');
|
||||
args[parts[0]] = decodeURIComponent(parts[1] || '');
|
||||
var parts = pairs[i].split("=");
|
||||
args[parts[0]] = decodeURIComponent(parts[1] || "");
|
||||
}
|
||||
|
||||
var mapnikOptions = {
|
||||
|
@ -37,7 +37,7 @@ window.onload = function () {
|
|||
};
|
||||
|
||||
var map = L.map("map");
|
||||
map.attributionControl.setPrefix('');
|
||||
map.attributionControl.setPrefix("");
|
||||
map.removeControl(map.attributionControl);
|
||||
|
||||
if (args.layer === "cyclosm") {
|
||||
|
@ -53,7 +53,7 @@ window.onload = function () {
|
|||
}
|
||||
|
||||
if (args.marker) {
|
||||
L.marker(args.marker.split(','), {icon: L.icon({
|
||||
L.marker(args.marker.split(","), { icon: L.icon({
|
||||
iconUrl: <%= asset_path('leaflet/dist/images/marker-icon.png').to_json %>,
|
||||
iconSize: new L.Point(25, 41),
|
||||
iconAnchor: new L.Point(12, 41),
|
||||
|
@ -63,9 +63,11 @@ window.onload = function () {
|
|||
}
|
||||
|
||||
if (args.bbox) {
|
||||
var bbox = args.bbox.split(',');
|
||||
map.fitBounds([L.latLng(bbox[1], bbox[0]),
|
||||
L.latLng(bbox[3], bbox[2])]);
|
||||
var bbox = args.bbox.split(",");
|
||||
map.fitBounds([
|
||||
L.latLng(bbox[1], bbox[0]),
|
||||
L.latLng(bbox[3], bbox[2])
|
||||
]);
|
||||
} else {
|
||||
map.fitWorld();
|
||||
}
|
||||
|
@ -75,14 +77,14 @@ window.onload = function () {
|
|||
|
||||
L.Control.OSMReportAProblem = L.Control.Attribution.extend({
|
||||
options: {
|
||||
position: 'bottomright',
|
||||
prefix: '<a href="https://www.openstreetmap.org/fixthemap?lat={x}&lon={y}&zoom={z}" target="_blank">'+I18n.t('javascripts.embed.report_problem')+'</a>'
|
||||
position: "bottomright",
|
||||
prefix: "<a href=\"https://www.openstreetmap.org/fixthemap?lat={x}&lon={y}&zoom={z}\" target=\"_blank\">" + I18n.t("javascripts.embed.report_problem") + "</a>"
|
||||
},
|
||||
|
||||
onAdd: function (map) {
|
||||
var container = L.Control.Attribution.prototype.onAdd.call(this, map);
|
||||
|
||||
map.on('moveend', this._update, this);
|
||||
map.on("moveend", this._update, this);
|
||||
|
||||
return container;
|
||||
},
|
||||
|
@ -92,8 +94,8 @@ L.Control.OSMReportAProblem = L.Control.Attribution.extend({
|
|||
|
||||
this._container.innerHTML =
|
||||
this._container.innerHTML
|
||||
.replace('{x}', this._map.getCenter().lat)
|
||||
.replace('{y}', this._map.getCenter().lng)
|
||||
.replace('{z}', this._map.getZoom());
|
||||
.replace("{x}", this._map.getCenter().lat)
|
||||
.replace("{y}", this._map.getCenter().lng)
|
||||
.replace("{z}", this._map.getZoom());
|
||||
}
|
||||
});
|
||||
|
|
|
@ -61,11 +61,11 @@ OSM = {
|
|||
params: function (search) {
|
||||
var params = {};
|
||||
|
||||
search = (search || window.location.search).replace('?', '').split(/&|;/);
|
||||
search = (search || window.location.search).replace("?", "").split(/&|;/);
|
||||
|
||||
for (var i = 0; i < search.length; ++i) {
|
||||
var pair = search[i],
|
||||
j = pair.indexOf('='),
|
||||
j = pair.indexOf("="),
|
||||
key = pair.slice(0, j),
|
||||
val = pair.slice(++j);
|
||||
|
||||
|
@ -90,18 +90,18 @@ OSM = {
|
|||
|
||||
// Old-style object parameters; still in use for edit links e.g. /edit?way=1234
|
||||
if (params.node) {
|
||||
mapParams.object = {type: 'node', id: parseInt(params.node)};
|
||||
mapParams.object = { type: "node", id: parseInt(params.node, 10) };
|
||||
} else if (params.way) {
|
||||
mapParams.object = {type: 'way', id: parseInt(params.way)};
|
||||
mapParams.object = { type: "way", id: parseInt(params.way, 10) };
|
||||
} else if (params.relation) {
|
||||
mapParams.object = {type: 'relation', id: parseInt(params.relation)};
|
||||
mapParams.object = { type: "relation", id: parseInt(params.relation, 10) };
|
||||
} else if (params.note) {
|
||||
mapParams.object = {type: 'note', id: parseInt(params.note)};
|
||||
mapParams.object = { type: "note", id: parseInt(params.note, 10) };
|
||||
}
|
||||
|
||||
var hash = OSM.parseHash(location.hash);
|
||||
|
||||
const loc = Cookies.get('_osm_location')?.split("|");
|
||||
const loc = Cookies.get("_osm_location")?.split("|");
|
||||
|
||||
// Decide on a map starting position. Various ways of doing this.
|
||||
if (hash.center) {
|
||||
|
@ -109,7 +109,7 @@ OSM = {
|
|||
mapParams.lat = hash.center.lat;
|
||||
mapParams.zoom = hash.zoom;
|
||||
} else if (params.bbox) {
|
||||
var bbox = params.bbox.split(',');
|
||||
var bbox = params.bbox.split(",");
|
||||
mapParams.bounds = L.latLngBounds(
|
||||
[parseFloat(bbox[1]), parseFloat(bbox[0])],
|
||||
[parseFloat(bbox[3]), parseFloat(bbox[2])]);
|
||||
|
@ -120,28 +120,27 @@ OSM = {
|
|||
} else if (params.mlon && params.mlat) {
|
||||
mapParams.lon = parseFloat(params.mlon);
|
||||
mapParams.lat = parseFloat(params.mlat);
|
||||
mapParams.zoom = parseInt(params.zoom || 12);
|
||||
mapParams.zoom = parseInt(params.zoom || 12, 10);
|
||||
} else if (loc) {
|
||||
mapParams.lon = parseFloat(loc[0]);
|
||||
mapParams.lat = parseFloat(loc[1]);
|
||||
mapParams.zoom = parseInt(loc[2]);
|
||||
mapParams.zoom = parseInt(loc[2], 10);
|
||||
} else if (OSM.home) {
|
||||
mapParams.lon = OSM.home.lon;
|
||||
mapParams.lat = OSM.home.lat;
|
||||
mapParams.zoom = 10;
|
||||
} else if (OSM.location) {
|
||||
mapParams.bounds = L.latLngBounds(
|
||||
[OSM.location.minlat,
|
||||
OSM.location.minlon],
|
||||
[OSM.location.maxlat,
|
||||
OSM.location.maxlon]);
|
||||
[OSM.location.minlat, OSM.location.minlon],
|
||||
[OSM.location.maxlat, OSM.location.maxlon]
|
||||
);
|
||||
} else {
|
||||
mapParams.lon = -0.1;
|
||||
mapParams.lat = 51.5;
|
||||
mapParams.zoom = parseInt(params.zoom || 5);
|
||||
mapParams.zoom = parseInt(params.zoom || 5, 10);
|
||||
}
|
||||
|
||||
mapParams.layers = hash.layers || (loc && loc[3]) || '';
|
||||
mapParams.layers = hash.layers || (loc && loc[3]) || "";
|
||||
|
||||
var scale = parseFloat(params.scale);
|
||||
if (scale > 0) {
|
||||
|
@ -154,14 +153,14 @@ OSM = {
|
|||
parseHash: function (hash) {
|
||||
var args = {};
|
||||
|
||||
var i = hash.indexOf('#');
|
||||
var i = hash.indexOf("#");
|
||||
if (i < 0) {
|
||||
return args;
|
||||
}
|
||||
|
||||
hash = Qs.parse(hash.slice(i + 1));
|
||||
|
||||
var map = (hash.map || '').split('/'),
|
||||
var map = (hash.map || "").split("/"),
|
||||
zoom = parseInt(map[0], 10),
|
||||
lat = parseFloat(map[1]),
|
||||
lon = parseFloat(map[2]);
|
||||
|
@ -188,19 +187,19 @@ OSM = {
|
|||
} else {
|
||||
center = args.center || L.latLng(args.lat, args.lon);
|
||||
zoom = args.zoom;
|
||||
layers = args.layers || '';
|
||||
layers = args.layers || "";
|
||||
}
|
||||
|
||||
center = center.wrap();
|
||||
layers = layers.replace('M', '');
|
||||
layers = layers.replace("M", "");
|
||||
|
||||
var precision = OSM.zoomPrecision(zoom),
|
||||
hash = '#map=' + zoom +
|
||||
'/' + center.lat.toFixed(precision) +
|
||||
'/' + center.lng.toFixed(precision);
|
||||
hash = "#map=" + zoom +
|
||||
"/" + center.lat.toFixed(precision) +
|
||||
"/" + center.lng.toFixed(precision);
|
||||
|
||||
if (layers) {
|
||||
hash += '&layers=' + layers;
|
||||
hash += "&layers=" + layers;
|
||||
}
|
||||
|
||||
return hash;
|
||||
|
@ -216,7 +215,7 @@ OSM = {
|
|||
var center = map.getCenter().wrap(),
|
||||
zoom = map.getZoom(),
|
||||
precision = OSM.zoomPrecision(zoom);
|
||||
return [center.lng.toFixed(precision), center.lat.toFixed(precision), zoom, map.getLayersCode()].join('|');
|
||||
return [center.lng.toFixed(precision), center.lat.toFixed(precision), zoom, map.getLayersCode()].join("|");
|
||||
},
|
||||
|
||||
distance: function (latlng1, latlng2) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue