Add bookmarks for epubs
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
<table style="table-layout: fixed;">
|
||||
<tr>
|
||||
<td style="text-align: left; padding-top: 0; padding-bottom: 0;"><a href="{info.directUrl}/..">back</a></td>
|
||||
<td style="text-align: right; padding-top: 0; padding-bottom: 0;"><a href="#" onclick="rendition.prev()"><</a> <a href="#" onclick="rendition.next()">></a></td>
|
||||
<td style="text-align: right; padding-top: 0; padding-bottom: 0;"><a href="#" onclick="rendition.prev()"><</a> <a href="#" onclick="saveBookmark()">🔖</a> <a href="#" onclick="rendition.next()">></a></td>
|
||||
</tr>
|
||||
</table>
|
||||
<hr />
|
||||
@@ -56,11 +56,19 @@
|
||||
rendition.next();
|
||||
});
|
||||
}
|
||||
function saveBookmark() {
|
||||
document.cookie = "bookmark=" + rendition.currentLocation().start.cfi + "; Max-Age=31536000";
|
||||
}
|
||||
rendition.on("rendered", (e0,i) => {
|
||||
setEvents(i.document);
|
||||
});
|
||||
setEvents(document);
|
||||
rendition.display();
|
||||
var bookmarkCookie = document.cookie.split('; ').find(row => row.startsWith('bookmark='));
|
||||
if (bookmarkCookie !== undefined) {
|
||||
rendition.display(bookmarkCookie.split('=')[1]);
|
||||
} else {
|
||||
rendition.display();
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user