about summary refs log tree commit diff stats
path: root/src/reader.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/reader.js')
-rw-r--r--src/reader.js32
1 files changed, 31 insertions, 1 deletions
diff --git a/src/reader.js b/src/reader.js
index 1df71b5..f436810 100644
--- a/src/reader.js
+++ b/src/reader.js
@@ -751,6 +751,9 @@ class ReaderClass extends AppCommon {
 
     }
 
+    /**
+     * @param {ePub.Book} book
+     */
     initToc(book) {
         const _reader = this;
 
@@ -762,7 +765,8 @@ class ReaderClass extends AppCommon {
                     return k.indexOf(cfiBase) != -1
                 });
 
-                return Math.round(_reader.book.locations.locationFromCfi(loc) / LOCATION_DIVISOR);
+                if (loc)
+                    return Math.round(_reader.book.locations.locationFromCfi(loc) / LOCATION_DIVISOR);
 
             } catch (e) {
                 console.warn(e);
@@ -771,6 +775,11 @@ class ReaderClass extends AppCommon {
             return "";
         }
 
+        /**
+         * @param {ePub.NavItem} row
+         * @param {JQuery<HTMLElement>} list
+         * @param {number} nest
+         */
         function process_toc_sublist(row, list, nest) {
 
             if (nest == 3) return false;
@@ -853,6 +862,9 @@ class ReaderClass extends AppCommon {
     }
 
     /* embedded styles may conflict with our font sizes, etc */
+    /**
+     * @param {Document} doc
+     */
     cleanupEmbeddedStyles(doc) {
         $(doc).find("p")
                 // @ts-ignore
@@ -896,6 +908,9 @@ class ReaderClass extends AppCommon {
         }
     }
 
+    /**
+     * @param {string} base_url
+     */
     generateFontsCss(base_url) {
         return `
             /** Calibri */
@@ -1070,6 +1085,10 @@ class ReaderClass extends AppCommon {
             `;
     }
 
+    /**
+     * @param {ePub.NavItem} entry
+     * @param {number} nest
+     */
     flattenTocSubItems(entry, nest) {
         let rv = [];
 
@@ -1150,6 +1169,10 @@ class ReaderClass extends AppCommon {
         this.updateTocBarPosition(book, book.rendition.currentLocation())
     }
 
+    /**
+     * @param {ePub.Book} book
+     * @param {ePub.Location} location
+     */
     updateTocBarPosition(book, location) {
         const cur_pct = Math.round(location.start.location / book.locations.length() * 100);
 
@@ -1239,6 +1262,9 @@ class ReaderClass extends AppCommon {
             });
     }
 
+    /**
+     * @param {JQuery.KeyUpEvent<Document, undefined, Document, Document>} e
+     */
     hotkeyHandler(e) {
         try {
             //console.log('K3:' + e.which, e);
@@ -1329,10 +1355,14 @@ class ReaderClass extends AppCommon {
         }
     }
 
+    /** @param {string} [suffix] */
     cacheId(suffix) {
         return "epube-book." + this.urlParam("b") + (suffix ? "." + suffix : "");
     }
 
+    /**
+     * @param {boolean} show
+     */
     showUI(show) {
         if (show)
             $(".header,.footer").fadeIn();