Use blocked scoped variables

In addition to using const and let, this also upgrades our linter config and removes lint (mostly whitespace).
This commit is contained in:
Tim Schaub
2018-01-11 23:32:36 -07:00
parent 0bf2b04dee
commit ad62739a6e
684 changed files with 18120 additions and 18184 deletions

View File

@@ -8,7 +8,7 @@ import Icon from '../src/ol/style/Icon.js';
import Style from '../src/ol/style/Style.js';
var iconInfo = [{
const iconInfo = [{
offset: [0, 0],
opacity: 1.0,
rotateWithView: true,
@@ -38,12 +38,12 @@ var iconInfo = [{
size: [44, 44]
}];
var i;
let i;
var iconCount = iconInfo.length;
var icons = new Array(iconCount);
const iconCount = iconInfo.length;
const icons = new Array(iconCount);
for (i = 0; i < iconCount; ++i) {
var info = iconInfo[i];
const info = iconInfo[i];
icons[i] = new Icon({
offset: info.offset,
opacity: info.opacity,
@@ -56,30 +56,30 @@ for (i = 0; i < iconCount; ++i) {
});
}
var featureCount = 50000;
var features = new Array(featureCount);
var feature, geometry;
var e = 25000000;
const featureCount = 50000;
const features = new Array(featureCount);
let feature, geometry;
const e = 25000000;
for (i = 0; i < featureCount; ++i) {
geometry = new Point(
[2 * e * Math.random() - e, 2 * e * Math.random() - e]);
[2 * e * Math.random() - e, 2 * e * Math.random() - e]);
feature = new Feature(geometry);
feature.setStyle(
new Style({
image: icons[i % (iconCount - 1)]
})
new Style({
image: icons[i % (iconCount - 1)]
})
);
features[i] = feature;
}
var vectorSource = new VectorSource({
const vectorSource = new VectorSource({
features: features
});
var vector = new VectorLayer({
const vector = new VectorLayer({
source: vectorSource
});
var map = new Map({
const map = new Map({
renderer: /** @type {Array<ol.renderer.Type>} */ (['webgl', 'canvas']),
layers: [vector],
target: document.getElementById('map'),
@@ -89,9 +89,9 @@ var map = new Map({
})
});
var overlayFeatures = [];
const overlayFeatures = [];
for (i = 0; i < featureCount; i += 30) {
var clone = features[i].clone();
const clone = features[i].clone();
clone.setStyle(null);
overlayFeatures.push(clone);
}
@@ -107,12 +107,12 @@ new VectorLayer({
});
map.on('click', function(evt) {
var info = document.getElementById('info');
const info = document.getElementById('info');
info.innerHTML =
'Hold on a second, while I catch those butterflies for you ...';
window.setTimeout(function() {
var features = [];
const features = [];
map.forEachFeatureAtPixel(evt.pixel, function(feature) {
features.push(feature);
return false;
@@ -132,7 +132,7 @@ map.on('pointermove', function(evt) {
if (evt.dragging) {
return;
}
var pixel = map.getEventPixel(evt.originalEvent);
var hit = map.hasFeatureAtPixel(pixel);
const pixel = map.getEventPixel(evt.originalEvent);
const hit = map.hasFeatureAtPixel(pixel);
map.getTarget().style.cursor = hit ? 'pointer' : '';
});