From 9520faa7486e4494bb878ffe2430e9fd198ee33a Mon Sep 17 00:00:00 2001 From: Oleguer Llopart Date: Thu, 25 Jan 2024 18:21:43 +0100 Subject: [PATCH] New: Show the current reading title in app window --- CHANGELOG.md | 1 + scripts/dom.js | 21 +++++++++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ea340dfe7..96d646f2b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - Show error message if continue reading file does not exist [`7aee55c`](https://github.com/ollm/OpenComic/commit/7aee55ca5dac6b937824728b7ded116dc00c28df) - Support background music from folder: MP3, M4A, WEBM, WEBA, OGG, OPUS, WAV, FLAC [`26947a2`](https://github.com/ollm/OpenComic/commit/26947a297868e86069cc6daca77e1a3f016d0705) - Now when applying Webtoon mode the vertical margin is 0 [`683a08a`](https://github.com/ollm/OpenComic/commit/683a08aad3a6d947004ad77476184d613718b098) +- Show the current reading title in app window ##### 🐛 Bug Fixes diff --git a/scripts/dom.js b/scripts/dom.js index b8260d489..2054c856a 100644 --- a/scripts/dom.js +++ b/scripts/dom.js @@ -138,6 +138,12 @@ function addImageToDom(querySelector, path, animation = true) } } +function setWindowTitle(title = 'OpenComic') +{ + let _title = document.querySelector('head title'); + _title.innerText = title; +} + function translatePageName(name) { name = name.replace(/^[0-9]+\_sortonly - /, ''); @@ -365,6 +371,7 @@ async function loadIndexPage(animation = true, path = false, content = false, ke reading.music.pause(); generateAppMenu(); + setWindowTitle(); currentPathScrollTop[currentPath === false ? 0 : currentPath] = template.contentRight().children().scrollTop(); @@ -985,7 +992,7 @@ function fromLibrary(value) isFromLibrary = value; } -function headerPath(path, mainPath) +function headerPath(path, mainPath, windowTitle = false) { let _mainPath = mainPath; @@ -1005,8 +1012,13 @@ function headerPath(path, mainPath) path.push({name: metadataPathName({path: _path, name: files[i]}, true), path: _path, mainPath: mainPath}); } - if(path.length > 0) - path[path.length - 1].last = true; + let len = path.length; + + if(len > 0) + path[len - 1].last = true; + + if(windowTitle && len > 0) + setWindowTitle(path[len - 1].name); handlebarsContext.headerTitlePath = path; } @@ -1934,7 +1946,7 @@ async function openComic(animation = true, path = true, mainPath = true, end = f } // Show loadign page - headerPath(path, mainPath); + headerPath(path, mainPath, true); // Load files let file = fileManager.file(path); @@ -2202,6 +2214,7 @@ module.exports = { getFolderThumbnails: getFolderThumbnails, translatePageName: translatePageName, metadataPathName: metadataPathName, + setWindowTitle: setWindowTitle, fromLibrary: fromLibrary, continueReadingError: continueReadingError, poster: domPoster,