Skip to content

Commit 9520faa

Browse files
committed
New: Show the current reading title in app window
1 parent 1485b25 commit 9520faa

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
1111
- Show error message if continue reading file does not exist [`7aee55c`](https://github.com/ollm/OpenComic/commit/7aee55ca5dac6b937824728b7ded116dc00c28df)
1212
- Support background music from folder: MP3, M4A, WEBM, WEBA, OGG, OPUS, WAV, FLAC [`26947a2`](https://github.com/ollm/OpenComic/commit/26947a297868e86069cc6daca77e1a3f016d0705)
1313
- Now when applying Webtoon mode the vertical margin is 0 [`683a08a`](https://github.com/ollm/OpenComic/commit/683a08aad3a6d947004ad77476184d613718b098)
14+
- Show the current reading title in app window
1415

1516
##### 🐛 Bug Fixes
1617

scripts/dom.js

+17-4
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,12 @@ function addImageToDom(querySelector, path, animation = true)
138138
}
139139
}
140140

141+
function setWindowTitle(title = 'OpenComic')
142+
{
143+
let _title = document.querySelector('head title');
144+
_title.innerText = title;
145+
}
146+
141147
function translatePageName(name)
142148
{
143149
name = name.replace(/^[0-9]+\_sortonly - /, '');
@@ -365,6 +371,7 @@ async function loadIndexPage(animation = true, path = false, content = false, ke
365371
reading.music.pause();
366372

367373
generateAppMenu();
374+
setWindowTitle();
368375

369376
currentPathScrollTop[currentPath === false ? 0 : currentPath] = template.contentRight().children().scrollTop();
370377

@@ -985,7 +992,7 @@ function fromLibrary(value)
985992
isFromLibrary = value;
986993
}
987994

988-
function headerPath(path, mainPath)
995+
function headerPath(path, mainPath, windowTitle = false)
989996
{
990997
let _mainPath = mainPath;
991998

@@ -1005,8 +1012,13 @@ function headerPath(path, mainPath)
10051012
path.push({name: metadataPathName({path: _path, name: files[i]}, true), path: _path, mainPath: mainPath});
10061013
}
10071014

1008-
if(path.length > 0)
1009-
path[path.length - 1].last = true;
1015+
let len = path.length;
1016+
1017+
if(len > 0)
1018+
path[len - 1].last = true;
1019+
1020+
if(windowTitle && len > 0)
1021+
setWindowTitle(path[len - 1].name);
10101022

10111023
handlebarsContext.headerTitlePath = path;
10121024
}
@@ -1934,7 +1946,7 @@ async function openComic(animation = true, path = true, mainPath = true, end = f
19341946
}
19351947

19361948
// Show loadign page
1937-
headerPath(path, mainPath);
1949+
headerPath(path, mainPath, true);
19381950

19391951
// Load files
19401952
let file = fileManager.file(path);
@@ -2202,6 +2214,7 @@ module.exports = {
22022214
getFolderThumbnails: getFolderThumbnails,
22032215
translatePageName: translatePageName,
22042216
metadataPathName: metadataPathName,
2217+
setWindowTitle: setWindowTitle,
22052218
fromLibrary: fromLibrary,
22062219
continueReadingError: continueReadingError,
22072220
poster: domPoster,

0 commit comments

Comments
 (0)