Skip to content
Snippets Groups Projects
Verified Commit 63d75fb1 authored by TheJoeCoder's avatar TheJoeCoder
Browse files

EPUB percentage fixes

parent c9bfcb5d
Branches
No related tags found
No related merge requests found
......@@ -35,6 +35,7 @@
<div id="next" class="epr-arrow"></div>
<script>
let partial_md5 = "{{ book.partial_md5 }}";
let book = ePub("{{ book.original_file.url }}");
let rendition = book.renderTo("viewer", {
manager: "continuous",
......@@ -49,11 +50,26 @@
let displayed = rendition.display();
{% endif %}
// Generate locations
book.ready.then(function(){
const stored = localStorage.getItem(partial_md5 + "-locations");
if (stored) {
return book.locations.load(stored);
} else {
return book.locations.generate(300);
}
}).then(function(location) {
localStorage.setItem(partial_md5 + "-locations", book.locations.save());
console.log("Locations generated");
});
{% include "reader/book_read/bookreader_save.js" %}
rendition.on("relocated", function(location){
console.log(location);
saveProgress(location.start.cfi, rendition.location.start.percentage / 100);
let percentage = location.start.percentage;
if (location.atEnd) percentage = 1; // Fix for last page
saveProgress(location.start.cfi, percentage);
});
displayed.then(function(renderer){
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment