From: Tom Hughes
" + instruction + "
") @@ -298,32 +298,32 @@ OSM.Directions = function (map) { map.removeLayer(highlight); }); - $('#turnbyturn').append(row); + $("#turnbyturn").append(row); }); - $('#sidebar_content').append('' + - I18n.t('javascripts.directions.instructions.courtesy', {link: chosenEngine.creditline}) + - '
'); + $("#sidebar_content").append("" + + 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(''); + $("#sidebar_content").html(""); map.setSidebarOverlaid(true); // TODO: collapse width of sidebar back to previous }); }); } - var chosenEngineIndex = findEngine('fossgis_osrm_car'); - if ($.cookie('_osm_directions_engine')) { - chosenEngineIndex = findEngine($.cookie('_osm_directions_engine')); + var chosenEngineIndex = findEngine("fossgis_osrm_car"); + if ($.cookie("_osm_directions_engine")) { + chosenEngineIndex = findEngine($.cookie("_osm_directions_engine")); } setEngine(chosenEngineIndex); select.on("change", function (e) { chosenEngine = engines[e.target.selectedIndex]; - $.cookie('_osm_directions_engine', chosenEngine.id, { expires: expiry, path: '/' }); + $.cookie("_osm_directions_engine", chosenEngine.id, { expires: expiry, path: "/" }); if (map.hasLayer(polyline)) { getRoute(true, true); } @@ -334,11 +334,11 @@ OSM.Directions = function (map) { getRoute(true, true); }); - $(".routing_marker").on('dragstart', function (e) { + $(".routing_marker").on("dragstart", function (e) { var dt = e.originalEvent.dataTransfer; - dt.effectAllowed = 'move'; - var dragData = { type: $(this).data('type') }; - dt.setData('text', JSON.stringify(dragData)); + dt.effectAllowed = "move"; + var dragData = { type: $(this).data("type") }; + dt.setData("text", JSON.stringify(dragData)); if (dt.setDragImage) { var img = $("").attr("src", $(e.originalEvent.target).attr("src")); dt.setDragImage(img.get(0), 12, 21); @@ -351,26 +351,26 @@ OSM.Directions = function (map) { $(".search_form").hide(); $(".directions_form").show(); - $("#map").on('dragend dragover', function (e) { + $("#map").on("dragend dragover", function (e) { e.preventDefault(); }); - $("#map").on('drop', function (e) { + $("#map").on("drop", function (e) { e.preventDefault(); var oe = e.originalEvent; - var dragData = JSON.parse(oe.dataTransfer.getData('text')); + var dragData = JSON.parse(oe.dataTransfer.getData("text")); var type = dragData.type; var pt = L.DomEvent.getMousePosition(oe, map.getContainer()); // co-ordinates of the mouse pointer at present pt.y += 20; var ll = map.containerPointToLatLng(pt); - endpoints[type === 'from' ? 0 : 1].setLatLng(ll); + endpoints[type === "from" ? 0 : 1].setLatLng(ll); getRoute(true, true); }); var params = querystring.parse(location.search.substring(1)), - route = (params.route || '').split(';'), - from = route[0] && L.latLng(route[0].split(',')), - to = route[1] && L.latLng(route[1].split(',')); + route = (params.route || "").split(";"), + from = route[0] && L.latLng(route[0].split(",")), + to = route[1] && L.latLng(route[1].split(",")); if (params.engine) { var engineIndex = findEngine(params.engine); @@ -395,7 +395,7 @@ OSM.Directions = function (map) { page.unload = function() { $(".search_form").show(); $(".directions_form").hide(); - $("#map").off('dragend dragover drop'); + $("#map").off("dragend dragover drop"); map .removeLayer(popup) diff --git a/app/assets/javascripts/index/directions/fossgis.js b/app/assets/javascripts/index/directions/fossgis.js index 1d6e1f82c..6033e511b 100644 --- a/app/assets/javascripts/index/directions/fossgis.js +++ b/app/assets/javascripts/index/directions/fossgis.js @@ -6,63 +6,63 @@ function FOSSGISEngine(id, vehicleType) { return { id: id, - creditline: 'FOSSGIS Routing Service', + creditline: "FOSSGIS Routing Service", draggable: true, _transformSteps: function(input_steps, line) { var INSTRUCTION_TEMPLATE = { - 'continue': 'javascripts.directions.instructions.continue', - 'merge right': 'javascripts.directions.instructions.merge_right', - 'merge left': 'javascripts.directions.instructions.merge_left', - 'off ramp right': 'javascripts.directions.instructions.offramp_right', - 'off ramp left': 'javascripts.directions.instructions.offramp_left', - 'on ramp right': 'javascripts.directions.instructions.onramp_right', - 'on ramp left': 'javascripts.directions.instructions.onramp_left', - 'fork right': 'javascripts.directions.instructions.fork_right', - 'fork left': 'javascripts.directions.instructions.fork_left', - 'end of road right': 'javascripts.directions.instructions.endofroad_right', - 'end of road left': 'javascripts.directions.instructions.endofroad_left', - 'turn straight': 'javascripts.directions.instructions.continue', - 'turn slight right': 'javascripts.directions.instructions.slight_right', - 'turn right': 'javascripts.directions.instructions.turn_right', - 'turn sharp right': 'javascripts.directions.instructions.sharp_right', - 'turn uturn': 'javascripts.directions.instructions.uturn', - 'turn sharp left': 'javascripts.directions.instructions.sharp_left', - 'turn left': 'javascripts.directions.instructions.turn_left', - 'turn slight left': 'javascripts.directions.instructions.slight_left', - 'roundabout': 'javascripts.directions.instructions.roundabout', - 'rotary': 'javascripts.directions.instructions.roundabout', - 'exit roundabout': 'javascripts.directions.instructions.exit_roundabout', - 'exit rotary': 'javascripts.directions.instructions.exit_roundabout', - 'depart': 'javascripts.directions.instructions.start', - 'arrive': 'javascripts.directions.instructions.destination', + "continue": "javascripts.directions.instructions.continue", + "merge right": "javascripts.directions.instructions.merge_right", + "merge left": "javascripts.directions.instructions.merge_left", + "off ramp right": "javascripts.directions.instructions.offramp_right", + "off ramp left": "javascripts.directions.instructions.offramp_left", + "on ramp right": "javascripts.directions.instructions.onramp_right", + "on ramp left": "javascripts.directions.instructions.onramp_left", + "fork right": "javascripts.directions.instructions.fork_right", + "fork left": "javascripts.directions.instructions.fork_left", + "end of road right": "javascripts.directions.instructions.endofroad_right", + "end of road left": "javascripts.directions.instructions.endofroad_left", + "turn straight": "javascripts.directions.instructions.continue", + "turn slight right": "javascripts.directions.instructions.slight_right", + "turn right": "javascripts.directions.instructions.turn_right", + "turn sharp right": "javascripts.directions.instructions.sharp_right", + "turn uturn": "javascripts.directions.instructions.uturn", + "turn sharp left": "javascripts.directions.instructions.sharp_left", + "turn left": "javascripts.directions.instructions.turn_left", + "turn slight left": "javascripts.directions.instructions.slight_left", + "roundabout": "javascripts.directions.instructions.roundabout", + "rotary": "javascripts.directions.instructions.roundabout", + "exit roundabout": "javascripts.directions.instructions.exit_roundabout", + "exit rotary": "javascripts.directions.instructions.exit_roundabout", + "depart": "javascripts.directions.instructions.start", + "arrive": "javascripts.directions.instructions.destination", }; var ICON_MAP = { - 'continue': 0, - 'merge right': 21, - 'merge left': 20, - 'off ramp right': 24, - 'off ramp left': 25, - 'on ramp right': 2, - 'on ramp left': 6, - 'fork right': 18, - 'fork left': 19, - 'end of road right': 22, - 'end of road left': 23, - 'turn straight': 0, - 'turn slight right': 1, - 'turn right': 2, - 'turn sharp right': 3, - 'turn uturn': 4, - 'turn slight left': 5, - 'turn left': 6, - 'turn sharp left': 7, - 'roundabout': 10, - 'rotary': 10, - 'exit roundabout': 10, - 'exit rotary': 10, - 'depart': 8, - 'arrive': 14 + "continue": 0, + "merge right": 21, + "merge left": 20, + "off ramp right": 24, + "off ramp left": 25, + "on ramp right": 2, + "on ramp left": 6, + "fork right": 18, + "fork left": 19, + "end of road right": 22, + "end of road left": 23, + "turn straight": 0, + "turn slight right": 1, + "turn right": 2, + "turn sharp right": 3, + "turn uturn": 4, + "turn slight left": 5, + "turn left": 6, + "turn sharp left": 7, + "roundabout": 10, + "rotary": 10, + "exit roundabout": 10, + "exit rotary": 10, + "depart": 8, + "arrive": 14 }; var numToWord = function(num) { return ["first", "second", "third", "fourth", "fifth", "sixth", "seventh", "eighth", "ninth", "tenth"][num-1]; @@ -72,23 +72,23 @@ function FOSSGISEngine(id, vehicleType) { // special case handling switch (step.maneuver.type) { - case 'on ramp': - case 'off ramp': - case 'merge': - case 'end of road': - case 'fork': - maneuver_id = step.maneuver.type + ' ' + (step.maneuver.modifier.indexOf('left') >= 0 ? 'left' : 'right'); + case "on ramp": + case "off ramp": + case "merge": + case "end of road": + case "fork": + maneuver_id = step.maneuver.type + " " + (step.maneuver.modifier.indexOf("left") >= 0 ? "left" : "right"); break; - case 'depart': - case 'arrive': - case 'roundabout': - case 'rotary': - case 'exit roundabout': - case 'exit rotary': + case "depart": + case "arrive": + case "roundabout": + case "rotary": + case "exit roundabout": + case "exit rotary": maneuver_id = step.maneuver.type; break; - case 'roundabout turn': - case 'turn': + case "roundabout turn": + case "turn": maneuver_id = "turn " + step.maneuver.modifier; break; // for unknown types the fallback is turn @@ -115,7 +115,7 @@ function FOSSGISEngine(id, vehicleType) { } else if (step.ref) { name = "" + step.ref + ""; } else { - name = I18n.t('javascripts.directions.instructions.unnamed'); + name = I18n.t("javascripts.directions.instructions.unnamed"); namedRoad = false; } @@ -124,12 +124,12 @@ function FOSSGISEngine(id, vehicleType) { } else if (step.maneuver.type.match(/^(rotary|roundabout)$/)) { if (step.maneuver.exit) { if (step.maneuver.exit <= 10) { - instText += I18n.t(template + '_with_exit_ordinal', { exit: I18n.t('javascripts.directions.instructions.exit_counts.' + numToWord(step.maneuver.exit)), name: name }); + instText += I18n.t(template + "_with_exit_ordinal", { exit: I18n.t("javascripts.directions.instructions.exit_counts." + numToWord(step.maneuver.exit)), name: name }); } else { - instText += I18n.t(template + '_with_exit', { exit: step.maneuver.exit, name: name }); + instText += I18n.t(template + "_with_exit", { exit: step.maneuver.exit, name: name }); } } else { - instText += I18n.t(template + '_without_exit', { name: name }); + instText += I18n.t(template + "_without_exit", { name: name }); } } else if (step.maneuver.type.match(/^(on ramp|off ramp)$/)) { var params = {}; @@ -141,7 +141,7 @@ function FOSSGISEngine(id, vehicleType) { } instText += I18n.t(template, params); } else { - instText += I18n.t(template + '_without_exit', { name: name }); + instText += I18n.t(template + "_without_exit", { name: name }); } return [[step.maneuver.location[1], step.maneuver.location[0]], ICON_MAP[maneuver_id], instText, step.distance, step_geometry]; }); @@ -166,13 +166,13 @@ function FOSSGISEngine(id, vehicleType) { } var encoded_coords = points.map(function(p) { - return p.lng + ',' + p.lat; - }).join(';'); + 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) { diff --git a/app/assets/javascripts/index/directions/graphhopper.js b/app/assets/javascripts/index/directions/graphhopper.js index ce568409d..83f266acc 100644 --- a/app/assets/javascripts/index/directions/graphhopper.js +++ b/app/assets/javascripts/index/directions/graphhopper.js @@ -14,7 +14,7 @@ function GraphHopperEngine(id, vehicleType) { return { id: id, - creditline: 'Graphhopper', + creditline: "Graphhopper", draggable: false, getRoute: function (points, callback) { diff --git a/app/assets/javascripts/index/history.js b/app/assets/javascripts/index/history.js index 38d0b249a..4f03de06d 100644 --- a/app/assets/javascripts/index/history.js +++ b/app/assets/javascripts/index/history.js @@ -14,7 +14,7 @@ OSM.History = function(map) { .on("mousedown", "[data-changeset]", function () { var moved = false; $(this).one("click", function (e) { - if (!moved && !$(e.target).is('a')) { + if (!moved && !$(e.target).is("a")) { clickChangeset($(this).data("changeset").id, e); } }).one("mousemove", function () { @@ -52,9 +52,9 @@ OSM.History = function(map) { } function update() { - var data = {list: '1'}; + var data = {list: "1"}; - if (window.location.pathname === '/history') { + if (window.location.pathname === "/history") { data.bbox = map.getBounds().wrap().toBBoxString(); } @@ -63,15 +63,15 @@ OSM.History = function(map) { method: "GET", data: data, success: function(html) { - $('#sidebar_content .changesets').html(html); + $("#sidebar_content .changesets").html(html); updateMap(); } }); - var feedLink = $('link[type="application/atom+xml"]'), - feedHref = feedLink.attr('href').split('?')[0]; + var feedLink = $("link[type=\"application/atom+xml\"]"), + feedHref = feedLink.attr("href").split("?")[0]; - feedLink.attr('href', feedHref + '?bbox=' + data.bbox); + feedLink.attr("href", feedHref + "?bbox=" + data.bbox); } function loadMore(e) { @@ -130,14 +130,14 @@ OSM.History = function(map) { function updateMap() { changesets = $("[data-changeset]").map(function (index,element) { - return $(element).data('changeset'); + return $(element).data("changeset"); }).get().filter(function (changeset) { return changeset.bbox; }); updateBounds(); - if (window.location.pathname !== '/history') { + if (window.location.pathname !== "/history") { var bounds = group.getBounds(); if (bounds.isValid()) map.fitBounds(bounds); } @@ -151,7 +151,7 @@ OSM.History = function(map) { page.load = function() { map.addLayer(group); - if (window.location.pathname === '/history') { + if (window.location.pathname === "/history") { map.on("moveend", update); } diff --git a/app/assets/javascripts/index/new_note.js b/app/assets/javascripts/index/new_note.js index d79643984..3111a579f 100644 --- a/app/assets/javascripts/index/new_note.js +++ b/app/assets/javascripts/index/new_note.js @@ -1,6 +1,6 @@ OSM.NewNote = function(map) { var noteLayer = map.noteLayer, - content = $('#sidebar_content'), + content = $("#sidebar_content"), page = {}, addNoteButton = $(".control-note .control-button"), newNote, @@ -28,9 +28,9 @@ OSM.NewNote = function(map) { e.preventDefault(); e.stopPropagation(); - if ($(this).hasClass('disabled')) return; + if ($(this).hasClass("disabled")) return; - OSM.router.route('/note/new'); + OSM.router.route("/note/new"); }); function createNote(marker, form, url) { @@ -61,7 +61,7 @@ OSM.NewNote = function(map) { newNote = null; noteLayer.removeLayer(marker); addNoteButton.removeClass("active"); - OSM.router.route('/note/' + feature.properties.id); + OSM.router.route("/note/" + feature.properties.id); } } @@ -83,7 +83,7 @@ OSM.NewNote = function(map) { }; function newHalo(loc, a) { - if (a === 'dragstart' && map.hasLayer(halo)) { + if (a === "dragstart" && map.hasLayer(halo)) { map.removeLayer(halo); } else { if (map.hasLayer(halo)) map.removeLayer(halo); @@ -107,7 +107,7 @@ OSM.NewNote = function(map) { map.addLayer(noteLayer); - var params = querystring.parse(path.substring(path.indexOf('?') + 1)); + var params = querystring.parse(path.substring(path.indexOf("?") + 1)); var markerLatlng; if (params.lat && params.lon) { @@ -149,9 +149,9 @@ OSM.NewNote = function(map) { $(e.target.form.add).prop("disabled", $(e.target).val() === ""); } - content.find('input[type=submit]').on('click', function (e) { + content.find("input[type=submit]").on("click", function (e) { e.preventDefault(); - createNote(newNote, e.target.form, '/api/0.6/notes.json'); + createNote(newNote, e.target.form, "/api/0.6/notes.json"); }); return map.getState(); diff --git a/app/assets/javascripts/index/note.js b/app/assets/javascripts/index/note.js index 85267ab93..fadaadfd8 100644 --- a/app/assets/javascripts/index/note.js +++ b/app/assets/javascripts/index/note.js @@ -1,5 +1,5 @@ OSM.Note = function (map) { - var content = $('#sidebar_content'), + var content = $("#sidebar_content"), page = {}, halo, currentNote; @@ -38,8 +38,8 @@ OSM.Note = function (map) { page.pushstate = page.popstate = function (path) { OSM.loadSidebarContent(path, function() { initialize(function() { - var data = $('.details').data(), - latLng = L.latLng(data.coordinates.split(',')); + var data = $(".details").data(), + latLng = L.latLng(data.coordinates.split(",")); if (!map.getBounds().contains(latLng)) moveToNote(); }); }); @@ -68,10 +68,10 @@ OSM.Note = function (map) { } }); - content.find("textarea").val('').trigger("input"); + content.find("textarea").val("").trigger("input"); - var data = $('.details').data(), - latLng = L.latLng(data.coordinates.split(',')); + var data = $(".details").data(), + latLng = L.latLng(data.coordinates.split(",")); if (!map.hasLayer(halo)) { halo = L.circleMarker(latLng, { @@ -96,8 +96,8 @@ OSM.Note = function (map) { } function moveToNote() { - var data = $('.details').data(), - latLng = L.latLng(data.coordinates.split(',')); + var data = $(".details").data(), + latLng = L.latLng(data.coordinates.split(",")); if (!window.location.hash || window.location.hash.match(/^#?c[0-9]+$/)) { OSM.router.withoutMoveListener(function () { diff --git a/app/assets/javascripts/index/notes.js b/app/assets/javascripts/index/notes.js index 9feee888c..1eb61f8eb 100644 --- a/app/assets/javascripts/index/notes.js +++ b/app/assets/javascripts/index/notes.js @@ -33,9 +33,9 @@ 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); + OSM.router.route("/note/" + e.layer.id); } }); diff --git a/app/assets/javascripts/index/query.js b/app/assets/javascripts/index/query.js index 3da84c7d9..407e088e5 100644 --- a/app/assets/javascripts/index/query.js +++ b/app/assets/javascripts/index/query.js @@ -3,7 +3,7 @@ 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'], + 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"], marker; var featureStyle = { @@ -55,7 +55,7 @@ OSM.Query = function(map) { var geometry = $(this).data("geometry"); if (geometry) map.removeLayer(geometry); - if (!$(e.target).is('a')) { + if (!$(e.target).is("a")) { $(this).find("a").simulate("click", e); } } @@ -342,7 +342,7 @@ OSM.Query = function(map) { }; page.load = function(path, noCentre) { - var params = querystring.parse(path.substring(path.indexOf('?') + 1)), + var params = querystring.parse(path.substring(path.indexOf("?") + 1)), latlng = L.latLng(params.lat, params.lon); if (!window.location.hash && !noCentre && !map.getBounds().contains(latlng)) { diff --git a/app/assets/javascripts/index/search.js b/app/assets/javascripts/index/search.js index 6ca145c03..17945436e 100644 --- a/app/assets/javascripts/index/search.js +++ b/app/assets/javascripts/index/search.js @@ -47,7 +47,7 @@ OSM.Search = function(map) { .on("mousedown", "p.search_results_entry:has(a.set_position)", function () { var moved = false; $(this).one("click", function (e) { - if (!moved && !$(e.target).is('a')) { + if (!moved && !$(e.target).is("a")) { $(this).find("a.set_position").simulate("click", e); } }).one("mousemove", function () { @@ -120,7 +120,7 @@ OSM.Search = function(map) { var page = {}; page.pushstate = page.popstate = function(path) { - var params = querystring.parse(path.substring(path.indexOf('?') + 1)); + 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); @@ -131,7 +131,7 @@ OSM.Search = function(map) { var entry = $(this); $.ajax({ url: entry.data("href"), - method: 'GET', + method: "GET", data: { zoom: map.getZoom(), minlon: map.getBounds().getWest(), @@ -143,7 +143,7 @@ OSM.Search = function(map) { entry.html(html); // go to first result of first geocoder if (index === 0) { - var firstResult = entry.find('*[data-lat][data-lon]:first').first(); + var firstResult = entry.find("*[data-lat][data-lon]:first").first(); if (firstResult.length) { panToSearchResult(firstResult.data()); } diff --git a/app/assets/javascripts/leaflet.key.js b/app/assets/javascripts/leaflet.key.js index 5223b1420..321f937db 100644 --- a/app/assets/javascripts/leaflet.key.js +++ b/app/assets/javascripts/leaflet.key.js @@ -2,78 +2,78 @@ L.OSM.key = function (options) { var control = L.control(options); control.onAdd = function (map) { - var $container = $('