From 9ef58347ed3b640db1d4397a716b247688dd628a Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Sun, 5 Apr 2020 11:15:21 +0200 Subject: [PATCH] A couple of small improvements of the `PDFViewerApplication.{_initializeMetadata, _initializePdfHistory}` methods - Use template strings when printing document/viewer information in `_initializeMetadata`, since the old format feels overly verbose. Also, get the WebGL state from the `BaseViewer` instance[1] rather than the `AppOptions`. Since the `AppOptions` value could theoretically have been changed (by the user) after the viewer components were initialized, it seems much more useful to print the *actual* value that'll be used during rendering. - Change `_initializePdfHistory` to actually do the "is embedded"-check first, in accordance with the comment and given that the "disableHistory" option usually shouldn't be set. --- [1] Admittedly reaching into the `BaseViewer` instance and just grabbing the value perhaps isn't a great approach overall, but given that the WebGL-backend isn't even on by default this probably doesn't matter too much. --- web/app.js | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/web/app.js b/web/app.js index ab26f567b..5ddfd8adf 100644 --- a/web/app.js +++ b/web/app.js @@ -1270,19 +1270,10 @@ const PDFViewerApplication = { // Provides some basic debug information console.log( - "PDF " + - pdfDocument.fingerprint + - " [" + - info.PDFFormatVersion + - " " + - (info.Producer || "-").trim() + - " / " + - (info.Creator || "-").trim() + - "]" + - " (PDF.js: " + - (version || "-") + - (AppOptions.get("enableWebGL") ? " [WebGL]" : "") + - ")" + `PDF ${pdfDocument.fingerprint} [${info.PDFFormatVersion} ` + + `${(info.Producer || "-").trim()} / ${(info.Creator || "-").trim()}] ` + + `(PDF.js: ${version || "-"}` + + `${this.pdfViewer.enableWebGL ? " [WebGL]" : ""})` ); let pdfTitle; @@ -1444,7 +1435,7 @@ const PDFViewerApplication = { * @private */ _initializePdfHistory({ fingerprint, viewOnLoad, initialDest = null }) { - if (AppOptions.get("disableHistory") || this.isViewerEmbedded) { + if (this.isViewerEmbedded || AppOptions.get("disableHistory")) { // The browsing history is only enabled when the viewer is standalone, // i.e. not when it is embedded in a web page. return;