1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-26 01:58:06 +02:00

Replace *most* cases of var with let/const in the examples/ folder

These changes were done automatically, by using the `gulp lint --fix` command, in preparation for the next patch.
This commit is contained in:
Jonas Jenwald 2021-03-12 17:08:17 +01:00
parent 56fd01bf8d
commit 276fa4ad8f
15 changed files with 196 additions and 194 deletions

View file

@ -20,15 +20,15 @@ if (!pdfjsImageDecoders.JpegImage) {
alert("Please build the pdfjs-dist library using `gulp dist-install`");
}
var JPEG_IMAGE = "fish.jpg";
const JPEG_IMAGE = "fish.jpg";
var jpegCanvas = document.getElementById("jpegCanvas");
var jpegCtx = jpegCanvas.getContext("2d");
const jpegCanvas = document.getElementById("jpegCanvas");
const jpegCtx = jpegCanvas.getContext("2d");
// Load the image data, and convert it to a Uint8Array.
//
var nonBinaryRequest = false;
var request = new XMLHttpRequest();
let nonBinaryRequest = false;
const request = new XMLHttpRequest();
request.open("GET", JPEG_IMAGE, false);
try {
request.responseType = "arraybuffer";
@ -41,12 +41,12 @@ if (nonBinaryRequest && request.overrideMimeType) {
}
request.send(null);
var typedArrayImage;
let typedArrayImage;
if (nonBinaryRequest) {
var str = request.responseText,
const str = request.responseText,
length = str.length;
var bytes = new Uint8Array(length);
for (var i = 0; i < length; ++i) {
const bytes = new Uint8Array(length);
for (let i = 0; i < length; ++i) {
bytes[i] = str.charCodeAt(i) & 0xff;
}
typedArrayImage = bytes;
@ -56,12 +56,12 @@ if (nonBinaryRequest) {
// Parse the image data using `JpegImage`.
//
var jpegImage = new pdfjsImageDecoders.JpegImage();
const jpegImage = new pdfjsImageDecoders.JpegImage();
jpegImage.parse(typedArrayImage);
var width = jpegImage.width,
const width = jpegImage.width,
height = jpegImage.height;
var jpegData = jpegImage.getData({
const jpegData = jpegImage.getData({
width,
height,
forceRGB: true,
@ -69,9 +69,9 @@ var jpegData = jpegImage.getData({
// Render the JPEG image on a <canvas>.
//
var imageData = jpegCtx.createImageData(width, height);
var imageBytes = imageData.data;
for (var j = 0, k = 0, jj = width * height * 4; j < jj; ) {
const imageData = jpegCtx.createImageData(width, height);
const imageBytes = imageData.data;
for (let j = 0, k = 0, jj = width * height * 4; j < jj; ) {
imageBytes[j++] = jpegData[k++];
imageBytes[j++] = jpegData[k++];
imageBytes[j++] = jpegData[k++];