Use object to return multiple info instead of array.

This commit is contained in:
Viperinius 2022-07-05 16:31:48 +02:00
parent b78d6439b0
commit ba2c365ac9
2 changed files with 15 additions and 15 deletions

View File

@ -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);
markers.push({
name: currentChapter.Name,
progress: fraction
});
}
}
return [chapterNames, chapterFractions];
}
return [[], []];
return markers;
};
view.querySelector('.btnPreviousTrack').addEventListener('click', function () {

View File

@ -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');