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
+28 -27
View File
@@ -17,21 +17,21 @@ import Style from '../src/ol/style/Style.js';
import Text from '../src/ol/style/Text.js';
var earthquakeFill = new Fill({
const earthquakeFill = new Fill({
color: 'rgba(255, 153, 0, 0.8)'
});
var earthquakeStroke = new Stroke({
const earthquakeStroke = new Stroke({
color: 'rgba(255, 204, 0, 0.2)',
width: 1
});
var textFill = new Fill({
const textFill = new Fill({
color: '#fff'
});
var textStroke = new Stroke({
const textStroke = new Stroke({
color: 'rgba(0, 0, 0, 0.6)',
width: 3
});
var invisibleFill = new Fill({
const invisibleFill = new Fill({
color: 'rgba(255, 255, 255, 0.01)'
});
@@ -39,9 +39,9 @@ function createEarthquakeStyle(feature) {
// 2012_Earthquakes_Mag5.kml stores the magnitude of each earthquake in a
// standards-violating <magnitude> tag in each Placemark. We extract it
// from the Placemark's name instead.
var name = feature.get('name');
var magnitude = parseFloat(name.substr(2));
var radius = 5 + 20 * (magnitude - 5);
const name = feature.get('name');
const magnitude = parseFloat(name.substr(2));
const radius = 5 + 20 * (magnitude - 5);
return new Style({
geometry: feature.getGeometry(),
@@ -56,16 +56,17 @@ function createEarthquakeStyle(feature) {
});
}
var maxFeatureCount, vector;
function calculateClusterInfo(resolution) {
let maxFeatureCount;
let vector = null;
const calculateClusterInfo = function(resolution) {
maxFeatureCount = 0;
var features = vector.getSource().getFeatures();
var feature, radius;
for (var i = features.length - 1; i >= 0; --i) {
const features = vector.getSource().getFeatures();
let feature, radius;
for (let i = features.length - 1; i >= 0; --i) {
feature = features[i];
var originalFeatures = feature.get('features');
var extent = _ol_extent_.createEmpty();
var j, jj;
const originalFeatures = feature.get('features');
const extent = _ol_extent_.createEmpty();
let j, jj;
for (j = 0, jj = originalFeatures.length; j < jj; ++j) {
_ol_extent_.extend(extent, originalFeatures[j].getGeometry().getExtent());
}
@@ -74,16 +75,16 @@ function calculateClusterInfo(resolution) {
resolution;
feature.set('radius', radius);
}
}
};
var currentResolution;
let currentResolution;
function styleFunction(feature, resolution) {
if (resolution != currentResolution) {
calculateClusterInfo(resolution);
currentResolution = resolution;
}
var style;
var size = feature.get('features').length;
let style;
const size = feature.get('features').length;
if (size > 1) {
style = new Style({
image: new CircleStyle({
@@ -99,22 +100,22 @@ function styleFunction(feature, resolution) {
})
});
} else {
var originalFeature = feature.get('features')[0];
const originalFeature = feature.get('features')[0];
style = createEarthquakeStyle(originalFeature);
}
return style;
}
function selectStyleFunction(feature) {
var styles = [new Style({
const styles = [new Style({
image: new CircleStyle({
radius: feature.get('radius'),
fill: invisibleFill
})
})];
var originalFeatures = feature.get('features');
var originalFeature;
for (var i = originalFeatures.length - 1; i >= 0; --i) {
const originalFeatures = feature.get('features');
let originalFeature;
for (let i = originalFeatures.length - 1; i >= 0; --i) {
originalFeature = originalFeatures[i];
styles.push(createEarthquakeStyle(originalFeature));
}
@@ -134,13 +135,13 @@ vector = new VectorLayer({
style: styleFunction
});
var raster = new TileLayer({
const raster = new TileLayer({
source: new Stamen({
layer: 'toner'
})
});
var map = new Map({
const map = new Map({
layers: [raster, vector],
interactions: defaultInteractions().extend([new Select({
condition: function(evt) {