mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 01:10:08 +02:00
Manually fix remaining ESLint errors
This commit is contained in:
parent
ef1f255649
commit
9e3f7ac7fa
9 changed files with 42 additions and 21 deletions
|
@ -38,7 +38,8 @@ loadingTask.promise.then(function(doc) {
|
||||||
id: pageNum,
|
id: pageNum,
|
||||||
scale: DEFAULT_SCALE,
|
scale: DEFAULT_SCALE,
|
||||||
defaultViewport: pdfPage.getViewport(DEFAULT_SCALE),
|
defaultViewport: pdfPage.getViewport(DEFAULT_SCALE),
|
||||||
annotationLayerFactory: new pdfjsViewer.DefaultAnnotationLayerFactory(),
|
annotationLayerFactory:
|
||||||
|
new pdfjsViewer.DefaultAnnotationLayerFactory(),
|
||||||
renderInteractiveForms: true,
|
renderInteractiveForms: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -24,9 +24,11 @@ gulp.task('build-worker', function() {
|
||||||
return browserify(workerSrc, { output: TMP_FILE_PREFIX + 'worker.tmp', })
|
return browserify(workerSrc, { output: TMP_FILE_PREFIX + 'worker.tmp', })
|
||||||
.bundle()
|
.bundle()
|
||||||
.pipe(source(TMP_FILE_PREFIX + 'worker.tmp'))
|
.pipe(source(TMP_FILE_PREFIX + 'worker.tmp'))
|
||||||
.pipe(streamify(uglify({ compress: {
|
.pipe(streamify(uglify({
|
||||||
sequences: false, // Chrome has issue with the generated code if true
|
compress: {
|
||||||
}, })))
|
sequences: false, // Chrome has issue with the generated code if true
|
||||||
|
},
|
||||||
|
})))
|
||||||
.pipe(rename('pdf.worker.bundle.js'))
|
.pipe(rename('pdf.worker.bundle.js'))
|
||||||
.pipe(gulp.dest(OUTPUT_PATH));
|
.pipe(gulp.dest(OUTPUT_PATH));
|
||||||
});
|
});
|
||||||
|
|
|
@ -68,11 +68,12 @@ var jpegData = jpegImage.getData({
|
||||||
//
|
//
|
||||||
var imageData = jpegCtx.createImageData(width, height);
|
var imageData = jpegCtx.createImageData(width, height);
|
||||||
var imageBytes = imageData.data;
|
var imageBytes = imageData.data;
|
||||||
for (var i = 0, j = 0, ii = width * height * 4; i < ii;) {
|
for (var j = 0, k = 0, jj = width * height * 4; j < jj;) {
|
||||||
imageBytes[i++] = jpegData[j++];
|
imageBytes[j++] = jpegData[k++];
|
||||||
imageBytes[i++] = jpegData[j++];
|
imageBytes[j++] = jpegData[k++];
|
||||||
imageBytes[i++] = jpegData[j++];
|
imageBytes[j++] = jpegData[k++];
|
||||||
imageBytes[i++] = 255;
|
imageBytes[j++] = 255;
|
||||||
}
|
}
|
||||||
jpegCanvas.width = width, jpegCanvas.height = height;
|
jpegCanvas.width = width;
|
||||||
|
jpegCanvas.height = height;
|
||||||
jpegCtx.putImageData(imageData, 0, 0);
|
jpegCtx.putImageData(imageData, 0, 0);
|
||||||
|
|
|
@ -339,8 +339,9 @@ var PDFViewerApplication = {
|
||||||
function() {
|
function() {
|
||||||
PDFViewerApplication.page = (this.value | 0);
|
PDFViewerApplication.page = (this.value | 0);
|
||||||
|
|
||||||
// Ensure that the page number input displays the correct value, even if the
|
// Ensure that the page number input displays the correct value,
|
||||||
// value entered by the user was invalid (e.g. a floating point number).
|
// even if the value entered by the user was invalid
|
||||||
|
// (e.g. a floating point number).
|
||||||
if (this.value !== PDFViewerApplication.page.toString()) {
|
if (this.value !== PDFViewerApplication.page.toString()) {
|
||||||
this.value = PDFViewerApplication.page;
|
this.value = PDFViewerApplication.page;
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,7 +96,7 @@ DOMElement.prototype = {
|
||||||
|
|
||||||
appendChild: function DOMElement_appendChild(element) {
|
appendChild: function DOMElement_appendChild(element) {
|
||||||
var childNodes = this.childNodes;
|
var childNodes = this.childNodes;
|
||||||
if (childNodes.indexOf(element) === -1) {
|
if (!childNodes.includes(element)) {
|
||||||
childNodes.push(element);
|
childNodes.push(element);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -152,10 +152,12 @@ DOMElementSerializer.prototype = {
|
||||||
return ' xmlns:xlink="http://www.w3.org/1999/xlink"' +
|
return ' xmlns:xlink="http://www.w3.org/1999/xlink"' +
|
||||||
' xmlns:svg="http://www.w3.org/2000/svg"';
|
' xmlns:svg="http://www.w3.org/2000/svg"';
|
||||||
}
|
}
|
||||||
|
/* falls through */
|
||||||
case 2: // Initialize variables for looping over attributes.
|
case 2: // Initialize variables for looping over attributes.
|
||||||
++this._state;
|
++this._state;
|
||||||
this._loopIndex = 0;
|
this._loopIndex = 0;
|
||||||
this._attributeKeys = Object.keys(node.attributes);
|
this._attributeKeys = Object.keys(node.attributes);
|
||||||
|
/* falls through */
|
||||||
case 3: // Serialize any attributes and end opening tag.
|
case 3: // Serialize any attributes and end opening tag.
|
||||||
if (this._loopIndex < this._attributeKeys.length) {
|
if (this._loopIndex < this._attributeKeys.length) {
|
||||||
var name = this._attributeKeys[this._loopIndex++];
|
var name = this._attributeKeys[this._loopIndex++];
|
||||||
|
@ -170,6 +172,7 @@ DOMElementSerializer.prototype = {
|
||||||
}
|
}
|
||||||
++this._state;
|
++this._state;
|
||||||
this._loopIndex = 0;
|
this._loopIndex = 0;
|
||||||
|
/* falls through */
|
||||||
case 5: // Serialize child nodes (only for non-tspan/style elements).
|
case 5: // Serialize child nodes (only for non-tspan/style elements).
|
||||||
var value;
|
var value;
|
||||||
while (true) {
|
while (true) {
|
||||||
|
@ -186,6 +189,7 @@ DOMElementSerializer.prototype = {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/* falls through */
|
||||||
case 6: // Ending tag.
|
case 6: // Ending tag.
|
||||||
++this._state;
|
++this._state;
|
||||||
return '</' + node.nodeName + '>';
|
return '</' + node.nodeName + '>';
|
||||||
|
|
|
@ -66,7 +66,8 @@ loadingTask.promise.then(function(pdfDocument) {
|
||||||
// Render the page on a Node canvas with 100% scale.
|
// Render the page on a Node canvas with 100% scale.
|
||||||
var viewport = page.getViewport(1.0);
|
var viewport = page.getViewport(1.0);
|
||||||
var canvasFactory = new NodeCanvasFactory();
|
var canvasFactory = new NodeCanvasFactory();
|
||||||
var canvasAndContext = canvasFactory.create(viewport.width, viewport.height);
|
var canvasAndContext =
|
||||||
|
canvasFactory.create(viewport.width, viewport.height);
|
||||||
var renderContext = {
|
var renderContext = {
|
||||||
canvasContext: canvasAndContext.context,
|
canvasContext: canvasAndContext.context,
|
||||||
viewport: viewport,
|
viewport: viewport,
|
||||||
|
@ -81,7 +82,8 @@ loadingTask.promise.then(function(pdfDocument) {
|
||||||
if (error) {
|
if (error) {
|
||||||
console.error('Error: ' + error);
|
console.error('Error: ' + error);
|
||||||
} else {
|
} else {
|
||||||
console.log('Finished converting first page of PDF file to a PNG image.');
|
console.log(
|
||||||
|
'Finished converting first page of PDF file to a PNG image.');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -108,11 +108,12 @@ loadingTask.promise.then(function(doc) {
|
||||||
var svgGfx = new pdfjsLib.SVGGraphics(page.commonObjs, page.objs);
|
var svgGfx = new pdfjsLib.SVGGraphics(page.commonObjs, page.objs);
|
||||||
svgGfx.embedFonts = true;
|
svgGfx.embedFonts = true;
|
||||||
return svgGfx.getSVG(opList, viewport).then(function (svg) {
|
return svgGfx.getSVG(opList, viewport).then(function (svg) {
|
||||||
return writeSvgToFile(svg, getFilePathForPage(pageNum)).then(function () {
|
return writeSvgToFile(svg, getFilePathForPage(pageNum))
|
||||||
console.log('Page: ' + pageNum);
|
.then(function () {
|
||||||
}, function(err) {
|
console.log('Page: ' + pageNum);
|
||||||
console.log('Error: ' + err);
|
}, function(err) {
|
||||||
});
|
console.log('Error: ' + err);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
9
examples/webpack/.eslintrc
Normal file
9
examples/webpack/.eslintrc
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
{
|
||||||
|
"extends": [
|
||||||
|
"../.eslintrc"
|
||||||
|
],
|
||||||
|
|
||||||
|
"env": {
|
||||||
|
"node": true,
|
||||||
|
},
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
var webpack = require('webpack');
|
var webpack = require('webpack'); // eslint-disable-line no-unused-vars
|
||||||
var path = require('path');
|
var path = require('path');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue