From 0a03843e5fe2bb5bb6eae72b2945a4cc937993e5 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Sun, 28 Mar 2021 18:09:43 +0200 Subject: [PATCH] Re-factor the pre-processor statements used with `webViewerOpenFileViaURL` Given that the `webViewerOpenFileViaURL` helper function is being defined in *all* builds anyway, the current pre-processor usage doesn't really improve readability in my opinion. --- web/app.js | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/web/app.js b/web/app.js index 125a56644..35ea06607 100644 --- a/web/app.js +++ b/web/app.js @@ -2274,10 +2274,9 @@ function webViewerInitialized() { } } -let webViewerOpenFileViaURL; -if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) { - webViewerOpenFileViaURL = function (file) { - if (file && file.lastIndexOf("file:", 0) === 0) { +function webViewerOpenFileViaURL(file) { + if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) { + if (file?.lastIndexOf("file:", 0) === 0) { // file:-scheme. Load the contents in the main thread because QtWebKit // cannot load file:-URLs in a Web Worker. file:-URLs are usually loaded // very quickly, so there is no need to set up progress event listeners. @@ -2295,18 +2294,14 @@ if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) { if (file) { PDFViewerApplication.open(file); } - }; -} else if (PDFJSDev.test("MOZCENTRAL || CHROME")) { - webViewerOpenFileViaURL = function (file) { + } else if (PDFJSDev.test("MOZCENTRAL || CHROME")) { PDFViewerApplication.setTitleUsingUrl(file); PDFViewerApplication.initPassiveLoading(); - }; -} else { - webViewerOpenFileViaURL = function (file) { + } else { if (file) { throw new Error("Not implemented: webViewerOpenFileViaURL"); } - }; + } } function webViewerResetPermissions() {