Skip to content

Commit

Permalink
New: Show the current reading title in app window
Browse files Browse the repository at this point in the history
  • Loading branch information
ollm committed Jan 25, 2024
1 parent 1485b25 commit 9520faa
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
21 changes: 17 additions & 4 deletions scripts/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 - /, '');
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -985,7 +992,7 @@ function fromLibrary(value)
isFromLibrary = value;
}

function headerPath(path, mainPath)
function headerPath(path, mainPath, windowTitle = false)
{
let _mainPath = mainPath;

Expand All @@ -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;
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -2202,6 +2214,7 @@ module.exports = {
getFolderThumbnails: getFolderThumbnails,
translatePageName: translatePageName,
metadataPathName: metadataPathName,
setWindowTitle: setWindowTitle,
fromLibrary: fromLibrary,
continueReadingError: continueReadingError,
poster: domPoster,
Expand Down

0 comments on commit 9520faa

Please sign in to comment.