forked from futurepress/epub.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAPI.js
108 lines (82 loc) · 2.45 KB
/
API.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
// API
// Epub Rendition
// > Package (book)
// - Manifest (files)
// - Metadata (info)
// - Spine (order)
// - Navagation (toc)
// Need to split out rendering and book completely
// Something like
var epub = ePub("moby-dick.epub");
var epub = ePub("http://s3path/ip/moby-dick.opf");
// or
var epub = new EPUBJS.Book("http://s3path/ip/moby-dick.opf");
// Returns a Scroll Controller, Attachs to a document (or window?)
var epub = ePub("moby-dick.epub");
var epub = ePub();
var book = epub.open(_url)
return epub
// Creates a Book Package object, parses manifest
var book = epub.open("moby-dick.epub");
var book = epub.open("META-INF/container.xml");
var book = epub.open("package.opf"); //-- maybe, not in spec?
// Set the store
// Unzip if needed
// Get the container
// Get the package path
book = new Book("path/to/book/package.opf", store);
unpacked = book.unpack();
return unpacked
book.unpack()
book.manifest
book.metadata
book.spine
book.navigation.toc
// book.navigation.landmarks
// book.navigation.lot
return book
// Loads a chapter of the Book
var section = book.spine.get(1);
var section = book.spine.get("chap1.html");
var section = book.spine.get("#id1234");
// Alias for spine
var section = book.section("epubcfi(/6/30[id-id2640702])");
var section = book.section(1);
book.loaded.navigation.then()
book.navigation.get()
book.navigation.get("#toc-chap-1")
book.navigation.get("chap1.html")
// Returns the straight html of the chapter
//-- When does the chapter content processing happen?
section.render()
// Create a new renderer
var rendition = book.renderTo("viewer", {method: "paginate", options: true});
// is the same as
var rendition = new EPUBJS.Paginate(book, {options: true});
rendition.attachTo("viewer");
// Render to a div
rendition.attachTo("elementID");
// Display the provided chapter
rendition.display(chapter);
epub.display();
epub.display(1);
epub.display("chapt1.html#something");
epub.display("epubcfi(/6/30[id-id2640702]!2/4/1:0)");
section = book.section(_arg);
rendition.display(section);
section.render();
section.load();
return rendition;
epub.rendition.backwards();
epub.rendition.forwards();
epub.rendition.addStyle();
epub.rendition.addStyles();
epub.find("query");
section.find("query");
epub.on("noAuth", function(){
});
rendition = epub.renderTo("elementID", { method: "paginate", width: "900", height: "600" });
rendition.next();
rendition.prev();
rendition.page();
rendition.map();