diff options
author | Andrew Dolgov <[email protected]> | 2021-09-14 21:20:52 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2021-09-14 21:20:52 +0300 |
commit | 0f21cf99048957daf586942e85cb9a4b2a94624e (patch) | |
tree | 272cbd4d946e00e7d0cd3f652c00e0254b5172e6 /js | |
parent | a8d98e68cc3ad674d4047fdb7ab7a3519d438a6f (diff) |
bring back location numbers to something more manageable
Diffstat (limited to 'js')
-rw-r--r-- | js/reader.js | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/js/reader.js b/js/reader.js index b141f67..044d907 100644 --- a/js/reader.js +++ b/js/reader.js @@ -7,6 +7,7 @@ const DEFAULT_FONT_FAMILY = "Georgia"; const DEFAULT_LINE_HEIGHT = 140; const MIN_LENGTH_TO_JUSTIFY = 32; /* characters */ +const LOCATION_DIVISOR = 20; const PAGE_RESET_PROGRESS = -1; const Reader = { @@ -666,13 +667,13 @@ const Reader = { } $(".location").click(function() { - const current = book.rendition.currentLocation().start.location; - const total = book.locations.length(); + const current = Math.floor(book.rendition.currentLocation().start.location / LOCATION_DIVISOR); + const total = Math.floor(book.locations.length() / LOCATION_DIVISOR); const page = prompt("Jump to location [1-" + total + "]", current); if (page) { - book.rendition.display(book.locations._locations[page]); + book.rendition.display(book.locations._locations[page * LOCATION_DIVISOR]); } }); Reader.Page.openLastRead(); @@ -744,8 +745,8 @@ const Reader = { const currentCfi = location.start.cfi; const currentPct = parseInt(book.locations.percentageFromCfi(currentCfi) * 100); - $("#cur_page").text(location.start.location); - $("#total_pages").text(book.locations.length()); + $("#cur_page").text(Math.floor(location.start.location / LOCATION_DIVISOR)); + $("#total_pages").text(Math.floor(book.locations.length() / LOCATION_DIVISOR)); $("#page_pct").text(parseInt(book.locations.percentageFromCfi(currentCfi)*100) + '%'); Reader.updateTocBarPosition(book, location); |