diff options
| author | Andrew Dolgov <fox@fakecake.org> | 2026-05-24 21:11:15 +0300 |
|---|---|---|
| committer | Andrew Dolgov <fox@fakecake.org> | 2026-05-24 21:11:15 +0300 |
| commit | ce40334f1a4708958b38c8565635019e4fbeefb9 (patch) | |
| tree | 1111c4ce4483f543a3bd3729228d8e04e2ad24ce /src | |
| parent | 76b2eb6f191c535a428ee71c74c406dc9d206d9e (diff) | |
| download | the-epube-ce40334f1a4708958b38c8565635019e4fbeefb9.tar.gz the-epube-ce40334f1a4708958b38c8565635019e4fbeefb9.tar.xz | |
remove inline event handlers, bring back html book descriptions
Diffstat (limited to 'src')
| -rw-r--r-- | src/app.js | 84 |
1 files changed, 63 insertions, 21 deletions
diff --git a/src/app.js b/src/app.js index fb20538..f83817b 100644 --- a/src/app.js +++ b/src/app.js @@ -159,6 +159,39 @@ class AppClass extends AppCommon { $(".logout_link").on('click', () => { this.logout(); }); + + $(".download_all_link").on('click', (e) => { + e.preventDefault(); + this.getAll(); + }); + + $(".summary_link").on('click', (e) => { + e.preventDefault(); + this.showSummary(e.currentTarget); + }); + + $(".fav_item").on('click', (e) => { + e.preventDefault(); + this.toggleFavorite(e.currentTarget); + }); + + $(".offline_dropitem").on('click', async (e) => { + e.preventDefault(); + const bookId = e.currentTarget.getAttribute("data-book-id"); + const cacheId = "epube-book." + bookId; + const book = await localforage.getItem(cacheId); + + if (book) { + this.remove(bookId, () => { + this.updateOfflinePrompt(e.currentTarget); + }); + } else { + this.get(bookId, () => { + this.updateOfflinePrompt(e.currentTarget); + }); + } + }); + } logout() { @@ -176,7 +209,7 @@ class AppClass extends AppCommon { const comment = data.comment ? data.comment : 'No description available'; $("#summary-modal .modal-title").text(data.title); - $("#summary-modal .book-summary").text(comment); + $("#summary-modal .book-summary").html(comment); $("#summary-modal").modal(); @@ -185,7 +218,7 @@ class AppClass extends AppCommon { const comment = data.comment ? data.comment : 'No description available'; $("#summary-modal .modal-title").text(data.title); - $("#summary-modal .book-summary").text(comment); + $("#summary-modal .book-summary").html(comment); $("#summary-modal").modal(); } @@ -498,7 +531,7 @@ class AppClass extends AppCommon { const books = $("#books_container"); books.html(""); - localforage.iterate(function(value, key/*, i*/) { + localforage.iterate((value, key/*, i*/) => { if (key.match(/epube-book\.\d{1,}$/)) { Promise.all([ @@ -506,7 +539,7 @@ class AppClass extends AppCommon { localforage.getItem(key + ".cover"), localforage.getItem(key + ".lastread"), localforage.getItem(key + ".book") - ]).then(function(results) { + ]).then((results) => { if (results[0] && results[3]) { const info = results[0]; @@ -520,7 +553,6 @@ class AppClass extends AppCommon { if (!match) return; } - let cover = ""; if (results && results[1]) { @@ -542,22 +574,32 @@ class AppClass extends AppCommon { const series_link = info.series_name ? `<div><a class="series_link" href="#">${info.series_name + " [" + info.series_index + "]"}</a></div>` : ""; const cell = $(`<div class="col-xxs-6 col-xs-4 col-sm-3 col-md-2" id="cell-${info.id}"> - <a class="thumbnail ${thumb_class}" href="read.html?id=${info.epub_id}&b=${info.id}"> - <img style="display : none"> - </a> - <div class="caption"> - <div><a class="${title_class}" href="read.html?id=${info.epub_id}&b=${info.id}">${info.title}</a></div> - <div><a class="author_link" href="#">${info.author_sort}</a></div> - ${series_link} - </div> - <div class="dropdown" style="white-space : nowrap"> - <a href="#" data-toggle="dropdown" role="button">More...<span class="caret"></span></a> - <ul class="dropdown-menu"> - <li><a href="#" data-book-id="${info.id}" onclick="return App.showSummary(this)">Summary</a></li> - <li><a href="#" data-book-id="${info.id}" onclick="App.removeFromList(this)">Remove offline data</a></li> - </ul> - </div> - </div>`); + <a class="thumbnail ${thumb_class}" href="read.html?id=${info.epub_id}&b=${info.id}"> + <img style="display : none"> + </a> + <div class="caption"> + <div><a class="${title_class}" href="read.html?id=${info.epub_id}&b=${info.id}">${info.title}</a></div> + <div><a class="author_link" href="#">${info.author_sort}</a></div> + ${series_link} + </div> + <div class="dropdown" style="white-space : nowrap"> + <a href="#" data-toggle="dropdown" role="button">More...<span class="caret"></span></a> + <ul class="dropdown-menu"> + <li><a href="#" class="offline_summary" data-book-id="${info.id}">Summary</a></li> + <li><a href="#" class="remove_offline_data" data-book-id="${info.id}">Remove offline data</a></li> + </ul> + </div> + </div>`); + + $(cell).find(".offline_summary").on('click', (e) => { + e.preventDefault(); + this.showSummary(e.currentTarget); + }); + + $(cell).find(".remove_offline_data").on('click', (e) => { + e.preventDefault(); + this.removeFromList(e.currentTarget); + }); if (cover) { cell.find("img") |
