From 8323c948a737fa1eac6ed73c13cfc6e7858327b9 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Thu, 24 Oct 2013 14:58:31 -0700 Subject: [PATCH] jshint fixes --- js/id/actions/add_member.js | 2 +- js/id/actions/change_member.js | 2 +- js/id/actions/connect.js | 2 ++ js/id/actions/discard_tags.js | 2 +- js/id/actions/straighten.js | 2 +- js/id/behavior/drag.js | 8 ++++---- js/id/behavior/hover.js | 4 ++-- js/id/core/connection.js | 2 +- js/id/core/history.js | 18 +++++++++++------- js/id/core/relation.js | 2 +- js/id/end.js | 1 + js/id/geo/extent.js | 2 +- js/id/id.js | 2 +- js/id/renderer/background.js | 2 +- js/id/renderer/map.js | 2 +- js/id/start.js | 1 + js/id/svg.js | 2 +- js/id/svg/areas.js | 3 ++- js/id/svg/restrictions.js | 2 +- js/id/svg/vertices.js | 9 +++++---- js/id/ui/preset_list.js | 2 +- js/id/ui/raw_membership_editor.js | 2 +- js/id/ui/success.js | 2 +- js/id/util.js | 3 ++- 24 files changed, 45 insertions(+), 34 deletions(-) diff --git a/js/id/actions/add_member.js b/js/id/actions/add_member.js index 304507a2b..7617cf386 100644 --- a/js/id/actions/add_member.js +++ b/js/id/actions/add_member.js @@ -25,5 +25,5 @@ iD.actions.AddMember = function(relationId, member, memberIndex) { } return graph.replace(relation.addMember(member, memberIndex)); - } + }; }; diff --git a/js/id/actions/change_member.js b/js/id/actions/change_member.js index ece118fab..a84b30487 100644 --- a/js/id/actions/change_member.js +++ b/js/id/actions/change_member.js @@ -1,5 +1,5 @@ iD.actions.ChangeMember = function(relationId, member, memberIndex) { return function(graph) { return graph.replace(graph.entity(relationId).updateMember(member, memberIndex)); - } + }; }; diff --git a/js/id/actions/connect.js b/js/id/actions/connect.js index 933201e4f..df36c1d39 100644 --- a/js/id/actions/connect.js +++ b/js/id/actions/connect.js @@ -19,6 +19,7 @@ iD.actions.Connect = function(nodeIds) { for (var i = 0; i < nodeIds.length - 1; i++) { var node = graph.entity(nodeIds[i]); + /*jshint -W083 */ graph.parentWays(node).forEach(function(parent) { if (!parent.areAdjacent(node.id, survivor.id)) { graph = graph.replace(parent.replaceNode(node.id, survivor.id)); @@ -28,6 +29,7 @@ iD.actions.Connect = function(nodeIds) { graph.parentRelations(node).forEach(function(parent) { graph = graph.replace(parent.replaceMember(node, survivor)); }); + /*jshint +W083 */ survivor = survivor.mergeTags(node.tags); graph = iD.actions.DeleteNode(node.id)(graph); diff --git a/js/id/actions/discard_tags.js b/js/id/actions/discard_tags.js index 855db3b13..a647faa5e 100644 --- a/js/id/actions/discard_tags.js +++ b/js/id/actions/discard_tags.js @@ -12,5 +12,5 @@ iD.actions.DiscardTags = function(difference) { difference.created().forEach(discardTags); return graph; - } + }; }; diff --git a/js/id/actions/straighten.js b/js/id/actions/straighten.js index 535f90a7a..01860daaf 100644 --- a/js/id/actions/straighten.js +++ b/js/id/actions/straighten.js @@ -27,7 +27,7 @@ iD.actions.Straighten = function(wayId, projection) { var u = positionAlongWay(point, startPoint, endPoint), p0 = startPoint[0] + u * (endPoint[0] - startPoint[0]), - p1 = startPoint[1] + u * (endPoint[1] - startPoint[1]), + p1 = startPoint[1] + u * (endPoint[1] - startPoint[1]); graph = graph.replace(graph.entity(node.id) .move(projection.invert([p0, p1]))); diff --git a/js/id/behavior/drag.js b/js/id/behavior/drag.js index 7d5012971..e92e8f48a 100644 --- a/js/id/behavior/drag.js +++ b/js/id/behavior/drag.js @@ -28,10 +28,10 @@ iD.behavior.drag = function() { event.of = function(thiz, argumentz) { return function(e1) { + var e0 = e1.sourceEvent = d3.event; + e1.target = drag; + d3.event = e1; try { - var e0 = e1.sourceEvent = d3.event; - e1.target = drag; - d3.event = e1; event[e1.type].apply(thiz, argumentz); } finally { d3.event = e0; @@ -64,7 +64,7 @@ iD.behavior.drag = function() { offset, origin_ = point(), started = false, - selectEnable = d3_event_userSelectSuppress(touchId != null ? "drag-" + touchId : "drag"); + selectEnable = d3_event_userSelectSuppress(touchId !== null ? "drag-" + touchId : "drag"); var w = d3.select(window) .on(touchId !== null ? "touchmove.drag-" + touchId : "mousemove.drag", dragmove) diff --git a/js/id/behavior/hover.js b/js/id/behavior/hover.js index 59082b58e..5e8742b1d 100644 --- a/js/id/behavior/hover.js +++ b/js/id/behavior/hover.js @@ -81,7 +81,7 @@ iD.behavior.Hover = function(context) { function mousedown() { down = true; d3.select(window) - .on('mouseup.hover', mouseup) + .on('mouseup.hover', mouseup); } function mouseup() { @@ -114,7 +114,7 @@ iD.behavior.Hover = function(context) { d3.select(window) .on('keydown.hover', null) .on('keyup.hover', null) - .on('mouseup.hover', null) + .on('mouseup.hover', null); }; hover.altDisables = function(_) { diff --git a/js/id/core/connection.js b/js/id/core/connection.js index 7442a9992..4b368da40 100644 --- a/js/id/core/connection.js +++ b/js/id/core/connection.js @@ -315,7 +315,7 @@ iD.Connection = function() { extent: iD.geo.Extent( projection.invert([x, y + ts]), projection.invert([x + ts, y])) - } + }; }); function bboxUrl(tile) { diff --git a/js/id/core/history.js b/js/id/core/history.js index 4a8edb5d3..95e32f2de 100644 --- a/js/id/core/history.js +++ b/js/id/core/history.js @@ -233,14 +233,18 @@ iD.History = function(context) { stack = h.stack.map(function(d) { var entities = {}, entity; - d.modified && d.modified.forEach(function(key) { - entity = allEntities[key]; - entities[entity.id] = entity; - }); + if (d.modified) { + d.modified.forEach(function(key) { + entity = allEntities[key]; + entities[entity.id] = entity; + }); + } - d.deleted && d.deleted.forEach(function(id) { - entities[id] = undefined; - }); + if (d.deleted) { + d.deleted.forEach(function(id) { + entities[id] = undefined; + }); + } return { graph: iD.Graph(stack[0].graph).load(entities), diff --git a/js/id/core/relation.js b/js/id/core/relation.js index d8429e8a8..e9511a397 100644 --- a/js/id/core/relation.js +++ b/js/id/core/relation.js @@ -40,7 +40,7 @@ _.extend(iD.Relation.prototype, { indexedMembers: function() { var result = new Array(this.members.length); for (var i = 0; i < this.members.length; i++) { - result[i] = _.extend({}, this.members[i], {index: i}) + result[i] = _.extend({}, this.members[i], {index: i}); } return result; }, diff --git a/js/id/end.js b/js/id/end.js index 0319a0fe5..7885eb370 100644 --- a/js/id/end.js +++ b/js/id/end.js @@ -1 +1,2 @@ +/* jshint ignore:start */ })(); diff --git a/js/id/geo/extent.js b/js/id/geo/extent.js index 7a0c03dc2..189e03058 100644 --- a/js/id/geo/extent.js +++ b/js/id/geo/extent.js @@ -34,7 +34,7 @@ _.extend(iD.geo.Extent.prototype, { [this[1][0], this[1][1]], [this[1][0], this[0][1]], [this[0][0], this[0][1]] - ] + ]; }, intersects: function(obj) { diff --git a/js/id/id.js b/js/id/id.js index c13187d9e..f950b5020 100644 --- a/js/id/id.js +++ b/js/id/id.js @@ -107,7 +107,7 @@ window.iD = function () { var result = fn.apply(history, arguments); debouncedSave(); return result; - } + }; } context.perform = withDebouncedSave(history.perform); diff --git a/js/id/renderer/background.js b/js/id/renderer/background.js index 16afb82ed..29cfb9f70 100644 --- a/js/id/renderer/background.js +++ b/js/id/renderer/background.js @@ -85,7 +85,7 @@ iD.Background = function(context) { gpx.call(gpxLayer); var overlays = selection.selectAll('.overlay-layer') - .data(overlayLayers, function(d) { return d.source().name }); + .data(overlayLayers, function(d) { return d.source().name; }); overlays.enter().insert('div', '.layer-data') .attr('class', 'layer-layer overlay-layer'); diff --git a/js/id/renderer/map.js b/js/id/renderer/map.js index 531469de5..7200d8198 100644 --- a/js/id/renderer/map.js +++ b/js/id/renderer/map.js @@ -255,7 +255,7 @@ iD.Map = function(context) { map.mouse = function() { var e = mousemove || d3.event, s; - while (s = e.sourceEvent) e = s; + while ((s = e.sourceEvent)) e = s; return mouse(e); }; diff --git a/js/id/start.js b/js/id/start.js index 6d6f50c31..773daac48 100644 --- a/js/id/start.js +++ b/js/id/start.js @@ -1,2 +1,3 @@ +/* jshint ignore:start */ (function () { 'use strict'; diff --git a/js/id/svg.js b/js/id/svg.js index 623828b0b..c4dca3025 100644 --- a/js/id/svg.js +++ b/js/id/svg.js @@ -31,7 +31,7 @@ iD.svg = { if (entity.id in cache) { return cache[entity.id]; } else { - return cache[entity.id] = path(entity.asGeoJSON(graph, polygon)); + return cache[entity.id] = path(entity.asGeoJSON(graph, polygon)); // jshint ignore:line } }; }, diff --git a/js/id/svg/areas.js b/js/id/svg/areas.js index ba6c42313..772b6dfa7 100644 --- a/js/id/svg/areas.js +++ b/js/id/svg/areas.js @@ -35,7 +35,8 @@ iD.svg.Areas = function(projection) { var entity = entities[i]; if (entity.geometry(graph) !== 'area') continue; - if (multipolygon = iD.geo.isSimpleMultipolygonOuterMember(entity, graph)) { + multipolygon = iD.geo.isSimpleMultipolygonOuterMember(entity, graph); + if (multipolygon) { areas[multipolygon.id] = { entity: multipolygon.mergeTags(entity.tags), area: Math.abs(entity.area(graph)) diff --git a/js/id/svg/restrictions.js b/js/id/svg/restrictions.js index 9d9e41b53..76c2ef3bb 100644 --- a/js/id/svg/restrictions.js +++ b/js/id/svg/restrictions.js @@ -68,7 +68,7 @@ iD.svg.Restrictions = function(context) { to: to, restriction: restriction, angle: Math.atan2(b[1] - a[1], b[0] - a[0]) - } + }; }; return drawRestrictions; diff --git a/js/id/svg/vertices.js b/js/id/svg/vertices.js index 4352cdbbd..19b14b838 100644 --- a/js/id/svg/vertices.js +++ b/js/id/svg/vertices.js @@ -60,9 +60,10 @@ iD.svg.Vertices = function(projection, context) { var icons = {}; function icon(entity) { if (entity.id in icons) return icons[entity.id]; - return icons[entity.id] = (zoom !== 0 && + icons[entity.id] = zoom !== 0 && entity.hasInterestingTags() && - context.presets().match(entity, graph).icon); + context.presets().match(entity, graph).icon; + return icons[entity.id]; } function circle(klass) { @@ -75,7 +76,7 @@ iD.svg.Vertices = function(projection, context) { this.setAttribute('cx', c); this.setAttribute('cy', -c); this.setAttribute('r', r); - } + }; } var enter = groups.enter().append('g') @@ -120,7 +121,7 @@ iD.svg.Vertices = function(projection, context) { if (entity.id in selected || entity.hasInterestingTags() || entity.isIntersection(graph)) { - vertices.push(entity) + vertices.push(entity); } } diff --git a/js/id/ui/preset_list.js b/js/id/ui/preset_list.js index 595dea7b5..31b35a56a 100644 --- a/js/id/ui/preset_list.js +++ b/js/id/ui/preset_list.js @@ -103,7 +103,7 @@ iD.ui.PresetList = function(context) { function drawList(list, presets) { var collection = presets.collection.map(function(preset) { - return preset.members ? CategoryItem(preset) : PresetItem(preset) + return preset.members ? CategoryItem(preset) : PresetItem(preset); }); var items = list.selectAll('.preset-list-item') diff --git a/js/id/ui/raw_membership_editor.js b/js/id/ui/raw_membership_editor.js index 33f1426a1..ef86f12f7 100644 --- a/js/id/ui/raw_membership_editor.js +++ b/js/id/ui/raw_membership_editor.js @@ -75,7 +75,7 @@ iD.ui.RawMembershipEditor = function(context) { if (member.id === entity.id) { memberships.push({relation: relation, member: member, index: index}); } - }) + }); }); selection.call(iD.ui.Disclosure() diff --git a/js/id/ui/success.js b/js/id/ui/success.js index 0f4bde80d..73d23fbe4 100644 --- a/js/id/ui/success.js +++ b/js/id/ui/success.js @@ -13,7 +13,7 @@ iD.ui.Success = function(context) { .attr('class', 'fr') .append('span') .attr('class', 'icon close') - .on('click', function() { event.cancel(success) }); + .on('click', function() { event.cancel(success); }); header.append('h3') .text(t('success.just_edited')); diff --git a/js/id/util.js b/js/id/util.js index d8a490c1e..2e407f4b2 100644 --- a/js/id/util.js +++ b/js/id/util.js @@ -17,7 +17,7 @@ iD.util.entityOrMemberSelector = function(ids, graph) { var entity = graph.hasEntity(id); if (entity && entity.type === 'relation') { entity.members.forEach(function(member) { - s += ',.' + member.id + s += ',.' + member.id; }); } }); @@ -130,6 +130,7 @@ iD.util.fastMouse = function(container) { }; }; +/* jshint -W103 */ iD.util.getPrototypeOf = Object.getPrototypeOf || function(obj) { return obj.__proto__; }; iD.util.asyncMap = function(inputs, func, callback) {