mirror of
https://github.com/jellyfin/jellyfin-web.git
synced 2024-11-17 19:08:18 -07:00
Use object to return multiple info instead of array.
This commit is contained in:
parent
b78d6439b0
commit
ba2c365ac9
@ -1577,25 +1577,26 @@ import { setBackdropTransparency, TRANSPARENCY_LEVEL } from '../../../components
|
||||
nowPlayingPositionSlider.getChapterNamesAndFractions = function () {
|
||||
showOsd();
|
||||
|
||||
const markers = [];
|
||||
|
||||
const item = currentItem;
|
||||
|
||||
if (item && item.Chapters && item.Chapters.length) {
|
||||
const chapterNames = [];
|
||||
const chapterFractions = [];
|
||||
const runtimeDuration = item.RunTimeTicks;
|
||||
|
||||
for (let i = 0, length = item.Chapters.length; i < length; i++) {
|
||||
const currentChapter = item.Chapters[i];
|
||||
|
||||
const fraction = currentChapter.StartPositionTicks / runtimeDuration;
|
||||
chapterFractions.push(fraction);
|
||||
chapterNames.push(currentChapter.Name);
|
||||
}
|
||||
|
||||
return [chapterNames, chapterFractions];
|
||||
markers.push({
|
||||
name: currentChapter.Name,
|
||||
progress: fraction
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return [[], []];
|
||||
return markers;
|
||||
};
|
||||
|
||||
view.querySelector('.btnPreviousTrack').addEventListener('click', function () {
|
||||
|
@ -163,20 +163,19 @@ import '../emby-input/emby-input';
|
||||
}
|
||||
|
||||
function updateChapterMarks(range, currentValue) {
|
||||
if (range.chapterFractions && range.chapterFractions.length && range.chapterMarkElements && range.chapterMarkElements.length) {
|
||||
if (range.chapterInfo && range.chapterInfo.length && range.chapterMarkElements && range.chapterMarkElements.length) {
|
||||
for (let i = 0, length = range.chapterMarkElements.length; i < length; i++) {
|
||||
if (range.chapterFractions.length > i) {
|
||||
setChapterMark(range, mapFractionToValue(range, range.chapterFractions[i]), range.chapterMarkElements[i], currentValue);
|
||||
if (range.chapterInfo.length > i) {
|
||||
setChapterMark(range, mapFractionToValue(range, range.chapterInfo[i].progress), range.chapterMarkElements[i], currentValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function addChapterMarks(range) {
|
||||
range.chapterNames = [];
|
||||
range.chapterFractions = [];
|
||||
range.chapterInfo = [];
|
||||
if (range.getChapterNamesAndFractions) {
|
||||
[range.chapterNames, range.chapterFractions] = range.getChapterNamesAndFractions();
|
||||
range.chapterInfo = range.getChapterNamesAndFractions();
|
||||
}
|
||||
|
||||
function htmlToInsert(chapterName) {
|
||||
@ -188,8 +187,8 @@ import '../emby-input/emby-input';
|
||||
return `<span class="material-icons sliderChapterMark ${classChapterName}" aria-hidden="true"></span>`;
|
||||
}
|
||||
|
||||
range.chapterNames.forEach(chapterName => {
|
||||
range.chapterMarkContainerElement.insertAdjacentHTML('beforeend', htmlToInsert(chapterName || ''));
|
||||
range.chapterInfo.forEach(chapter => {
|
||||
range.chapterMarkContainerElement.insertAdjacentHTML('beforeend', htmlToInsert(chapter.name || ''));
|
||||
});
|
||||
|
||||
range.chapterMarkElements = range.chapterMarkContainerElement.querySelectorAll('.sliderChapterMark');
|
||||
|
Loading…
Reference in New Issue
Block a user