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:
parent
80c33253ed
commit
d64ac95a91
474
web/app.js
474
web/app.js
File diff suppressed because it is too large
Load Diff
@ -16,18 +16,18 @@
|
|||||||
|
|
||||||
'use strict';
|
'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')) {
|
if (typeof PDFJSDev !== 'undefined' && PDFJSDev.test('CHROME')) {
|
||||||
(function rewriteUrlClosure() {
|
(function rewriteUrlClosure() {
|
||||||
// Run this code outside DOMContentLoaded to make sure that the URL
|
// Run this code outside DOMContentLoaded to make sure that the URL
|
||||||
// is rewritten as soon as possible.
|
// is rewritten as soon as possible.
|
||||||
var queryString = document.location.search.slice(1);
|
let queryString = document.location.search.slice(1);
|
||||||
var m = /(^|&)file=([^&]*)/.exec(queryString);
|
let m = /(^|&)file=([^&]*)/.exec(queryString);
|
||||||
DEFAULT_URL = m ? decodeURIComponent(m[2]) : '';
|
DEFAULT_URL = m ? decodeURIComponent(m[2]) : '';
|
||||||
|
|
||||||
// Example: chrome-extension://.../http://example.com/file.pdf
|
// 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);
|
history.replaceState(history.state, '', humanReadableUrl);
|
||||||
if (top === window) {
|
if (top === window) {
|
||||||
chrome.runtime.sendMessage('showPageAction');
|
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')) {
|
if (typeof PDFJSDev !== 'undefined' && PDFJSDev.test('PRODUCTION')) {
|
||||||
pdfjsWebApp = require('./app.js');
|
pdfjsWebApp = require('./app.js');
|
||||||
}
|
}
|
||||||
@ -172,14 +172,13 @@ function getViewerConfiguration() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function webViewerLoad() {
|
function webViewerLoad() {
|
||||||
var config = getViewerConfiguration();
|
let config = getViewerConfiguration();
|
||||||
if (typeof PDFJSDev === 'undefined' || !PDFJSDev.test('PRODUCTION')) {
|
if (typeof PDFJSDev === 'undefined' || !PDFJSDev.test('PRODUCTION')) {
|
||||||
Promise.all([
|
Promise.all([
|
||||||
SystemJS.import('pdfjs-web/app'),
|
SystemJS.import('pdfjs-web/app'),
|
||||||
SystemJS.import('pdfjs-web/genericcom'),
|
SystemJS.import('pdfjs-web/genericcom'),
|
||||||
SystemJS.import('pdfjs-web/pdf_print_service'),
|
SystemJS.import('pdfjs-web/pdf_print_service'),
|
||||||
]).then(function (modules) {
|
]).then(function([app, ...otherModules]) {
|
||||||
var app = modules[0];
|
|
||||||
window.PDFViewerApplication = app.PDFViewerApplication;
|
window.PDFViewerApplication = app.PDFViewerApplication;
|
||||||
app.PDFViewerApplication.run(config);
|
app.PDFViewerApplication.run(config);
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user