From 86a9e55b4310ec6e5ac975b0cf491656da07b72d Mon Sep 17 00:00:00 2001 From: RhiobeT Date: Sat, 2 Oct 2021 14:13:40 +0200 Subject: [PATCH] Add bookmarks for epubs --- src/main/resources/templates/epub-index.html | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/resources/templates/epub-index.html b/src/main/resources/templates/epub-index.html index fe665e1..b644c4c 100644 --- a/src/main/resources/templates/epub-index.html +++ b/src/main/resources/templates/epub-index.html @@ -15,7 +15,7 @@ - +
back< >< 🔖 >

@@ -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(); + }