From 295cab93f39a800154225672f5b400370dfe0974 Mon Sep 17 00:00:00 2001 From: lenafx Date: Sat, 27 Dec 2025 20:35:57 +0100 Subject: [PATCH] enhanced list modal and fixes --- desktop/src/scripts/anime/anime.js | 2 +- desktop/src/scripts/anime/animes.js | 1 + desktop/src/scripts/books/book.js | 3 +- desktop/src/scripts/books/books.js | 3 +- desktop/src/scripts/gallery/gallery.js | 2 +- desktop/src/scripts/list.js | 2 +- .../src/scripts/utils/list-modal-manager.js | 32 +++-- desktop/views/anime/anime.html | 69 ---------- desktop/views/anime/animes.html | 67 ---------- desktop/views/books/book.html | 66 ---------- desktop/views/books/books.html | 66 ---------- desktop/views/components/list-modal.html | 66 ++++++++++ desktop/views/list.html | 71 ---------- docker/src/scripts/anime/anime.js | 2 +- docker/src/scripts/anime/animes.js | 1 + docker/src/scripts/books/book.js | 2 + docker/src/scripts/books/books.js | 3 +- docker/src/scripts/gallery/gallery.js | 2 +- .../src/scripts/utils/list-modal-manager.js | 32 +++-- docker/views/anime/anime.html | 124 ------------------ docker/views/anime/animes.html | 67 ---------- docker/views/books/book.html | 66 ---------- docker/views/books/books.html | 66 ---------- docker/views/components/list-modal.html | 66 ++++++++++ docker/views/list.html | 71 ---------- 25 files changed, 191 insertions(+), 761 deletions(-) create mode 100644 desktop/views/components/list-modal.html create mode 100644 docker/views/components/list-modal.html diff --git a/desktop/src/scripts/anime/anime.js b/desktop/src/scripts/anime/anime.js index 2ea41f0..b637837 100644 --- a/desktop/src/scripts/anime/anime.js +++ b/desktop/src/scripts/anime/anime.js @@ -64,7 +64,7 @@ async function loadAnime() { } animeData = data; - + animeData.entry_type = 'ANIME'; const metadata = MediaMetadataUtils.formatAnimeData(data, !!extensionName); updatePageTitle(metadata.title); diff --git a/desktop/src/scripts/anime/animes.js b/desktop/src/scripts/anime/animes.js index 3f18f32..c9a0224 100644 --- a/desktop/src/scripts/anime/animes.js +++ b/desktop/src/scripts/anime/animes.js @@ -92,6 +92,7 @@ function startHeroCycle() { async function updateHeroUI(anime) { if(!anime) return; + anime.entry_type = 'ANIME'; const title = anime.title.english || anime.title.romaji || "Unknown Title"; const score = anime.averageScore ? anime.averageScore + '% Match' : 'N/A'; diff --git a/desktop/src/scripts/books/book.js b/desktop/src/scripts/books/book.js index 22f2cb6..2ee4a93 100644 --- a/desktop/src/scripts/books/book.js +++ b/desktop/src/scripts/books/book.js @@ -69,7 +69,8 @@ async function loadBookMetadata() { bookData = raw; const metadata = MediaMetadataUtils.formatBookData(raw, !!extensionName); - + bookData.entry_type = + metadata.format === 'MANGA' ? 'MANGA' : 'NOVEL'; updatePageTitle(metadata.title); updateMetadata(metadata); updateExtensionPill(); diff --git a/desktop/src/scripts/books/books.js b/desktop/src/scripts/books/books.js index 95de71a..2891158 100644 --- a/desktop/src/scripts/books/books.js +++ b/desktop/src/scripts/books/books.js @@ -55,7 +55,8 @@ function startHeroCycle() { async function updateHeroUI(book) { if(!book) return; - + book.entry_type = + book.format === 'MANGA' ? 'MANGA' : 'NOVEL'; const title = book.title.english || book.title.romaji; const desc = book.description || "No description available."; const poster = (book.coverImage && (book.coverImage.extraLarge || book.coverImage.large)) || ''; diff --git a/desktop/src/scripts/gallery/gallery.js b/desktop/src/scripts/gallery/gallery.js index 06c46ff..8d9433e 100644 --- a/desktop/src/scripts/gallery/gallery.js +++ b/desktop/src/scripts/gallery/gallery.js @@ -299,7 +299,7 @@ async function searchGallery(isLoadMore = false) { const msg = favoritesMode ? (query ? 'No favorites found matching your search' : 'You don\'t have any favorite images yet') : 'No results found'; - resultsContainer.innerHTML = `

${msg}

`; + resultsContainer.innerHTML = `

${msg}

`; } if (msnry) msnry.layout(); diff --git a/desktop/src/scripts/list.js b/desktop/src/scripts/list.js index 6691863..3271bdb 100644 --- a/desktop/src/scripts/list.js +++ b/desktop/src/scripts/list.js @@ -284,7 +284,7 @@ function createListItem(item) { const itemLink = getEntryLink(item); - const posterUrl = item.poster || '/public/assets/placeholder.png'; + const posterUrl = item.poster || '/public/assets/placeholder.svg'; const progress = item.progress || 0; const totalUnits = item.entry_type === 'ANIME' ? diff --git a/desktop/src/scripts/utils/list-modal-manager.js b/desktop/src/scripts/utils/list-modal-manager.js index be33a4a..5d61eef 100644 --- a/desktop/src/scripts/utils/list-modal-manager.js +++ b/desktop/src/scripts/utils/list-modal-manager.js @@ -83,7 +83,7 @@ const ListModalManager = { document.getElementById('progress-label'); if (this.isInList && this.currentEntry) { - document.getElementById('entry-status').value = this.currentEntry.status || 'PLANNING'; + document.getElementById('entry-status').value = this.normalizeStatus(this.currentEntry.status); document.getElementById('entry-progress').value = this.currentEntry.progress || 0; document.getElementById('entry-score').value = this.currentEntry.score || ''; document.getElementById('entry-start-date').value = this.currentEntry.start_date?.split('T')[0] || ''; @@ -131,6 +131,12 @@ const ListModalManager = { document.getElementById('add-list-modal').classList.add('active'); }, + normalizeStatus(status) { + if (!status) return 'PLANNING'; + if (status === 'WATCHING' || status === 'READING') return 'CURRENT'; + return status; + }, + close() { document.getElementById('add-list-modal').classList.remove('active'); }, @@ -212,15 +218,21 @@ const ListModalManager = { } }; -document.addEventListener('DOMContentLoaded', () => { +async function loadListModal() { + if (document.getElementById('add-list-modal')) return; + + const res = await fetch('/views/components/list-modal.html'); + const html = await res.text(); + document.body.insertAdjacentHTML('beforeend', html); + const modal = document.getElementById('add-list-modal'); - if (modal) { - modal.addEventListener('click', (e) => { - if (e.target.id === 'add-list-modal') { - ListModalManager.close(); - } - }); - } -}); + modal.addEventListener('click', (e) => { + if (e.target.id === 'add-list-modal') { + ListModalManager.close(); + } + }); +} + +document.addEventListener('DOMContentLoaded', loadListModal); window.ListModalManager = ListModalManager; \ No newline at end of file diff --git a/desktop/views/anime/anime.html b/desktop/views/anime/anime.html index b962931..ae75aaa 100644 --- a/desktop/views/anime/anime.html +++ b/desktop/views/anime/anime.html @@ -34,75 +34,6 @@ - - Back to Home diff --git a/desktop/views/anime/animes.html b/desktop/views/anime/animes.html index f8a8e04..801c84f 100644 --- a/desktop/views/anime/animes.html +++ b/desktop/views/anime/animes.html @@ -157,73 +157,6 @@ - - - Back to Books diff --git a/desktop/views/books/books.html b/desktop/views/books/books.html index c18f419..46c9ab5 100644 --- a/desktop/views/books/books.html +++ b/desktop/views/books/books.html @@ -51,72 +51,6 @@ -
diff --git a/desktop/views/components/list-modal.html b/desktop/views/components/list-modal.html new file mode 100644 index 0000000..ad89e9b --- /dev/null +++ b/desktop/views/components/list-modal.html @@ -0,0 +1,66 @@ + \ No newline at end of file diff --git a/desktop/views/list.html b/desktop/views/list.html index c5e58fc..dc660e8 100644 --- a/desktop/views/list.html +++ b/desktop/views/list.html @@ -127,77 +127,6 @@
- -
- -
- - -
diff --git a/docker/views/components/list-modal.html b/docker/views/components/list-modal.html new file mode 100644 index 0000000..ad89e9b --- /dev/null +++ b/docker/views/components/list-modal.html @@ -0,0 +1,66 @@ + \ No newline at end of file diff --git a/docker/views/list.html b/docker/views/list.html index a937712..4e46327 100644 --- a/docker/views/list.html +++ b/docker/views/list.html @@ -115,77 +115,6 @@
- -