mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
Simplify setting the defaultUrl
-option in the CHROME viewer (PR 12470 follow-up)
This should really have been done as part of PR 12470, since it's now possible to directly set the `defaultUrl`-option without having to fallback to `var`-usage.
This commit is contained in:
parent
b9f5a70ded
commit
abcc32ade0
1 changed files with 3 additions and 7 deletions
|
@ -27,14 +27,12 @@ window.PDFViewerApplication = PDFViewerApplication;
|
|||
window.PDFViewerApplicationOptions = AppOptions;
|
||||
|
||||
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("CHROME")) {
|
||||
var defaultUrl; // eslint-disable-line no-var
|
||||
|
||||
(function rewriteUrlClosure() {
|
||||
// Run this code outside DOMContentLoaded to make sure that the URL
|
||||
// is rewritten as soon as possible.
|
||||
const queryString = document.location.search.slice(1);
|
||||
const m = /(^|&)file=([^&]*)/.exec(queryString);
|
||||
defaultUrl = m ? decodeURIComponent(m[2]) : "";
|
||||
const defaultUrl = m ? decodeURIComponent(m[2]) : "";
|
||||
|
||||
// Example: chrome-extension://.../http://example.com/file.pdf
|
||||
const humanReadableUrl = "/" + defaultUrl + location.hash;
|
||||
|
@ -43,6 +41,8 @@ if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("CHROME")) {
|
|||
// eslint-disable-next-line no-undef
|
||||
chrome.runtime.sendMessage("showPageAction");
|
||||
}
|
||||
|
||||
AppOptions.set("defaultUrl", defaultUrl);
|
||||
})();
|
||||
}
|
||||
|
||||
|
@ -222,10 +222,6 @@ function webViewerLoad() {
|
|||
PDFViewerApplication.run(config);
|
||||
});
|
||||
} else {
|
||||
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("CHROME")) {
|
||||
AppOptions.set("defaultUrl", defaultUrl);
|
||||
}
|
||||
|
||||
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("GENERIC")) {
|
||||
// Give custom implementations of the default viewer a simpler way to
|
||||
// set various `AppOptions`, by dispatching an event once all viewer
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue