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
+24 -24
View File
@@ -8,25 +8,25 @@ 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 format = new WKT();
var feature = format.readFeature(
'POLYGON((10.689697265625 -25.0927734375, 34.595947265625 ' +
const format = new WKT();
const feature = format.readFeature(
'POLYGON((10.689697265625 -25.0927734375, 34.595947265625 ' +
'-20.1708984375, 38.814697265625 -35.6396484375, 13.502197265625 ' +
'-39.1552734375, 10.689697265625 -25.0927734375))');
feature.getGeometry().transform('EPSG:4326', 'EPSG:3857');
var vector = new VectorLayer({
const vector = new VectorLayer({
source: new VectorSource({
features: [feature]
})
});
var map = new Map({
const map = new Map({
layers: [raster, vector],
target: 'map',
controls: defaultControls({
@@ -41,7 +41,7 @@ var map = new Map({
});
var dims = {
const dims = {
a0: [1189, 841],
a1: [841, 594],
a2: [594, 420],
@@ -50,39 +50,39 @@ var dims = {
a5: [210, 148]
};
var loading = 0;
var loaded = 0;
let loading = 0;
let loaded = 0;
var exportButton = document.getElementById('export-pdf');
const exportButton = document.getElementById('export-pdf');
exportButton.addEventListener('click', function() {
exportButton.disabled = true;
document.body.style.cursor = 'progress';
var format = document.getElementById('format').value;
var resolution = document.getElementById('resolution').value;
var dim = dims[format];
var width = Math.round(dim[0] * resolution / 25.4);
var height = Math.round(dim[1] * resolution / 25.4);
var size = /** @type {ol.Size} */ (map.getSize());
var extent = map.getView().calculateExtent(size);
const format = document.getElementById('format').value;
const resolution = document.getElementById('resolution').value;
const dim = dims[format];
const width = Math.round(dim[0] * resolution / 25.4);
const height = Math.round(dim[1] * resolution / 25.4);
const size = /** @type {ol.Size} */ (map.getSize());
const extent = map.getView().calculateExtent(size);
var source = raster.getSource();
const source = raster.getSource();
var tileLoadStart = function() {
const tileLoadStart = function() {
++loading;
};
var tileLoadEnd = function() {
function tileLoadEnd() {
++loaded;
if (loading === loaded) {
var canvas = this;
const canvas = this;
window.setTimeout(function() {
loading = 0;
loaded = 0;
var data = canvas.toDataURL('image/png');
var pdf = new jsPDF('landscape', undefined, format);
const data = canvas.toDataURL('image/png');
const pdf = new jsPDF('landscape', undefined, format);
pdf.addImage(data, 'JPEG', 0, 0, dim[0], dim[1]);
pdf.save('map.pdf');
source.un('tileloadstart', tileLoadStart);
@@ -95,7 +95,7 @@ exportButton.addEventListener('click', function() {
document.body.style.cursor = 'auto';
}, 100);
}
};
}
map.once('postcompose', function(event) {
source.on('tileloadstart', tileLoadStart);