-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrenderer.js
More file actions
80 lines (63 loc) · 2.08 KB
/
renderer.js
File metadata and controls
80 lines (63 loc) · 2.08 KB
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
const { ipcRenderer } = require('electron');
let book;
let rendition;
ipcRenderer.on('open-file', function (event, filepath) {
console.log(filepath);
const splits = filepath.split('\\');
const extSplits = splits[splits.length - 1].split('.');
const ext = extSplits[extSplits.length - 1];
if (ext === 'epub') {
const epub = require('./epub');
epub(filepath);
} else if (ext === 'pdf') {
const pdf = require('./pdf');
pdf(filepath);
}
});
var title = document.getElementById('title');
// rendition.on("rendered", function(section){
// var current = book.navigation && book.navigation.get(section.href);
// if (current) {
// var $select = document.getElementById("toc");
// var $selected = $select.querySelector("option[selected]");
// if ($selected) {
// $selected.removeAttribute("selected");
// }
// var $options = $select.querySelectorAll("option");
// for (var i = 0; i < $options.length; ++i) {
// let selected = $options[i].getAttribute("ref") === current.href;
// if (selected) {
// $options[i].setAttribute("selected", "");
// }
// }
// }
// });
// rendition.on("layout", function(layout) {
// let viewer = document.getElementById("viewer");
// if (layout.spread) {
// viewer.classList.remove('single');
// } else {
// viewer.classList.add('single');
// }
// });
// window.addEventListener("unload", function () {
// console.log("unloading");
// this.book.destroy();
// });
// book.loaded.navigation.then(function(toc){
// var $select = document.getElementById("toc"),
// docfrag = document.createDocumentFragment();
// toc.forEach(function(chapter) {
// var option = document.createElement("option");
// option.textContent = chapter.label;
// option.setAttribute("ref", chapter.href);
// docfrag.appendChild(option);
// });
// $select.appendChild(docfrag);
// $select.onchange = function(){
// var index = $select.selectedIndex,
// url = $select.options[index].getAttribute("ref");
// rendition.display(url);
// return false;
// };
// });