Skip to content

Commit 8c38d22

Browse files
committed
Lint free examples
1 parent 0555bb0 commit 8c38d22

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+423
-483
lines changed

.eslintignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
examples/Jugl.js
2+
examples/resources/

examples/.eslintrc

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"globals": {
3+
"FastClick": false,
4+
"$": false,
5+
"arc": false,
6+
"common": false,
7+
"createMapboxStreetsV6Style": false,
8+
"d3": false,
9+
"jsPDF": false,
10+
"jsts": false,
11+
"topojson": false,
12+
"turf": false
13+
},
14+
"rules": {
15+
"no-unused-vars": [2, {"varsIgnorePattern": "^map"}]
16+
}
17+
}

examples/attributions.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ var map = new ol.Map({
1414
source: new ol.source.OSM()
1515
})
1616
],
17-
controls: ol.control.defaults({ attribution: false }).extend([attribution]),
17+
controls: ol.control.defaults({attribution: false}).extend([attribution]),
1818
renderer: common.getRendererFromQueryString(),
1919
target: 'map',
2020
view: new ol.View({

examples/blend-modes.js

+6-7
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,13 @@ var map = new ol.Map({
8585
})
8686
});
8787

88+
// Get the form elements and bind the listeners
89+
var select = document.getElementById('blend-mode');
90+
var affectRed = document.getElementById('affect-red');
91+
var affectGreen = document.getElementById('affect-green');
92+
var affectBlue = document.getElementById('affect-blue');
93+
8894

89-
// Various helper methods and event handlers
9095
/**
9196
* This method sets the globalCompositeOperation to the value of the select
9297
* field and it is bound to the precompose event of the layers.
@@ -154,12 +159,6 @@ var affectLayerClicked = function() {
154159
};
155160

156161

157-
// Get the form elements and bind the listeners
158-
var select = document.getElementById('blend-mode');
159-
var affectRed = document.getElementById('affect-red');
160-
var affectGreen = document.getElementById('affect-green');
161-
var affectBlue = document.getElementById('affect-blue');
162-
163162
// Rerender map when blend mode changes
164163
select.addEventListener('change', function() {
165164
map.render();

examples/box-selection.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ map.addInteraction(dragBox);
4848

4949
var infoBox = document.getElementById('info');
5050

51-
dragBox.on('boxend', function(e) {
51+
dragBox.on('boxend', function() {
5252
// features that intersect the box are added to the collection of
5353
// selected features, and their names are displayed in the "info"
5454
// div
@@ -64,7 +64,7 @@ dragBox.on('boxend', function(e) {
6464
});
6565

6666
// clear selection when drawing a new box and when clicking on the map
67-
dragBox.on('boxstart', function(e) {
67+
dragBox.on('boxstart', function() {
6868
selectedFeatures.clear();
6969
infoBox.innerHTML = ' ';
7070
});

examples/center.js

+5-36
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,7 @@ zoomtoswitzerlandbest.addEventListener('click', function() {
6565
var feature = source.getFeatures()[0];
6666
var polygon = /** @type {ol.geom.SimpleGeometry} */ (feature.getGeometry());
6767
var size = /** @type {ol.Size} */ (map.getSize());
68-
view.fit(
69-
polygon,
70-
size,
71-
{
72-
padding: [170, 50, 30, 150],
73-
constrainResolution: false
74-
}
75-
);
68+
view.fit(polygon, size, {padding: [170, 50, 30, 150], constrainResolution: false});
7669
}, false);
7770

7871
var zoomtoswitzerlandconstrained =
@@ -81,13 +74,7 @@ zoomtoswitzerlandconstrained.addEventListener('click', function() {
8174
var feature = source.getFeatures()[0];
8275
var polygon = /** @type {ol.geom.SimpleGeometry} */ (feature.getGeometry());
8376
var size = /** @type {ol.Size} */ (map.getSize());
84-
view.fit(
85-
polygon,
86-
size,
87-
{
88-
padding: [170, 50, 30, 150]
89-
}
90-
);
77+
view.fit(polygon, size, {padding: [170, 50, 30, 150]});
9178
}, false);
9279

