* view tab and various other links
*/
window.updateLinks = function (loc, zoom, layers, object) {
- $(".geolink").each(function(index, link) {
+ $(".geolink").each(function (index, link) {
var href = link.href.split(/[?#]/)[0],
args = querystring.parse(link.search.substring(1)),
editlink = $(link).hasClass("editlink");
var editDisabled = zoom < 13;
$("#edit_tab")
- .tooltip({placement: "bottom"})
+ .tooltip({ placement: "bottom" })
.off("click.minzoom")
- .on("click.minzoom", function() { return !editDisabled; })
+ .on("click.minzoom", function () { return !editDisabled; })
.toggleClass("disabled", editDisabled)
.attr("data-original-title", editDisabled ?
I18n.t("javascripts.site.edit_disabled_tooltip") : "");
* to defer the measurement slightly as a workaround.
*/
setTimeout(function () {
- $("header").children(":visible").each(function (i,e) {
+ $("header").children(":visible").each(function (i, e) {
headerWidth = headerWidth + $(e).outerWidth();
});
$("body").addClass("compact");
- $("header").children(":visible").each(function (i,e) {
+ $("header").children(":visible").each(function (i, e) {
compactWidth = compactWidth + $(e).outerWidth();
});
$(window).resize(updateHeader);
}, 0);
- $("#menu-icon").on("click", function(e) {
+ $("#menu-icon").on("click", function (e) {
e.preventDefault();
$("header").toggleClass("closed");
});
- $("nav.primary li a").on("click", function() {
+ $("nav.primary li a").on("click", function () {
$("header").toggleClass("closed");
});
map.removeLayer(marker);
}
- marker = L.marker(e.latlng, {icon: OSM.getUserIcon()}).addTo(map)
+ marker = L.marker(e.latlng, { icon: OSM.getUserIcon() }).addTo(map)
.bindPopup(I18n.t("diary_entries.edit.marker_text"));
}
zoomControl: false
}).addLayer(new L.OSM.Mapnik());
- L.OSM.zoom({position: position})
+ L.OSM.zoom({ position: position })
.addTo(map);
map.setView(centre, params.zoom);
if ($("#latitude").val() && $("#longitude").val()) {
- marker = L.marker(centre, {icon: OSM.getUserIcon()}).addTo(map)
+ marker = L.marker(centre, { icon: OSM.getUserIcon() }).addTo(map)
.bindPopup(I18n.t("diary_entries.edit.marker_text"));
}
-$(document).ready(function() {
+$(document).ready(function () {
var params = OSM.params();
var url = "/note/new";
/* globals iD */
-document.addEventListener("DOMContentLoaded", function() {
+document.addEventListener("DOMContentLoaded", function () {
var container = document.getElementById("id-container");
if (typeof iD === "undefined" || !iD.Detect().support) {
oauth_token_secret: container.dataset.tokenSecret
});
- id.map().on("move.embed", parent.$.throttle(250, function() {
+ id.map().on("move.embed", parent.$.throttle(250, function () {
if (id.inIntro()) return;
var zoom = ~~id.map().zoom(),
center = id.map().center(),
// 0ms timeout to avoid iframe JS context weirdness.
// http://bl.ocks.org/jfirebaugh/5439412
- setTimeout(function() {
+ setTimeout(function () {
id.map().centerZoom(
[data.lon, data.lat],
Math.max(data.zoom || 15, 13));
contextmenu: true
});
- OSM.loadSidebarContent = function(path, callback) {
+ OSM.loadSidebarContent = function (path, callback) {
map.setSidebarOverlaid(false);
clearTimeout(loaderTimeout);
- loaderTimeout = setTimeout(function() {
+ loaderTimeout = setTimeout(function () {
$("#sidebar_loader").show();
}, 200);
$.ajax({
url: path,
dataType: "html",
- complete: function(xhr) {
+ complete: function (xhr) {
clearTimeout(loaderTimeout);
$("#flash").empty();
$("#sidebar_loader").hide();
var position = $("html").attr("dir") === "rtl" ? "topleft" : "topright";
- L.OSM.zoom({position: position})
+ L.OSM.zoom({ position: position })
.addTo(map);
var locate = L.control.locate({
}).addTo(map);
L.OSM.share({
- position: position,
- sidebar: sidebar,
- short: true
+ "position": position,
+ "sidebar": sidebar,
+ "short": true
}).addTo(map);
L.OSM.note({
}
var placement = $("html").attr("dir") === "rtl" ? "right" : "left";
- $(".leaflet-control .control-button").tooltip({placement: placement, container: "body"});
+ $(".leaflet-control .control-button").tooltip({ placement: placement, container: "body" });
var expiry = new Date();
expiry.setYear(expiry.getFullYear() + 10);
- map.on("moveend layeradd layerremove", function() {
+ map.on("moveend layeradd layerremove", function () {
updateLinks(
map.getCenter().wrap(),
map.getZoom(),
$(".welcome").addClass("visible");
}
- $(".welcome .close-wrap").on("click", function() {
+ $(".welcome .close-wrap").on("click", function () {
$(".welcome").removeClass("visible");
$.cookie("_osm_welcome", "hide", { expires: expiry, path: "/" });
});
var bannerExpiry = new Date();
bannerExpiry.setYear(bannerExpiry.getFullYear() + 1);
- $("#banner .close-wrap").on("click", function(e) {
+ $("#banner .close-wrap").on("click", function (e) {
var cookieId = e.target.id;
$("#banner").hide();
e.preventDefault();
L.marker([params.mlat, params.mlon]).addTo(map);
}
- $("#homeanchor").on("click", function(e) {
+ $("#homeanchor").on("click", function (e) {
e.preventDefault();
var data = $(this).data(),
center = L.latLng(data.lat, data.lon);
map.setView(center, data.zoom);
- L.marker(center, {icon: OSM.getUserIcon()}).addTo(map);
+ L.marker(center, { icon: OSM.getUserIcon() }).addTo(map);
});
function remoteEditHandler(bbox, object) {
};
if (location.protocol === "http" ||
- bowser.check({chrome: "53", firefox: "55"})) {
+ bowser.check({ chrome: "53", firefox: "55" })) {
url = "http://127.0.0.1:8111/load_and_zoom?";
} else {
url = "https://127.0.0.1:8112/load_and_zoom?";
.hide()
.appendTo("body")
.attr("src", url + querystring.stringify(query))
- .on("load", function() {
+ .on("load", function () {
$(this).remove();
loaded = true;
});
return false;
}
- $("a[data-editor=remote]").click(function(e) {
+ $("a[data-editor=remote]").click(function (e) {
var params = OSM.mapParams(this.search);
remoteEditHandler(map.getBounds(), params.object);
e.preventDefault();
})
.tooltip("show");
- $("body").one("click", function() {
+ $("body").one("click", function () {
$("#editanchor").tooltip("hide");
});
}
- OSM.Index = function(map) {
+ OSM.Index = function (map) {
var page = {};
- page.pushstate = page.popstate = function() {
+ page.pushstate = page.popstate = function () {
map.setSidebarOverlaid(true);
document.title = I18n.t("layouts.project_name.title");
};
- page.load = function() {
+ page.load = function () {
var params = querystring.parse(location.search.substring(1));
if (params.query) {
$("#sidebar .search_form input[name=query]").value(params.query);
return page;
};
- OSM.Browse = function(map, type) {
+ OSM.Browse = function (map, type) {
var page = {};
- page.pushstate = page.popstate = function(path, id) {
- OSM.loadSidebarContent(path, function() {
+ page.pushstate = page.popstate = function (path, id) {
+ OSM.loadSidebarContent(path, function () {
addObject(type, id);
});
};
- page.load = function(path, id) {
+ page.load = function (path, id) {
addObject(type, id, true);
};
function addObject(type, id, center) {
- map.addObject({type: type, id: parseInt(id, 10)}, function(bounds) {
+ map.addObject({ type: type, id: parseInt(id, 10) }, function (bounds) {
if (!window.location.hash && bounds.isValid() &&
(center || !map.getBounds().contains(bounds))) {
OSM.router.withoutMoveListener(function () {
});
}
- page.unload = function() {
+ page.unload = function () {
map.removeObject();
};
var history = OSM.History(map);
OSM.router = OSM.Router(map, {
- "/": OSM.Index(map),
- "/search": OSM.Search(map),
- "/directions": OSM.Directions(map),
- "/export": OSM.Export(map),
- "/note/new": OSM.NewNote(map),
- "/history/friends": history,
- "/history/nearby": history,
- "/history": history,
+ "/": OSM.Index(map),
+ "/search": OSM.Search(map),
+ "/directions": OSM.Directions(map),
+ "/export": OSM.Export(map),
+ "/note/new": OSM.NewNote(map),
+ "/history/friends": history,
+ "/history/nearby": history,
+ "/history": history,
"/user/:display_name/history": history,
- "/note/:id": OSM.Note(map),
- "/node/:id(/history)": OSM.Browse(map, "node"),
- "/way/:id(/history)": OSM.Browse(map, "way"),
- "/relation/:id(/history)": OSM.Browse(map, "relation"),
- "/changeset/:id": OSM.Changeset(map),
- "/query": OSM.Query(map)
+ "/note/:id": OSM.Note(map),
+ "/node/:id(/history)": OSM.Browse(map, "node"),
+ "/way/:id(/history)": OSM.Browse(map, "way"),
+ "/relation/:id(/history)": OSM.Browse(map, "relation"),
+ "/changeset/:id": OSM.Changeset(map),
+ "/query": OSM.Query(map)
});
if (OSM.preferred_editor === "remote" && document.location.pathname === "/edit") {
OSM.router.load();
- $(document).on("click", "a", function(e) {
- if (e.isDefaultPrevented() || e.isPropagationStopped())
+ $(document).on("click", "a", function (e) {
+ if (e.isDefaultPrevented() || e.isPropagationStopped()) {
return;
+ }
// Open links in a new tab as normal.
- if (e.which > 1 || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey)
+ if (e.which > 1 || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) {
return;
+ }
// Ignore cross-protocol and cross-origin links.
- if (location.protocol !== this.protocol || location.host !== this.host)
+ if (location.protocol !== this.protocol || location.host !== this.host) {
return;
+ }
- if (OSM.router.route(this.pathname + this.search + this.hash))
+ if (OSM.router.route(this.pathname + this.search + this.hash)) {
e.preventDefault();
+ }
});
});
// Redraw in selected style
layer.originalStyle = layer.options;
- layer.setStyle({color: "#0000ff", weight: 8});
+ layer.setStyle({ color: "#0000ff", weight: 8 });
OSM.router.route("/" + layer.feature.type + "/" + layer.feature.id);
content = $("#sidebar_content"),
currentChangesetId;
- page.pushstate = page.popstate = function(path, id) {
- OSM.loadSidebarContent(path, function() {
+ page.pushstate = page.popstate = function (path, id) {
+ OSM.loadSidebarContent(path, function () {
page.load(path, id);
});
};
- page.load = function(path, id) {
- if (id)
- currentChangesetId = id;
+ page.load = function (path, id) {
+ if (id) currentChangesetId = id;
initialize();
addChangeset(currentChangesetId, true);
};
function addChangeset(id, center) {
- map.addObject({type: "changeset", id: parseInt(id, 10)}, function(bounds) {
+ map.addObject({ type: "changeset", id: parseInt(id, 10) }, function (bounds) {
if (!window.location.hash && bounds.isValid() &&
(center || !map.getBounds().contains(bounds))) {
OSM.router.withoutMoveListener(function () {
$(form).find("input[type=submit]").prop("disabled", true);
if (include_data) {
- data = {text: $(form.text).val()};
+ data = { text: $(form.text).val() };
} else {
data = {};
}
content.find("textarea").val("").trigger("input");
}
- page.unload = function() {
+ page.unload = function () {
map.removeObject();
};
else map.contextmenu.enable();
});
- var updateMenu = function updateMenu () {
+ var updateMenu = function updateMenu() {
map.contextmenu.setDisabled(2, map.getZoom() < 12);
map.contextmenu.setDisabled(4, map.getZoom() < 14);
};
var awaitingRoute; // true if we've asked the engine for a route and are waiting to hear back
var chosenEngine;
- var popup = L.popup({autoPanPadding: [100, 100]});
+ var popup = L.popup({ autoPanPadding: [100, 100] });
var polyline = L.polyline([], {
color: "#03f",
var select = $("select.routing_engines");
- engines.forEach(function(engine, i) {
+ engines.forEach(function (engine, i) {
select.append("<option value='" + i + "'>" + I18n.t("javascripts.directions.engines." + engine.id) + "</option>");
});
}
});
- input.on("keydown", function() {
+ input.on("keydown", function () {
input.removeClass("error");
});
endpoint.setValue(value);
});
- endpoint.setValue = function(value, latlng) {
+ endpoint.setValue = function (value, latlng) {
endpoint.value = value;
delete endpoint.latlng;
input.removeClass("error");
}
};
- endpoint.getGeocode = function() {
+ endpoint.getGeocode = function () {
// if no one has entered a value yet, then we can't geocode, so don't
// even try.
if (!endpoint.value) {
endpoint.hasGeocode = true;
if (json.length === 0) {
input.addClass("error");
- alert(I18n.t("javascripts.directions.errors.no_place", {place: endpoint.value}));
+ alert(I18n.t("javascripts.directions.errors.no_place", { place: endpoint.value }));
return;
}
return endpoint;
}
- $(".directions_form .reverse_directions").on("click", function() {
+ $(".directions_form .reverse_directions").on("click", function () {
var from = endpoints[0].latlng,
to = endpoints[1].latlng;
}));
});
- $(".directions_form .close").on("click", function(e) {
+ $(".directions_form .close").on("click", function (e) {
e.preventDefault();
var route_from = endpoints[0].value;
if (route_from) {
}
function findEngine(id) {
- return engines.findIndex(function(engine) {
+ return engines.findIndex(function (engine) {
return engine.id === id;
});
}
if (typeof route.ascend !== "undefined" && typeof route.descend !== "undefined") {
html += "<br />" +
I18n.t("javascripts.directions.ascend") + ": " + Math.round(route.ascend) + "m. " +
- I18n.t("javascripts.directions.descend") + ": " + Math.round(route.descend) +"m.";
+ I18n.t("javascripts.directions.descend") + ": " + Math.round(route.descend) + "m.";
}
html += "</p><table id=\"turnbyturn\" />";
if (dist < 5) {
dist = "";
} else if (dist < 200) {
- dist = Math.round(dist / 10) * 10 + "m";
+ dist = String(Math.round(dist / 10) * 10) + "m";
} else if (dist < 1500) {
- dist = Math.round(dist / 100) * 100 + "m";
+ dist = String(Math.round(dist / 100) * 100) + "m";
} else if (dist < 5000) {
- dist = Math.round(dist / 100) / 10 + "km";
+ dist = String(Math.round(dist / 100) / 10) + "km";
} else {
- dist = Math.round(dist / 1000) + "km";
+ dist = String(Math.round(dist / 1000)) + "km";
}
var row = $("<tr class='turn'/>");
});
$("#sidebar_content").append("<p id=\"routing_credit\">" +
- I18n.t("javascripts.directions.instructions.courtesy", {link: chosenEngine.creditline}) +
+ I18n.t("javascripts.directions.instructions.courtesy", { link: chosenEngine.creditline }) +
"</p>");
- $("#sidebar_content a.geolink").on("click", function(e) {
+ $("#sidebar_content a.geolink").on("click", function (e) {
e.preventDefault();
map.removeLayer(polyline);
$("#sidebar_content").html("");
}
});
- $(".directions_form").on("submit", function(e) {
+ $(".directions_form").on("submit", function (e) {
e.preventDefault();
getRoute(true, true);
});
var page = {};
- page.pushstate = page.popstate = function() {
+ page.pushstate = page.popstate = function () {
$(".search_form").hide();
$(".directions_form").show();
getRoute(true, true);
};
- page.load = function() {
+ page.load = function () {
page.pushstate();
};
- page.unload = function() {
+ page.unload = function () {
$(".search_form").show();
$(".directions_form").hide();
$("#map").off("dragend dragover drop");
creditline: "<a href=\"https://routing.openstreetmap.de/about.html\" target=\"_blank\">FOSSGIS Routing Service</a>",
draggable: true,
- _transformSteps: function(input_steps, line) {
+ _transformSteps: function (input_steps, line) {
var INSTRUCTION_TEMPLATE = {
"continue": "javascripts.directions.instructions.continue",
"merge right": "javascripts.directions.instructions.merge_right",
"exit roundabout": "javascripts.directions.instructions.exit_roundabout",
"exit rotary": "javascripts.directions.instructions.exit_roundabout",
"depart": "javascripts.directions.instructions.start",
- "arrive": "javascripts.directions.instructions.destination",
+ "arrive": "javascripts.directions.instructions.destination"
};
var ICON_MAP = {
"continue": 0,
"depart": 8,
"arrive": 14
};
- var numToWord = function(num) {
- return ["first", "second", "third", "fourth", "fifth", "sixth", "seventh", "eighth", "ninth", "tenth"][num-1];
+ var numToWord = function (num) {
+ return ["first", "second", "third", "fourth", "fifth", "sixth", "seventh", "eighth", "ninth", "tenth"][num - 1];
};
- var transformed_steps = input_steps.map(function(step, idx) {
+ var transformed_steps = input_steps.map(function (step, idx) {
var maneuver_id;
// special case handling
var template = INSTRUCTION_TEMPLATE[maneuver_id];
// convert lat,lng pairs to LatLng objects
- var step_geometry = L.PolylineUtil.decode(step.geometry, { precision: 5 }).map(function(a) { return L.latLng(a); });
+ var step_geometry = L.PolylineUtil.decode(step.geometry, { precision: 5 }).map(function (a) { return L.latLng(a); });
// append step_geometry on line
Array.prototype.push.apply(line, step_geometry);
},
getRoute: function (points, callback) {
-
var params = [
{ name: "overview", value: "false" },
{ name: "geometries", value: "polyline" },
if (cachedHints.length === points.length) {
- params.push({name: "hints", value: cachedHints.join(";")});
+ params.push({ name: "hints", value: cachedHints.join(";") });
} else {
// invalidate cache
cachedHints = [];
}
- var encoded_coords = points.map(function(p) {
+ var encoded_coords = points.map(function (p) {
return p.lng + "," + p.lat;
}).join(";");
var req_url = OSM.FOSSGIS_OSRM_URL + "routed-" + vehicleType + "/route/v1/driving/" + encoded_coords;
var onResponse = function (data) {
- if (data.code !== "Ok")
+ if (data.code !== "Ok") {
return callback(true);
+ }
- cachedHints = data.waypoints.map(function(wp) {
+ cachedHints = data.waypoints.map(function (wp) {
return wp.hint;
});
"-3": 7, // sharp left
"-2": 6, // left
"-1": 5, // slight left
- 0: 0, // straight
- 1: 1, // slight right
- 2: 2, // right
- 3: 3, // sharp right
- 4: 14, // finish reached
- 5: 14, // via reached
- 6: 10 // roundabout
+ "0": 0, // straight
+ "1": 1, // slight right
+ "2": 2, // right
+ "3": 3, // sharp right
+ "4": 14, // finish reached
+ "5": 14, // via reached
+ "6": 10 // roundabout
};
return {
return $.ajax({
url: OSM.GRAPHHOPPER_URL,
data: {
- vehicle: vehicleType,
- locale: I18n.currentLocale(),
- key: "LijBPDQGfu7Iiq80w3HzwB4RUDJbMbhs6BU0dEnn",
+ "vehicle": vehicleType,
+ "locale": I18n.currentLocale(),
+ "key": "LijBPDQGfu7Iiq80w3HzwB4RUDJbMbhs6BU0dEnn",
"ch.disable": vehicleType === "car",
- elevation: false,
- instructions: true,
- point: points.map(function (p) { return p.lat + "," + p.lng; })
+ "elevation": false,
+ "instructions": true,
+ "point": points.map(function (p) { return p.lat + "," + p.lng; })
},
traditional: true,
dataType: "json",
success: function (data) {
- if (!data.paths || data.paths.length === 0)
+ if (!data.paths || data.paths.length === 0) {
return callback(true);
+ }
var path = data.paths[0];
var line = L.PolylineUtil.decode(path.points);
var distInMeter = instr.distance;
var lineseg = [];
for (var j = instr.interval[0]; j <= instr.interval[1]; j++) {
- lineseg.push({lat: line[j][0], lng: line[j][1]});
+ lineseg.push({ lat: line[j][0], lng: line[j][1] });
}
steps.push([
- {lat: latLng[0], lng: latLng[1]},
+ { lat: latLng[0], lng: latLng[1] },
instrCode,
instrText,
distInMeter,
-OSM.Export = function(map) {
+OSM.Export = function (map) {
var page = {};
var locationFilter = new L.LocationFilter({
if (getBounds().getSize() > OSM.MAX_REQUEST_AREA) e.preventDefault();
}
- page.pushstate = page.popstate = function(path) {
+ page.pushstate = page.popstate = function (path) {
$("#export_tab").addClass("current");
OSM.loadSidebarContent(path, page.load);
};
- page.load = function() {
+ page.load = function () {
map
.addLayer(locationFilter)
.on("moveend", update);
return map.getState();
};
- page.unload = function() {
+ page.unload = function () {
map
.removeLayer(locationFilter)
.off("moveend", update);
//= require jquery.simulate
-OSM.History = function(map) {
+OSM.History = function (map) {
var page = {};
$("#sidebar_content")
})
.on("mousedown", "[data-changeset]", function () {
var moved = false;
- $(this).one("click", function (e) {
- if (!moved && !$(e.target).is("a")) {
- clickChangeset($(this).data("changeset").id, e);
- }
- }).one("mousemove", function () {
- moved = true;
- });
+ $(this)
+ .one("click", function (e) {
+ if (!moved && !$(e.target).is("a")) {
+ clickChangeset($(this).data("changeset").id, e);
+ }
+ })
+ .one("mousemove", function () {
+ moved = true;
+ });
});
var group = L.featureGroup()
clickChangeset(e.layer.id, e);
});
- group.getLayerId = function(layer) {
+ group.getLayerId = function (layer) {
return layer.id;
};
function highlightChangeset(id) {
- group.getLayer(id).setStyle({fillOpacity: 0.3, color: "#FF6600", weight: 3});
+ group.getLayer(id).setStyle({ fillOpacity: 0.3, color: "#FF6600", weight: 3 });
$("#changeset_" + id).addClass("selected");
}
function unHighlightChangeset(id) {
- group.getLayer(id).setStyle({fillOpacity: 0, color: "#FF9500", weight: 2});
+ group.getLayer(id).setStyle({ fillOpacity: 0, color: "#FF9500", weight: 2 });
$("#changeset_" + id).removeClass("selected");
}
}
function update() {
- var data = {list: "1"};
+ var data = { list: "1" };
if (window.location.pathname === "/history") {
data.bbox = map.getBounds().wrap().toBBoxString();
url: window.location.pathname,
method: "GET",
data: data,
- success: function(html) {
+ success: function (html) {
$("#sidebar_content .changesets").html(html);
updateMap();
}
$(this).hide();
div.find(".loader").show();
- $.get($(this).attr("href"), function(data) {
+ $.get($(this).attr("href"), function (data) {
div.replaceWith(data);
updateMap();
});
function updateBounds() {
group.clearLayers();
- changesets.forEach(function(changeset) {
+ changesets.forEach(function (changeset) {
var bottomLeft = map.project(L.latLng(changeset.bbox.minlat, changeset.bbox.minlon)),
topRight = map.project(L.latLng(changeset.bbox.maxlat, changeset.bbox.maxlon)),
width = topRight.x - bottomLeft.x,
for (var i = 0; i < changesets.length; ++i) {
var changeset = changesets[i],
rect = L.rectangle(changeset.bounds,
- {weight: 2, color: "#FF9500", opacity: 1, fillColor: "#FFFFAF", fillOpacity: 0});
+ { weight: 2, color: "#FF9500", opacity: 1, fillColor: "#FFFFAF", fillOpacity: 0 });
rect.id = changeset.id;
rect.addTo(group);
}
}
function updateMap() {
- changesets = $("[data-changeset]").map(function (index,element) {
+ changesets = $("[data-changeset]").map(function (index, element) {
return $(element).data("changeset");
}).get().filter(function (changeset) {
return changeset.bbox;
}
}
- page.pushstate = page.popstate = function(path) {
+ page.pushstate = page.popstate = function (path) {
$("#history_tab").addClass("current");
OSM.loadSidebarContent(path, page.load);
};
- page.load = function() {
+ page.load = function () {
map.addLayer(group);
if (window.location.pathname === "/history") {
update();
};
- page.unload = function() {
+ page.unload = function () {
map.removeLayer(group);
map.off("moveend", update);
-OSM.NewNote = function(map) {
+OSM.NewNote = function (map) {
var noteLayer = map.noteLayer,
content = $("#sidebar_content"),
page = {},
draggable: true
});
- newNote.on("dragstart dragend", function(a) {
+ newNote.on("dragstart dragend", function (a) {
newHalo(newNote.getLatLng(), a.type);
});
newNote.on("remove", function () {
addNoteButton.removeClass("active");
- }).on("dragstart",function () {
+ }).on("dragstart", function () {
$(newNote).stopTime("removenote");
}).on("dragend", function () {
content.find("textarea").focus();
url: url,
type: method,
oauth: true,
- data: {text: $(form.text).val()},
+ data: { text: $(form.text).val() },
success: function () {
OSM.loadSidebarContent(window.location.pathname, page.load);
}
}
page.pushstate = page.popstate = function (path) {
- OSM.loadSidebarContent(path, function() {
- initialize(function() {
+ OSM.loadSidebarContent(path, function () {
+ initialize(function () {
var data = $(".details").data(),
latLng = L.latLng(data.coordinates.split(","));
if (!map.getBounds().contains(latLng)) moveToNote();
});
};
- page.load = function() {
+ page.load = function () {
initialize(moveToNote);
};
if (!window.location.hash || window.location.hash.match(/^#?c[0-9]+$/)) {
OSM.router.withoutMoveListener(function () {
- map.setView(latLng, 15, {reset: true});
+ map.setView(latLng, 15, { reset: true });
});
}
}
}
});
- noteLayer.on("click", function(e) {
+ noteLayer.on("click", function (e) {
if (e.layer.id) {
OSM.router.route("/note/" + e.layer.id);
}
return marker;
}
- noteLayer.getLayerId = function(marker) {
+ noteLayer.getLayerId = function (marker) {
return marker.id;
};
//= require jquery.simulate
-OSM.Query = function(map) {
+OSM.Query = function (map) {
var url = OSM.OVERPASS_URL,
queryButton = $(".control-query .control-button"),
uninterestingTags = ["source", "source_ref", "source:ref", "history", "attribution", "created_by", "tiger:county", "tiger:tlid", "tiger:upload_uuid", "KSJ2:curve_id", "KSJ2:lat", "KSJ2:lon", "KSJ2:coordinate", "KSJ2:filename", "note:ja"],
url: url,
method: "POST",
data: {
- data: "[timeout:10][out:json];" + query,
+ data: "[timeout:10][out:json];" + query
},
- success: function(results) {
+ success: function (results) {
var elements;
$section.find(".loader").stopTime("loading").hide();
.appendTo($ul);
}
},
- error: function(xhr, status, error) {
+ error: function (xhr, status, error) {
$section.find(".loader").stopTime("loading").hide();
$("<li>")
map.removeLayer(marker);
} else {
marker.setStyle({
- opacity: 1 - i * 0.1,
- fillOpacity: 0.5 - i * 0.05
+ opacity: 1 - (i * 0.1),
+ fillOpacity: 0.5 - (i * 0.05)
});
}
}, 10);
var page = {};
- page.pushstate = page.popstate = function(path) {
+ page.pushstate = page.popstate = function (path) {
OSM.loadSidebarContent(path, function () {
page.load(path, true);
});
};
- page.load = function(path, noCentre) {
+ page.load = function (path, noCentre) {
var params = querystring.parse(path.substring(path.indexOf("?") + 1)),
latlng = L.latLng(params.lat, params.lon);
queryOverpass(params.lat, params.lon);
};
- page.unload = function(sameController) {
+ page.unload = function (sameController) {
if (!sameController) {
disableQueryMode();
}
//= require jquery.simulate
-OSM.Search = function(map) {
- $(".search_form input[name=query]").on("input", function(e) {
+OSM.Search = function (map) {
+ $(".search_form input[name=query]").on("input", function (e) {
if ($(e.target).val() === "") {
$(".describe_location").fadeIn(100);
} else {
}
});
- $(".search_form a.button.switch_link").on("click", function(e) {
+ $(".search_form a.button.switch_link").on("click", function (e) {
e.preventDefault();
var query = $(e.target).parent().parent().find("input[name=query]").val();
if (query) {
}
});
- $(".search_form").on("submit", function(e) {
+ $(".search_form").on("submit", function (e) {
e.preventDefault();
$("header").addClass("closed");
var query = $(this).find("input[name=query]").val();
}
});
- $(".describe_location").on("click", function(e) {
+ $(".describe_location").on("click", function (e) {
e.preventDefault();
var center = map.getCenter().wrap(),
precision = OSM.zoomPrecision(map.getZoom());
$(this).hide();
div.find(".loader").show();
- $.get($(this).attr("href"), function(data) {
+ $.get($(this).attr("href"), function (data) {
div.replaceWith(data);
});
}
if (!marker) {
var data = $(this).find("a.set_position").data();
- marker = L.marker([data.lat, data.lon], {icon: OSM.getUserIcon()});
+ marker = L.marker([data.lat, data.lon], { icon: OSM.getUserIcon() });
$(this).data("marker", marker);
}
var page = {};
- page.pushstate = page.popstate = function(path) {
+ page.pushstate = page.popstate = function (path) {
var params = querystring.parse(path.substring(path.indexOf("?") + 1));
$(".search_form input[name=query]").val(params.query);
$(".describe_location").hide();
OSM.loadSidebarContent(path, page.load);
};
- page.load = function() {
- $(".search_results_entry").each(function(index) {
+ page.load = function () {
+ $(".search_results_entry").each(function (index) {
var entry = $(this);
$.ajax({
url: entry.data("href"),
maxlon: map.getBounds().getEast(),
maxlat: map.getBounds().getNorth()
},
- success: function(html) {
+ success: function (html) {
entry.html(html);
// go to first result of first geocoder
if (index === 0) {
return map.getState();
};
- page.unload = function() {
+ page.unload = function () {
markers.clearLayers();
$(".search_form input[name=query]").val("");
$(".describe_location").fadeIn(100);
-L.OSM.layers = function(options) {
+L.OSM.layers = function (options) {
var control = L.control(options);
control.onAdd = function (map) {
var baseLayers = $("<ul>")
.appendTo(baseSection);
- layers.forEach(function(layer) {
+ layers.forEach(function (layer) {
var item = $("<li>")
.appendTo(baseLayers);
var div = $("<div>")
.appendTo(item);
- map.whenReady(function() {
- var miniMap = L.map(div[0], {attributionControl: false, zoomControl: false, keyboard: false})
+ map.whenReady(function () {
+ var miniMap = L.map(div[0], { attributionControl: false, zoomControl: false, keyboard: false })
.addLayer(new layer.constructor({ apikey: layer.options.apikey }));
miniMap.dragging.disable();
function shown() {
miniMap.invalidateSize();
- setView({animate: false});
+ setView({ animate: false });
map.on("moveend", moved);
}
label.append(layer.options.name);
- item.on("click", function() {
- layers.forEach(function(other) {
+ item.on("click", function () {
+ layers.forEach(function (other) {
if (other === layer) {
map.addLayer(other);
} else {
map.removeLayer(other);
}
});
- map.fire("baselayerchange", {layer: layer});
+ map.fire("baselayerchange", { layer: layer });
});
item.on("dblclick", toggle);
- map.on("layeradd layerremove", function() {
+ map.on("layeradd layerremove", function () {
item.toggleClass("active", map.hasLayer(layer));
input.prop("checked", map.hasLayer(layer));
});
label.append(I18n.t("javascripts.map.layers." + name));
- input.on("change", function() {
+ input.on("change", function () {
checked = input.is(":checked");
if (checked) {
map.addLayer(layer);
} else {
map.removeLayer(layer);
}
- map.fire("overlaylayerchange", {layer: layer});
+ map.fire("overlaylayerchange", { layer: layer });
});
- map.on("layeradd layerremove", function() {
+ map.on("layeradd layerremove", function () {
input.prop("checked", map.hasLayer(layer));
});
- map.on("zoomend", function() {
+ map.on("zoomend", function () {
var disabled = map.getBounds().getSize() >= maxArea;
$(input).prop("disabled", disabled);
});
L.OSM.Map = L.Map.extend({
- initialize: function(id, options) {
+ initialize: function (id, options) {
L.Map.prototype.initialize.call(this, id, options);
- var copyright = I18n.t("javascripts.map.copyright", {copyright_url: "/copyright"});
- var donate = I18n.t("javascripts.map.donate_link_text", {donate_url: "https://donate.openstreetmap.org"});
+ var copyright = I18n.t("javascripts.map.copyright", { copyright_url: "/copyright" });
+ var donate = I18n.t("javascripts.map.donate_link_text", { donate_url: "https://donate.openstreetmap.org" });
this.baseLayers = [];
}));
this.noteLayer = new L.FeatureGroup();
- this.noteLayer.options = {code: "N"};
+ this.noteLayer.options = { code: "N" };
this.dataLayer = new L.OSM.DataLayer(null);
this.dataLayer.options.code = "D";
});
},
- updateLayers: function(layerParam) {
+ updateLayers: function (layerParam) {
layerParam = layerParam || "M";
var layersAdded = "";
return baseLayer.keyid;
},
- getUrl: function(marker) {
+ getUrl: function (marker) {
var precision = OSM.zoomPrecision(this.getZoom()),
params = {};
return url;
},
- getShortUrl: function(marker) {
+ getShortUrl: function (marker) {
var zoom = this.getZoom(),
latLng = marker && this.hasLayer(marker) ? marker.getLatLng().wrap() : this.getCenter().wrap(),
str = window.location.hostname.match(/^www\.openstreetmap\.org/i) ?
i;
for (i = 0; i < Math.ceil((zoom + 8) / 3.0) && i < 5; ++i) {
- digit = (c1 >> (24 - 6 * i)) & 0x3f;
+ digit = (c1 >> (24 - (6 * i))) & 0x3f;
str += char_array.charAt(digit);
}
for (i = 5; i < Math.ceil((zoom + 8) / 3.0); ++i) {
- digit = (c2 >> (24 - 6 * (i - 5))) & 0x3f;
+ digit = (c2 >> (24 - (6 * (i - 5)))) & 0x3f;
str += char_array.charAt(digit);
}
for (i = 0; i < ((zoom + 8) % 3); ++i) str += "-";
return str;
},
- getGeoUri: function(marker) {
+ getGeoUri: function (marker) {
var precision = OSM.zoomPrecision(this.getZoom()),
latLng,
params = {};
return "geo:" + params.lat + "," + params.lon + "?z=" + params.zoom;
},
- addObject: function(object, callback) {
+ addObject: function (object, callback) {
var objectStyle = {
color: "#FF6200",
weight: 4,
if (object.type === "node") {
return true;
} else if (object.type === "relation") {
- for (var i = 0; i < relations.length; i++)
- if (relations[i].members.indexOf(node) !== -1)
- return true;
+ for (var i = 0; i < relations.length; i++) {
+ if (relations[i].members.indexOf(node) !== -1) return true;
+ }
} else {
return false;
}
});
},
- removeObject: function() {
+ removeObject: function () {
this._object = null;
if (this._objectLoader) this._objectLoader.abort();
if (this._objectLayer) this.removeLayer(this._objectLayer);
},
- getState: function() {
+ getState: function () {
return {
center: this.getCenter().wrap(),
zoom: this.getZoom(),
};
},
- setState: function(state, options) {
+ setState: function (state, options) {
if (state.center) this.setView(state.center, state.zoom, options);
if (state.layers) this.updateLayers(state.layers);
},
- setSidebarOverlaid: function(overlaid) {
+ setSidebarOverlaid: function (overlaid) {
if (overlaid && !$("#content").hasClass("overlay-sidebar")) {
$("#content").addClass("overlay-sidebar");
- this.invalidateSize({pan: false})
- .panBy([-350, 0], {animate: false});
+ this.invalidateSize({ pan: false })
+ .panBy([-350, 0], { animate: false });
} else if (!overlaid && $("#content").hasClass("overlay-sidebar")) {
- this.panBy([350, 0], {animate: false});
+ this.panBy([350, 0], { animate: false });
$("#content").removeClass("overlay-sidebar");
- this.invalidateSize({pan: false});
+ this.invalidateSize({ pan: false });
}
return this;
}
L.extend(L.Icon.Default.prototype, {
_oldGetIconUrl: L.Icon.Default.prototype._getIconUrl,
- _getIconUrl: function (name) {
+ _getIconUrl: function (name) {
var url = this._oldGetIconUrl(name);
return L.Icon.Default.imageUrls[url];
}
L.OSM.share = function (options) {
var control = L.control(options),
- marker = L.marker([0, 0], {draggable: true}),
+ marker = L.marker([0, 0], { draggable: true }),
locationFilter = new L.LocationFilter({
enableButton: false,
adjustButton: false
.attr("for", "embed_html")
.attr("href", "#")
.text(I18n.t("javascripts.share.embed")))
- .on("click", "a", function(e) {
+ .on("click", "a", function (e) {
e.preventDefault();
var id = "#" + $(this).attr("for");
$linkSection.find(".share-tabs a")
.attr("type", "text")
.on("change", update));
- ["minlon", "minlat", "maxlon", "maxlat"].forEach(function(name) {
+ ["minlon", "minlat", "maxlon", "maxlat"].forEach(function (name) {
$("<input>")
.attr("id", "mapnik_" + name)
.attr("name", name)
"\"": """,
"'": "'"
};
- return string === null ? "" : String(string).replace(/[&<>"']/g, function(match) {
+ return string === null ? "" : String(string).replace(/[&<>"']/g, function (match) {
return htmlEscapes[match];
});
}
-L.OSM.sidebar = function(selector) {
+L.OSM.sidebar = function (selector) {
var control = {},
sidebar = $(selector),
current = $(),
return control;
};
- control.addPane = function(pane) {
+ control.addPane = function (pane) {
pane
.hide()
.appendTo(sidebar);
};
- control.togglePane = function(pane, button) {
+ control.togglePane = function (pane, button) {
current
.hide()
.trigger("hide");
currentButton = button || $();
}
- map.invalidateSize({pan: false, animate: false});
+ map.invalidateSize({ pan: false, animate: false });
current
.show()
-$(document).ready(function() {
+$(document).ready(function () {
// Preserve location hash in referer
if (window.location.hash) {
$("#referer").val($("#referer").val() + window.location.hash);
});
// Add click handler to show OpenID field
- $("#openid_open_url").click(function() {
+ $("#openid_open_url").click(function () {
$("#openid_url").val("http://");
$("#login_auth_buttons").hide();
$("#login_openid_url").show();
$("#login_openid_submit").hide();
// Handle OpenID submission by redirecting to omniauth
- $("#openid_login_form").submit(function() {
+ $("#openid_login_form").submit(function () {
var action = $(this).prop("action"),
openid_url = $(this).find("#openid_url").val(),
referer = $(this).find("#openid_referer").val(),
token_secret: application_data.tokenSecret
});
- $.ajaxPrefilter(function(options, jqxhr) {
+ $.ajaxPrefilter(function (options, jqxhr) {
if (options.oauth) {
options.headers = options.headers || {};
options.headers.Authorization = headerGenerator(options.type, makeAbsolute(options.url), jqxhr.data);
`OSM.router.withoutMoveListener` to run a block of code that may update
move the map without the hash changing.
*/
-OSM.Router = function(map, rts) {
+OSM.Router = function (map, rts) {
var escapeRegExp = /[\-{}\[\]+?.,\\\^$|#\s]/g;
var optionalParam = /\((.*?)\)/g;
var namedParam = /(\(\?)?:\w+/g;
var regexp = new RegExp("^" +
path.replace(escapeRegExp, "\\$&")
.replace(optionalParam, "(?:$1)?")
- .replace(namedParam, function(match, optional){
+ .replace(namedParam, function (match, optional) {
return optional ? match : "([^\/]+)";
})
.replace(splatParam, "(.*?)") + "(?:\\?.*)?$");
var route = {};
- route.match = function(path) {
+ route.match = function (path) {
return regexp.test(path);
};
- route.run = function(action, path) {
+ route.run = function (action, path) {
var params = [];
if (path) {
- params = regexp.exec(path).map(function(param, i) {
+ params = regexp.exec(path).map(function (param, i) {
return (i > 0 && param) ? decodeURIComponent(param) : param;
});
}
}
var routes = [];
- for (var r in rts)
+ for (var r in rts) {
routes.push(new Route(r, rts[r]));
+ }
- routes.recognize = function(path) {
+ routes.recognize = function (path) {
for (var i = 0; i < this.length; i++) {
if (this[i].match(path)) return this[i];
}
var router = {};
if (window.history && window.history.pushState) {
- $(window).on("popstate", function(e) {
+ $(window).on("popstate", function (e) {
if (!e.originalEvent.state) return; // Is it a real popstate event or just a hash change?
var path = window.location.pathname + window.location.search,
route = routes.recognize(path);
currentPath = path;
currentRoute = route;
currentRoute.run("popstate", currentPath);
- map.setState(e.originalEvent.state, {animate: false});
+ map.setState(e.originalEvent.state, { animate: false });
});
router.route = function (url) {
window.history.replaceState(OSM.parseHash(url), document.title, url);
};
- router.stateChange = function(state) {
+ router.stateChange = function (state) {
if (state.center) {
window.history.replaceState(state, document.title, OSM.formatHash(state));
} else {
window.location.assign(url);
};
- router.stateChange = function(state) {
+ router.stateChange = function (state) {
if (state.center) window.location.replace(OSM.formatHash(state));
};
}
- router.updateHash = function() {
+ router.updateHash = function () {
var hash = OSM.formatHash(map);
if (hash === currentHash) return;
currentHash = hash;
router.stateChange(OSM.parseHash(hash));
};
- router.hashUpdated = function() {
+ router.hashUpdated = function () {
var hash = location.hash;
if (hash === currentHash) return;
currentHash = hash;
map.off("movestart", disableMoveListener);
};
- router.load = function() {
+ router.load = function () {
var loadState = currentRoute.run("load", currentPath);
router.stateChange(loadState || {});
};
var position = $("html").attr("dir") === "rtl" ? "topleft" : "topright";
- L.OSM.zoom({position: position})
+ L.OSM.zoom({ position: position })
.addTo(map);
var locate = L.control.locate({
}
if ($("#map").hasClass("set_location")) {
- var marker = L.marker([0, 0], {icon: OSM.getUserIcon()});
+ var marker = L.marker([0, 0], { icon: OSM.getUserIcon() });
if (OSM.home) {
marker.setLatLng([OSM.home.lat, OSM.home.lon]);
$("[data-user]").each(function () {
var user = $(this).data("user");
if (user.lon && user.lat) {
- L.marker([user.lat, user.lon], {icon: OSM.getUserIcon(user.icon)}).addTo(map)
+ L.marker([user.lat, user.lon], { icon: OSM.getUserIcon(user.icon) }).addTo(map)
.bindPopup(user.description);
}
});
-$(document).ready(function() {
+$(document).ready(function () {
var params = OSM.params();
if (params.lat && params.lon) {
url += OSM.formatHash(params);
$(".start-mapping").attr("href", url);
-
} else {
var geoSuccess = function (position) {
window.location = "/edit" + OSM.formatHash({
});
};
- $(".start-mapping").on("click", function(e) {
+ $(".start-mapping").on("click", function (e) {
e.preventDefault();
$(".start-mapping").addClass("loading");
},
"rules": {
"accessor-pairs": "error",
+ "array-bracket-newline": ["error", "consistent"],
+ "array-bracket-spacing": "error",
"array-callback-return": "error",
"block-scoped-var": "error",
+ "block-spacing": "error",
+ "brace-style": ["error", "1tbs", { "allowSingleLine": true }],
+ "comma-dangle": "error",
+ "comma-spacing": "error",
+ "comma-style": "error",
+ "computed-property-spacing": "error",
+ "curly": ["error", "multi-line", "consistent"],
"dot-notation": "error",
+ "eol-last": "error",
"eqeqeq": ["error", "smart"],
+ "func-call-spacing": "error",
+ "key-spacing": "error",
"keyword-spacing": "error",
"no-alert": "warn",
+ "no-array-constructor": "error",
"no-caller": "error",
"no-div-regex": "error",
"no-eval": "error",
"no-labels": "error",
"no-label-var": "error",
"no-lone-blocks": "error",
+ "no-lonely-if": "error",
"no-loop-func": "error",
+ "no-mixed-operators": "error",
+ "no-multiple-empty-lines": "error",
"no-multi-str": "error",
+ "no-negated-condition": "error",
+ "no-nested-ternary": "error",
"no-new": "error",
"no-new-func": "error",
+ "no-new-object": "error",
"no-new-wrappers": "error",
"no-octal-escape": "error",
"no-process-env": "error",
"no-useless-call": "error",
"no-useless-concat": "error",
"no-useless-return": "error",
- "no-use-before-define": ["error", {"functions": false}],
+ "no-use-before-define": ["error", { "functions": false }],
"no-void": "error",
"no-warning-comments": "warn",
+ "no-whitespace-before-property": "error",
"no-with": "error",
+ "object-curly-newline": ["error", { "consistent": true }],
+ "object-curly-spacing": ["error", "always"],
+ "object-property-newline": ["error", { "allowAllPropertiesOnSameLine": true }],
+ "operator-linebreak": ["error", "after"],
+ "padded-blocks": ["error", "never"],
+ "quote-props": ["error", "consistent-as-needed", { "keywords": true, "numbers": true }],
"quotes": ["error", "double"],
"radix": ["error", "always"],
"semi": ["error", "always"],
"semi-spacing": "error",
+ "semi-style": "error",
+ "space-before-blocks": "error",
+ "space-before-function-paren": ["error", { "named": "never" }],
+ "space-in-parens": "error",
+ "space-infix-ops": "error",
"space-unary-ops": "error",
+ "switch-colon-spacing": "error",
"wrap-iife": "error",
"wrap-regex": "error",
"yoda": "error"