mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Change chapter mark classes to include name info.
In order to use different icons depending on the chapter name, the name is provided as a class with the prefix scm-.
This commit is contained in:
parent
20a1c34ea8
commit
b78d6439b0
2 changed files with 18 additions and 8 deletions
|
@ -173,15 +173,23 @@ import '../emby-input/emby-input';
|
|||
}
|
||||
|
||||
function addChapterMarks(range) {
|
||||
range.chapterNames = [];
|
||||
range.chapterFractions = [];
|
||||
if (range.getChapterFractions) {
|
||||
range.chapterFractions = range.getChapterFractions();
|
||||
if (range.getChapterNamesAndFractions) {
|
||||
[range.chapterNames, range.chapterFractions] = range.getChapterNamesAndFractions();
|
||||
}
|
||||
|
||||
const htmlToInsert = '<span class="material-icons sliderChapterMark" aria-hidden="true"></span>';
|
||||
function htmlToInsert(chapterName) {
|
||||
let classChapterName = '';
|
||||
if (typeof chapterName === 'string' && chapterName.length) {
|
||||
// limit the class length in case the name contains half a novel
|
||||
classChapterName = `scm-${chapterName.substring(0, 100).toLowerCase().replace(' ', '-')}`;
|
||||
}
|
||||
return `<span class="material-icons sliderChapterMark ${classChapterName}" aria-hidden="true"></span>`;
|
||||
}
|
||||
|
||||
range.chapterFractions.forEach(() => {
|
||||
range.chapterMarkContainerElement.insertAdjacentHTML('beforeend', htmlToInsert);
|
||||
range.chapterNames.forEach(chapterName => {
|
||||
range.chapterMarkContainerElement.insertAdjacentHTML('beforeend', htmlToInsert(chapterName || ''));
|
||||
});
|
||||
|
||||
range.chapterMarkElements = range.chapterMarkContainerElement.querySelectorAll('.sliderChapterMark');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue