ESLint --fix

This commit is contained in:
Wojciech Maj 2018-12-06 13:55:15 +01:00
parent 80d7ff4912
commit ef1f255649
13 changed files with 47 additions and 47 deletions

View File

@ -9,7 +9,7 @@ var OUTPUT_PATH = '../../build/browserify';
var TMP_FILE_PREFIX = '../../build/browserify_';
gulp.task('build-bundle', function() {
return browserify('main.js', {output: TMP_FILE_PREFIX + 'main.tmp'})
return browserify('main.js', { output: TMP_FILE_PREFIX + 'main.tmp', })
.ignore(require.resolve('pdfjs-dist/build/pdf.worker')) // Reducing size
.bundle()
.pipe(source(TMP_FILE_PREFIX + 'main.tmp'))
@ -21,12 +21,12 @@ gulp.task('build-bundle', function() {
gulp.task('build-worker', function() {
// We can create our own viewer (see worker.js) or use already defined one.
var workerSrc = require.resolve('pdfjs-dist/build/pdf.worker.entry');
return browserify(workerSrc, {output: TMP_FILE_PREFIX + 'worker.tmp'})
return browserify(workerSrc, { output: TMP_FILE_PREFIX + 'worker.tmp', })
.bundle()
.pipe(source(TMP_FILE_PREFIX + 'worker.tmp'))
.pipe(streamify(uglify({compress:{
sequences: false // Chrome has issue with the generated code if true
}})))
.pipe(streamify(uglify({ compress: {
sequences: false, // Chrome has issue with the generated code if true
}, })))
.pipe(rename('pdf.worker.bundle.js'))
.pipe(gulp.dest(OUTPUT_PATH));
});

View File

@ -24,7 +24,7 @@ loadingTask.promise.then(function (pdfDocument) {
var ctx = canvas.getContext('2d');
var renderTask = pdfPage.render({
canvasContext: ctx,
viewport: viewport
viewport: viewport,
});
return renderTask.promise;
});

View File

@ -15,7 +15,7 @@
'use strict';
if (!pdfjsLib.getDocument || !pdfjsViewer.PDFViewer) {
if (!pdfjsLib.getDocument || !pdfjsViewer.PDFViewer) {
alert('Please build the pdfjs-dist library using\n' +
' `gulp dist-install`');
}

View File

@ -59,8 +59,8 @@ jpegImage.parse(typedArrayImage);
var width = jpegImage.width, height = jpegImage.height;
var jpegData = jpegImage.getData({
width,
height,
width: width,
height: height,
forceRGB: true,
});
@ -76,4 +76,3 @@ for (var i = 0, j = 0, ii = width * height * 4; i < ii;) {
}
jpegCanvas.width = width, jpegCanvas.height = height;
jpegCtx.putImageData(imageData, 0, 0);

View File

@ -47,7 +47,7 @@ var PDFViewerApplication = {
* @returns {Promise} - Returns the promise, which is resolved when document
* is opened.
*/
open: function (params) {
open: function(params) {
if (this.pdfLoadingTask) {
// We need to destroy already opened document
return this.close().then(function () {
@ -104,7 +104,7 @@ var PDFViewerApplication = {
}
loadingErrorMessage.then(function (msg) {
self.error(msg, {message: message});
self.error(msg, { message: message, });
});
self.loadingBar.hide();
});
@ -115,7 +115,7 @@ var PDFViewerApplication = {
* @returns {Promise} - Returns the promise, which is resolved when all
* destruction is completed.
*/
close: function () {
close: function() {
var errorWrapper = document.getElementById('errorWrapper');
errorWrapper.setAttribute('hidden', 'true');
@ -154,7 +154,7 @@ var PDFViewerApplication = {
this.setTitle(title);
},
setTitleUsingMetadata: function (pdfDocument) {
setTitleUsingMetadata: function(pdfDocument) {
var self = this;
pdfDocument.getMetadata().then(function(data) {
var info = data.info, metadata = data.metadata;
@ -196,26 +196,26 @@ var PDFViewerApplication = {
var l10n = this.l10n;
var moreInfoText = [l10n.get('error_version_info',
{ version: pdfjsLib.version || '?',
build: pdfjsLib.build || '?' },
build: pdfjsLib.build || '?', },
'PDF.js v{{version}} (build: {{build}})')];
if (moreInfo) {
moreInfoText.push(
l10n.get('error_message', {message: moreInfo.message},
l10n.get('error_message', { message: moreInfo.message, },
'Message: {{message}}'));
if (moreInfo.stack) {
moreInfoText.push(
l10n.get('error_stack', {stack: moreInfo.stack},
l10n.get('error_stack', { stack: moreInfo.stack, },
'Stack: {{stack}}'));
} else {
if (moreInfo.filename) {
moreInfoText.push(
l10n.get('error_file', {file: moreInfo.filename},
l10n.get('error_file', { file: moreInfo.filename, },
'File: {{file}}'));
}
if (moreInfo.lineNumber) {
moreInfoText.push(
l10n.get('error_line', {line: moreInfo.lineNumber},
l10n.get('error_line', { line: moreInfo.lineNumber, },
'Line: {{line}}'));
}
}
@ -311,7 +311,7 @@ var PDFViewerApplication = {
linkService.setViewer(pdfViewer);
this.pdfHistory = new pdfjsViewer.PDFHistory({
linkService: linkService
linkService: linkService,
});
linkService.setHistory(this.pdfHistory);
@ -359,7 +359,7 @@ var PDFViewerApplication = {
document.getElementById('previous').disabled = (page <= 1);
document.getElementById('next').disabled = (page >= numPages);
}, true);
}
},
};
document.addEventListener('DOMContentLoaded', function () {
@ -378,6 +378,6 @@ document.addEventListener('DOMContentLoaded', function () {
// We need to delay opening until all HTML is loaded.
PDFViewerApplication.animationStartedPromise.then(function () {
PDFViewerApplication.open({
url: DEFAULT_URL
url: DEFAULT_URL,
});
});

View File

@ -1,7 +1,7 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
function xmlEncode(s){
function xmlEncode(s) {
var i = 0, ch;
s = String(s);
while (i < s.length && (ch = s[i]) !== '&' && ch !== '<' &&
@ -50,7 +50,7 @@ function DOMElement(name) {
if (name === 'style') {
this.sheet = {
cssRules: [],
insertRule: function (rule) {
insertRule: function(rule) {
this.cssRules.push(rule);
},
};
@ -124,8 +124,8 @@ DOMElement.prototype = {
getSerializer: function DOMElement_getSerializer() {
return new DOMElementSerializer(this);
}
}
},
};
function DOMElementSerializer(node) {
this._node = node;
@ -198,48 +198,48 @@ DOMElementSerializer.prototype = {
};
const document = {
childNodes : [],
childNodes: [],
get currentScript() {
return { src: '' };
return { src: '', };
},
get documentElement() {
return this;
},
createElementNS: function (NS, element) {
createElementNS: function(NS, element) {
var elObject = new DOMElement(element);
return elObject;
},
createElement: function (element) {
createElement: function(element) {
return this.createElementNS('', element);
},
getElementsByTagName: function (element) {
getElementsByTagName: function(element) {
if (element === 'head') {
return [this.head || (this.head = new DOMElement('head'))];
}
return [];
}
},
};
function Image () {
function Image() {
this._src = null;
this.onload = null;
}
Image.prototype = {
get src () {
get src() {
return this._src;
},
set src (value) {
set src(value) {
this._src = value;
if (this.onload) {
this.onload();
}
}
}
},
};
exports.document = document;
exports.Image = Image;

View File

@ -52,7 +52,7 @@ loadingTask.promise.then(function(doc) {
}).then(function () {
console.log();
});
})
});
};
// Loading of the first page will wait on metadata and subsequent loadings
// will wait on the previous pages.

View File

@ -70,7 +70,7 @@ loadingTask.promise.then(function(pdfDocument) {
var renderContext = {
canvasContext: canvasAndContext.context,
viewport: viewport,
canvasFactory: canvasFactory
canvasFactory: canvasFactory,
};
var renderTask = page.render(renderContext);

View File

@ -86,8 +86,9 @@ function writeSvgToFile(svgElement, filePath) {
// callback.
var loadingTask = pdfjsLib.getDocument({
data: data,
// Try to export JPEG images directly if they don't need any further processing.
nativeImageDecoderSupport: pdfjsLib.NativeImageDecoding.DISPLAY
// Try to export JPEG images directly if they don't need any further
// processing.
nativeImageDecoderSupport: pdfjsLib.NativeImageDecoding.DISPLAY,
});
loadingTask.promise.then(function(doc) {
var numPages = doc.numPages;

View File

@ -15,7 +15,7 @@
'use strict';
if (!pdfjsLib.getDocument || !pdfjsViewer.PDFViewer) {
if (!pdfjsLib.getDocument || !pdfjsViewer.PDFViewer) {
alert('Please build the pdfjs-dist library using\n' +
' `gulp dist-install`');
}

View File

@ -49,7 +49,7 @@ function buildSVG(viewport, textContent) {
function pageLoaded() {
// Loading document and page text content
var loadingTask = pdfjsLib.getDocument({url: PDF_PATH});
var loadingTask = pdfjsLib.getDocument({ url: PDF_PATH, });
loadingTask.promise.then(function(pdfDocument) {
pdfDocument.getPage(PAGE_NUMBER).then(function (page) {
var viewport = page.getViewport(PAGE_SCALE);

View File

@ -24,7 +24,7 @@ loadingTask.promise.then(function (pdfDocument) {
var ctx = canvas.getContext('2d');
var renderTask = pdfPage.render({
canvasContext: ctx,
viewport: viewport
viewport: viewport,
});
return renderTask.promise;
});

View File

@ -5,12 +5,12 @@ module.exports = {
context: __dirname,
entry: {
'main': './main.js',
'pdf.worker': 'pdfjs-dist/build/pdf.worker.entry'
'pdf.worker': 'pdfjs-dist/build/pdf.worker.entry',
},
mode: 'none',
output: {
path: path.join(__dirname, '../../build/webpack'),
publicPath: '../../build/webpack/',
filename: '[name].bundle.js'
}
filename: '[name].bundle.js',
},
};