9380
var zoomtoswitzerlandnearest =
@@ -96,39 +83,21 @@ zoomtoswitzerlandnearest.addEventListener('click', function() {
9683
var feature = source.getFeatures()[0];
9784
var polygon = /** @type {ol.geom.SimpleGeometry} */ (feature.getGeometry());
9885
var size = /** @type {ol.Size} */ (map.getSize());
99-
view.fit(
100-
polygon,
101-
size,
102-
{
103-
padding: [170, 50, 30, 150],
104-
nearest: true
105-
}
106-
);
86+
view.fit(polygon, size, {padding: [170, 50, 30, 150], nearest: true});
10787
}, false);
10888

10989
var zoomtolausanne = document.getElementById('zoomtolausanne');
11090
zoomtolausanne.addEventListener('click', function() {
11191
var feature = source.getFeatures()[1];
11292
var point = /** @type {ol.geom.SimpleGeometry} */ (feature.getGeometry());
11393
var size = /** @type {ol.Size} */ (map.getSize());
114-
view.fit(
115-
point,
116-
size,
117-
{
118-
padding: [170, 50, 30, 150],
119-
minResolution: 50
120-
}
121-
);
94+
view.fit(point, size, {padding: [170, 50, 30, 150], minResolution: 50});
12295
}, false);
12396

12497
var centerlausanne = document.getElementById('centerlausanne');
12598
centerlausanne.addEventListener('click', function() {
12699
var feature = source.getFeatures()[1];
127100
var point = /** @type {ol.geom.Point} */ (feature.getGeometry());
128101
var size = /** @type {ol.Size} */ (map.getSize());
129-
view.centerOn(
130-
point.getCoordinates(),
131-
size,
132-
[570, 500]
133-
);
102+
view.centerOn(point.getCoordinates(), size, [570, 500]);
134103
}, false);

examples/cluster.js

+1-5
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ var clusterSource = new ol.source.Cluster({
3434
var styleCache = {};
3535
var clusters = new ol.layer.Vector({
3636
source: clusterSource,
37-
style: function(feature, resolution) {
37+
style: function(feature) {
3838
var size = feature.get('features').length;
3939
var style = styleCache[size];
4040
if (!style) {
@@ -65,10 +65,6 @@ var raster = new ol.layer.Tile({
6565
source: new ol.source.MapQuest({layer: 'sat'})
6666
});
6767

68-
var raw = new ol.layer.Vector({
69-
source: source
70-
});
71-
7268
var map = new ol.Map({
7369
layers: [raster, clusters],
7470
renderer: 'canvas',

examples/color-manipulation.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@ var raster = new ol.source.Raster({
138138
}
139139
});
140140

141+
var controls = {};
142+
141143
raster.on('beforeoperations', function(event) {
142144
var data = event.data;
143145
for (var id in controls) {
@@ -160,7 +162,6 @@ var map = new ol.Map({
160162
});
161163

162164
var controlIds = ['hue', 'chroma', 'lightness'];
163-
var controls = {};
164165
controlIds.forEach(function(id) {
165166
var control = document.getElementById(id);
166167
var output = document.getElementById(id + 'Out');

examples/custom-controls.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ app.RotateNorthControl = function(opt_options) {
3333
button.innerHTML = 'N';
3434

3535
var this_ = this;
36-
var handleRotateNorth = function(e) {
36+
var handleRotateNorth = function() {
3737
this_.getMap().getView().setRotation(0);
3838
};
3939

examples/custom-interactions.js

+3-11
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ app.Drag.prototype.handleDownEvent = function(evt) {
7272
var map = evt.map;
7373

7474
var feature = map.forEachFeatureAtPixel(evt.pixel,
75-
function(feature, layer) {
75+
function(feature) {
7676
return feature;
7777
});
7878

@@ -89,13 +89,6 @@ app.Drag.prototype.handleDownEvent = function(evt) {
8989
* @param {ol.MapBrowserEvent} evt Map browser event.
9090
*/
9191
app.Drag.prototype.handleDragEvent = function(evt) {
92-
var map = evt.map;
93-
94-
var feature = map.forEachFeatureAtPixel(evt.pixel,
95-
function(feature, layer) {
96-
return feature;
97-
});
98-
9992
var deltaX = evt.coordinate[0] - this.coordinate_[0];
10093
var deltaY = evt.coordinate[1] - this.coordinate_[1];
10194

@@ -115,7 +108,7 @@ app.Drag.prototype.handleMoveEvent = function(evt) {
115108
if (this.cursor_) {
116109
var map = evt.map;
117110
var feature = map.forEachFeatureAtPixel(evt.pixel,
118-
function(feature, layer) {
111+
function(feature) {
119112
return feature;
120113
});
121114
var element = evt.map.getTargetElement();
@@ -133,10 +126,9 @@ app.Drag.prototype.handleMoveEvent = function(evt) {
133126

134127

135128
/**
136-
* @param {ol.MapBrowserEvent} evt Map browser event.
137129
* @return {boolean} `false` to stop the drag sequence.
138130
*/
139-
app.Drag.prototype.handleUpEvent = function(evt) {
131+
app.Drag.prototype.handleUpEvent = function() {
140132
this.coordinate_ = null;
141133
this.feature_ = null;
142134
return false;

examples/d3.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ d3.json('data/topojson/us.json', function(error, us) {
3939
* @param {number} pixelRatio Pixel ratio.
4040
* @param {ol.Size} size Size.
4141
* @param {ol.proj.Projection} projection Projection.
42-
* @return {HTMLCanvasElement}
42+
* @return {HTMLCanvasElement} A canvas element.
4343
*/
4444
var canvasFunction = function(extent, resolution, pixelRatio,
4545
size, projection) {

examples/device-orientation.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ el('track').addEventListener('change', function() {
3939
deviceOrientation.setTracking(this.checked);
4040
});
4141

42-
deviceOrientation.on('change', function(event) {
42+
deviceOrientation.on('change', function() {
4343
el('alpha').innerText = deviceOrientation.getAlpha() + ' [rad]';
4444
el('beta').innerText = deviceOrientation.getBeta() + ' [rad]';
4545
el('gamma').innerText = deviceOrientation.getGamma() + ' [rad]';

examples/drag-and-drop-image-vector.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ dragAndDropInteraction.on('addfeatures', function(event) {
128128

129129
var displayFeatureInfo = function(pixel) {
130130
var features = [];
131-
map.forEachFeatureAtPixel(pixel, function(feature, layer) {
131+
map.forEachFeatureAtPixel(pixel, function(feature) {
132132
features.push(feature);
133133
});
134134
if (features.length > 0) {

examples/drag-and-drop.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ dragAndDropInteraction.on('addfeatures', function(event) {
124124

125125
var displayFeatureInfo = function(pixel) {
126126
var features = [];
127-
map.forEachFeatureAtPixel(pixel, function(feature, layer) {
127+
map.forEachFeatureAtPixel(pixel, function(feature) {
128128
features.push(feature);
129129
});
130130
if (features.length > 0) {

examples/draw-and-modify-features.js

+4-5
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ var modify = new ol.interaction.Modify({
6060
map.addInteraction(modify);
6161

6262
var draw; // global so we can remove it later
63+
var typeSelect = document.getElementById('type');
64+
6365
function addInteraction() {
6466
draw = new ol.interaction.Draw({
6567
features: features,
@@ -68,14 +70,11 @@ function addInteraction() {
6870
map.addInteraction(draw);
6971
}
7072

71-
var typeSelect = document.getElementById('type');
72-
7373

7474
/**
75-
* Let user change the geometry type.
76-
* @param {Event} e Change event.
75+
* Handle change event.
7776
*/
78-
typeSelect.onchange = function(e) {
77+
typeSelect.onchange = function() {
7978
map.removeInteraction(draw);
8079
addInteraction();
8180
};

examples/draw-features.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,9 @@ function addInteraction() {
8383

8484

8585
/**
86-
* Let user change the geometry type.
87-
* @param {Event} e Change event.
86+
* Handle change event.
8887
*/
89-
typeSelect.onchange = function(e) {
88+
typeSelect.onchange = function() {
9089
map.removeInteraction(draw);
9190
addInteraction();
9291
};

examples/earthquake-clusters.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ function createEarthquakeStyle(feature) {
5656
});
5757
}
5858

59-
var maxFeatureCount;
59+
var maxFeatureCount, vector;
6060
function calculateClusterInfo(resolution) {
6161
maxFeatureCount = 0;
6262
var features = vector.getSource().getFeatures();
@@ -65,7 +65,8 @@ function calculateClusterInfo(resolution) {
6565
feature = features[i];
6666
var originalFeatures = feature.get('features');
6767
var extent = ol.extent.createEmpty();
68-
for (var j = 0, jj = originalFeatures.length; j < jj; ++j) {
68+
var j, jj;
69+
for (j = 0, jj = originalFeatures.length; j < jj; ++j) {
6970
ol.extent.extend(extent, originalFeatures[j].getGeometry().getExtent());
7071
}
7172
maxFeatureCount = Math.max(maxFeatureCount, jj);
@@ -104,7 +105,7 @@ function styleFunction(feature, resolution) {
104105
return style;
105106
}
106107

107-
function selectStyleFunction(feature, resolution) {
108+
function selectStyleFunction(feature) {
108109
var styles = [new ol.style.Style({
109110
image: new ol.style.Circle({
110111
radius: feature.get('radius'),
@@ -120,7 +121,7 @@ function selectStyleFunction(feature, resolution) {
120121
return styles;
121122
}
122123

123-
var vector = new ol.layer.Vector({
124+
vector = new ol.layer.Vector({
124125
source: new ol.source.Cluster({
125126
distance: 40,
126127
source: new ol.source.Vector({

examples/earthquake-custom-symbol.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ goog.require('ol.style.Style');
1414

1515

1616
var styleCache = {};
17-
var styleFunction = function(feature, resolution) {
17+
var styleFunction = function(feature) {
1818
// 2012_Earthquakes_Mag5.kml stores the magnitude of each earthquake in a
1919
// standards-violating <magnitude> tag in each Placemark. We extract it from
2020
// the Placemark's name instead.
@@ -29,8 +29,8 @@ var styleFunction = function(feature, resolution) {
2929
/** @type {CanvasRenderingContext2D} */ (canvas.getContext('2d')),
3030
{size: [size + 2, size + 2], pixelRatio: size / 10});
3131
render.setFillStrokeStyle(
32-
new ol.style.Fill({ color: 'rgba(255, 153, 0, 0.4)' }),
33-
new ol.style.Stroke({ color: 'rgba(255, 204, 0, 0.2)', width: 1 }));
32+
new ol.style.Fill({color: 'rgba(255, 153, 0, 0.4)'}),
33+
new ol.style.Stroke({color: 'rgba(255, 204, 0, 0.2)', width: 1}));
3434
render.drawPolygonGeometry(new ol.geom.Polygon(
3535
[[[0, 0], [4, 2], [6, 0], [10, 5], [6, 3], [4, 5], [0, 0]]]));
3636
style = new ol.style.Style({

examples/export-map.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ var map = new ol.Map({
3434
var exportPNGElement = document.getElementById('export-png');
3535

3636
if ('download' in exportPNGElement) {
37-
exportPNGElement.addEventListener('click', function(e) {
37+
exportPNGElement.addEventListener('click', function() {
3838
map.once('postcompose', function(event) {
3939
var canvas = event.context.canvas;
4040
exportPNGElement.href = canvas.toDataURL('image/png');

examples/export-pdf.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ var loaded = 0;
5454

5555
var exportButton = document.getElementById('export-pdf');
5656

57-
exportButton.addEventListener('click', function(e) {
57+
exportButton.addEventListener('click', function() {
5858

5959
exportButton.disabled = true;
6060
document.body.style.cursor = 'progress';
@@ -73,7 +73,7 @@ exportButton.addEventListener('click', function(e) {
7373
++loading;
7474
};
7575

76-
var tileLoadEnd = function(callback) {
76+
var tileLoadEnd = function() {
7777
++loaded;
7878
if (loading === loaded) {
7979
var canvas = this;

0 commit comments

Comments
 (0)