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

@@ -7,17 +7,17 @@ import VectorLayer from '../src/ol/layer/Vector.js';
import OSM from '../src/ol/source/OSM.js';
import VectorSource from '../src/ol/source/Vector.js';
var raster = new TileLayer({
const raster = new TileLayer({
source: new OSM()
});
var source = new VectorSource({wrapX: false});
const source = new VectorSource({wrapX: false});
var vector = new VectorLayer({
const vector = new VectorLayer({
source: source
});
var map = new Map({
const map = new Map({
layers: [raster, vector],
target: 'map',
view: new View({
@@ -26,13 +26,13 @@ var map = new Map({
})
});
var typeSelect = document.getElementById('type');
const typeSelect = document.getElementById('type');
var draw; // global so we can remove it later
let draw; // global so we can remove it later
function addInteraction() {
var value = typeSelect.value;
let value = typeSelect.value;
if (value !== 'None') {
var geometryFunction;
let geometryFunction;
if (value === 'Square') {
value = 'Circle';
geometryFunction = Draw.createRegularPolygon(4);
@@ -45,19 +45,19 @@ function addInteraction() {
if (!geometry) {
geometry = new Polygon(null);
}
var center = coordinates[0];
var last = coordinates[1];
var dx = center[0] - last[0];
var dy = center[1] - last[1];
var radius = Math.sqrt(dx * dx + dy * dy);
var rotation = Math.atan2(dy, dx);
var newCoordinates = [];
var numPoints = 12;
for (var i = 0; i < numPoints; ++i) {
var angle = rotation + i * 2 * Math.PI / numPoints;
var fraction = i % 2 === 0 ? 1 : 0.5;
var offsetX = radius * fraction * Math.cos(angle);
var offsetY = radius * fraction * Math.sin(angle);
const center = coordinates[0];
const last = coordinates[1];
const dx = center[0] - last[0];
const dy = center[1] - last[1];
const radius = Math.sqrt(dx * dx + dy * dy);
const rotation = Math.atan2(dy, dx);
const newCoordinates = [];
const numPoints = 12;
for (let i = 0; i < numPoints; ++i) {
const angle = rotation + i * 2 * Math.PI / numPoints;
const fraction = i % 2 === 0 ? 1 : 0.5;
const offsetX = radius * fraction * Math.cos(angle);
const offsetY = radius * fraction * Math.sin(angle);
newCoordinates.push([center[0] + offsetX, center[1] + offsetY]);
}
newCoordinates.push(newCoordinates[0].slice());