From 5bd59e19368d8761a7dbaa5db0e8833174c11f36 Mon Sep 17 00:00:00 2001
From: Tom Hughes
" +
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(); $("