ES6-ify the code in web/app.js and web/viewer.js

The changes consist mostly of changing `var` to `let`/`const`, and using shorthand method signatures.
This commit is contained in:
Jonas Jenwald 2017-06-29 12:14:26 +02:00
parent 80c33253ed
commit d64ac95a91
2 changed files with 236 additions and 253 deletions

File diff suppressed because it is too large Load Diff

View File

@ -16,18 +16,18 @@
'use strict';
var DEFAULT_URL = 'compressed.tracemonkey-pldi-09.pdf';
let DEFAULT_URL = 'compressed.tracemonkey-pldi-09.pdf';
if (typeof PDFJSDev !== 'undefined' && PDFJSDev.test('CHROME')) {
(function rewriteUrlClosure() {
// Run this code outside DOMContentLoaded to make sure that the URL
// is rewritten as soon as possible.
var queryString = document.location.search.slice(1);
var m = /(^|&)file=([^&]*)/.exec(queryString);
let queryString = document.location.search.slice(1);
let m = /(^|&)file=([^&]*)/.exec(queryString);
DEFAULT_URL = m ? decodeURIComponent(m[2]) : '';
// Example: chrome-extension://.../http://example.com/file.pdf
var humanReadableUrl = '/' + DEFAULT_URL + location.hash;
let humanReadableUrl = '/' + DEFAULT_URL + location.hash;
history.replaceState(history.state, '', humanReadableUrl);
if (top === window) {
chrome.runtime.sendMessage('showPageAction');
@ -35,7 +35,7 @@ if (typeof PDFJSDev !== 'undefined' && PDFJSDev.test('CHROME')) {
})();
}
var pdfjsWebApp;
let pdfjsWebApp;
if (typeof PDFJSDev !== 'undefined' && PDFJSDev.test('PRODUCTION')) {
pdfjsWebApp = require('./app.js');
}
@ -172,14 +172,13 @@ function getViewerConfiguration() {
}
function webViewerLoad() {
var config = getViewerConfiguration();
let config = getViewerConfiguration();
if (typeof PDFJSDev === 'undefined' || !PDFJSDev.test('PRODUCTION')) {
Promise.all([
SystemJS.import('pdfjs-web/app'),
SystemJS.import('pdfjs-web/genericcom'),
SystemJS.import('pdfjs-web/pdf_print_service'),
]).then(function (modules) {
var app = modules[0];
]).then(function([app, ...otherModules]) {
window.PDFViewerApplication = app.PDFViewerApplication;
app.PDFViewerApplication.run(config);
});