1
0
Fork 0
mirror of https://github.com/futurepress/epub.js.git synced 2025-10-02 14:49:16 +02:00
This commit is contained in:
Anees Ijaz 2023-05-17 11:24:01 -07:00 committed by GitHub
commit 07b6b4373f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,5 +1,5 @@
import EventEmitter from "event-emitter";
import {extend, defer} from "./utils/core";
import { extend, defer } from "./utils/core";
import Url from "./utils/url";
import Path from "./utils/path";
import Spine from "./spine";
@ -50,8 +50,8 @@ const INPUT_TYPE = {
class Book {
constructor(url, options) {
// Allow passing just options to the Book
if (typeof(options) === "undefined" &&
typeof(url) !== "string" &&
if (typeof (options) === "undefined" &&
typeof (url) !== "string" &&
url instanceof Blob === false &&
url instanceof ArrayBuffer === false) {
options = url;
@ -229,9 +229,9 @@ class Book {
this.store(this.settings.store);
}
if(url) {
if (url) {
this.open(url, this.settings.openAs).catch((error) => {
var err = new Error("Cannot load book at "+ url );
var err = new Error("Cannot load book at " + url);
this.emit(EVENTS.BOOK.OPEN_FAILED, err);
});
}
@ -261,10 +261,10 @@ class Book {
this.url = new Url("/", "");
opening = this.request(input, "binary", this.settings.requestCredentials, this.settings.requestHeaders)
.then(this.openEpub.bind(this));
} else if(type == INPUT_TYPE.OPF) {
} else if (type == INPUT_TYPE.OPF) {
this.url = new Url(input);
opening = this.openPackaging(this.url.Path.toString());
} else if(type == INPUT_TYPE.MANIFEST) {
} else if (type == INPUT_TYPE.MANIFEST) {
this.url = new Url(input);
opening = this.openManifest(this.url.Path.toString());
} else {
@ -345,7 +345,7 @@ class Book {
*/
load(path) {
var resolved = this.resolve(path);
if(this.archived) {
if (this.archived) {
return this.archive.request(resolved);
} else {
return this.request(resolved, null, this.settings.requestCredentials, this.settings.requestHeaders);
@ -373,7 +373,7 @@ class Book {
resolved = this.path.resolve(path);
}
if(absolute != false && this.url) {
if (absolute != false && this.url) {
resolved = this.url.resolve(resolved);
}
@ -416,7 +416,7 @@ class Book {
return INPUT_TYPE.BASE64;
}
if(typeof(input) != "string") {
if (typeof (input) != "string") {
return INPUT_TYPE.BINARY;
}
@ -433,15 +433,15 @@ class Book {
return INPUT_TYPE.DIRECTORY;
}
if(extension === "epub"){
if (extension === "epub") {
return INPUT_TYPE.EPUB;
}
if(extension === "opf"){
if (extension === "opf") {
return INPUT_TYPE.OPF;
}
if(extension === "json"){
if (extension === "json") {
return INPUT_TYPE.MANIFEST;
}
}
@ -496,7 +496,7 @@ class Book {
this.isOpen = true;
if(this.archived || this.settings.replacements && this.settings.replacements != "none") {
if (this.archived || this.settings.replacements && this.settings.replacements != "none") {
this.replacements().then(() => {
this.loaded.displayOptions.then(() => {
this.opening.resolve(this);
@ -670,7 +670,7 @@ class Book {
}
if (this.archived) {
return this.archive.createUrl(this.cover);
return this.archive.createUrl(this.cover, { "base64": (this.settings.replacements === "base64") });
} else {
return this.cover;
}