diff options
Diffstat (limited to 'src/reader.ts')
| -rw-r--r-- | src/reader.ts | 397 |
1 files changed, 265 insertions, 132 deletions
diff --git a/src/reader.ts b/src/reader.ts index a3b81b7..8b7cdb3 100644 --- a/src/reader.ts +++ b/src/reader.ts @@ -12,6 +12,8 @@ const PAGE_RESET_PROGRESS = -1; /* eslint-disable-next-line no-unused-vars */ class ReaderClass extends AppCommon { + _flattened_toc: any; + loader: any; csrf_token = ""; last_stored_cfi = ""; @@ -22,9 +24,9 @@ class ReaderClass extends AppCommon { hyphenate = {}; - _prevent_lastread_timeout; + _prevent_lastread_timeout: any; - _prevent_lastread; + _prevent_lastread: any; cacheVersion = BUILD_CACHE_VERSION; @@ -54,11 +56,12 @@ class ReaderClass extends AppCommon { constructor() { super(); + // @ts-expect-error TS(2304): Cannot find name 'ePub'. this.book = new ePub.Book(); this.loader = new ReaderLoader(); } - onTouchStart(evt) { + onTouchStart(evt: any) { const touch = evt.touches[0] || evt.changedTouches[0]; this._swipeState = { @@ -66,11 +69,12 @@ class ReaderClass extends AppCommon { startX: touch.clientX, startY: touch.clientY, startTime: Date.now(), + // @ts-expect-error TS(2322): Type 'string' is not assignable to type 'null'. direction: evt.target.id == "right" ? 'left' : 'right', }; } - onTouchEnd(evt) { + onTouchEnd(evt: any) { if (!this._swipeState.active) return; const touch = evt.changedTouches[0] || evt.changedTouches[evt.changedTouches.length - 1]; @@ -96,7 +100,7 @@ class ReaderClass extends AppCommon { } } - onTouchMove(evt) { + onTouchMove(evt: any) { if (!this._swipeState.active) return; const touch = evt.touches[0] || evt.changedTouches[0]; @@ -116,39 +120,48 @@ class ReaderClass extends AppCommon { Http.setCsrfToken(this.csrf_token); - $(document).on("keyup", (e) => { + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message + $(document).on("keyup", (e: any) => { this.hotkeyHandler(e); }); + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $(".close_book").on("click", () => { this.close(); }); + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $("#left").on("mouseup", () => { this.prevPage(); }); + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $(".search_input").on("change", () => { this.search(); }); - $(".prev_location_btn").on("click", (evt) => { + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message + $(".prev_location_btn").on("click", (evt: any) => { this.openPrevious(evt.target); }); + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $("#right").on("mouseup", () => { this.nextPage(); }); - $("#left, #right").on("touchstart", (evt) => { + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message + $("#left, #right").on("touchstart", (evt: any) => { this.onTouchStart(evt); }); - $("#left, #right").on("touchmove", (evt) => { + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message + $("#left, #right").on("touchmove", (evt: any) => { this.onTouchMove(evt); }); - $("#left, #right").on("touchend", (evt) => { + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message + $("#left, #right").on("touchend", (evt: any) => { this.onTouchEnd(evt); }); @@ -161,6 +174,7 @@ class ReaderClass extends AppCommon { } else { this.applyTheme(); + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $(".loading-message").text('Resource loader failed to initialize.'); } } @@ -174,7 +188,7 @@ class ReaderClass extends AppCommon { /** * @param {boolean} offline */ - async onOfflineModeChanged(offline) { + async onOfflineModeChanged(offline: any) { console.log('onOfflineModeChanged', offline); if (!offline && this.book) { @@ -188,7 +202,7 @@ class ReaderClass extends AppCommon { cfi: currentCfi, timestamp: String(new Date().getTime()) }); } catch (e) { const err = /** @type {HttpError} */(e); - if (err.status == 401) { + if ((err as any).status == 401) { window.location.href = "index.html"; } } @@ -200,10 +214,12 @@ class ReaderClass extends AppCommon { if (typeof EpubeApp != "undefined") { EpubeApp.setPage("PAGE_READER"); } else { + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $(window).on('online', () => { this.onOfflineModeChanged(false); }); + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $(window).on('offline', () => { this.onOfflineModeChanged(true); }); @@ -211,6 +227,7 @@ class ReaderClass extends AppCommon { this.applyTheme(); + // @ts-expect-error TS(2554): Expected 1 arguments, but got 0. const bookinfo = await localforage.getItem(this.cacheId()); if (!bookinfo) { @@ -232,6 +249,7 @@ class ReaderClass extends AppCommon { await localforage.setItem(this.cacheId('cover'), cover.blob); } + // @ts-expect-error TS(2554): Expected 1 arguments, but got 0. await localforage.setItem(this.cacheId(), info); console.log('bookinfo saved'); @@ -242,7 +260,8 @@ class ReaderClass extends AppCommon { console.error(err); - $(".loading-message").html(`Unable to load book info.<br/><small>${this.escapeHtml((String)(err.responseText))}</small>`); + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message + $(".loading-message").html(`Unable to load book info.<br/><small>${this.escapeHtml((String)((err as any).responseText))}</small>`); return; } } @@ -254,6 +273,7 @@ class ReaderClass extends AppCommon { if (!book_data) { console.log("local data not found, loading from network..."); + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $(".loading-message").html("Downloading book…"); /** @type {HttpBlobResponse} */ @@ -266,6 +286,7 @@ class ReaderClass extends AppCommon { console.log('saved local data for book'); } else { + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $(".loading-message").html(`Unable to download book: ${book_resp.status}`); return; } @@ -279,25 +300,28 @@ class ReaderClass extends AppCommon { _reader.openBookData(this.result); } catch (e) { console.error(e); + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $(".loading-message").html("Unable to load book blob: " + e); } }; fileReader.onerror = (e) => { console.log('filereader error', e); + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $(".loading-message").html("Unable to open book.<br/><small>" + this.escapeHtml(String(e)) + "</small>"); }; fileReader.readAsArrayBuffer(book_data); } - async openBookData(book_data) { + async openBookData(book_data: any) { //this.book = new ePub.Book(); try { await this.book.open(book_data); } catch (e) { console.error(e); + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $(".loading-message").html(`Unable to open book.<br/><small>${this.escapeHtml(e instanceof Error ? e.message : String(e))}</small>`); return; } @@ -316,6 +340,7 @@ class ReaderClass extends AppCommon { minSpreadWidth: 961 }); + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $(".location").on('click', async () => { const current = Math.floor(rendition.currentLocation().start.location / LOCATION_DIVISOR); const total = Math.floor(this.book.locations.length() / LOCATION_DIVISOR); @@ -330,8 +355,10 @@ class ReaderClass extends AppCommon { if (enable_hyphens) { /* global hyphenationPatternsEnUs, hyphenationPatternsRu, createHyphenator */ - this.hyphenate.en = createHyphenator(hyphenationPatternsEnUs, { html: true }); - this.hyphenate.ru = createHyphenator(hyphenationPatternsRu, { html: true }); +// @ts-expect-error TS(2304): Cannot find name 'createHyphenator'. +(this.hyphenate as any).en = createHyphenator(hyphenationPatternsEnUs, { html: true }); + // @ts-expect-error TS(2304): Cannot find name 'createHyphenator'. + (this.hyphenate as any).ru = createHyphenator(hyphenationPatternsRu, { html: true }); } this.initRenditionHooks(this.book, rendition); @@ -349,7 +376,8 @@ class ReaderClass extends AppCommon { /** * @param {ePub.Book} book */ - async showBookInfo(book) { + async showBookInfo(book: any) { + // @ts-expect-error TS(2554): Expected 1 arguments, but got 0. const bookinfo = await localforage.getItem(this.cacheId()); let title; @@ -367,6 +395,7 @@ class ReaderClass extends AppCommon { document.title = title + " – " + author + " – The Epube"; + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $(".title") .text(title) .attr("title", title + " – " + author); @@ -380,7 +409,7 @@ class ReaderClass extends AppCommon { /** * @param {ePub.Book} book */ - async loadLocations(book) { + async loadLocations(book: any) { let locations = await localforage.getItem(this.cacheId("locations")); // legacy format is array of objects {cfi: ..., page: ...} @@ -397,6 +426,7 @@ class ReaderClass extends AppCommon { if (this.isOnline()) { console.log("downloading locations..."); + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $(".loading-message").html("Downloading locations…"); try { @@ -429,11 +459,12 @@ class ReaderClass extends AppCommon { } } + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $(".loading-message").html("Preparing locations…"); let generate_queue_max = 0; - locations = await book.locations.generate(100, (queue) => { + locations = await book.locations.generate(100, (queue: any) => { if (!generate_queue_max) generate_queue_max = queue.length(); @@ -441,6 +472,7 @@ class ReaderClass extends AppCommon { if (generate_queue_max > 0) { const queue_pct = Math.round((1 - queue.length() / generate_queue_max) * 100); // TODO un-wtf + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $(".loading-message").html(`Preparing locations (${queue_pct}%)…`); } }); @@ -459,21 +491,22 @@ class ReaderClass extends AppCommon { * @param {ePub.Book} book * @param {ePub.Rendition} rendition */ - initRenditionHooks(book, rendition) { + initRenditionHooks(book: any, rendition: any) { console.log('initRenditionHooks'); - book.spine.hooks.content.register((doc/*, section */) => { + book.spine.hooks.content.register((doc: any/*, section */) => { this.cleanupEmbeddedStyles(doc); }); - rendition.hooks.content.register(async (contents) => { + rendition.hooks.content.register(async (contents: any) => { - contents.on("linkClicked", (href) => { + contents.on("linkClicked", (href: any) => { console.log('linkClicked', href); this.blockLastReadUpdate(); if (href.indexOf("://") == -1) { + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $(".prev_location_btn") .attr("data-location-cfi", rendition.currentLocation().start.cfi) .show(); @@ -484,7 +517,7 @@ class ReaderClass extends AppCommon { } }); - contents.on("selected", async (cfiRange) => { + contents.on("selected", async (cfiRange: any) => { if (this.isOnline()) { const range = await book.getRange(cfiRange); @@ -493,6 +526,7 @@ class ReaderClass extends AppCommon { console.log('selected', cfiRange, selection); if (selection.match(/^[\w]+$/)) { + // @ts-expect-error TS(2554): Expected 3 arguments, but got 2. this.lookupWord(selection, () => { if (typeof EpubeApp != "undefined") EpubeApp.showActionBar(false); @@ -510,24 +544,31 @@ class ReaderClass extends AppCommon { const match = window.location.href.match(/^.*\//); const base_url = match ? match[0] : window.location.href; + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $(contents.document.head) + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message .append($("<style type='text/css'>") .text(this.generateFontsCss(base_url))); + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $(contents.document.head) + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message .append($("<style type='text/css'>") .text(this.loader._res_data[base_url + 'dist/reader_iframe.min.css'])); - const theme = await localforage.getItem("epube.theme") || 'default'; + const theme = (await localforage.getItem("epube.theme")) || 'default'; + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $(contents.document).find("body") .attr("class", typeof EpubeApp != "undefined" ? "is-epube-app" : "") .addClass("theme-" + theme); console.log('contents', contents); - $(contents.window).on("click tap", (evt) => { + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message + $(contents.window).on("click tap", (evt: any) => { if (evt.button == 0) { + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message if ($(".modal").is(":visible")) return; @@ -538,7 +579,8 @@ class ReaderClass extends AppCommon { } }); - $(contents.window).on("wheel", async (evt) => { + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message + $(contents.window).on("wheel", async (evt: any) => { if (await localforage.getItem("epube.enable-wheel")) { if ((evt.originalEvent?.deltaY ?? 0) > 0) { this.nextPage(); @@ -549,7 +591,7 @@ class ReaderClass extends AppCommon { }); }); - rendition.on("keyup", (e) => { + rendition.on("keyup", (e: any) => { this.hotkeyHandler(e); }); @@ -560,81 +602,80 @@ class ReaderClass extends AppCommon { this.open_last_read_when_displayed = true; }); - rendition.on('rendered', async (/* section */) => { - console.log('rendition rendered'); - - this.applyTheme(); - this.resizeSideColumns(); - - try { - const location = rendition.currentLocation(); - - if (location.start) { - const cur_href = book.canonical(location.start.href); - let toc_entry = {}; - - $.each(this.flattenToc(book), function(i, r) { - - if (book.spine.get(r.href).canonical == cur_href) { - toc_entry = r; - return; - } - }); - - if (toc_entry && toc_entry.label) - $(".chapter_title").text(this.escapeHtml(toc_entry.label.trim()) + " | "); - - this.generateTocBar(book, this.flattenToc(book)); + rendition.on('rendered', async ( /* section */) => { + console.log('rendition rendered'); + this.applyTheme(); + this.resizeSideColumns(); + try { + const location = rendition.currentLocation(); + if (location.start) { + const cur_href = book.canonical(location.start.href); + let toc_entry = {}; + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message + $.each(this.flattenToc(book), function (i: any, r: any) { + if (book.spine.get(r.href).canonical == cur_href) { + toc_entry = r; + return; } - - } catch (e) { - console.warn(e); - } - - if (this.open_last_read_when_displayed) { - this.open_last_read_when_displayed = false; - - await this.openLastRead(); - } - }); + }); + if (toc_entry && (toc_entry as any).label) + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message + $(".chapter_title").text(this.escapeHtml((toc_entry as any).label.trim()) + " | "); + this.generateTocBar(book, this.flattenToc(book)); + } + } + catch (e) { + console.warn(e); + } + if (this.open_last_read_when_displayed) { + this.open_last_read_when_displayed = false; + await this.openLastRead(); + } +}); // this seems to be called a lot more than rendered rendition.on('displayed', function(/*chapter*/) { console.log('rendition displayed'); }); - rendition.on('relocated', (/** @type {ePub.Location} */ location) => this.onRelocated(book, location)); + rendition.on('relocated', (/** @type {ePub.Location} */ location: any) => this.onRelocated(book, location)); } initModals() { + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $('#settings-modal').on('shown.bs.modal', async () => { const last_read = await localforage.getItem(this.cacheId("lastread")); if (last_read && last_read.cfi) { + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $(".lastread_input") .val(last_read.page + '%') .attr('title', `[local] ${last_read.cfi}`); } + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $(".clear_last_read") .off("click") .on("click", () => { this.clearLastRead(); }); + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $(".open_last_read") .off("click") .on("click", () => { this.openLastRead(); }); + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $(".mark_as_read") .off("click") .on("click", () => { this.markAsRead(); }); + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $(".reset_locations") .off("click") .on("click", () => { @@ -645,6 +686,7 @@ class ReaderClass extends AppCommon { try { /** @type {HttpResponse} */ const lrResp = await Http.get("backend.php", { op: "getlastread", id: this.urlParam("id") }); + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $(".lastread_input") .val(lrResp.data.page + '%') .attr('title', `[remote] ${lrResp.data.cfi}`); @@ -653,34 +695,39 @@ class ReaderClass extends AppCommon { } } + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $(".font_family") .off("change") - .on("change", (evt) => { + .on("change", (evt: any) => { this.onFontChanged(evt.target); }); + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $(".font_size") .off("change") - .on("change", (evt) => { + .on("change", (evt: any) => { this.onTextSizeChanged(evt.target); }); + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $(".line_height") .off("change") - .on("change", (evt) => { + .on("change", (evt: any) => { this.onLineHeightChanged(evt.target); }); + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $(".theme_name") .off("change") - .on("change", (evt) => { + .on("change", (evt: any) => { this.onThemeChanged(evt.target); }); + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $(".enable_hyphens_checkbox") .attr("checked", await localforage.getItem("epube.enable-hyphens")) .off("click") - .on("click", (evt) => { + .on("click", (evt: any) => { localforage.setItem("epube.enable-hyphens", evt.target.checked); if (confirm("Toggling hyphens requires page reload. Reload now?")) { @@ -688,67 +735,83 @@ class ReaderClass extends AppCommon { } }); + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $(".enable_wheel_checkbox") .attr("checked", await localforage.getItem("epube.enable-wheel")) .off("click") - .on("click", (evt) => { + .on("click", (evt: any) => { localforage.setItem("epube.enable-wheel", evt.target.checked); }); if (typeof EpubeApp != "undefined") { + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $(".keep_ui_checkbox").parent().parent().hide(); } else { + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $(".keep_ui_checkbox") .attr("checked", await localforage.getItem("epube.keep-ui-visible")) .off("click") - .on("click", (evt) => { + .on("click", (evt: any) => { localforage.setItem("epube.keep-ui-visible", evt.target.checked); }); } + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $(".last-mod-timestamp").html(`${this.cosmeticVersion} — ${this.cacheVersion} (${this.isOnline() ? `<span class='text-success'>Online</span>` : `<span class='text-danger'>Offline</span>`}) `); - $(".font_family").val(await localforage.getItem("epube.fontFamily") || DEFAULT_FONT_FAMILY); - $(".theme_name").val(await localforage.getItem("epube.theme") || 'default'); + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message + $(".font_family").val((await localforage.getItem("epube.fontFamily")) || DEFAULT_FONT_FAMILY); + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message + $(".theme_name").val((await localforage.getItem("epube.theme")) || 'default'); + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message const zoom = $(".font_size").html(""); for (let i = 10; i <= 32; i++) { + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message const opt = $("<option>").val(i).html(i + " px"); zoom.append(opt); } - zoom.val(await localforage.getItem("epube.fontSize") || DEFAULT_FONT_SIZE); + zoom.val((await localforage.getItem("epube.fontSize")) || DEFAULT_FONT_SIZE); + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message const line_height = $(".line_height").html(""); for (let i = 100; i <= 220; i += 10) { + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message const opt = $("<option>").val(i).html(i + "%"); line_height.append(opt); } - line_height.val(await localforage.getItem("epube.lineHeight") || DEFAULT_LINE_HEIGHT); + line_height.val((await localforage.getItem("epube.lineHeight")) || DEFAULT_LINE_HEIGHT); }); + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $('#dict-modal').on('shown.bs.modal', () => { + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $(".dict_query") .off("keyup") - .on("keyup", (evt) => { + .on("keyup", (evt: any) => { if (evt.which === 13) { evt.preventDefault(); this.lookupWord(null, null, '.dict_query'); } }); + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $(".dict_result").scrollTop(0); }); // TODO: make configurable + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $(".dict_search_btn").on("click", function() { + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $("#dict-modal").modal('hide'); + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message window.open("https://duckduckgo.com/?q=" + $(".dict_query").val()); }); @@ -757,14 +820,14 @@ class ReaderClass extends AppCommon { /** * @param {ePub.Book} book */ - initToc(book) { + initToc(book: any) { const _reader = this; - function toc_loc_msg(href) { + function toc_loc_msg(href: any) { try { const cfiBase = book.spine.get(href).cfiBase; - const loc = book.locations._locations.find(function(k) { + const loc = book.locations._locations.find(function(k: any) { return k.indexOf(cfiBase) != -1 }); @@ -783,16 +846,19 @@ class ReaderClass extends AppCommon { * @param {JQuery<HTMLElement>} list * @param {number} nest */ - function process_toc_sublist(row, list, nest) { + function process_toc_sublist(row: any, list: any, nest: any) { if (nest == 3) return false; if (row.subitems) { + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message const sublist = $("<ul class='toc_sublist list-unstyled'>"); - $.each(row.subitems, function(i, row) { + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message + $.each(row.subitems, function(i: any, row: any) { + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message const a = $("<a>") .attr('href', '#') .html("<b class='pull-right'>" + toc_loc_msg(row.href) + "</b>" + _reader.escapeHtml(row.label)) @@ -801,6 +867,7 @@ class ReaderClass extends AppCommon { book.rendition.display(a.attr('data-href')); }); + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message sublist.append($("<li>").append(a)); process_toc_sublist(row, sublist, nest + 1); @@ -811,17 +878,21 @@ class ReaderClass extends AppCommon { } } + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $('#toc-modal').on('shown.bs.modal', function() { const toc = book.navigation.toc; + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message const list = $(".toc_list"); list.html(""); - $.each(toc, function(i, row) { + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message + $.each(toc, function(i: any, row: any) { // if anything fails here the toc entry is likely useless anyway (i.e. no cfi) try { + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message const a = $("<a>") .attr('href', '#') .html("<b class='pull-right'>" + toc_loc_msg(row.href) + "</b>" + _reader.escapeHtml(row.label)) @@ -830,6 +901,7 @@ class ReaderClass extends AppCommon { book.rendition.display(a.attr('data-href')); }); + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message list.append($("<li>").append(a)); process_toc_sublist(row, list, 0); @@ -844,18 +916,20 @@ class ReaderClass extends AppCommon { list.html(""); - $.each(book.spine.items, function (i, row) { + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message + $.each(book.spine.items, function (i: any, row: any) { + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message const a = $("<a>") .attr('href', '#') .attr('title', row.url) - // @ts-ignore .html(`Section ${i+1}`) .attr('data-href', row.href) .on('click', () => { book.rendition.display(a.attr('data-href')); }); + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message list.append($("<li>").append(a)); }); @@ -868,18 +942,22 @@ class ReaderClass extends AppCommon { /** * @param {Document} doc */ - cleanupEmbeddedStyles(doc) { + cleanupEmbeddedStyles(doc: any) { + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $(doc).find("p") - // @ts-ignore - .filter((i, e) => (($(e).text().length >= MIN_LENGTH_TO_JUSTIFY) ? e : null)) + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message + .filter((i: any, e: any) => (($(e).text().length >= MIN_LENGTH_TO_JUSTIFY) ? e : null)) .css("text-align", "justify"); + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $(doc).find("html") .attr("class", ""); + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $(doc).find("pre") .css("white-space", "pre-wrap"); + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $(doc).find("a, p, span, em, i, strong, b, body, header, section, div, big, small, table, tr, td, th, ul, ol, li") .attr("class", "") .css("font-family", "inherit") @@ -893,6 +971,7 @@ class ReaderClass extends AppCommon { .attr("height", ""); // same as above except for allowed font-size + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $(doc).find("h1, h2, h3, h4, h5") .attr("class", "") .css("font-family", "inherit") @@ -901,20 +980,21 @@ class ReaderClass extends AppCommon { .css("background", "") .css("background-color", ""); - if (typeof this.hyphenate.en != "undefined") { - $(doc).find('p, div').each((i, elem) => { - const p = $(elem); - - p.html(this.hyphenate.en(p.html())); - p.html(this.hyphenate.ru(p.html())); - }); + if (typeof (this.hyphenate as any).en != "undefined") { + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message + $(doc).find('p, div').each((i: any, elem: any) => { + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message + const p = $(elem); + p.html((this.hyphenate as any).en(p.html())); + p.html((this.hyphenate as any).ru(p.html())); +}); } } /** * @param {string} base_url */ - generateFontsCss(base_url) { + generateFontsCss(base_url: any) { return ` /** Calibri */ @@ -1092,13 +1172,14 @@ class ReaderClass extends AppCommon { * @param {ePub.NavItem} entry * @param {number} nest */ - flattenTocSubItems(entry, nest) { - let rv = []; + flattenTocSubItems(entry: any, nest: any) { + let rv: any = []; if (nest == 3) return false; if (entry.subitems) { - $.each(entry.subitems, (i, r) => { + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message + $.each(entry.subitems, (i: any, r: any) => { r._nest = nest; rv.push(r); @@ -1114,14 +1195,14 @@ class ReaderClass extends AppCommon { * * @returns { ePub.NavItem[] } */ - flattenToc(book) { + flattenToc(book: any) { if (this._flattened_toc) { return this._flattened_toc; } else { - let rv = []; + let rv: any = []; - $.each(book.navigation.toc, (i, r) => { - // @ts-ignore + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message + $.each(book.navigation.toc, (i: any, r: any) => { r._nest = 0; rv.push(r); @@ -1138,21 +1219,25 @@ class ReaderClass extends AppCommon { * @param { ePub.Book } book * @param { any[] } toc */ - generateTocBar(book, toc) { + generateTocBar(book: any, toc: any) { + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $(".spacer") .html(""); - $.each(toc, function(i, te) { + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message + $.each(toc, function(i: any, te: any) { try { const cfiBase = book.spine.get(te.href).cfiBase; - const loc = book.locations._locations.find(function(k) { + const loc = book.locations._locations.find(function(k: any) { return k.indexOf(cfiBase) != -1 }); if (loc) { const pct = Math.round(book.locations.percentageFromCfi(loc) * 100); + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $(".spacer").append( + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $("<div class='toc-bar-entry'>") .attr('data-nest-level', te._nest) .css('left', pct + '%') @@ -1167,6 +1252,7 @@ class ReaderClass extends AppCommon { } }); + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $(".spacer").append($("<div class='toc-bar-entry current-position'>")); this.updateTocBarPosition(book, book.rendition.currentLocation()) @@ -1176,9 +1262,10 @@ class ReaderClass extends AppCommon { * @param {ePub.Book} book * @param {ePub.Location} location */ - updateTocBarPosition(book, location) { + updateTocBarPosition(book: any, location: any) { const cur_pct = Math.round(location.start.location / book.locations.length() * 100); + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $(".toc-bar-entry.current-position") .css('left', cur_pct + '%'); } @@ -1206,7 +1293,7 @@ class ReaderClass extends AppCommon { } }); - let theme = await localforage.getItem("epube.theme") || "default"; + let theme = (await localforage.getItem("epube.theme")) || "default"; console.log('called for theme', theme); @@ -1216,6 +1303,7 @@ class ReaderClass extends AppCommon { console.log('setting main UI theme', theme); + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $("body") .attr("class", typeof EpubeApp != "undefined" ? "is-epube-app" : "") .addClass("epube-reader theme-" + theme) @@ -1251,7 +1339,7 @@ class ReaderClass extends AppCommon { } if (this.book && this.book.rendition) - this.book.rendition.getContents().forEach((rendition) => { + this.book.rendition.getContents().forEach((rendition: any) => { console.log(`applying styles and theme ${theme} to `, rendition); rendition.css("font-size", fontSize); @@ -1259,6 +1347,7 @@ class ReaderClass extends AppCommon { rendition.css("line-height", lineHeight); rendition.css("text-align", 'justify'); + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $(rendition.document).find("body") .attr("class", typeof EpubeApp != "undefined" ? "is-epube-app" : "") .addClass("theme-" + theme); @@ -1268,10 +1357,11 @@ class ReaderClass extends AppCommon { /** * @param {JQuery.KeyUpEvent<Document, undefined, Document, Document>} e */ - hotkeyHandler(e) { + hotkeyHandler(e: any) { try { //console.log('K3:' + e.which, e); + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message if ($(".modal").is(":visible")) return; @@ -1298,10 +1388,11 @@ class ReaderClass extends AppCommon { } resizeSideColumns() { + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message let width = $("#reader").position().left; if (this.book && this.book.rendition) - this.book.rendition.getContents().forEach((rendition) => { + this.book.rendition.getContents().forEach((rendition: any) => { const body = rendition.document.querySelector('body'); if (body) @@ -1310,11 +1401,13 @@ class ReaderClass extends AppCommon { console.log(`resizing side columns to ${width} px`); + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $("#left, #right").width(width); } async markAsRead() { if (confirm("Mark book as read?")) { + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $("#settings-modal").modal('hide'); const total = 100; @@ -1324,6 +1417,7 @@ class ReaderClass extends AppCommon { if (this.isOnline()) { /** @type {HttpResponse} */ const data = await Http.post("backend.php", { op: "storelastread", page: String(total), cfi: lastCfi, id: this.urlParam("id"), timestamp: String(lastread_timestamp) }); + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $(".lastread_input").val(data.data.page + '%'); } @@ -1359,37 +1453,45 @@ class ReaderClass extends AppCommon { } /** @param {string} [suffix] */ - cacheId(suffix) { + cacheId(suffix: any) { return "epube-book." + this.urlParam("b") + (suffix ? "." + suffix : ""); } /** * @param {boolean} show */ - showUI(show) { + showUI(show: any) { if (show) + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $(".header,.footer").fadeIn(); else + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $(".header,.footer").fadeOut(); } toggleUI() { + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message if ($(".header").is(":visible")) + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $(".header,.footer").fadeOut(); else + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $(".header,.footer").fadeIn(); } - async lookupWord(word, callback, elem) { + async lookupWord(word: any, callback: any, elem: any) { if (elem) + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message word = $(elem).val(); word = word.replace(//g, ""); console.log('lookupWord', word); + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $(".dict_result").html('Loading, please wait...'); + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $("#dict-modal").modal('show'); try { @@ -1398,7 +1500,9 @@ class ReaderClass extends AppCommon { if (data.data) { - $(".dict_result").html(data.data.result.map((r) => this.escapeHtml(String(r))).join("<br/>")); + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message + $(".dict_result").html(data.data.result.map((r: any) => this.escapeHtml(String(r))).join("<br/>")); + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $(".dict_query").val(word); if (callback) callback(); @@ -1409,7 +1513,8 @@ class ReaderClass extends AppCommon { console.error(err); - $(".dict_result").html(`Network error while looking up word: ${this.escapeHtml((String)(err.responseText))}.`); + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message + $(".dict_result").html(`Network error while looking up word: ${this.escapeHtml((String)((err as any).responseText))}.`); } } @@ -1417,7 +1522,9 @@ class ReaderClass extends AppCommon { * @returns {Promise<void>} */ async search() { + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message const query = $(".search_input").val(); + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message const list = $(".search_results"); list.html(""); @@ -1428,7 +1535,7 @@ class ReaderClass extends AppCommon { try { const searchResults = await Promise.all( - this.book.spine.spineItems.map(async (item) => { + this.book.spine.spineItems.map(async (item: any) => { try { await item.load(this.book.load.bind(this.book)); const results = await item.find(`${query}`); @@ -1441,17 +1548,20 @@ class ReaderClass extends AppCommon { list.html(""); - searchResults.flat().forEach((row) => { + searchResults.flat().forEach((row: any) => { console.log('sr', row); + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message const a = $("<a>") .attr('href', '#') .html(`<b class='pull-right'>${this.book.locations.locationFromCfi(row.cfi)}</b>${this.escapeHtml(row.excerpt)}`) .attr('data-cfi', row.cfi) .on('click', () => { + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message this.book.rendition.display($(a).attr('data-cfi')); }); + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message list.append($("<li>").append(a)); }); } catch (e) { @@ -1465,7 +1575,7 @@ class ReaderClass extends AppCommon { if (typeof EpubeApp != "undefined") EpubeApp.showActionBar(false); else - localforage.getItem("epube.keep-ui-visible").then((keep) => { + localforage.getItem("epube.keep-ui-visible").then((keep: any) => { if (!keep) this.showUI(false); }); } @@ -1476,7 +1586,7 @@ class ReaderClass extends AppCommon { if (typeof EpubeApp != "undefined") EpubeApp.showActionBar(false); else - localforage.getItem("epube.keep-ui-visible").then((keep) => { + localforage.getItem("epube.keep-ui-visible").then((keep: any) => { if (!keep) this.showUI(false); }); } @@ -1484,12 +1594,14 @@ class ReaderClass extends AppCommon { /** * @param {HTMLElement} elem */ - async openPrevious(elem) { + async openPrevious(elem: any) { + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message const cfi = $(elem).attr("data-location-cfi"); if (cfi) await this.book.rendition.display(cfi); + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $(elem).fadeOut(); } @@ -1512,7 +1624,7 @@ class ReaderClass extends AppCommon { * @param { ePub.Book } book * @param { ePub.Location } location */ - async onRelocated(book, location) { + async onRelocated(book: any, location: any) { // locations not generated yet if (book.locations.length() == 0) return; @@ -1520,8 +1632,11 @@ class ReaderClass extends AppCommon { const currentCfi = location.start.cfi; const currentPct = Math.round(book.locations.percentageFromCfi(currentCfi) * 100); + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $("#cur_page").text(Math.floor(location.start.location / LOCATION_DIVISOR)); + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $("#total_pages").text(Math.floor(book.locations.length() / LOCATION_DIVISOR)); + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $("#page_pct").text(Math.round(book.locations.percentageFromCfi(currentCfi)*100) + '%'); this.updateTocBarPosition(book, location); @@ -1529,10 +1644,13 @@ class ReaderClass extends AppCommon { const displayed = location.start.displayed; if (displayed) { + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $("#chapter_cur_page").text(displayed.page); + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $("#chapter_total_pages").text(displayed.total); if (displayed.total > 0) + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $("#chapter_pct").text(Math.round(displayed.page / displayed.total * 100) + '%') } @@ -1558,6 +1676,7 @@ class ReaderClass extends AppCommon { async clearLastRead() { if (confirm("Reset reading progress for this book?")) { + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $("#settings-modal").modal('hide'); const total = this.book.locations.length(); @@ -1571,12 +1690,14 @@ class ReaderClass extends AppCommon { await this.book.rendition.display(this.book.locations.cfiFromPercentage(0)); + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $(".lastread_input").val('0%'); } } async resetLocations() { if (confirm("Reset stored pagination data? This will also reset reading progress.")) { + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $("#settings-modal").modal('hide'); await localforage.removeItem(this.cacheId("lastread")); @@ -1593,9 +1714,12 @@ class ReaderClass extends AppCommon { } async openLastRead() { + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $(".loading").show(); + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $(".loading-message").html("Opening last read page…"); + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $("#settings-modal").modal('hide'); const rendition = this.book.rendition; @@ -1607,7 +1731,7 @@ class ReaderClass extends AppCommon { let location_found = false; - const lr_local = await localforage.getItem(this.cacheId("lastread")) || {}; + const lr_local = (await localforage.getItem(this.cacheId("lastread"))) || {}; console.log('got local lastread', lr_local); if (this.isOnline()) { @@ -1646,6 +1770,7 @@ class ReaderClass extends AppCommon { } } + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $(".loading").fadeOut(); } @@ -1653,13 +1778,13 @@ class ReaderClass extends AppCommon { * @param {?string} a * @param {?string} b */ - calculateCfiDelta(a, b) { + calculateCfiDelta(a: any, b: any) { if (!a || !b) return -1; - // @ts-ignore + // @ts-expect-error TS(2304): Cannot find name 'ePub'. const acfi = new ePub.CFI(a); - // @ts-ignore + // @ts-expect-error TS(2304): Cannot find name 'ePub'. const bcfi = new ePub.CFI(b); console.log('calculateCfiDelta', acfi, bcfi); @@ -1691,7 +1816,7 @@ class ReaderClass extends AppCommon { * @param {ePub.Rendition} rendition * @param {string} cfi */ - async moveToCfiVerify(rendition, cfi, attempts = 5, maxDelta = 5) { + async moveToCfiVerify(rendition: any, cfi: any, attempts = 5, maxDelta = 5) { for (let att = 1; att < attempts; att++) { this.blockLastReadUpdate(); @@ -1728,7 +1853,8 @@ class ReaderClass extends AppCommon { /** * @param {HTMLElement} elem */ - async onThemeChanged(elem) { + async onThemeChanged(elem: any) { + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message const theme = $(elem).val(); await localforage.setItem("epube.theme", theme); @@ -1738,7 +1864,8 @@ class ReaderClass extends AppCommon { /** * @param {HTMLElement} elem */ - async onLineHeightChanged(elem) { + async onLineHeightChanged(elem: any) { + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message const height = $(elem).val(); await localforage.setItem("epube.lineHeight", height); @@ -1748,7 +1875,8 @@ class ReaderClass extends AppCommon { /** * @param {HTMLElement} elem */ - async onTextSizeChanged(elem) { + async onTextSizeChanged(elem: any) { + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message const size = $(elem).val(); await localforage.setItem("epube.fontSize", size); @@ -1758,7 +1886,8 @@ class ReaderClass extends AppCommon { /** * @param {HTMLElement} elem */ - async onFontChanged(elem) { + async onFontChanged(elem: any) { + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message const font = $(elem).val(); await localforage.setItem("epube.fontFamily", font); @@ -1772,12 +1901,13 @@ class ReaderLoader { /** * @param {ReaderClass} app */ - async init(app) { + async init(app: any) { const cacheName = await app.getActiveCacheName(); console.log('loader init for cache:', cacheName); if (typeof EpubeApp != "undefined") { + // @ts-expect-error TS(2581): Cannot find name '$'. Do you need to install type ... Remove this comment to see the full error message $("body").addClass("epube-app"); } @@ -1808,10 +1938,12 @@ class ReaderLoader { let promise; if (req.url.match(/\.(ttf|otf)$/)) { promise = response.blob().then((blob) => { + // @ts-expect-error TS(7053): Element implicitly has an 'any' type because expre... Remove this comment to see the full error message this._res_data[key] = URL.createObjectURL(blob); }); } else { promise = response.text().then((text) => { + // @ts-expect-error TS(7053): Element implicitly has an 'any' type because expre... Remove this comment to see the full error message this._res_data[key] = text; }); } @@ -1822,6 +1954,7 @@ class ReaderLoader { })); } + // @ts-expect-error TS(2550): Property 'allSettled' does not exist on type 'Prom... Remove this comment to see the full error message await Promise.allSettled(promises); if (Object.keys(this._res_data).length === 0) loadFailed = true; |
