diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js
index d73b3c69c..4a310f22b 100644
--- a/app/assets/javascripts/application.js
+++ b/app/assets/javascripts/application.js
@@ -24,7 +24,7 @@ var querystring = require("querystring-component");
* 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");
@@ -58,9 +58,9 @@ window.updateLinks = function (loc, zoom, layers, object) {
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") : "");
@@ -97,13 +97,13 @@ $(document).ready(function () {
* 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();
});
@@ -114,12 +114,12 @@ $(document).ready(function () {
$(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");
});
diff --git a/app/assets/javascripts/diary_entry.js b/app/assets/javascripts/diary_entry.js
index 73a179ba9..625d43a52 100644
--- a/app/assets/javascripts/diary_entry.js
+++ b/app/assets/javascripts/diary_entry.js
@@ -9,7 +9,7 @@ $(document).ready(function () {
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"));
}
@@ -28,13 +28,13 @@ $(document).ready(function () {
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"));
}
diff --git a/app/assets/javascripts/fixthemap.js b/app/assets/javascripts/fixthemap.js
index 9bfb01ad5..47ba9baf4 100644
--- a/app/assets/javascripts/fixthemap.js
+++ b/app/assets/javascripts/fixthemap.js
@@ -1,4 +1,4 @@
-$(document).ready(function() {
+$(document).ready(function () {
var params = OSM.params();
var url = "/note/new";
diff --git a/app/assets/javascripts/id.js b/app/assets/javascripts/id.js
index fbe810d28..0aae749f7 100644
--- a/app/assets/javascripts/id.js
+++ b/app/assets/javascripts/id.js
@@ -2,7 +2,7 @@
/* globals iD */
-document.addEventListener("DOMContentLoaded", function() {
+document.addEventListener("DOMContentLoaded", function () {
var container = document.getElementById("id-container");
if (typeof iD === "undefined" || !iD.Detect().support) {
@@ -24,7 +24,7 @@ document.addEventListener("DOMContentLoaded", function() {
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(),
@@ -46,7 +46,7 @@ document.addEventListener("DOMContentLoaded", function() {
// 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));
diff --git a/app/assets/javascripts/index.js b/app/assets/javascripts/index.js
index cce07f324..6228b2376 100644
--- a/app/assets/javascripts/index.js
+++ b/app/assets/javascripts/index.js
@@ -31,12 +31,12 @@ $(document).ready(function () {
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);
@@ -54,7 +54,7 @@ $(document).ready(function () {
$.ajax({
url: path,
dataType: "html",
- complete: function(xhr) {
+ complete: function (xhr) {
clearTimeout(loaderTimeout);
$("#flash").empty();
$("#sidebar_loader").hide();
@@ -96,7 +96,7 @@ $(document).ready(function () {
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({
@@ -134,9 +134,9 @@ $(document).ready(function () {
}).addTo(map);
L.OSM.share({
- position: position,
- sidebar: sidebar,
- short: true
+ "position": position,
+ "sidebar": sidebar,
+ "short": true
}).addTo(map);
L.OSM.note({
@@ -171,12 +171,12 @@ $(document).ready(function () {
}
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(),
@@ -191,7 +191,7 @@ $(document).ready(function () {
$(".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: "/" });
});
@@ -199,7 +199,7 @@ $(document).ready(function () {
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();
@@ -230,14 +230,14 @@ $(document).ready(function () {
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) {
@@ -251,7 +251,7 @@ $(document).ready(function () {
};
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?";
@@ -263,7 +263,7 @@ $(document).ready(function () {
.hide()
.appendTo("body")
.attr("src", url + querystring.stringify(query))
- .on("load", function() {
+ .on("load", function () {
$(this).remove();
loaded = true;
});
@@ -278,7 +278,7 @@ $(document).ready(function () {
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();
@@ -293,20 +293,20 @@ $(document).ready(function () {
})
.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);
@@ -320,21 +320,21 @@ $(document).ready(function () {
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 () {
@@ -344,7 +344,7 @@ $(document).ready(function () {
});
}
- page.unload = function() {
+ page.unload = function () {
map.removeObject();
};
@@ -354,21 +354,21 @@ $(document).ready(function () {
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") {
@@ -378,19 +378,23 @@ $(document).ready(function () {
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();
+ }
});
});
diff --git a/app/assets/javascripts/index/browse.js b/app/assets/javascripts/index/browse.js
index c840ecdfa..630944411 100644
--- a/app/assets/javascripts/index/browse.js
+++ b/app/assets/javascripts/index/browse.js
@@ -120,7 +120,7 @@ OSM.initializeBrowse = function (map) {
// 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);
diff --git a/app/assets/javascripts/index/changeset.js b/app/assets/javascripts/index/changeset.js
index b670bd289..5ff8edc71 100644
--- a/app/assets/javascripts/index/changeset.js
+++ b/app/assets/javascripts/index/changeset.js
@@ -3,21 +3,20 @@ OSM.Changeset = function (map) {
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 () {
@@ -33,7 +32,7 @@ OSM.Changeset = function (map) {
$(form).find("input[type=submit]").prop("disabled", true);
if (include_data) {
- data = {text: $(form.text).val()};
+ data = { text: $(form.text).val() };
} else {
data = {};
}
@@ -75,7 +74,7 @@ OSM.Changeset = function (map) {
content.find("textarea").val("").trigger("input");
}
- page.unload = function() {
+ page.unload = function () {
map.removeObject();
};
diff --git a/app/assets/javascripts/index/contextmenu.js b/app/assets/javascripts/index/contextmenu.js
index 080a4de72..e3e30ce6b 100644
--- a/app/assets/javascripts/index/contextmenu.js
+++ b/app/assets/javascripts/index/contextmenu.js
@@ -77,7 +77,7 @@ OSM.initializeContextMenu = function (map) {
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);
};
diff --git a/app/assets/javascripts/index/directions.js b/app/assets/javascripts/index/directions.js
index 28d436a96..4283ef5aa 100644
--- a/app/assets/javascripts/index/directions.js
+++ b/app/assets/javascripts/index/directions.js
@@ -6,7 +6,7 @@ OSM.Directions = function (map) {
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",
@@ -38,7 +38,7 @@ OSM.Directions = function (map) {
var select = $("select.routing_engines");
- engines.forEach(function(engine, i) {
+ engines.forEach(function (engine, i) {
select.append("");
});
@@ -68,7 +68,7 @@ OSM.Directions = function (map) {
}
});
- input.on("keydown", function() {
+ input.on("keydown", function () {
input.removeClass("error");
});
@@ -80,7 +80,7 @@ OSM.Directions = function (map) {
endpoint.setValue(value);
});
- endpoint.setValue = function(value, latlng) {
+ endpoint.setValue = function (value, latlng) {
endpoint.value = value;
delete endpoint.latlng;
input.removeClass("error");
@@ -93,7 +93,7 @@ OSM.Directions = function (map) {
}
};
- 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) {
@@ -107,7 +107,7 @@ OSM.Directions = function (map) {
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;
}
@@ -135,7 +135,7 @@ OSM.Directions = function (map) {
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;
@@ -146,7 +146,7 @@ OSM.Directions = function (map) {
}));
});
- $(".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) {
@@ -174,7 +174,7 @@ OSM.Directions = function (map) {
}
function findEngine(id) {
- return engines.findIndex(function(engine) {
+ return engines.findIndex(function (engine) {
return engine.id === id;
});
}
@@ -251,7 +251,7 @@ OSM.Directions = function (map) {
if (typeof route.ascend !== "undefined" && typeof route.descend !== "undefined") {
html += "
" +
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 += "
" + - I18n.t("javascripts.directions.instructions.courtesy", {link: chosenEngine.creditline}) + + I18n.t("javascripts.directions.instructions.courtesy", { link: chosenEngine.creditline }) + "
"); - $("#sidebar_content a.geolink").on("click", function(e) { + $("#sidebar_content a.geolink").on("click", function (e) { e.preventDefault(); map.removeLayer(polyline); $("#sidebar_content").html(""); @@ -329,7 +329,7 @@ OSM.Directions = function (map) { } }); - $(".directions_form").on("submit", function(e) { + $(".directions_form").on("submit", function (e) { e.preventDefault(); getRoute(true, true); }); @@ -347,7 +347,7 @@ OSM.Directions = function (map) { var page = {}; - page.pushstate = page.popstate = function() { + page.pushstate = page.popstate = function () { $(".search_form").hide(); $(".directions_form").show(); @@ -388,11 +388,11 @@ OSM.Directions = function (map) { 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"); diff --git a/app/assets/javascripts/index/directions/fossgis.js b/app/assets/javascripts/index/directions/fossgis.js index 6033e511b..8e5e8e621 100644 --- a/app/assets/javascripts/index/directions/fossgis.js +++ b/app/assets/javascripts/index/directions/fossgis.js @@ -9,7 +9,7 @@ function FOSSGISEngine(id, vehicleType) { creditline: "FOSSGIS Routing Service", 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", @@ -35,7 +35,7 @@ function FOSSGISEngine(id, vehicleType) { "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, @@ -64,10 +64,10 @@ function FOSSGISEngine(id, vehicleType) { "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 @@ -99,7 +99,7 @@ function FOSSGISEngine(id, vehicleType) { 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); @@ -150,7 +150,6 @@ function FOSSGISEngine(id, vehicleType) { }, getRoute: function (points, callback) { - var params = [ { name: "overview", value: "false" }, { name: "geometries", value: "polyline" }, @@ -159,23 +158,24 @@ function FOSSGISEngine(id, vehicleType) { 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; }); diff --git a/app/assets/javascripts/index/directions/graphhopper.js b/app/assets/javascripts/index/directions/graphhopper.js index 83f266acc..6bd430c06 100644 --- a/app/assets/javascripts/index/directions/graphhopper.js +++ b/app/assets/javascripts/index/directions/graphhopper.js @@ -3,13 +3,13 @@ function GraphHopperEngine(id, vehicleType) { "-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 { @@ -23,19 +23,20 @@ function GraphHopperEngine(id, vehicleType) { 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); @@ -51,10 +52,10 @@ function GraphHopperEngine(id, vehicleType) { 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, diff --git a/app/assets/javascripts/index/export.js b/app/assets/javascripts/index/export.js index 48e950b21..67530370d 100644 --- a/app/assets/javascripts/index/export.js +++ b/app/assets/javascripts/index/export.js @@ -1,4 +1,4 @@ -OSM.Export = function(map) { +OSM.Export = function (map) { var page = {}; var locationFilter = new L.LocationFilter({ @@ -57,12 +57,12 @@ OSM.Export = function(map) { 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); @@ -75,7 +75,7 @@ OSM.Export = function(map) { return map.getState(); }; - page.unload = function() { + page.unload = function () { map .removeLayer(locationFilter) .off("moveend", update); diff --git a/app/assets/javascripts/index/history.js b/app/assets/javascripts/index/history.js index 4f03de06d..a0c68e840 100644 --- a/app/assets/javascripts/index/history.js +++ b/app/assets/javascripts/index/history.js @@ -1,6 +1,6 @@ //= require jquery.simulate -OSM.History = function(map) { +OSM.History = function (map) { var page = {}; $("#sidebar_content") @@ -13,13 +13,15 @@ OSM.History = function(map) { }) .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() @@ -33,17 +35,17 @@ OSM.History = function(map) { 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"); } @@ -52,7 +54,7 @@ OSM.History = function(map) { } function update() { - var data = {list: "1"}; + var data = { list: "1" }; if (window.location.pathname === "/history") { data.bbox = map.getBounds().wrap().toBBoxString(); @@ -62,7 +64,7 @@ OSM.History = function(map) { url: window.location.pathname, method: "GET", data: data, - success: function(html) { + success: function (html) { $("#sidebar_content .changesets").html(html); updateMap(); } @@ -83,7 +85,7 @@ OSM.History = function(map) { $(this).hide(); div.find(".loader").show(); - $.get($(this).attr("href"), function(data) { + $.get($(this).attr("href"), function (data) { div.replaceWith(data); updateMap(); }); @@ -94,7 +96,7 @@ OSM.History = function(map) { 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, @@ -122,14 +124,14 @@ OSM.History = function(map) { 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; @@ -143,12 +145,12 @@ OSM.History = function(map) { } } - 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") { @@ -160,7 +162,7 @@ OSM.History = function(map) { update(); }; - page.unload = function() { + page.unload = function () { map.removeLayer(group); map.off("moveend", update); diff --git a/app/assets/javascripts/index/new_note.js b/app/assets/javascripts/index/new_note.js index 3111a579f..7196a779b 100644 --- a/app/assets/javascripts/index/new_note.js +++ b/app/assets/javascripts/index/new_note.js @@ -1,4 +1,4 @@ -OSM.NewNote = function(map) { +OSM.NewNote = function (map) { var noteLayer = map.noteLayer, content = $("#sidebar_content"), page = {}, @@ -126,7 +126,7 @@ OSM.NewNote = function(map) { draggable: true }); - newNote.on("dragstart dragend", function(a) { + newNote.on("dragstart dragend", function (a) { newHalo(newNote.getLatLng(), a.type); }); @@ -135,7 +135,7 @@ OSM.NewNote = function(map) { newNote.on("remove", function () { addNoteButton.removeClass("active"); - }).on("dragstart",function () { + }).on("dragstart", function () { $(newNote).stopTime("removenote"); }).on("dragend", function () { content.find("textarea").focus(); diff --git a/app/assets/javascripts/index/note.js b/app/assets/javascripts/index/note.js index fadaadfd8..52bb1c909 100644 --- a/app/assets/javascripts/index/note.js +++ b/app/assets/javascripts/index/note.js @@ -28,7 +28,7 @@ OSM.Note = function (map) { 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); } @@ -36,8 +36,8 @@ OSM.Note = function (map) { } 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(); @@ -45,7 +45,7 @@ OSM.Note = function (map) { }); }; - page.load = function() { + page.load = function () { initialize(moveToNote); }; @@ -101,7 +101,7 @@ OSM.Note = function (map) { 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 }); }); } } diff --git a/app/assets/javascripts/index/notes.js b/app/assets/javascripts/index/notes.js index 1eb61f8eb..4890a2687 100644 --- a/app/assets/javascripts/index/notes.js +++ b/app/assets/javascripts/index/notes.js @@ -33,7 +33,7 @@ OSM.initializeNotes = function (map) { } }); - noteLayer.on("click", function(e) { + noteLayer.on("click", function (e) { if (e.layer.id) { OSM.router.route("/note/" + e.layer.id); } @@ -55,7 +55,7 @@ OSM.initializeNotes = function (map) { return marker; } - noteLayer.getLayerId = function(marker) { + noteLayer.getLayerId = function (marker) { return marker.id; }; diff --git a/app/assets/javascripts/index/query.js b/app/assets/javascripts/index/query.js index 407e088e5..6869e19f6 100644 --- a/app/assets/javascripts/index/query.js +++ b/app/assets/javascripts/index/query.js @@ -1,6 +1,6 @@ //= 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"], @@ -178,9 +178,9 @@ OSM.Query = function(map) { 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(); @@ -237,7 +237,7 @@ OSM.Query = function(map) { .appendTo($ul); } }, - error: function(xhr, status, error) { + error: function (xhr, status, error) { $section.find(".loader").stopTime("loading").hide(); $("