mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-10-26 19:01:39 -04:00
308 lines
8.1 KiB
HTML
308 lines
8.1 KiB
HTML
|
|
<!DOCTYPE html>
|
|||
|
|
<!--Copyright (c) 2013, FuturePress
|
|||
|
|
|
|||
|
|
All rights reserved.
|
|||
|
|
|
|||
|
|
Redistribution and use in source and binary forms, with or without
|
|||
|
|
modification, are permitted provided that the following conditions are met:
|
|||
|
|
|
|||
|
|
1. Redistributions of source code must retain the above copyright notice, this
|
|||
|
|
list of conditions and the following disclaimer.
|
|||
|
|
2. Redistributions in binary form must reproduce the above copyright notice,
|
|||
|
|
this list of conditions and the following disclaimer in the documentation
|
|||
|
|
and/or other materials provided with the distribution.
|
|||
|
|
|
|||
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|||
|
|
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|||
|
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|||
|
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
|||
|
|
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|||
|
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|||
|
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|||
|
|
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|||
|
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|||
|
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
|
|
|||
|
|
The views and conclusions contained in the software and documentation are those
|
|||
|
|
of the authors and should not be interpreted as representing official policies,
|
|||
|
|
either expressed or implied, of the FreeBSD Project. -->
|
|||
|
|
<html lang="en">
|
|||
|
|
<head>
|
|||
|
|
<meta charset="UTF-8">
|
|||
|
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
|
|||
|
|
<script src="/jszip.min.js"></script>
|
|||
|
|
<script src="/epub.js"></script>
|
|||
|
|
</head>
|
|||
|
|
<body>
|
|||
|
|
|
|||
|
|
<style>
|
|||
|
|
body {
|
|||
|
|
margin: 0;
|
|||
|
|
background: #fafafa;
|
|||
|
|
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
|
|||
|
|
color: #333;
|
|||
|
|
|
|||
|
|
position: absolute;
|
|||
|
|
height: 100%;
|
|||
|
|
width: 100%;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#title {
|
|||
|
|
width: 900px;
|
|||
|
|
min-height: 18px;
|
|||
|
|
margin: 10px auto;
|
|||
|
|
text-align: center;
|
|||
|
|
font-size: 16px;
|
|||
|
|
color: #E2E2E2;
|
|||
|
|
font-weight: 400;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#title:hover {
|
|||
|
|
color: #777;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#viewer {
|
|||
|
|
width: 80%;
|
|||
|
|
height: 90%;
|
|||
|
|
box-shadow: 0 0 4px #ccc;
|
|||
|
|
padding: 10px 10px 0px 10px;
|
|||
|
|
margin: 5px auto;
|
|||
|
|
background: white;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#prev {
|
|||
|
|
left: 0;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#next {
|
|||
|
|
right: 0;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#toc {
|
|||
|
|
display: block;
|
|||
|
|
margin: 10px auto;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
.arrow {
|
|||
|
|
position: fixed;
|
|||
|
|
top: 50%;
|
|||
|
|
margin-top: -32px;
|
|||
|
|
font-size: 64px;
|
|||
|
|
color: #E2E2E2;
|
|||
|
|
font-family: arial, sans-serif;
|
|||
|
|
font-weight: bold;
|
|||
|
|
cursor: pointer;
|
|||
|
|
-webkit-user-select: none;
|
|||
|
|
-moz-user-select: none;
|
|||
|
|
user-select: none;
|
|||
|
|
text-decoration: none;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
.arrow:hover {
|
|||
|
|
color: #777;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
.arrow:active {
|
|||
|
|
color: #000;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#book-viewer iframe {
|
|||
|
|
padding: 40px 40px;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#controls > input[type=range] {
|
|||
|
|
width: 400px;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#navigation h1 {
|
|||
|
|
width: 200px;
|
|||
|
|
font-size: 16px;
|
|||
|
|
font-weight: normal;
|
|||
|
|
color: #fff;
|
|||
|
|
margin-bottom: 10px;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#navigation h2 {
|
|||
|
|
font-size: 14px;
|
|||
|
|
font-weight: normal;
|
|||
|
|
color: #B0B0B0;
|
|||
|
|
margin-bottom: 20px;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#navigation ul {
|
|||
|
|
padding-left: 36px;
|
|||
|
|
margin-left: 0;
|
|||
|
|
margin-top: 12px;
|
|||
|
|
margin-bottom: 12px;
|
|||
|
|
width: 340px;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#navigation ul li {
|
|||
|
|
list-style: decimal;
|
|||
|
|
margin-bottom: 10px;
|
|||
|
|
color: #cccddd;
|
|||
|
|
font-size: 12px;
|
|||
|
|
padding-left: 0;
|
|||
|
|
margin-left: 0;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#navigation ul li a {
|
|||
|
|
color: #ccc;
|
|||
|
|
text-decoration: none;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#navigation ul li a:hover {
|
|||
|
|
color: #fff;
|
|||
|
|
text-decoration: underline;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#navigation ul li {
|
|||
|
|
color: #fff;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
svg {
|
|||
|
|
display: block;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
</style>
|
|||
|
|
|
|||
|
|
<select id="toc"></select>
|
|||
|
|
<div id="viewer"></div>
|
|||
|
|
<a id="prev" href="#prev" class="arrow">‹</a>
|
|||
|
|
<a id="next" href="#next" class="arrow">›</a>
|
|||
|
|
|
|||
|
|
<script>
|
|||
|
|
let params = URLSearchParams && new URLSearchParams(document.location.search.substring(1));
|
|||
|
|
let url = params && params.get("url") && decodeURIComponent(params.get("url"));
|
|||
|
|
let currentSectionIndex = (params && params.get("loc")) ? params.get("loc") : undefined;
|
|||
|
|
|
|||
|
|
let book = ePub(url);
|
|||
|
|
let rendition = book.renderTo("viewer", {
|
|||
|
|
flow: "paginated",
|
|||
|
|
width: "100%",
|
|||
|
|
height: "100%"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
rendition.display(currentSectionIndex);
|
|||
|
|
|
|||
|
|
book.ready.then(() => {
|
|||
|
|
|
|||
|
|
let next = document.getElementById("next");
|
|||
|
|
|
|||
|
|
next.addEventListener("click", function (e) {
|
|||
|
|
book.package.metadata.direction === "rtl" ? rendition.prev() : rendition.next();
|
|||
|
|
e.preventDefault();
|
|||
|
|
}, false);
|
|||
|
|
|
|||
|
|
let prev = document.getElementById("prev");
|
|||
|
|
prev.addEventListener("click", function (e) {
|
|||
|
|
book.package.metadata.direction === "rtl" ? rendition.next() : rendition.prev();
|
|||
|
|
e.preventDefault();
|
|||
|
|
}, false);
|
|||
|
|
|
|||
|
|
let keyListener = function (e) {
|
|||
|
|
|
|||
|
|
// Left Key
|
|||
|
|
if ((e.keyCode || e.which) === 37) {
|
|||
|
|
book.package.metadata.direction === "rtl" ? rendition.next() : rendition.prev();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// Right Key
|
|||
|
|
if ((e.keyCode || e.which) === 39) {
|
|||
|
|
book.package.metadata.direction === "rtl" ? rendition.prev() : rendition.next();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
rendition.on("keyup", keyListener);
|
|||
|
|
document.addEventListener("keyup", keyListener, false);
|
|||
|
|
|
|||
|
|
})
|
|||
|
|
|
|||
|
|
let title = document.getElementById("title");
|
|||
|
|
|
|||
|
|
rendition.on("rendered", function (section) {
|
|||
|
|
let current = book.navigation && book.navigation.get(section.href);
|
|||
|
|
|
|||
|
|
if (current) {
|
|||
|
|
let $select = document.getElementById("toc");
|
|||
|
|
let $selected = $select.querySelector("option[selected]");
|
|||
|
|
if ($selected) {
|
|||
|
|
$selected.removeAttribute("selected");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
let $options = $select.querySelectorAll("option");
|
|||
|
|
for (let i = 0; i < $options.length; ++i) {
|
|||
|
|
let selected = $options[i].getAttribute("ref") === current.href;
|
|||
|
|
if (selected) {
|
|||
|
|
$options[i].setAttribute("selected", "");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
rendition.on("relocated", function (location) {
|
|||
|
|
console.log(location);
|
|||
|
|
|
|||
|
|
let next = book.package.metadata.direction === "rtl" ? document.getElementById("prev") : document.getElementById("next");
|
|||
|
|
let prev = book.package.metadata.direction === "rtl" ? document.getElementById("next") : document.getElementById("prev");
|
|||
|
|
|
|||
|
|
if (location.atEnd) {
|
|||
|
|
next.style.visibility = "hidden";
|
|||
|
|
} else {
|
|||
|
|
next.style.visibility = "visible";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (location.atStart) {
|
|||
|
|
prev.style.visibility = "hidden";
|
|||
|
|
} else {
|
|||
|
|
prev.style.visibility = "visible";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
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) {
|
|||
|
|
let $select = document.getElementById("toc"),
|
|||
|
|
docfrag = document.createDocumentFragment();
|
|||
|
|
|
|||
|
|
toc.forEach(function (chapter) {
|
|||
|
|
let option = document.createElement("option");
|
|||
|
|
option.textContent = chapter.label;
|
|||
|
|
option.setAttribute("ref", chapter.href);
|
|||
|
|
|
|||
|
|
docfrag.appendChild(option);
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
$select.appendChild(docfrag);
|
|||
|
|
|
|||
|
|
$select.onchange = function () {
|
|||
|
|
let index = $select.selectedIndex,
|
|||
|
|
url = $select.options[index].getAttribute("ref");
|
|||
|
|
rendition.display(url);
|
|||
|
|
return false;
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
</script>
|
|||
|
|
|
|||
|
|
</body>
|
|||
|
|
|
|||
|
|
</html>
|