2020-05-04 03:44:12 -07:00
|
|
|
define(['loading', 'appRouter', 'layoutManager', 'connectionManager', 'userSettings', 'cardBuilder', 'datetime', 'mediaInfo', 'backdrop', 'listView', 'itemContextMenu', 'itemHelper', 'dom', 'indicators', 'imageLoader', 'libraryMenu', 'globalize', 'browser', 'events', 'playbackManager', 'scrollStyles', 'emby-itemscontainer', 'emby-checkbox', 'emby-button', 'emby-playstatebutton', 'emby-ratingbutton', 'emby-scroller', 'emby-select'], function (loading, appRouter, layoutManager, connectionManager, userSettings, cardBuilder, datetime, mediaInfo, backdrop, listView, itemContextMenu, itemHelper, dom, indicators, imageLoader, libraryMenu, globalize, browser, events, playbackManager) {
|
|
|
|
'use strict';
|
2018-10-22 15:05:09 -07:00
|
|
|
|
|
|
|
function getPromise(apiClient, params) {
|
|
|
|
var id = params.id;
|
2019-11-06 03:43:39 -07:00
|
|
|
|
|
|
|
if (id) {
|
|
|
|
return apiClient.getItem(apiClient.getCurrentUserId(), id);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (params.seriesTimerId) {
|
|
|
|
return apiClient.getLiveTvSeriesTimer(params.seriesTimerId);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (params.genre) {
|
|
|
|
return apiClient.getGenre(params.genre, apiClient.getCurrentUserId());
|
|
|
|
}
|
|
|
|
|
|
|
|
if (params.musicgenre) {
|
|
|
|
return apiClient.getMusicGenre(params.musicgenre, apiClient.getCurrentUserId());
|
|
|
|
}
|
|
|
|
|
|
|
|
if (params.musicartist) {
|
|
|
|
return apiClient.getArtist(params.musicartist, apiClient.getCurrentUserId());
|
|
|
|
}
|
|
|
|
|
2020-05-04 03:44:12 -07:00
|
|
|
throw new Error('Invalid request');
|
2018-10-22 15:05:09 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function hideAll(page, className, show) {
|
2019-11-06 03:43:39 -07:00
|
|
|
var i;
|
|
|
|
var length;
|
2020-05-04 03:44:12 -07:00
|
|
|
var elems = page.querySelectorAll('.' + className);
|
2019-11-06 03:43:39 -07:00
|
|
|
|
|
|
|
for (i = 0, length = elems.length; i < length; i++) {
|
|
|
|
if (show) {
|
2020-05-04 03:44:12 -07:00
|
|
|
elems[i].classList.remove('hide');
|
2019-11-06 03:43:39 -07:00
|
|
|
} else {
|
2020-05-04 03:44:12 -07:00
|
|
|
elems[i].classList.add('hide');
|
2019-11-06 03:43:39 -07:00
|
|
|
}
|
|
|
|
}
|
2018-10-22 15:05:09 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function getContextMenuOptions(item, user, button) {
|
|
|
|
var options = {
|
|
|
|
item: item,
|
2019-11-06 03:43:39 -07:00
|
|
|
open: false,
|
|
|
|
play: false,
|
|
|
|
playAllFromHere: false,
|
|
|
|
queueAllFromHere: false,
|
2018-10-22 15:05:09 -07:00
|
|
|
positionTo: button,
|
2019-11-06 03:43:39 -07:00
|
|
|
cancelTimer: false,
|
|
|
|
record: false,
|
|
|
|
deleteItem: true === item.IsFolder,
|
|
|
|
shuffle: false,
|
|
|
|
instantMix: false,
|
2018-10-22 15:05:09 -07:00
|
|
|
user: user,
|
2019-11-06 03:43:39 -07:00
|
|
|
share: true
|
2018-10-22 15:05:09 -07:00
|
|
|
};
|
2019-03-18 22:22:48 -07:00
|
|
|
return options;
|
2018-10-22 15:05:09 -07:00
|
|
|
}
|
|
|
|
|
2020-03-01 07:33:41 -07:00
|
|
|
function getProgramScheduleHtml(items) {
|
2020-05-04 03:44:12 -07:00
|
|
|
var html = '';
|
2019-11-06 03:43:39 -07:00
|
|
|
html += '<div is="emby-itemscontainer" class="itemsContainer vertical-list" data-contextmenu="false">';
|
|
|
|
html += listView.getListViewHtml({
|
2018-10-22 15:05:09 -07:00
|
|
|
items: items,
|
2019-11-06 03:43:39 -07:00
|
|
|
enableUserDataButtons: false,
|
|
|
|
image: true,
|
2020-05-04 03:44:12 -07:00
|
|
|
imageSource: 'channel',
|
2019-11-06 03:43:39 -07:00
|
|
|
showProgramDateTime: true,
|
|
|
|
showChannel: false,
|
|
|
|
mediaInfo: false,
|
2020-05-04 03:44:12 -07:00
|
|
|
action: 'none',
|
2019-11-06 03:43:39 -07:00
|
|
|
moreButton: false,
|
|
|
|
recordButton: false
|
|
|
|
});
|
2020-05-04 03:44:12 -07:00
|
|
|
return html += '</div>';
|
2018-10-22 15:05:09 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function renderSeriesTimerSchedule(page, apiClient, seriesTimerId) {
|
|
|
|
apiClient.getLiveTvTimers({
|
|
|
|
UserId: apiClient.getCurrentUserId(),
|
|
|
|
ImageTypeLimit: 1,
|
2020-05-04 03:44:12 -07:00
|
|
|
EnableImageTypes: 'Primary,Backdrop,Thumb',
|
|
|
|
SortBy: 'StartDate',
|
2019-11-06 03:43:39 -07:00
|
|
|
EnableTotalRecordCount: false,
|
|
|
|
EnableUserData: false,
|
2018-10-22 15:05:09 -07:00
|
|
|
SeriesTimerId: seriesTimerId,
|
2020-05-04 03:44:12 -07:00
|
|
|
Fields: 'ChannelInfo,ChannelImage'
|
2019-11-06 03:43:39 -07:00
|
|
|
}).then(function (result) {
|
|
|
|
if (result.Items.length && result.Items[0].SeriesTimerId != seriesTimerId) {
|
|
|
|
result.Items = [];
|
|
|
|
}
|
|
|
|
|
|
|
|
var html = getProgramScheduleHtml(result.Items);
|
2020-05-04 03:44:12 -07:00
|
|
|
var scheduleTab = page.querySelector('.seriesTimerSchedule');
|
2019-11-06 03:43:39 -07:00
|
|
|
scheduleTab.innerHTML = html;
|
|
|
|
imageLoader.lazyChildren(scheduleTab);
|
|
|
|
});
|
2018-10-22 15:05:09 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function renderTimerEditor(page, item, apiClient, user) {
|
2020-05-04 03:44:12 -07:00
|
|
|
if ('Recording' !== item.Type || !user.Policy.EnableLiveTvManagement || !item.TimerId || 'InProgress' !== item.Status) {
|
|
|
|
return void hideAll(page, 'btnCancelTimer');
|
2019-11-06 03:43:39 -07:00
|
|
|
}
|
|
|
|
|
2020-05-04 03:44:12 -07:00
|
|
|
hideAll(page, 'btnCancelTimer', true);
|
2018-10-22 15:05:09 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function renderSeriesTimerEditor(page, item, apiClient, user) {
|
2020-05-04 03:44:12 -07:00
|
|
|
if ('SeriesTimer' !== item.Type) {
|
|
|
|
return void hideAll(page, 'btnCancelSeriesTimer');
|
2019-11-06 03:43:39 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (user.Policy.EnableLiveTvManagement) {
|
2020-05-04 03:44:12 -07:00
|
|
|
require(['seriesRecordingEditor'], function (seriesRecordingEditor) {
|
2019-11-06 03:43:39 -07:00
|
|
|
seriesRecordingEditor.embed(item, apiClient.serverId(), {
|
2020-05-04 03:44:12 -07:00
|
|
|
context: page.querySelector('.seriesRecordingEditor')
|
2019-11-06 03:43:39 -07:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2020-05-04 03:44:12 -07:00
|
|
|
page.querySelector('.seriesTimerScheduleSection').classList.remove('hide');
|
|
|
|
hideAll(page, 'btnCancelSeriesTimer', true);
|
2019-11-06 03:43:39 -07:00
|
|
|
return void renderSeriesTimerSchedule(page, apiClient, item.Id);
|
|
|
|
}
|
|
|
|
|
2020-05-04 03:44:12 -07:00
|
|
|
page.querySelector('.seriesTimerScheduleSection').classList.add('hide');
|
|
|
|
return void hideAll(page, 'btnCancelSeriesTimer');
|
2018-10-22 15:05:09 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function renderTrackSelections(page, instance, item, forceReload) {
|
2020-05-04 03:44:12 -07:00
|
|
|
var select = page.querySelector('.selectSource');
|
|
|
|
|
|
|
|
if (!item.MediaSources || !itemHelper.supportsMediaSourceSelection(item) || -1 === playbackManager.getSupportedCommands().indexOf('PlayMediaSource') || !playbackManager.canPlay(item)) {
|
|
|
|
page.querySelector('.trackSelections').classList.add('hide');
|
|
|
|
select.innerHTML = '';
|
|
|
|
page.querySelector('.selectVideo').innerHTML = '';
|
|
|
|
page.querySelector('.selectAudio').innerHTML = '';
|
|
|
|
page.querySelector('.selectSubtitles').innerHTML = '';
|
2019-11-06 03:43:39 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
playbackManager.getPlaybackMediaSources(item).then(function (mediaSources) {
|
|
|
|
instance._currentPlaybackMediaSources = mediaSources;
|
2020-05-04 03:44:12 -07:00
|
|
|
page.querySelector('.trackSelections').classList.remove('hide');
|
|
|
|
select.setLabel(globalize.translate('LabelVersion'));
|
2019-11-06 03:43:39 -07:00
|
|
|
var currentValue = select.value;
|
|
|
|
var selectedId = mediaSources[0].Id;
|
|
|
|
select.innerHTML = mediaSources.map(function (v) {
|
2020-05-04 03:44:12 -07:00
|
|
|
var selected = v.Id === selectedId ? ' selected' : '';
|
|
|
|
return '<option value="' + v.Id + '"' + selected + '>' + v.Name + '</option>';
|
|
|
|
}).join('');
|
2019-11-06 03:43:39 -07:00
|
|
|
|
|
|
|
if (mediaSources.length > 1) {
|
2020-05-04 03:44:12 -07:00
|
|
|
page.querySelector('.selectSourceContainer').classList.remove('hide');
|
2019-11-06 03:43:39 -07:00
|
|
|
} else {
|
2020-05-04 03:44:12 -07:00
|
|
|
page.querySelector('.selectSourceContainer').classList.add('hide');
|
2019-11-06 03:43:39 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (select.value !== currentValue || forceReload) {
|
|
|
|
renderVideoSelections(page, mediaSources);
|
|
|
|
renderAudioSelections(page, mediaSources);
|
|
|
|
renderSubtitleSelections(page, mediaSources);
|
|
|
|
}
|
|
|
|
});
|
2018-10-22 15:05:09 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function renderVideoSelections(page, mediaSources) {
|
2020-05-04 03:44:12 -07:00
|
|
|
var mediaSourceId = page.querySelector('.selectSource').value;
|
2019-11-06 03:43:39 -07:00
|
|
|
var mediaSource = mediaSources.filter(function (m) {
|
|
|
|
return m.Id === mediaSourceId;
|
|
|
|
})[0];
|
|
|
|
var tracks = mediaSource.MediaStreams.filter(function (m) {
|
2020-05-04 03:44:12 -07:00
|
|
|
return 'Video' === m.Type;
|
2019-11-06 03:43:39 -07:00
|
|
|
});
|
2020-05-04 03:44:12 -07:00
|
|
|
var select = page.querySelector('.selectVideo');
|
|
|
|
select.setLabel(globalize.translate('LabelVideo'));
|
2018-10-22 15:05:09 -07:00
|
|
|
var selectedId = tracks.length ? tracks[0].Index : -1;
|
2019-11-06 03:43:39 -07:00
|
|
|
select.innerHTML = tracks.map(function (v) {
|
2020-05-04 03:44:12 -07:00
|
|
|
var selected = v.Index === selectedId ? ' selected' : '';
|
2019-11-06 03:43:39 -07:00
|
|
|
var titleParts = [];
|
|
|
|
var resolutionText = mediaInfo.getResolutionText(v);
|
|
|
|
|
|
|
|
if (resolutionText) {
|
|
|
|
titleParts.push(resolutionText);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (v.Codec) {
|
|
|
|
titleParts.push(v.Codec.toUpperCase());
|
|
|
|
}
|
|
|
|
|
2020-05-04 03:44:12 -07:00
|
|
|
return '<option value="' + v.Index + '" ' + selected + '>' + (v.DisplayTitle || titleParts.join(' ')) + '</option>';
|
|
|
|
}).join('');
|
|
|
|
select.setAttribute('disabled', 'disabled');
|
2019-11-06 03:43:39 -07:00
|
|
|
|
|
|
|
if (tracks.length) {
|
2020-05-04 03:44:12 -07:00
|
|
|
page.querySelector('.selectVideoContainer').classList.remove('hide');
|
2019-11-06 03:43:39 -07:00
|
|
|
} else {
|
2020-05-04 03:44:12 -07:00
|
|
|
page.querySelector('.selectVideoContainer').classList.add('hide');
|
2019-11-06 03:43:39 -07:00
|
|
|
}
|
2018-10-22 15:05:09 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function renderAudioSelections(page, mediaSources) {
|
2020-05-04 03:44:12 -07:00
|
|
|
var mediaSourceId = page.querySelector('.selectSource').value;
|
2019-11-06 03:43:39 -07:00
|
|
|
var mediaSource = mediaSources.filter(function (m) {
|
|
|
|
return m.Id === mediaSourceId;
|
|
|
|
})[0];
|
|
|
|
var tracks = mediaSource.MediaStreams.filter(function (m) {
|
2020-05-04 03:44:12 -07:00
|
|
|
return 'Audio' === m.Type;
|
2019-11-06 03:43:39 -07:00
|
|
|
});
|
2020-05-04 03:44:12 -07:00
|
|
|
var select = page.querySelector('.selectAudio');
|
|
|
|
select.setLabel(globalize.translate('LabelAudio'));
|
2018-10-22 15:05:09 -07:00
|
|
|
var selectedId = mediaSource.DefaultAudioStreamIndex;
|
2019-11-06 03:43:39 -07:00
|
|
|
select.innerHTML = tracks.map(function (v) {
|
2020-05-04 03:44:12 -07:00
|
|
|
var selected = v.Index === selectedId ? ' selected' : '';
|
|
|
|
return '<option value="' + v.Index + '" ' + selected + '>' + v.DisplayTitle + '</option>';
|
|
|
|
}).join('');
|
2019-11-06 03:43:39 -07:00
|
|
|
|
|
|
|
if (tracks.length > 1) {
|
2020-05-04 03:44:12 -07:00
|
|
|
select.removeAttribute('disabled');
|
2019-11-06 03:43:39 -07:00
|
|
|
} else {
|
2020-05-04 03:44:12 -07:00
|
|
|
select.setAttribute('disabled', 'disabled');
|
2019-11-06 03:43:39 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (tracks.length) {
|
2020-05-04 03:44:12 -07:00
|
|
|
page.querySelector('.selectAudioContainer').classList.remove('hide');
|
2019-11-06 03:43:39 -07:00
|
|
|
} else {
|
2020-05-04 03:44:12 -07:00
|
|
|
page.querySelector('.selectAudioContainer').classList.add('hide');
|
2019-11-06 03:43:39 -07:00
|
|
|
}
|
2018-10-22 15:05:09 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function renderSubtitleSelections(page, mediaSources) {
|
2020-05-04 03:44:12 -07:00
|
|
|
var mediaSourceId = page.querySelector('.selectSource').value;
|
2019-11-06 03:43:39 -07:00
|
|
|
var mediaSource = mediaSources.filter(function (m) {
|
|
|
|
return m.Id === mediaSourceId;
|
|
|
|
})[0];
|
|
|
|
var tracks = mediaSource.MediaStreams.filter(function (m) {
|
2020-05-04 03:44:12 -07:00
|
|
|
return 'Subtitle' === m.Type;
|
2019-11-06 03:43:39 -07:00
|
|
|
});
|
2020-05-04 03:44:12 -07:00
|
|
|
var select = page.querySelector('.selectSubtitles');
|
|
|
|
select.setLabel(globalize.translate('LabelSubtitles'));
|
2018-10-22 15:05:09 -07:00
|
|
|
var selectedId = null == mediaSource.DefaultSubtitleStreamIndex ? -1 : mediaSource.DefaultSubtitleStreamIndex;
|
2019-11-06 03:43:39 -07:00
|
|
|
|
2018-10-22 15:05:09 -07:00
|
|
|
if (tracks.length) {
|
2020-05-04 03:44:12 -07:00
|
|
|
var selected = -1 === selectedId ? ' selected' : '';
|
|
|
|
select.innerHTML = '<option value="-1">' + globalize.translate('Off') + '</option>' + tracks.map(function (v) {
|
|
|
|
selected = v.Index === selectedId ? ' selected' : '';
|
|
|
|
return '<option value="' + v.Index + '" ' + selected + '>' + v.DisplayTitle + '</option>';
|
|
|
|
}).join('');
|
|
|
|
page.querySelector('.selectSubtitlesContainer').classList.remove('hide');
|
2019-11-06 03:43:39 -07:00
|
|
|
} else {
|
2020-05-04 03:44:12 -07:00
|
|
|
select.innerHTML = '';
|
|
|
|
page.querySelector('.selectSubtitlesContainer').classList.add('hide');
|
2019-11-06 03:43:39 -07:00
|
|
|
}
|
2018-10-22 15:05:09 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function reloadPlayButtons(page, item) {
|
2019-11-06 03:43:39 -07:00
|
|
|
var canPlay = false;
|
|
|
|
|
2020-05-04 03:44:12 -07:00
|
|
|
if ('Program' == item.Type) {
|
2019-11-06 03:43:39 -07:00
|
|
|
var now = new Date();
|
|
|
|
|
|
|
|
if (now >= datetime.parseISO8601Date(item.StartDate, true) && now < datetime.parseISO8601Date(item.EndDate, true)) {
|
2020-05-04 03:44:12 -07:00
|
|
|
hideAll(page, 'btnPlay', true);
|
2019-11-06 03:43:39 -07:00
|
|
|
canPlay = true;
|
|
|
|
} else {
|
2020-05-04 03:44:12 -07:00
|
|
|
hideAll(page, 'btnPlay');
|
2019-11-06 03:43:39 -07:00
|
|
|
}
|
|
|
|
|
2020-05-04 03:44:12 -07:00
|
|
|
hideAll(page, 'btnResume');
|
|
|
|
hideAll(page, 'btnInstantMix');
|
|
|
|
hideAll(page, 'btnShuffle');
|
2018-10-22 15:05:09 -07:00
|
|
|
} else if (playbackManager.canPlay(item)) {
|
2020-05-04 03:44:12 -07:00
|
|
|
hideAll(page, 'btnPlay', true);
|
|
|
|
var enableInstantMix = -1 !== ['Audio', 'MusicAlbum', 'MusicGenre', 'MusicArtist'].indexOf(item.Type);
|
|
|
|
hideAll(page, 'btnInstantMix', enableInstantMix);
|
|
|
|
var enableShuffle = item.IsFolder || -1 !== ['MusicAlbum', 'MusicGenre', 'MusicArtist'].indexOf(item.Type);
|
|
|
|
hideAll(page, 'btnShuffle', enableShuffle);
|
2019-11-06 03:43:39 -07:00
|
|
|
canPlay = true;
|
2020-05-04 03:44:12 -07:00
|
|
|
hideAll(page, 'btnResume', item.UserData && item.UserData.PlaybackPositionTicks > 0);
|
2019-11-06 03:43:39 -07:00
|
|
|
} else {
|
2020-05-04 03:44:12 -07:00
|
|
|
hideAll(page, 'btnPlay');
|
|
|
|
hideAll(page, 'btnResume');
|
|
|
|
hideAll(page, 'btnInstantMix');
|
|
|
|
hideAll(page, 'btnShuffle');
|
2019-11-06 03:43:39 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return canPlay;
|
2018-10-22 15:05:09 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function reloadUserDataButtons(page, item) {
|
2019-11-06 03:43:39 -07:00
|
|
|
var i;
|
|
|
|
var length;
|
2020-05-04 03:44:12 -07:00
|
|
|
var btnPlaystates = page.querySelectorAll('.btnPlaystate');
|
2019-11-06 03:43:39 -07:00
|
|
|
|
2018-10-22 15:05:09 -07:00
|
|
|
for (i = 0, length = btnPlaystates.length; i < length; i++) {
|
|
|
|
var btnPlaystate = btnPlaystates[i];
|
2019-11-06 03:43:39 -07:00
|
|
|
|
|
|
|
if (itemHelper.canMarkPlayed(item)) {
|
2020-05-04 03:44:12 -07:00
|
|
|
btnPlaystate.classList.remove('hide');
|
2019-11-06 03:43:39 -07:00
|
|
|
btnPlaystate.setItem(item);
|
|
|
|
} else {
|
2020-05-04 03:44:12 -07:00
|
|
|
btnPlaystate.classList.add('hide');
|
2019-11-06 03:43:39 -07:00
|
|
|
btnPlaystate.setItem(null);
|
|
|
|
}
|
2018-10-22 15:05:09 -07:00
|
|
|
}
|
2019-11-06 03:43:39 -07:00
|
|
|
|
2020-05-04 03:44:12 -07:00
|
|
|
var btnUserRatings = page.querySelectorAll('.btnUserRating');
|
2019-11-06 03:43:39 -07:00
|
|
|
|
2018-10-22 15:05:09 -07:00
|
|
|
for (i = 0, length = btnUserRatings.length; i < length; i++) {
|
|
|
|
var btnUserRating = btnUserRatings[i];
|
2019-11-06 03:43:39 -07:00
|
|
|
|
|
|
|
if (itemHelper.canRate(item)) {
|
2020-05-04 03:44:12 -07:00
|
|
|
btnUserRating.classList.remove('hide');
|
2019-11-06 03:43:39 -07:00
|
|
|
btnUserRating.setItem(item);
|
|
|
|
} else {
|
2020-05-04 03:44:12 -07:00
|
|
|
btnUserRating.classList.add('hide');
|
2019-11-06 03:43:39 -07:00
|
|
|
btnUserRating.setItem(null);
|
|
|
|
}
|
2018-10-22 15:05:09 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function getArtistLinksHtml(artists, serverId, context) {
|
2019-11-06 03:43:39 -07:00
|
|
|
var html = [];
|
|
|
|
|
|
|
|
for (var i = 0, length = artists.length; i < length; i++) {
|
|
|
|
var artist = artists[i];
|
|
|
|
var href = appRouter.getRouteUrl(artist, {
|
|
|
|
context: context,
|
2020-05-04 03:44:12 -07:00
|
|
|
itemType: 'MusicArtist',
|
2019-11-06 03:43:39 -07:00
|
|
|
serverId: serverId
|
|
|
|
});
|
2020-05-04 03:44:12 -07:00
|
|
|
html.push('<a style="color:inherit;" class="button-link" is="emby-linkbutton" href="' + href + '">' + artist.Name + '</a>');
|
2018-10-22 15:05:09 -07:00
|
|
|
}
|
2019-11-06 03:43:39 -07:00
|
|
|
|
2020-05-04 03:44:12 -07:00
|
|
|
return html = html.join(' / ');
|
2018-10-22 15:05:09 -07:00
|
|
|
}
|
|
|
|
function renderName(item, container, isStatic, context) {
|
2019-11-06 03:43:39 -07:00
|
|
|
var parentRoute;
|
|
|
|
var parentNameHtml = [];
|
|
|
|
var parentNameLast = false;
|
|
|
|
|
|
|
|
if (item.AlbumArtists) {
|
|
|
|
parentNameHtml.push(getArtistLinksHtml(item.AlbumArtists, item.ServerId, context));
|
|
|
|
parentNameLast = true;
|
2020-05-04 03:44:12 -07:00
|
|
|
} else if (item.ArtistItems && item.ArtistItems.length && 'MusicVideo' === item.Type) {
|
2019-11-06 03:43:39 -07:00
|
|
|
parentNameHtml.push(getArtistLinksHtml(item.ArtistItems, item.ServerId, context));
|
|
|
|
parentNameLast = true;
|
2020-05-04 03:44:12 -07:00
|
|
|
} else if (item.SeriesName && 'Episode' === item.Type) {
|
2019-11-06 03:43:39 -07:00
|
|
|
parentRoute = appRouter.getRouteUrl({
|
|
|
|
Id: item.SeriesId,
|
|
|
|
Name: item.SeriesName,
|
2020-05-04 03:44:12 -07:00
|
|
|
Type: 'Series',
|
2019-11-06 03:43:39 -07:00
|
|
|
IsFolder: true,
|
|
|
|
ServerId: item.ServerId
|
|
|
|
}, {
|
|
|
|
context: context
|
|
|
|
});
|
2020-05-04 03:44:12 -07:00
|
|
|
parentNameHtml.push('<a style="color:inherit;" class="button-link" is="emby-linkbutton" href="' + parentRoute + '">' + item.SeriesName + '</a>');
|
2019-11-06 03:43:39 -07:00
|
|
|
} else if (item.IsSeries || item.EpisodeTitle) {
|
|
|
|
parentNameHtml.push(item.Name);
|
|
|
|
}
|
|
|
|
|
2020-05-04 03:44:12 -07:00
|
|
|
if (item.SeriesName && 'Season' === item.Type) {
|
2019-11-06 03:43:39 -07:00
|
|
|
parentRoute = appRouter.getRouteUrl({
|
|
|
|
Id: item.SeriesId,
|
|
|
|
Name: item.SeriesName,
|
2020-05-04 03:44:12 -07:00
|
|
|
Type: 'Series',
|
2019-11-06 03:43:39 -07:00
|
|
|
IsFolder: true,
|
|
|
|
ServerId: item.ServerId
|
|
|
|
}, {
|
|
|
|
context: context
|
|
|
|
});
|
2020-05-04 03:44:12 -07:00
|
|
|
parentNameHtml.push('<a style="color:inherit;" class="button-link" is="emby-linkbutton" href="' + parentRoute + '">' + item.SeriesName + '</a>');
|
|
|
|
} else if (null != item.ParentIndexNumber && 'Episode' === item.Type) {
|
2019-11-06 03:43:39 -07:00
|
|
|
parentRoute = appRouter.getRouteUrl({
|
|
|
|
Id: item.SeasonId,
|
|
|
|
Name: item.SeasonName,
|
2020-05-04 03:44:12 -07:00
|
|
|
Type: 'Season',
|
2019-11-06 03:43:39 -07:00
|
|
|
IsFolder: true,
|
|
|
|
ServerId: item.ServerId
|
|
|
|
}, {
|
|
|
|
context: context
|
|
|
|
});
|
2020-05-04 03:44:12 -07:00
|
|
|
parentNameHtml.push('<a style="color:inherit;" class="button-link" is="emby-linkbutton" href="' + parentRoute + '">' + item.SeasonName + '</a>');
|
2019-11-06 03:43:39 -07:00
|
|
|
} else if (null != item.ParentIndexNumber && item.IsSeries) {
|
2020-05-04 03:44:12 -07:00
|
|
|
parentNameHtml.push(item.SeasonName || 'S' + item.ParentIndexNumber);
|
|
|
|
} else if (item.Album && item.AlbumId && ('MusicVideo' === item.Type || 'Audio' === item.Type)) {
|
2019-11-06 03:43:39 -07:00
|
|
|
parentRoute = appRouter.getRouteUrl({
|
|
|
|
Id: item.AlbumId,
|
|
|
|
Name: item.Album,
|
2020-05-04 03:44:12 -07:00
|
|
|
Type: 'MusicAlbum',
|
2019-11-06 03:43:39 -07:00
|
|
|
IsFolder: true,
|
|
|
|
ServerId: item.ServerId
|
|
|
|
}, {
|
|
|
|
context: context
|
|
|
|
});
|
2020-05-04 03:44:12 -07:00
|
|
|
parentNameHtml.push('<a style="color:inherit;" class="button-link" is="emby-linkbutton" href="' + parentRoute + '">' + item.Album + '</a>');
|
2019-11-06 03:43:39 -07:00
|
|
|
} else if (item.Album) {
|
|
|
|
parentNameHtml.push(item.Album);
|
|
|
|
}
|
2020-04-05 05:19:31 -07:00
|
|
|
// FIXME: This whole section needs some refactoring, so it becames easier to scale across all form factors. See GH #1022
|
2020-05-04 03:44:12 -07:00
|
|
|
var html = '';
|
2020-04-05 05:19:31 -07:00
|
|
|
var tvShowHtml = parentNameHtml[0];
|
|
|
|
var tvSeasonHtml = parentNameHtml[1];
|
2019-11-06 03:43:39 -07:00
|
|
|
|
|
|
|
if (parentNameHtml.length) {
|
|
|
|
if (parentNameLast) {
|
2020-04-04 15:59:37 -07:00
|
|
|
// Music
|
|
|
|
if (layoutManager.mobile) {
|
2020-05-04 03:44:12 -07:00
|
|
|
html = '<h3 class="parentName" style="margin: .25em 0;">' + parentNameHtml.join('</br>') + '</h3>';
|
2020-04-04 15:59:37 -07:00
|
|
|
} else {
|
2020-05-04 03:44:12 -07:00
|
|
|
html = '<h3 class="parentName" style="margin: .25em 0;">' + parentNameHtml.join(' - ') + '</h3>';
|
2020-04-04 15:59:37 -07:00
|
|
|
}
|
2019-11-06 03:43:39 -07:00
|
|
|
} else {
|
2020-04-04 15:59:37 -07:00
|
|
|
if (layoutManager.mobile) {
|
2020-05-04 03:44:12 -07:00
|
|
|
html = '<h1 class="parentName" style="margin: .1em 0 .25em;">' + parentNameHtml.join('</br>') + '</h1>';
|
2020-04-04 15:59:37 -07:00
|
|
|
} else {
|
2020-05-04 03:44:12 -07:00
|
|
|
html = '<h1 class="parentName" style="margin: .1em 0 .25em;">' + tvShowHtml + '</h1>';
|
2020-04-04 15:59:37 -07:00
|
|
|
}
|
2019-11-06 03:43:39 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-22 15:05:09 -07:00
|
|
|
var name = itemHelper.getDisplayName(item, {
|
2019-11-06 03:43:39 -07:00
|
|
|
includeParentInfo: false
|
2018-10-22 15:05:09 -07:00
|
|
|
});
|
2020-05-04 03:44:12 -07:00
|
|
|
var offset = parentNameLast ? '.25em' : '.5em';
|
2019-11-06 03:43:39 -07:00
|
|
|
|
2019-09-11 08:59:00 -07:00
|
|
|
if (html && !parentNameLast) {
|
2020-04-05 05:19:31 -07:00
|
|
|
if (!layoutManager.mobile && tvSeasonHtml) {
|
|
|
|
html += '<h3 class="itemName infoText" style="margin: .25em 0 .5em;">' + tvSeasonHtml + ' - ' + name + '</h3>';
|
2020-04-04 15:59:37 -07:00
|
|
|
} else {
|
2020-04-05 05:02:20 -07:00
|
|
|
html += '<h3 class="itemName infoText" style="margin: .25em 0 .5em;">' + name + '</h3>';
|
2020-04-04 15:59:37 -07:00
|
|
|
}
|
2019-09-11 08:59:00 -07:00
|
|
|
} else {
|
2020-05-04 03:44:12 -07:00
|
|
|
html = '<h1 class="itemName infoText" style="margin: .1em 0 ' + offset + ';">' + name + '</h1>' + html;
|
2019-09-11 08:59:00 -07:00
|
|
|
}
|
|
|
|
|
2019-09-11 09:19:17 -07:00
|
|
|
if (item.OriginalTitle && item.OriginalTitle != item.Name) {
|
2020-04-05 05:02:20 -07:00
|
|
|
html += '<h4 class="itemName infoText" style="margin: -' + offset + ' 0 0;">' + item.OriginalTitle + '</h4>';
|
2019-09-11 08:59:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
container.innerHTML = html;
|
2019-11-06 03:43:39 -07:00
|
|
|
|
|
|
|
if (html.length) {
|
2020-05-04 03:44:12 -07:00
|
|
|
container.classList.remove('hide');
|
2019-11-06 03:43:39 -07:00
|
|
|
} else {
|
2020-05-04 03:44:12 -07:00
|
|
|
container.classList.add('hide');
|
2019-11-06 03:43:39 -07:00
|
|
|
}
|
2018-10-22 15:05:09 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function setTrailerButtonVisibility(page, item) {
|
2020-05-04 03:44:12 -07:00
|
|
|
if ((item.LocalTrailerCount || item.RemoteTrailers && item.RemoteTrailers.length) && -1 !== playbackManager.getSupportedCommands().indexOf('PlayTrailers')) {
|
|
|
|
hideAll(page, 'btnPlayTrailer', true);
|
2019-11-06 03:43:39 -07:00
|
|
|
} else {
|
2020-05-04 03:44:12 -07:00
|
|
|
hideAll(page, 'btnPlayTrailer');
|
2019-11-06 03:43:39 -07:00
|
|
|
}
|
2018-10-22 15:05:09 -07:00
|
|
|
}
|
|
|
|
|
2020-03-01 07:33:41 -07:00
|
|
|
function renderBackdrop(item) {
|
2020-01-13 08:09:55 -07:00
|
|
|
if (dom.getWindowSize().innerWidth >= 1000) {
|
|
|
|
backdrop.setBackdrops([item]);
|
|
|
|
} else {
|
|
|
|
backdrop.clear();
|
2019-11-28 12:46:57 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-22 15:05:09 -07:00
|
|
|
function renderDetailPageBackdrop(page, item, apiClient) {
|
2019-11-06 03:43:39 -07:00
|
|
|
var imgUrl;
|
|
|
|
var hasbackdrop = false;
|
2020-05-04 03:44:12 -07:00
|
|
|
var itemBackdropElement = page.querySelector('#itemBackdrop');
|
|
|
|
var usePrimaryImage = item.MediaType === 'Video' && item.Type !== 'Movie' && item.Type !== 'Trailer' ||
|
|
|
|
item.MediaType && item.MediaType !== 'Video' ||
|
|
|
|
item.Type === 'MusicAlbum' ||
|
|
|
|
item.Type === 'Person';
|
2019-11-06 03:43:39 -07:00
|
|
|
|
2020-02-17 14:03:36 -07:00
|
|
|
if (!layoutManager.mobile && !userSettings.enableBackdrops()) {
|
2020-03-03 05:31:57 -07:00
|
|
|
return false;
|
2020-02-17 14:03:36 -07:00
|
|
|
}
|
|
|
|
|
2020-05-04 03:44:12 -07:00
|
|
|
if ('Program' === item.Type && item.ImageTags && item.ImageTags.Thumb) {
|
2019-11-06 03:43:39 -07:00
|
|
|
imgUrl = apiClient.getScaledImageUrl(item.Id, {
|
2020-05-04 03:44:12 -07:00
|
|
|
type: 'Thumb',
|
2020-03-08 11:08:07 -07:00
|
|
|
maxWidth: dom.getScreenWidth(),
|
2019-11-06 03:43:39 -07:00
|
|
|
index: 0,
|
|
|
|
tag: item.ImageTags.Thumb
|
|
|
|
});
|
2020-05-04 03:44:12 -07:00
|
|
|
page.classList.remove('noBackdrop');
|
2019-11-06 03:43:39 -07:00
|
|
|
imageLoader.lazyImage(itemBackdropElement, imgUrl, false);
|
|
|
|
hasbackdrop = true;
|
|
|
|
} else if (usePrimaryImage && item.ImageTags && item.ImageTags.Primary) {
|
|
|
|
imgUrl = apiClient.getScaledImageUrl(item.Id, {
|
2020-05-04 03:44:12 -07:00
|
|
|
type: 'Primary',
|
2020-03-08 11:08:07 -07:00
|
|
|
maxWidth: dom.getScreenWidth(),
|
2019-11-06 03:43:39 -07:00
|
|
|
index: 0,
|
|
|
|
tag: item.ImageTags.Primary
|
|
|
|
});
|
2020-05-04 03:44:12 -07:00
|
|
|
page.classList.remove('noBackdrop');
|
2019-11-06 03:43:39 -07:00
|
|
|
imageLoader.lazyImage(itemBackdropElement, imgUrl, false);
|
|
|
|
hasbackdrop = true;
|
|
|
|
} else if (item.BackdropImageTags && item.BackdropImageTags.length) {
|
|
|
|
imgUrl = apiClient.getScaledImageUrl(item.Id, {
|
2020-05-04 03:44:12 -07:00
|
|
|
type: 'Backdrop',
|
2020-03-08 11:08:07 -07:00
|
|
|
maxWidth: dom.getScreenWidth(),
|
2019-11-06 03:43:39 -07:00
|
|
|
index: 0,
|
|
|
|
tag: item.BackdropImageTags[0]
|
|
|
|
});
|
2020-05-04 03:44:12 -07:00
|
|
|
page.classList.remove('noBackdrop');
|
2019-11-06 03:43:39 -07:00
|
|
|
imageLoader.lazyImage(itemBackdropElement, imgUrl, false);
|
|
|
|
hasbackdrop = true;
|
|
|
|
} else if (item.ParentBackdropItemId && item.ParentBackdropImageTags && item.ParentBackdropImageTags.length) {
|
|
|
|
imgUrl = apiClient.getScaledImageUrl(item.ParentBackdropItemId, {
|
2020-05-04 03:44:12 -07:00
|
|
|
type: 'Backdrop',
|
2020-03-08 11:08:07 -07:00
|
|
|
maxWidth: dom.getScreenWidth(),
|
2019-11-06 03:43:39 -07:00
|
|
|
index: 0,
|
2019-11-24 05:34:30 -07:00
|
|
|
tag: item.ParentBackdropImageTags[0]
|
2019-11-06 03:43:39 -07:00
|
|
|
});
|
2020-05-04 03:44:12 -07:00
|
|
|
page.classList.remove('noBackdrop');
|
2019-11-06 03:43:39 -07:00
|
|
|
imageLoader.lazyImage(itemBackdropElement, imgUrl, false);
|
|
|
|
hasbackdrop = true;
|
|
|
|
} else if (item.ImageTags && item.ImageTags.Thumb) {
|
|
|
|
imgUrl = apiClient.getScaledImageUrl(item.Id, {
|
2020-05-04 03:44:12 -07:00
|
|
|
type: 'Thumb',
|
2020-03-08 11:08:07 -07:00
|
|
|
maxWidth: dom.getScreenWidth(),
|
2019-11-06 03:43:39 -07:00
|
|
|
index: 0,
|
|
|
|
tag: item.ImageTags.Thumb
|
|
|
|
});
|
2020-05-04 03:44:12 -07:00
|
|
|
page.classList.remove('noBackdrop');
|
2019-11-06 03:43:39 -07:00
|
|
|
imageLoader.lazyImage(itemBackdropElement, imgUrl, false);
|
|
|
|
hasbackdrop = true;
|
|
|
|
} else {
|
2020-05-04 03:44:12 -07:00
|
|
|
itemBackdropElement.style.backgroundImage = '';
|
2019-11-06 03:43:39 -07:00
|
|
|
}
|
|
|
|
|
2020-05-04 03:44:12 -07:00
|
|
|
if ('Person' === item.Type) {
|
2020-03-03 11:36:52 -07:00
|
|
|
// FIXME: This hides the backdrop on all persons to fix a margin issue. Ideally, a proper fix should be made.
|
2020-02-29 12:14:21 -07:00
|
|
|
page.classList.add('noBackdrop');
|
2020-05-04 03:44:12 -07:00
|
|
|
itemBackdropElement.classList.add('personBackdrop');
|
2020-01-13 12:22:50 -07:00
|
|
|
} else {
|
2020-05-04 03:44:12 -07:00
|
|
|
itemBackdropElement.classList.remove('personBackdrop');
|
2020-01-13 12:22:50 -07:00
|
|
|
}
|
|
|
|
|
2019-11-06 03:43:39 -07:00
|
|
|
return hasbackdrop;
|
2018-10-22 15:05:09 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function reloadFromItem(instance, page, params, item, user) {
|
|
|
|
var context = params.context;
|
2020-05-04 03:44:12 -07:00
|
|
|
page.querySelector('.detailPagePrimaryContainer').classList.add('detailSticky');
|
2020-02-23 13:14:38 -07:00
|
|
|
|
2020-05-04 03:44:12 -07:00
|
|
|
renderName(item, page.querySelector('.nameContainer'), false, context);
|
2018-10-22 15:05:09 -07:00
|
|
|
var apiClient = connectionManager.getApiClient(item.ServerId);
|
2019-11-06 03:43:39 -07:00
|
|
|
renderSeriesTimerEditor(page, item, apiClient, user);
|
|
|
|
renderTimerEditor(page, item, apiClient, user);
|
|
|
|
renderImage(page, item, apiClient, user);
|
|
|
|
renderLogo(page, item, apiClient);
|
2020-04-30 11:15:39 -07:00
|
|
|
Emby.Page.setTitle('');
|
2019-11-06 03:43:39 -07:00
|
|
|
setInitialCollapsibleState(page, item, apiClient, context, user);
|
|
|
|
renderDetails(page, item, apiClient, context);
|
|
|
|
renderTrackSelections(page, instance, item);
|
2020-03-01 07:33:41 -07:00
|
|
|
renderBackdrop(item);
|
2019-11-06 03:43:39 -07:00
|
|
|
renderDetailPageBackdrop(page, item, apiClient);
|
2018-10-22 15:05:09 -07:00
|
|
|
var canPlay = reloadPlayButtons(page, item);
|
2019-11-06 03:43:39 -07:00
|
|
|
|
2020-05-04 03:44:12 -07:00
|
|
|
if ((item.LocalTrailerCount || item.RemoteTrailers && item.RemoteTrailers.length) && -1 !== playbackManager.getSupportedCommands().indexOf('PlayTrailers')) {
|
|
|
|
hideAll(page, 'btnPlayTrailer', true);
|
2019-03-20 14:48:59 -07:00
|
|
|
} else {
|
2020-05-04 03:44:12 -07:00
|
|
|
hideAll(page, 'btnPlayTrailer');
|
2019-03-20 14:48:59 -07:00
|
|
|
}
|
2019-11-06 03:43:39 -07:00
|
|
|
|
2019-03-18 22:22:48 -07:00
|
|
|
setTrailerButtonVisibility(page, item);
|
2019-11-06 03:43:39 -07:00
|
|
|
|
2019-03-20 14:48:59 -07:00
|
|
|
if (item.CanDelete && !item.IsFolder) {
|
2020-05-04 03:44:12 -07:00
|
|
|
hideAll(page, 'btnDeleteItem', true);
|
2019-03-20 14:48:59 -07:00
|
|
|
} else {
|
2020-05-04 03:44:12 -07:00
|
|
|
hideAll(page, 'btnDeleteItem');
|
2019-03-20 14:48:59 -07:00
|
|
|
}
|
2019-11-06 03:43:39 -07:00
|
|
|
|
2020-05-04 03:44:12 -07:00
|
|
|
if ('Program' !== item.Type || canPlay) {
|
|
|
|
hideAll(page, 'mainDetailButtons', true);
|
2019-03-20 14:48:59 -07:00
|
|
|
} else {
|
2020-05-04 03:44:12 -07:00
|
|
|
hideAll(page, 'mainDetailButtons');
|
2019-03-20 14:48:59 -07:00
|
|
|
}
|
2019-11-06 03:43:39 -07:00
|
|
|
|
2019-03-18 22:22:48 -07:00
|
|
|
showRecordingFields(instance, page, item, user);
|
2019-11-06 03:43:39 -07:00
|
|
|
var groupedVersions = (item.MediaSources || []).filter(function (g) {
|
2020-05-04 03:44:12 -07:00
|
|
|
return 'Grouping' == g.Type;
|
2018-10-22 15:05:09 -07:00
|
|
|
});
|
2019-11-06 03:43:39 -07:00
|
|
|
|
|
|
|
if (user.Policy.IsAdministrator && groupedVersions.length) {
|
2020-05-04 03:44:12 -07:00
|
|
|
page.querySelector('.btnSplitVersions').classList.remove('hide');
|
2019-11-06 03:43:39 -07:00
|
|
|
} else {
|
2020-05-04 03:44:12 -07:00
|
|
|
page.querySelector('.btnSplitVersions').classList.add('hide');
|
2019-11-06 03:43:39 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (itemContextMenu.getCommands(getContextMenuOptions(item, user)).length) {
|
2020-05-04 03:44:12 -07:00
|
|
|
hideAll(page, 'btnMoreCommands', true);
|
2019-11-06 03:43:39 -07:00
|
|
|
} else {
|
2020-05-04 03:44:12 -07:00
|
|
|
hideAll(page, 'btnMoreCommands');
|
2019-11-06 03:43:39 -07:00
|
|
|
}
|
|
|
|
|
2020-05-04 03:44:12 -07:00
|
|
|
var itemBirthday = page.querySelector('#itemBirthday');
|
2019-11-06 03:43:39 -07:00
|
|
|
|
2020-05-04 03:44:12 -07:00
|
|
|
if ('Person' == item.Type && item.PremiereDate) {
|
2019-11-06 03:43:39 -07:00
|
|
|
try {
|
|
|
|
var birthday = datetime.parseISO8601Date(item.PremiereDate, true).toDateString();
|
2020-05-04 03:44:12 -07:00
|
|
|
itemBirthday.classList.remove('hide');
|
|
|
|
itemBirthday.innerHTML = globalize.translate('BirthDateValue', birthday);
|
2019-11-06 03:43:39 -07:00
|
|
|
} catch (err) {
|
2020-05-04 03:44:12 -07:00
|
|
|
itemBirthday.classList.add('hide');
|
2019-11-06 03:43:39 -07:00
|
|
|
}
|
|
|
|
} else {
|
2020-05-04 03:44:12 -07:00
|
|
|
itemBirthday.classList.add('hide');
|
2019-11-06 03:43:39 -07:00
|
|
|
}
|
|
|
|
|
2020-05-04 03:44:12 -07:00
|
|
|
var itemDeathDate = page.querySelector('#itemDeathDate');
|
2019-11-06 03:43:39 -07:00
|
|
|
|
2020-05-04 03:44:12 -07:00
|
|
|
if ('Person' == item.Type && item.EndDate) {
|
2019-11-06 03:43:39 -07:00
|
|
|
try {
|
|
|
|
var deathday = datetime.parseISO8601Date(item.EndDate, true).toDateString();
|
2020-05-04 03:44:12 -07:00
|
|
|
itemDeathDate.classList.remove('hide');
|
|
|
|
itemDeathDate.innerHTML = globalize.translate('DeathDateValue', deathday);
|
2019-11-06 03:43:39 -07:00
|
|
|
} catch (err) {
|
2020-05-04 03:44:12 -07:00
|
|
|
itemDeathDate.classList.add('hide');
|
2019-11-06 03:43:39 -07:00
|
|
|
}
|
|
|
|
} else {
|
2020-05-04 03:44:12 -07:00
|
|
|
itemDeathDate.classList.add('hide');
|
2018-10-22 15:05:09 -07:00
|
|
|
}
|
2019-11-06 03:43:39 -07:00
|
|
|
|
2020-05-04 03:44:12 -07:00
|
|
|
var itemBirthLocation = page.querySelector('#itemBirthLocation');
|
2019-11-06 03:43:39 -07:00
|
|
|
|
2020-05-04 03:44:12 -07:00
|
|
|
if ('Person' == item.Type && item.ProductionLocations && item.ProductionLocations.length) {
|
|
|
|
var gmap = '<a is="emby-linkbutton" class="button-link textlink" target="_blank" href="https://maps.google.com/maps?q=' + item.ProductionLocations[0] + '">' + item.ProductionLocations[0] + '</a>';
|
|
|
|
itemBirthLocation.classList.remove('hide');
|
|
|
|
itemBirthLocation.innerHTML = globalize.translate('BirthPlaceValue', gmap);
|
2019-11-06 03:43:39 -07:00
|
|
|
} else {
|
2020-05-04 03:44:12 -07:00
|
|
|
itemBirthLocation.classList.add('hide');
|
2019-11-06 03:43:39 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
setPeopleHeader(page, item);
|
|
|
|
loading.hide();
|
2019-05-07 22:03:59 -07:00
|
|
|
|
2020-05-04 03:44:12 -07:00
|
|
|
if (item.Type === 'Book') {
|
|
|
|
hideAll(page, 'btnDownload', true);
|
2019-07-28 06:51:02 -07:00
|
|
|
}
|
|
|
|
|
2020-05-04 03:44:12 -07:00
|
|
|
require(['autoFocuser'], function (autoFocuser) {
|
2019-11-02 10:38:58 -07:00
|
|
|
autoFocuser.autoFocus(page);
|
|
|
|
});
|
2018-10-22 15:05:09 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function logoImageUrl(item, apiClient, options) {
|
2019-11-06 03:43:39 -07:00
|
|
|
options = options || {};
|
2020-05-04 03:44:12 -07:00
|
|
|
options.type = 'Logo';
|
2019-11-06 03:43:39 -07:00
|
|
|
|
|
|
|
if (item.ImageTags && item.ImageTags.Logo) {
|
|
|
|
options.tag = item.ImageTags.Logo;
|
|
|
|
return apiClient.getScaledImageUrl(item.Id, options);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (item.ParentLogoImageTag) {
|
|
|
|
options.tag = item.ParentLogoImageTag;
|
|
|
|
return apiClient.getScaledImageUrl(item.ParentLogoItemId, options);
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
2018-10-22 15:05:09 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function renderLogo(page, item, apiClient) {
|
|
|
|
var url = logoImageUrl(item, apiClient, {
|
2019-11-06 03:43:39 -07:00
|
|
|
maxWidth: 400
|
|
|
|
});
|
2020-05-04 03:44:12 -07:00
|
|
|
var detailLogo = page.querySelector('.detailLogo');
|
2019-11-06 03:43:39 -07:00
|
|
|
|
2020-02-17 14:03:36 -07:00
|
|
|
if (!layoutManager.mobile && !userSettings.enableBackdrops()) {
|
2020-05-04 03:44:12 -07:00
|
|
|
detailLogo.classList.add('hide');
|
2020-02-17 14:03:36 -07:00
|
|
|
} else if (url) {
|
2020-05-04 03:44:12 -07:00
|
|
|
detailLogo.classList.remove('hide');
|
|
|
|
detailLogo.classList.add('lazy');
|
|
|
|
detailLogo.setAttribute('data-src', url);
|
2019-11-06 03:43:39 -07:00
|
|
|
imageLoader.lazyImage(detailLogo);
|
|
|
|
} else {
|
2020-05-04 03:44:12 -07:00
|
|
|
detailLogo.classList.add('hide');
|
2019-11-06 03:43:39 -07:00
|
|
|
}
|
2018-10-22 15:05:09 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function showRecordingFields(instance, page, item, user) {
|
|
|
|
if (!instance.currentRecordingFields) {
|
2020-05-04 03:44:12 -07:00
|
|
|
var recordingFieldsElement = page.querySelector('.recordingFields');
|
2019-11-06 03:43:39 -07:00
|
|
|
|
2020-05-04 03:44:12 -07:00
|
|
|
if ('Program' == item.Type && user.Policy.EnableLiveTvManagement) {
|
|
|
|
require(['recordingFields'], function (recordingFields) {
|
2019-11-06 03:43:39 -07:00
|
|
|
instance.currentRecordingFields = new recordingFields({
|
|
|
|
parent: recordingFieldsElement,
|
|
|
|
programId: item.Id,
|
|
|
|
serverId: item.ServerId
|
|
|
|
});
|
2020-05-04 03:44:12 -07:00
|
|
|
recordingFieldsElement.classList.remove('hide');
|
2019-11-06 03:43:39 -07:00
|
|
|
});
|
|
|
|
} else {
|
2020-05-04 03:44:12 -07:00
|
|
|
recordingFieldsElement.classList.add('hide');
|
|
|
|
recordingFieldsElement.innerHTML = '';
|
2019-11-06 03:43:39 -07:00
|
|
|
}
|
2018-10-22 15:05:09 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function renderLinks(linksElem, item) {
|
|
|
|
var html = [];
|
2019-11-06 03:43:39 -07:00
|
|
|
|
2018-10-22 15:05:09 -07:00
|
|
|
var links = [];
|
2019-11-06 03:43:39 -07:00
|
|
|
|
|
|
|
if (!layoutManager.tv && item.HomePageUrl) {
|
2020-05-04 03:44:12 -07:00
|
|
|
links.push('<a style="color:inherit;" is="emby-linkbutton" class="button-link" href="' + item.HomePageUrl + '" target="_blank">' + globalize.translate('ButtonWebsite') + '</a>');
|
2019-11-06 03:43:39 -07:00
|
|
|
}
|
|
|
|
if (item.ExternalUrls) {
|
2018-10-22 15:05:09 -07:00
|
|
|
for (var i = 0, length = item.ExternalUrls.length; i < length; i++) {
|
|
|
|
var url = item.ExternalUrls[i];
|
2020-05-04 03:44:12 -07:00
|
|
|
links.push('<a style="color:inherit;" is="emby-linkbutton" class="button-link" href="' + url.Url + '" target="_blank">' + url.Name + '</a>');
|
2018-10-22 15:05:09 -07:00
|
|
|
}
|
2019-11-06 03:43:39 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (links.length) {
|
2020-05-04 03:44:12 -07:00
|
|
|
html.push(links.join(', '));
|
2019-11-06 03:43:39 -07:00
|
|
|
}
|
|
|
|
|
2020-05-04 03:44:12 -07:00
|
|
|
linksElem.innerHTML = html.join(', ');
|
2019-11-06 03:43:39 -07:00
|
|
|
|
|
|
|
if (html.length) {
|
2020-05-04 03:44:12 -07:00
|
|
|
linksElem.classList.remove('hide');
|
2019-11-06 03:43:39 -07:00
|
|
|
} else {
|
2020-05-04 03:44:12 -07:00
|
|
|
linksElem.classList.add('hide');
|
2019-11-06 03:43:39 -07:00
|
|
|
}
|
2018-10-22 15:05:09 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function renderDetailImage(page, elem, item, apiClient, editable, imageLoader, indicators) {
|
2020-05-04 03:44:12 -07:00
|
|
|
if ('SeriesTimer' === item.Type || 'Program' === item.Type) {
|
2019-11-06 03:43:39 -07:00
|
|
|
editable = false;
|
|
|
|
}
|
|
|
|
|
2020-05-04 03:44:12 -07:00
|
|
|
elem.classList.add('detailimg-hidemobile');
|
2019-11-06 03:43:39 -07:00
|
|
|
|
2018-10-22 15:05:09 -07:00
|
|
|
var imageTags = item.ImageTags || {};
|
2019-11-06 03:43:39 -07:00
|
|
|
|
|
|
|
if (item.PrimaryImageTag) {
|
|
|
|
imageTags.Primary = item.PrimaryImageTag;
|
|
|
|
}
|
|
|
|
|
|
|
|
var url;
|
2020-05-04 03:44:12 -07:00
|
|
|
var html = '';
|
|
|
|
var shape = 'portrait';
|
2019-11-06 03:43:39 -07:00
|
|
|
var detectRatio = false;
|
|
|
|
|
2020-03-12 13:11:06 -07:00
|
|
|
/* In the following section, getScreenWidth() is multiplied by 0.5 as the posters
|
|
|
|
are 25vw and we need double the resolution to counter Skia's scaling. */
|
|
|
|
// TODO: Find a reliable way to get the poster width
|
2019-11-06 03:43:39 -07:00
|
|
|
if (imageTags.Primary) {
|
|
|
|
url = apiClient.getScaledImageUrl(item.Id, {
|
2020-05-04 03:44:12 -07:00
|
|
|
type: 'Primary',
|
2020-03-09 13:02:08 -07:00
|
|
|
maxWidth: Math.round(dom.getScreenWidth() * 0.5),
|
2019-11-06 03:43:39 -07:00
|
|
|
tag: item.ImageTags.Primary
|
|
|
|
});
|
|
|
|
detectRatio = true;
|
|
|
|
} else if (item.BackdropImageTags && item.BackdropImageTags.length) {
|
|
|
|
url = apiClient.getScaledImageUrl(item.Id, {
|
2020-05-04 03:44:12 -07:00
|
|
|
type: 'Backdrop',
|
2020-03-09 13:02:08 -07:00
|
|
|
maxWidth: Math.round(dom.getScreenWidth() * 0.5),
|
2019-11-06 03:43:39 -07:00
|
|
|
tag: item.BackdropImageTags[0]
|
|
|
|
});
|
2020-05-04 03:44:12 -07:00
|
|
|
shape = 'thumb';
|
2019-11-06 03:43:39 -07:00
|
|
|
} else if (imageTags.Thumb) {
|
|
|
|
url = apiClient.getScaledImageUrl(item.Id, {
|
2020-05-04 03:44:12 -07:00
|
|
|
type: 'Thumb',
|
2020-03-09 13:02:08 -07:00
|
|
|
maxWidth: Math.round(dom.getScreenWidth() * 0.5),
|
2019-11-06 03:43:39 -07:00
|
|
|
tag: item.ImageTags.Thumb
|
|
|
|
});
|
2020-05-04 03:44:12 -07:00
|
|
|
shape = 'thumb';
|
2019-11-06 03:43:39 -07:00
|
|
|
} else if (imageTags.Disc) {
|
|
|
|
url = apiClient.getScaledImageUrl(item.Id, {
|
2020-05-04 03:44:12 -07:00
|
|
|
type: 'Disc',
|
2020-03-09 13:02:08 -07:00
|
|
|
maxWidth: Math.round(dom.getScreenWidth() * 0.5),
|
2019-11-06 03:43:39 -07:00
|
|
|
tag: item.ImageTags.Disc
|
|
|
|
});
|
2020-05-04 03:44:12 -07:00
|
|
|
shape = 'square';
|
2019-11-06 03:43:39 -07:00
|
|
|
} else if (item.AlbumId && item.AlbumPrimaryImageTag) {
|
|
|
|
url = apiClient.getScaledImageUrl(item.AlbumId, {
|
2020-05-04 03:44:12 -07:00
|
|
|
type: 'Primary',
|
2020-03-09 13:02:08 -07:00
|
|
|
maxWidth: Math.round(dom.getScreenWidth() * 0.5),
|
2019-11-06 03:43:39 -07:00
|
|
|
tag: item.AlbumPrimaryImageTag
|
|
|
|
});
|
2020-05-04 03:44:12 -07:00
|
|
|
shape = 'square';
|
2019-11-06 03:43:39 -07:00
|
|
|
} else if (item.SeriesId && item.SeriesPrimaryImageTag) {
|
|
|
|
url = apiClient.getScaledImageUrl(item.SeriesId, {
|
2020-05-04 03:44:12 -07:00
|
|
|
type: 'Primary',
|
2020-03-09 13:02:08 -07:00
|
|
|
maxWidth: Math.round(dom.getScreenWidth() * 0.5),
|
2019-11-06 03:43:39 -07:00
|
|
|
tag: item.SeriesPrimaryImageTag
|
|
|
|
});
|
|
|
|
} else if (item.ParentPrimaryImageItemId && item.ParentPrimaryImageTag) {
|
|
|
|
url = apiClient.getScaledImageUrl(item.ParentPrimaryImageItemId, {
|
2020-05-04 03:44:12 -07:00
|
|
|
type: 'Primary',
|
2020-03-09 13:02:08 -07:00
|
|
|
maxWidth: Math.round(dom.getScreenWidth() * 0.5),
|
2019-11-06 03:43:39 -07:00
|
|
|
tag: item.ParentPrimaryImageTag
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-01-29 10:59:18 -07:00
|
|
|
if (editable && url === undefined) {
|
|
|
|
html += "<a class='itemDetailGalleryLink itemDetailImage defaultCardBackground defaultCardBackground"+ cardBuilder.getDefaultBackgroundClass(item.Name) + "' is='emby-linkbutton' style='display:block;margin:0;padding:0;' href='#'>";
|
2020-01-29 11:05:23 -07:00
|
|
|
} else if (!editable && url === undefined) {
|
|
|
|
html += "<div class='itemDetailGalleryLink itemDetailImage defaultCardBackground defaultCardBackground"+ cardBuilder.getDefaultBackgroundClass(item.Name) + "' is='emby-linkbutton' style='display:block;margin:0;padding:0;' href='#'>";
|
2020-01-29 10:59:18 -07:00
|
|
|
} else if (editable) {
|
2020-01-08 07:18:00 -07:00
|
|
|
html += "<a class='itemDetailGalleryLink' is='emby-linkbutton' style='display:block;margin:0;padding:0;' href='#'>";
|
2019-11-06 03:43:39 -07:00
|
|
|
}
|
|
|
|
|
2020-01-29 10:59:18 -07:00
|
|
|
if (url) {
|
|
|
|
html += "<img class='itemDetailImage lazy' src='data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=' />";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (url === undefined) {
|
|
|
|
html += cardBuilder.getDefaultText(item);
|
|
|
|
}
|
2019-11-06 03:43:39 -07:00
|
|
|
|
|
|
|
if (editable) {
|
2020-05-04 03:44:12 -07:00
|
|
|
html += '</a>';
|
2020-01-29 11:05:23 -07:00
|
|
|
} else if (!editable && url === undefined) {
|
2020-05-04 03:44:12 -07:00
|
|
|
html += '</div>';
|
2019-11-06 03:43:39 -07:00
|
|
|
}
|
|
|
|
|
2020-05-04 03:44:12 -07:00
|
|
|
var progressHtml = item.IsFolder || !item.UserData ? '' : indicators.getProgressBarHtml(item);
|
2019-11-06 03:43:39 -07:00
|
|
|
html += '<div class="detailImageProgressContainer">';
|
|
|
|
|
|
|
|
if (progressHtml) {
|
|
|
|
html += progressHtml;
|
|
|
|
}
|
|
|
|
|
2020-05-04 03:44:12 -07:00
|
|
|
html += '</div>';
|
2019-11-06 03:43:39 -07:00
|
|
|
elem.innerHTML = html;
|
|
|
|
|
2020-01-29 11:05:23 -07:00
|
|
|
if (detectRatio && item.PrimaryImageAspectRatio) {
|
|
|
|
if (item.PrimaryImageAspectRatio >= 1.48) {
|
2020-05-04 03:44:12 -07:00
|
|
|
shape = 'thumb';
|
2020-01-29 11:05:23 -07:00
|
|
|
} else if (item.PrimaryImageAspectRatio >= 0.85 && item.PrimaryImageAspectRatio <= 1.34) {
|
2020-05-04 03:44:12 -07:00
|
|
|
shape = 'square';
|
2020-01-29 11:05:23 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-04 03:44:12 -07:00
|
|
|
if ('thumb' == shape) {
|
|
|
|
elem.classList.add('thumbDetailImageContainer');
|
|
|
|
elem.classList.remove('portraitDetailImageContainer');
|
|
|
|
elem.classList.remove('squareDetailImageContainer');
|
|
|
|
} else if ('square' == shape) {
|
|
|
|
elem.classList.remove('thumbDetailImageContainer');
|
|
|
|
elem.classList.remove('portraitDetailImageContainer');
|
|
|
|
elem.classList.add('squareDetailImageContainer');
|
2019-11-06 03:43:39 -07:00
|
|
|
} else {
|
2020-05-04 03:44:12 -07:00
|
|
|
elem.classList.remove('thumbDetailImageContainer');
|
|
|
|
elem.classList.add('portraitDetailImageContainer');
|
|
|
|
elem.classList.remove('squareDetailImageContainer');
|
2019-11-06 03:43:39 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (url) {
|
2020-05-04 03:44:12 -07:00
|
|
|
imageLoader.lazyImage(elem.querySelector('img'), url);
|
2019-11-06 03:43:39 -07:00
|
|
|
}
|
2018-10-22 15:05:09 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function renderImage(page, item, apiClient, user) {
|
2019-11-06 03:43:39 -07:00
|
|
|
renderDetailImage(
|
|
|
|
page,
|
2020-05-04 03:44:12 -07:00
|
|
|
page.querySelector('.detailImageContainer'),
|
2019-11-06 03:43:39 -07:00
|
|
|
item,
|
|
|
|
apiClient,
|
2020-05-04 03:44:12 -07:00
|
|
|
user.Policy.IsAdministrator && 'Photo' != item.MediaType,
|
2019-11-06 03:43:39 -07:00
|
|
|
imageLoader,
|
|
|
|
indicators
|
|
|
|
);
|
2018-10-22 15:05:09 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function refreshDetailImageUserData(elem, item) {
|
2020-05-04 03:44:12 -07:00
|
|
|
elem.querySelector('.detailImageProgressContainer').innerHTML = indicators.getProgressBarHtml(item);
|
2018-10-22 15:05:09 -07:00
|
|
|
}
|
|
|
|
|
2020-03-01 07:33:41 -07:00
|
|
|
function refreshImage(page, item) {
|
2020-05-04 03:44:12 -07:00
|
|
|
refreshDetailImageUserData(page.querySelector('.detailImageContainer'), item);
|
2018-10-22 15:05:09 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function setPeopleHeader(page, item) {
|
2020-05-04 03:44:12 -07:00
|
|
|
if ('Audio' == item.MediaType || 'MusicAlbum' == item.Type || 'Book' == item.MediaType || 'Photo' == item.MediaType) {
|
|
|
|
page.querySelector('#peopleHeader').innerHTML = globalize.translate('HeaderPeople');
|
2019-11-06 03:43:39 -07:00
|
|
|
} else {
|
2020-05-04 03:44:12 -07:00
|
|
|
page.querySelector('#peopleHeader').innerHTML = globalize.translate('HeaderCastAndCrew');
|
2019-11-06 03:43:39 -07:00
|
|
|
}
|
2018-10-22 15:05:09 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function renderNextUp(page, item, user) {
|
2020-05-04 03:44:12 -07:00
|
|
|
var section = page.querySelector('.nextUpSection');
|
2019-11-06 03:43:39 -07:00
|
|
|
|
2020-05-04 03:44:12 -07:00
|
|
|
if ('Series' != item.Type) {
|
|
|
|
return void section.classList.add('hide');
|
2019-11-06 03:43:39 -07:00
|
|
|
}
|
|
|
|
|
2018-10-22 15:05:09 -07:00
|
|
|
connectionManager.getApiClient(item.ServerId).getNextUpEpisodes({
|
|
|
|
SeriesId: item.Id,
|
|
|
|
UserId: user.Id
|
2019-11-06 03:43:39 -07:00
|
|
|
}).then(function (result) {
|
|
|
|
if (result.Items.length) {
|
2020-05-04 03:44:12 -07:00
|
|
|
section.classList.remove('hide');
|
2019-11-06 03:43:39 -07:00
|
|
|
} else {
|
2020-05-04 03:44:12 -07:00
|
|
|
section.classList.add('hide');
|
2019-11-06 03:43:39 -07:00
|
|
|
}
|
|
|
|
|
2018-10-22 15:05:09 -07:00
|
|
|
var html = cardBuilder.getCardsHtml({
|
2019-11-06 03:43:39 -07:00
|
|
|
items: result.Items,
|
2020-05-04 03:44:12 -07:00
|
|
|
shape: 'overflowBackdrop',
|
2019-11-06 03:43:39 -07:00
|
|
|
showTitle: true,
|
2020-05-04 03:44:12 -07:00
|
|
|
displayAsSpecial: 'Season' == item.Type && item.IndexNumber,
|
2019-11-06 03:43:39 -07:00
|
|
|
overlayText: false,
|
|
|
|
centerText: true,
|
|
|
|
overlayPlayButton: true
|
|
|
|
});
|
2020-05-04 03:44:12 -07:00
|
|
|
var itemsContainer = section.querySelector('.nextUpItems');
|
2019-11-06 03:43:39 -07:00
|
|
|
itemsContainer.innerHTML = html;
|
|
|
|
imageLoader.lazyChildren(itemsContainer);
|
|
|
|
});
|
2018-10-22 15:05:09 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function setInitialCollapsibleState(page, item, apiClient, context, user) {
|
2020-05-04 03:44:12 -07:00
|
|
|
page.querySelector('.collectionItems').innerHTML = '';
|
2019-11-06 03:43:39 -07:00
|
|
|
|
2020-05-04 03:44:12 -07:00
|
|
|
if ('Playlist' == item.Type) {
|
|
|
|
page.querySelector('#childrenCollapsible').classList.remove('hide');
|
2020-03-01 07:33:41 -07:00
|
|
|
renderPlaylistItems(page, item);
|
2020-05-04 03:44:12 -07:00
|
|
|
} else if ('Studio' == item.Type || 'Person' == item.Type || 'Genre' == item.Type || 'MusicGenre' == item.Type || 'MusicArtist' == item.Type) {
|
|
|
|
page.querySelector('#childrenCollapsible').classList.remove('hide');
|
2020-03-01 07:33:41 -07:00
|
|
|
renderItemsByName(page, item);
|
2019-11-06 03:43:39 -07:00
|
|
|
} else if (item.IsFolder) {
|
2020-05-04 03:44:12 -07:00
|
|
|
if ('BoxSet' == item.Type) {
|
|
|
|
page.querySelector('#childrenCollapsible').classList.add('hide');
|
2019-11-06 03:43:39 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
renderChildren(page, item);
|
|
|
|
} else {
|
2020-05-04 03:44:12 -07:00
|
|
|
page.querySelector('#childrenCollapsible').classList.add('hide');
|
2019-11-06 03:43:39 -07:00
|
|
|
}
|
|
|
|
|
2020-05-04 03:44:12 -07:00
|
|
|
if ('Series' == item.Type) {
|
2020-03-01 07:33:41 -07:00
|
|
|
renderSeriesSchedule(page, item);
|
2019-11-06 03:43:39 -07:00
|
|
|
renderNextUp(page, item, user);
|
|
|
|
} else {
|
2020-05-04 03:44:12 -07:00
|
|
|
page.querySelector('.nextUpSection').classList.add('hide');
|
2019-11-06 03:43:39 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
renderScenes(page, item);
|
|
|
|
|
2020-05-04 03:44:12 -07:00
|
|
|
if (item.SpecialFeatureCount && 0 != item.SpecialFeatureCount && 'Series' != item.Type) {
|
|
|
|
page.querySelector('#specialsCollapsible').classList.remove('hide');
|
2019-11-06 03:43:39 -07:00
|
|
|
renderSpecials(page, item, user, 6);
|
|
|
|
} else {
|
2020-05-04 03:44:12 -07:00
|
|
|
page.querySelector('#specialsCollapsible').classList.add('hide');
|
2019-11-06 03:43:39 -07:00
|
|
|
}
|
|
|
|
|
2020-03-01 07:33:41 -07:00
|
|
|
renderCast(page, item);
|
2019-11-06 03:43:39 -07:00
|
|
|
|
|
|
|
if (item.PartCount && item.PartCount > 1) {
|
2020-05-04 03:44:12 -07:00
|
|
|
page.querySelector('#additionalPartsCollapsible').classList.remove('hide');
|
2019-11-06 03:43:39 -07:00
|
|
|
renderAdditionalParts(page, item, user);
|
|
|
|
} else {
|
2020-05-04 03:44:12 -07:00
|
|
|
page.querySelector('#additionalPartsCollapsible').classList.add('hide');
|
2019-11-06 03:43:39 -07:00
|
|
|
}
|
|
|
|
|
2020-05-04 03:44:12 -07:00
|
|
|
if ('MusicAlbum' == item.Type) {
|
2019-11-06 03:43:39 -07:00
|
|
|
renderMusicVideos(page, item, user);
|
|
|
|
} else {
|
2020-05-04 03:44:12 -07:00
|
|
|
page.querySelector('#musicVideosCollapsible').classList.add('hide');
|
2019-11-06 03:43:39 -07:00
|
|
|
}
|
2018-10-22 15:05:09 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function renderOverview(elems, item) {
|
|
|
|
for (var i = 0, length = elems.length; i < length; i++) {
|
2019-11-06 03:43:39 -07:00
|
|
|
var elem = elems[i];
|
2020-05-04 03:44:12 -07:00
|
|
|
var overview = item.Overview || '';
|
2019-11-06 03:43:39 -07:00
|
|
|
|
2018-10-22 15:05:09 -07:00
|
|
|
if (overview) {
|
2019-11-06 03:43:39 -07:00
|
|
|
elem.innerHTML = overview;
|
2020-05-04 03:44:12 -07:00
|
|
|
elem.classList.remove('hide');
|
|
|
|
var anchors = elem.querySelectorAll('a');
|
2019-11-06 03:43:39 -07:00
|
|
|
|
|
|
|
for (var j = 0, length2 = anchors.length; j < length2; j++) {
|
2020-05-04 03:44:12 -07:00
|
|
|
anchors[j].setAttribute('target', '_blank');
|
2019-11-06 03:43:39 -07:00
|
|
|
}
|
|
|
|
} else {
|
2020-05-04 03:44:12 -07:00
|
|
|
elem.innerHTML = '';
|
|
|
|
elem.classList.add('hide');
|
2019-11-06 03:43:39 -07:00
|
|
|
}
|
2018-10-22 15:05:09 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-01 07:33:41 -07:00
|
|
|
function renderGenres(page, item, context) {
|
2018-10-22 15:05:09 -07:00
|
|
|
context = context || inferContext(item);
|
2019-11-06 03:43:39 -07:00
|
|
|
var type;
|
|
|
|
var genres = item.GenreItems || [];
|
|
|
|
|
2018-10-22 15:05:09 -07:00
|
|
|
switch (context) {
|
2020-05-04 03:44:12 -07:00
|
|
|
case 'music':
|
|
|
|
type = 'MusicGenre';
|
2018-10-22 15:05:09 -07:00
|
|
|
break;
|
2019-11-06 03:43:39 -07:00
|
|
|
|
2018-10-22 15:05:09 -07:00
|
|
|
default:
|
2020-05-04 03:44:12 -07:00
|
|
|
type = 'Genre';
|
2019-11-06 03:43:39 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
var html = genres.map(function (p) {
|
|
|
|
return '<a style="color:inherit;" class="button-link" is="emby-linkbutton" href="' + appRouter.getRouteUrl({
|
|
|
|
Name: p.Name,
|
|
|
|
Type: type,
|
|
|
|
ServerId: item.ServerId,
|
|
|
|
Id: p.Id
|
|
|
|
}, {
|
|
|
|
context: context
|
2020-05-04 03:44:12 -07:00
|
|
|
}) + '">' + p.Name + '</a>';
|
|
|
|
}).join(', ');
|
2019-11-06 03:43:39 -07:00
|
|
|
|
2020-05-04 03:44:12 -07:00
|
|
|
var genresLabel = page.querySelector('.genresLabel');
|
|
|
|
genresLabel.innerHTML = globalize.translate(genres.length > 1 ? 'Genres' : 'Genre');
|
|
|
|
var genresValue = page.querySelector('.genres');
|
2020-03-15 06:15:48 -07:00
|
|
|
genresValue.innerHTML = html;
|
|
|
|
|
2020-05-04 03:44:12 -07:00
|
|
|
var genresGroup = page.querySelector('.genresGroup');
|
2019-11-06 03:43:39 -07:00
|
|
|
if (genres.length) {
|
2020-05-04 03:44:12 -07:00
|
|
|
genresGroup.classList.remove('hide');
|
2019-11-06 03:43:39 -07:00
|
|
|
} else {
|
2020-05-04 03:44:12 -07:00
|
|
|
genresGroup.classList.add('hide');
|
2019-11-06 03:43:39 -07:00
|
|
|
}
|
2018-10-22 15:05:09 -07:00
|
|
|
}
|
|
|
|
|
2020-03-01 07:33:41 -07:00
|
|
|
function renderDirector(page, item, context) {
|
2019-11-06 03:43:39 -07:00
|
|
|
var directors = (item.People || []).filter(function (p) {
|
2020-05-04 03:44:12 -07:00
|
|
|
return 'Director' === p.Type;
|
2019-11-06 03:43:39 -07:00
|
|
|
});
|
|
|
|
var html = directors.map(function (p) {
|
|
|
|
return '<a style="color:inherit;" class="button-link" is="emby-linkbutton" href="' + appRouter.getRouteUrl({
|
|
|
|
Name: p.Name,
|
2020-05-04 03:44:12 -07:00
|
|
|
Type: 'Person',
|
2019-11-06 03:43:39 -07:00
|
|
|
ServerId: item.ServerId,
|
|
|
|
Id: p.Id
|
|
|
|
}, {
|
|
|
|
context: context
|
2020-05-04 03:44:12 -07:00
|
|
|
}) + '">' + p.Name + '</a>';
|
|
|
|
}).join(', ');
|
2019-11-06 03:43:39 -07:00
|
|
|
|
2020-05-04 03:44:12 -07:00
|
|
|
var directorsLabel = page.querySelector('.directorsLabel');
|
|
|
|
directorsLabel.innerHTML = globalize.translate(directors.length > 1 ? 'Directors' : 'Director');
|
|
|
|
var directorsValue = page.querySelector('.directors');
|
2020-03-15 06:15:48 -07:00
|
|
|
directorsValue.innerHTML = html;
|
|
|
|
|
2020-05-04 03:44:12 -07:00
|
|
|
var directorsGroup = page.querySelector('.directorsGroup');
|
2019-11-06 03:43:39 -07:00
|
|
|
if (directors.length) {
|
2020-05-04 03:44:12 -07:00
|
|
|
directorsGroup.classList.remove('hide');
|
2019-11-06 03:43:39 -07:00
|
|
|
} else {
|
2020-05-04 03:44:12 -07:00
|
|
|
directorsGroup.classList.add('hide');
|
2019-11-06 03:43:39 -07:00
|
|
|
}
|
2018-10-22 15:05:09 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function renderDetails(page, item, apiClient, context, isStatic) {
|
2019-09-11 09:47:39 -07:00
|
|
|
renderSimilarItems(page, item, context);
|
|
|
|
renderMoreFromSeason(page, item, apiClient);
|
|
|
|
renderMoreFromArtist(page, item, apiClient);
|
2020-03-01 07:33:41 -07:00
|
|
|
renderDirector(page, item, context);
|
|
|
|
renderGenres(page, item, context);
|
2019-09-11 09:47:39 -07:00
|
|
|
renderChannelGuide(page, apiClient, item);
|
2020-05-04 03:44:12 -07:00
|
|
|
var taglineElement = page.querySelector('.tagline');
|
2019-11-06 03:43:39 -07:00
|
|
|
|
2019-09-11 09:47:39 -07:00
|
|
|
if (item.Taglines && item.Taglines.length) {
|
2020-05-04 03:44:12 -07:00
|
|
|
taglineElement.classList.remove('hide');
|
2019-09-11 09:47:39 -07:00
|
|
|
taglineElement.innerHTML = item.Taglines[0];
|
|
|
|
} else {
|
2020-05-04 03:44:12 -07:00
|
|
|
taglineElement.classList.add('hide');
|
2019-09-11 09:47:39 -07:00
|
|
|
}
|
|
|
|
|
2020-05-04 03:44:12 -07:00
|
|
|
var overview = page.querySelector('.overview');
|
|
|
|
var externalLinksElem = page.querySelector('.itemExternalLinks');
|
2019-09-11 09:47:39 -07:00
|
|
|
|
2019-11-06 03:43:39 -07:00
|
|
|
renderOverview([overview], item);
|
|
|
|
var i;
|
|
|
|
var itemMiscInfo;
|
2020-05-04 03:44:12 -07:00
|
|
|
itemMiscInfo = page.querySelectorAll('.itemMiscInfo-primary');
|
2019-11-06 03:43:39 -07:00
|
|
|
|
2019-09-11 09:47:39 -07:00
|
|
|
for (i = 0; i < itemMiscInfo.length; i++) {
|
|
|
|
mediaInfo.fillPrimaryMediaInfo(itemMiscInfo[i], item, {
|
2019-11-06 03:43:39 -07:00
|
|
|
interactive: true,
|
|
|
|
episodeTitle: false,
|
|
|
|
subtitles: false
|
2019-09-11 09:47:39 -07:00
|
|
|
});
|
|
|
|
|
2020-05-04 03:44:12 -07:00
|
|
|
if (itemMiscInfo[i].innerHTML && 'SeriesTimer' !== item.Type) {
|
|
|
|
itemMiscInfo[i].classList.remove('hide');
|
2019-09-11 09:47:39 -07:00
|
|
|
} else {
|
2020-05-04 03:44:12 -07:00
|
|
|
itemMiscInfo[i].classList.add('hide');
|
2019-09-11 09:47:39 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-04 03:44:12 -07:00
|
|
|
itemMiscInfo = page.querySelectorAll('.itemMiscInfo-secondary');
|
2019-11-06 03:43:39 -07:00
|
|
|
|
2019-09-11 09:47:39 -07:00
|
|
|
for (i = 0; i < itemMiscInfo.length; i++) {
|
|
|
|
mediaInfo.fillSecondaryMediaInfo(itemMiscInfo[i], item, {
|
2019-11-06 03:43:39 -07:00
|
|
|
interactive: true
|
|
|
|
});
|
2019-09-11 09:47:39 -07:00
|
|
|
|
2020-05-04 03:44:12 -07:00
|
|
|
if (itemMiscInfo[i].innerHTML && 'SeriesTimer' !== item.Type) {
|
|
|
|
itemMiscInfo[i].classList.remove('hide');
|
2019-09-11 09:47:39 -07:00
|
|
|
} else {
|
2020-05-04 03:44:12 -07:00
|
|
|
itemMiscInfo[i].classList.add('hide');
|
2019-09-11 09:47:39 -07:00
|
|
|
}
|
|
|
|
}
|
2019-11-06 03:43:39 -07:00
|
|
|
|
2019-09-11 09:47:39 -07:00
|
|
|
reloadUserDataButtons(page, item);
|
|
|
|
renderLinks(externalLinksElem, item);
|
|
|
|
renderTags(page, item);
|
2019-11-06 03:43:39 -07:00
|
|
|
renderSeriesAirTime(page, item, isStatic);
|
2018-10-22 15:05:09 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function enableScrollX() {
|
2019-11-06 03:43:39 -07:00
|
|
|
return browser.mobile && screen.availWidth <= 1000;
|
2018-10-22 15:05:09 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function getPortraitShape(scrollX) {
|
2019-11-06 03:43:39 -07:00
|
|
|
if (null == scrollX) {
|
|
|
|
scrollX = enableScrollX();
|
|
|
|
}
|
|
|
|
|
2020-05-04 03:44:12 -07:00
|
|
|
return scrollX ? 'overflowPortrait' : 'portrait';
|
2018-10-22 15:05:09 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function getSquareShape(scrollX) {
|
2019-11-06 03:43:39 -07:00
|
|
|
if (null == scrollX) {
|
|
|
|
scrollX = enableScrollX();
|
|
|
|
}
|
|
|
|
|
2020-05-04 03:44:12 -07:00
|
|
|
return scrollX ? 'overflowSquare' : 'square';
|
2018-10-22 15:05:09 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function renderMoreFromSeason(view, item, apiClient) {
|
2020-05-04 03:44:12 -07:00
|
|
|
var section = view.querySelector('.moreFromSeasonSection');
|
2019-11-06 03:43:39 -07:00
|
|
|
|
2018-10-22 15:05:09 -07:00
|
|
|
if (section) {
|
2020-05-04 03:44:12 -07:00
|
|
|
if ('Episode' !== item.Type || !item.SeasonId || !item.SeriesId) {
|
|
|
|
return void section.classList.add('hide');
|
2019-11-06 03:43:39 -07:00
|
|
|
}
|
|
|
|
|
2018-10-22 15:05:09 -07:00
|
|
|
var userId = apiClient.getCurrentUserId();
|
|
|
|
apiClient.getEpisodes(item.SeriesId, {
|
|
|
|
SeasonId: item.SeasonId,
|
|
|
|
UserId: userId,
|
2020-05-04 03:44:12 -07:00
|
|
|
Fields: 'ItemCounts,PrimaryImageAspectRatio,BasicSyncInfo,CanDelete,MediaSourceCount'
|
2019-11-06 03:43:39 -07:00
|
|
|
}).then(function (result) {
|
|
|
|
if (result.Items.length < 2) {
|
2020-05-04 03:44:12 -07:00
|
|
|
return void section.classList.add('hide');
|
2019-11-06 03:43:39 -07:00
|
|
|
}
|
|
|
|
|
2020-05-04 03:44:12 -07:00
|
|
|
section.classList.remove('hide');
|
|
|
|
section.querySelector('h2').innerHTML = globalize.translate('MoreFromValue', item.SeasonName);
|
|
|
|
var itemsContainer = section.querySelector('.itemsContainer');
|
2018-10-22 15:05:09 -07:00
|
|
|
cardBuilder.buildCards(result.Items, {
|
|
|
|
parentContainer: section,
|
|
|
|
itemsContainer: itemsContainer,
|
2020-05-04 03:44:12 -07:00
|
|
|
shape: 'autooverflow',
|
|
|
|
sectionTitleTagName: 'h2',
|
2019-11-06 03:43:39 -07:00
|
|
|
scalable: true,
|
|
|
|
showTitle: true,
|
|
|
|
overlayText: false,
|
|
|
|
centerText: true,
|
|
|
|
includeParentInfoInTitle: false,
|
|
|
|
allowBottomPadding: false
|
2018-10-22 15:05:09 -07:00
|
|
|
});
|
|
|
|
var card = itemsContainer.querySelector('.card[data-id="' + item.Id + '"]');
|
2019-11-06 03:43:39 -07:00
|
|
|
|
|
|
|
if (card) {
|
|
|
|
setTimeout(function () {
|
2020-05-04 03:44:12 -07:00
|
|
|
section.querySelector('.emby-scroller').toStart(card.previousSibling || card, true);
|
2019-11-06 03:43:39 -07:00
|
|
|
}, 100);
|
|
|
|
}
|
|
|
|
});
|
2018-10-22 15:05:09 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function renderMoreFromArtist(view, item, apiClient) {
|
2020-05-04 03:44:12 -07:00
|
|
|
var section = view.querySelector('.moreFromArtistSection');
|
2019-11-06 03:43:39 -07:00
|
|
|
|
2018-10-22 15:05:09 -07:00
|
|
|
if (section) {
|
2020-05-04 03:44:12 -07:00
|
|
|
if ('MusicArtist' === item.Type) {
|
|
|
|
if (!apiClient.isMinServerVersion('3.4.1.19')) {
|
|
|
|
return void section.classList.add('hide');
|
2019-11-06 03:43:39 -07:00
|
|
|
}
|
2020-05-04 03:44:12 -07:00
|
|
|
} else if ('MusicAlbum' !== item.Type || !item.AlbumArtists || !item.AlbumArtists.length) {
|
|
|
|
return void section.classList.add('hide');
|
2019-11-06 03:43:39 -07:00
|
|
|
}
|
|
|
|
|
2018-10-22 15:05:09 -07:00
|
|
|
var query = {
|
2020-05-04 03:44:12 -07:00
|
|
|
IncludeItemTypes: 'MusicAlbum',
|
2019-11-06 03:43:39 -07:00
|
|
|
Recursive: true,
|
2018-10-22 15:05:09 -07:00
|
|
|
ExcludeItemIds: item.Id,
|
2020-05-04 03:44:12 -07:00
|
|
|
SortBy: 'ProductionYear,SortName',
|
|
|
|
SortOrder: 'Descending'
|
2018-10-22 15:05:09 -07:00
|
|
|
};
|
2019-11-06 03:43:39 -07:00
|
|
|
|
2020-05-04 03:44:12 -07:00
|
|
|
if ('MusicArtist' === item.Type) {
|
2019-11-06 03:43:39 -07:00
|
|
|
query.ContributingArtistIds = item.Id;
|
2020-05-04 03:44:12 -07:00
|
|
|
} else if (apiClient.isMinServerVersion('3.4.1.18')) {
|
2019-11-06 03:43:39 -07:00
|
|
|
query.AlbumArtistIds = item.AlbumArtists[0].Id;
|
|
|
|
} else {
|
|
|
|
query.ArtistIds = item.AlbumArtists[0].Id;
|
|
|
|
}
|
|
|
|
|
|
|
|
apiClient.getItems(apiClient.getCurrentUserId(), query).then(function (result) {
|
|
|
|
if (!result.Items.length) {
|
2020-05-04 03:44:12 -07:00
|
|
|
return void section.classList.add('hide');
|
2019-11-06 03:43:39 -07:00
|
|
|
}
|
|
|
|
|
2020-05-04 03:44:12 -07:00
|
|
|
section.classList.remove('hide');
|
2019-11-06 03:43:39 -07:00
|
|
|
|
2020-05-04 03:44:12 -07:00
|
|
|
if ('MusicArtist' === item.Type) {
|
|
|
|
section.querySelector('h2').innerHTML = globalize.translate('HeaderAppearsOn');
|
2019-11-06 03:43:39 -07:00
|
|
|
} else {
|
2020-05-04 03:44:12 -07:00
|
|
|
section.querySelector('h2').innerHTML = globalize.translate('MoreFromValue', item.AlbumArtists[0].Name);
|
2019-11-06 03:43:39 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
cardBuilder.buildCards(result.Items, {
|
2018-10-22 15:05:09 -07:00
|
|
|
parentContainer: section,
|
2020-05-04 03:44:12 -07:00
|
|
|
itemsContainer: section.querySelector('.itemsContainer'),
|
|
|
|
shape: 'autooverflow',
|
|
|
|
sectionTitleTagName: 'h2',
|
2019-11-06 03:43:39 -07:00
|
|
|
scalable: true,
|
2020-05-04 03:44:12 -07:00
|
|
|
coverImage: 'MusicArtist' === item.Type || 'MusicAlbum' === item.Type,
|
2019-11-06 03:43:39 -07:00
|
|
|
showTitle: true,
|
|
|
|
showParentTitle: false,
|
|
|
|
centerText: true,
|
|
|
|
overlayText: false,
|
|
|
|
overlayPlayButton: true,
|
|
|
|
showYear: true
|
|
|
|
});
|
|
|
|
});
|
2018-10-22 15:05:09 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function renderSimilarItems(page, item, context) {
|
2020-05-04 03:44:12 -07:00
|
|
|
var similarCollapsible = page.querySelector('#similarCollapsible');
|
2019-11-06 03:43:39 -07:00
|
|
|
|
2018-10-22 15:05:09 -07:00
|
|
|
if (similarCollapsible) {
|
2020-05-04 03:44:12 -07:00
|
|
|
if ('Movie' != item.Type && 'Trailer' != item.Type && 'Series' != item.Type && 'Program' != item.Type && 'Recording' != item.Type && 'MusicAlbum' != item.Type && 'MusicArtist' != item.Type && 'Playlist' != item.Type) {
|
|
|
|
return void similarCollapsible.classList.add('hide');
|
2019-11-06 03:43:39 -07:00
|
|
|
}
|
|
|
|
|
2020-05-04 03:44:12 -07:00
|
|
|
similarCollapsible.classList.remove('hide');
|
2019-11-06 03:43:39 -07:00
|
|
|
var apiClient = connectionManager.getApiClient(item.ServerId);
|
|
|
|
var options = {
|
|
|
|
userId: apiClient.getCurrentUserId(),
|
|
|
|
limit: 12,
|
2020-05-04 03:44:12 -07:00
|
|
|
fields: 'PrimaryImageAspectRatio,UserData,CanDelete'
|
2019-11-06 03:43:39 -07:00
|
|
|
};
|
|
|
|
|
2020-05-04 03:44:12 -07:00
|
|
|
if ('MusicAlbum' == item.Type && item.AlbumArtists && item.AlbumArtists.length) {
|
2019-11-06 03:43:39 -07:00
|
|
|
options.ExcludeArtistIds = item.AlbumArtists[0].Id;
|
|
|
|
}
|
|
|
|
|
|
|
|
apiClient.getSimilarItems(item.Id, options).then(function (result) {
|
|
|
|
if (!result.Items.length) {
|
2020-05-04 03:44:12 -07:00
|
|
|
return void similarCollapsible.classList.add('hide');
|
2019-11-06 03:43:39 -07:00
|
|
|
}
|
|
|
|
|
2020-05-04 03:44:12 -07:00
|
|
|
similarCollapsible.classList.remove('hide');
|
|
|
|
var html = '';
|
2018-10-22 15:05:09 -07:00
|
|
|
html += cardBuilder.getCardsHtml({
|
|
|
|
items: result.Items,
|
2020-05-04 03:44:12 -07:00
|
|
|
shape: 'autooverflow',
|
|
|
|
showParentTitle: 'MusicAlbum' == item.Type,
|
2019-11-06 03:43:39 -07:00
|
|
|
centerText: true,
|
|
|
|
showTitle: true,
|
2018-10-22 15:05:09 -07:00
|
|
|
context: context,
|
2019-11-06 03:43:39 -07:00
|
|
|
lazy: true,
|
|
|
|
showDetailsMenu: true,
|
2020-05-04 03:44:12 -07:00
|
|
|
coverImage: 'MusicAlbum' == item.Type || 'MusicArtist' == item.Type,
|
2019-11-06 03:43:39 -07:00
|
|
|
overlayPlayButton: true,
|
|
|
|
overlayText: false,
|
2020-05-04 03:44:12 -07:00
|
|
|
showYear: 'Movie' === item.Type || 'Trailer' === item.Type || 'Series' === item.Type
|
2018-10-22 15:05:09 -07:00
|
|
|
});
|
2020-05-04 03:44:12 -07:00
|
|
|
var similarContent = similarCollapsible.querySelector('.similarContent');
|
2019-11-06 03:43:39 -07:00
|
|
|
similarContent.innerHTML = html;
|
|
|
|
imageLoader.lazyChildren(similarContent);
|
|
|
|
});
|
2018-10-22 15:05:09 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function renderSeriesAirTime(page, item, isStatic) {
|
2020-05-04 03:44:12 -07:00
|
|
|
var seriesAirTime = page.querySelector('#seriesAirTime');
|
|
|
|
if ('Series' != item.Type) {
|
|
|
|
seriesAirTime.classList.add('hide');
|
2019-11-06 03:43:39 -07:00
|
|
|
return;
|
|
|
|
}
|
2020-05-04 03:44:12 -07:00
|
|
|
var html = '';
|
2019-11-06 03:43:39 -07:00
|
|
|
if (item.AirDays && item.AirDays.length) {
|
|
|
|
if (7 == item.AirDays.length) {
|
2020-05-04 03:44:12 -07:00
|
|
|
html += 'daily';
|
2019-11-06 03:43:39 -07:00
|
|
|
} else {
|
|
|
|
html += item.AirDays.map(function (a) {
|
2020-05-04 03:44:12 -07:00
|
|
|
return a + 's';
|
|
|
|
}).join(',');
|
2019-11-06 03:43:39 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (item.AirTime) {
|
2020-05-04 03:44:12 -07:00
|
|
|
html += ' at ' + item.AirTime;
|
2019-11-06 03:43:39 -07:00
|
|
|
}
|
|
|
|
if (item.Studios.length) {
|
|
|
|
if (isStatic) {
|
2020-05-04 03:44:12 -07:00
|
|
|
html += ' on ' + item.Studios[0].Name;
|
2019-11-06 03:43:39 -07:00
|
|
|
} else {
|
|
|
|
var context = inferContext(item);
|
|
|
|
var href = appRouter.getRouteUrl(item.Studios[0], {
|
|
|
|
context: context,
|
2020-05-04 03:44:12 -07:00
|
|
|
itemType: 'Studio',
|
2019-11-06 03:43:39 -07:00
|
|
|
serverId: item.ServerId
|
|
|
|
});
|
2020-05-04 03:44:12 -07:00
|
|
|
html += ' on <a class="textlink button-link" is="emby-linkbutton" href="' + href + '">' + item.Studios[0].Name + '</a>';
|
2019-11-06 03:43:39 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (html) {
|
2020-05-04 03:44:12 -07:00
|
|
|
html = ('Ended' == item.Status ? 'Aired ' : 'Airs ') + html;
|
2019-11-06 03:43:39 -07:00
|
|
|
seriesAirTime.innerHTML = html;
|
2020-05-04 03:44:12 -07:00
|
|
|
seriesAirTime.classList.remove('hide');
|
2019-11-06 03:43:39 -07:00
|
|
|
} else {
|
2020-05-04 03:44:12 -07:00
|
|
|
seriesAirTime.classList.add('hide');
|
2019-11-06 03:43:39 -07:00
|
|
|
}
|
2018-10-22 15:05:09 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function renderTags(page, item) {
|
2020-05-04 03:44:12 -07:00
|
|
|
var itemTags = page.querySelector('.itemTags');
|
2019-11-06 03:43:39 -07:00
|
|
|
var tagElements = [];
|
|
|
|
var tags = item.Tags || [];
|
|
|
|
|
2020-05-04 03:44:12 -07:00
|
|
|
if ('Program' === item.Type) {
|
2019-11-06 03:43:39 -07:00
|
|
|
tags = [];
|
|
|
|
}
|
|
|
|
|
|
|
|
for (var i = 0, length = tags.length; i < length; i++) {
|
|
|
|
tagElements.push(tags[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tagElements.length) {
|
2020-05-04 03:44:12 -07:00
|
|
|
itemTags.innerHTML = globalize.translate('TagsValue', tagElements.join(', '));
|
|
|
|
itemTags.classList.remove('hide');
|
2019-11-06 03:43:39 -07:00
|
|
|
} else {
|
2020-05-04 03:44:12 -07:00
|
|
|
itemTags.innerHTML = '';
|
|
|
|
itemTags.classList.add('hide');
|
2019-11-06 03:43:39 -07:00
|
|
|
}
|
2018-10-22 15:05:09 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function renderChildren(page, item) {
|
2020-05-04 03:44:12 -07:00
|
|
|
var fields = 'ItemCounts,PrimaryImageAspectRatio,BasicSyncInfo,CanDelete,MediaSourceCount';
|
2019-11-06 03:43:39 -07:00
|
|
|
var query = {
|
|
|
|
ParentId: item.Id,
|
2018-10-22 15:05:09 -07:00
|
|
|
Fields: fields
|
2019-11-06 03:43:39 -07:00
|
|
|
};
|
|
|
|
|
2020-05-04 03:44:12 -07:00
|
|
|
if ('BoxSet' !== item.Type) {
|
|
|
|
query.SortBy = 'SortName';
|
2019-11-06 03:43:39 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
var promise;
|
|
|
|
var apiClient = connectionManager.getApiClient(item.ServerId);
|
|
|
|
var userId = apiClient.getCurrentUserId();
|
|
|
|
|
2020-05-04 03:44:12 -07:00
|
|
|
if ('Series' == item.Type) {
|
2019-11-06 03:43:39 -07:00
|
|
|
promise = apiClient.getSeasons(item.Id, {
|
|
|
|
userId: userId,
|
|
|
|
Fields: fields
|
|
|
|
});
|
2020-05-04 03:44:12 -07:00
|
|
|
} else if ('Season' == item.Type) {
|
|
|
|
fields += ',Overview';
|
2019-11-06 03:43:39 -07:00
|
|
|
promise = apiClient.getEpisodes(item.SeriesId, {
|
|
|
|
seasonId: item.Id,
|
|
|
|
userId: userId,
|
|
|
|
Fields: fields
|
2018-10-22 15:05:09 -07:00
|
|
|
});
|
2020-05-04 03:44:12 -07:00
|
|
|
} else if ('MusicArtist' == item.Type) {
|
|
|
|
query.SortBy = 'ProductionYear,SortName';
|
2019-11-06 03:43:39 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
promise = promise || apiClient.getItems(apiClient.getCurrentUserId(), query);
|
|
|
|
promise.then(function (result) {
|
2020-05-04 03:44:12 -07:00
|
|
|
var html = '';
|
2019-11-06 03:43:39 -07:00
|
|
|
var scrollX = false;
|
|
|
|
var isList = false;
|
2020-05-04 03:44:12 -07:00
|
|
|
var childrenItemsContainer = page.querySelector('.childrenItemsContainer');
|
2019-11-06 03:43:39 -07:00
|
|
|
|
2020-05-04 03:44:12 -07:00
|
|
|
if ('MusicAlbum' == item.Type) {
|
2019-11-06 03:43:39 -07:00
|
|
|
html = listView.getListViewHtml({
|
2018-10-22 15:05:09 -07:00
|
|
|
items: result.Items,
|
2019-11-06 03:43:39 -07:00
|
|
|
smallIcon: true,
|
|
|
|
showIndex: true,
|
2020-05-04 03:44:12 -07:00
|
|
|
index: 'disc',
|
2019-11-06 03:43:39 -07:00
|
|
|
showIndexNumberLeft: true,
|
|
|
|
playFromHere: true,
|
2020-05-04 03:44:12 -07:00
|
|
|
action: 'playallfromhere',
|
2019-11-06 03:43:39 -07:00
|
|
|
image: false,
|
2020-05-04 03:44:12 -07:00
|
|
|
artist: 'auto',
|
2019-11-06 03:43:39 -07:00
|
|
|
containerAlbumArtists: item.AlbumArtists,
|
|
|
|
addToListButton: true
|
|
|
|
});
|
|
|
|
isList = true;
|
2020-05-04 03:44:12 -07:00
|
|
|
} else if ('Series' == item.Type) {
|
2019-11-06 03:43:39 -07:00
|
|
|
scrollX = enableScrollX();
|
|
|
|
html = cardBuilder.getCardsHtml({
|
2018-10-22 15:05:09 -07:00
|
|
|
items: result.Items,
|
2020-05-04 03:44:12 -07:00
|
|
|
shape: 'overflowPortrait',
|
2019-11-06 03:43:39 -07:00
|
|
|
showTitle: true,
|
|
|
|
centerText: true,
|
|
|
|
lazy: true,
|
|
|
|
overlayPlayButton: true,
|
|
|
|
allowBottomPadding: !scrollX
|
|
|
|
});
|
2020-05-04 03:44:12 -07:00
|
|
|
} else if ('Season' == item.Type || 'Episode' == item.Type) {
|
|
|
|
if ('Episode' !== item.Type) {
|
2019-11-06 03:43:39 -07:00
|
|
|
isList = true;
|
|
|
|
}
|
2020-05-04 03:44:12 -07:00
|
|
|
scrollX = 'Episode' == item.Type;
|
|
|
|
if (result.Items.length < 2 && 'Episode' === item.Type) {
|
2019-11-06 03:43:39 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-05-04 03:44:12 -07:00
|
|
|
if ('Episode' === item.Type) {
|
2019-11-06 03:43:39 -07:00
|
|
|
html = cardBuilder.getCardsHtml({
|
|
|
|
items: result.Items,
|
2020-05-04 03:44:12 -07:00
|
|
|
shape: 'overflowBackdrop',
|
2019-11-06 03:43:39 -07:00
|
|
|
showTitle: true,
|
2020-05-04 03:44:12 -07:00
|
|
|
displayAsSpecial: 'Season' == item.Type && item.IndexNumber,
|
2019-11-06 03:43:39 -07:00
|
|
|
playFromHere: true,
|
|
|
|
overlayText: true,
|
|
|
|
lazy: true,
|
|
|
|
showDetailsMenu: true,
|
|
|
|
overlayPlayButton: true,
|
|
|
|
allowBottomPadding: !scrollX,
|
|
|
|
includeParentInfoInTitle: false
|
|
|
|
});
|
2020-05-04 03:44:12 -07:00
|
|
|
} else if ('Season' === item.Type) {
|
2019-11-06 03:43:39 -07:00
|
|
|
html = listView.getListViewHtml({
|
|
|
|
items: result.Items,
|
|
|
|
showIndexNumber: false,
|
|
|
|
enableOverview: true,
|
2020-05-04 03:44:12 -07:00
|
|
|
imageSize: 'large',
|
2019-11-06 03:43:39 -07:00
|
|
|
enableSideMediaInfo: false,
|
|
|
|
highlight: false,
|
2020-05-04 03:44:12 -07:00
|
|
|
action: layoutManager.tv ? 'resume' : 'none',
|
2019-11-06 03:43:39 -07:00
|
|
|
infoButton: true,
|
|
|
|
imagePlayButton: true,
|
|
|
|
includeParentInfoInTitle: false
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-04 03:44:12 -07:00
|
|
|
if ('BoxSet' !== item.Type) {
|
|
|
|
page.querySelector('#childrenCollapsible').classList.remove('hide');
|
2019-01-27 14:10:07 -07:00
|
|
|
}
|
2019-11-06 03:43:39 -07:00
|
|
|
if (scrollX) {
|
2020-05-04 03:44:12 -07:00
|
|
|
childrenItemsContainer.classList.add('scrollX');
|
|
|
|
childrenItemsContainer.classList.add('hiddenScrollX');
|
|
|
|
childrenItemsContainer.classList.remove('vertical-wrap');
|
|
|
|
childrenItemsContainer.classList.remove('vertical-list');
|
2019-11-06 03:43:39 -07:00
|
|
|
} else {
|
2020-05-04 03:44:12 -07:00
|
|
|
childrenItemsContainer.classList.remove('scrollX');
|
|
|
|
childrenItemsContainer.classList.remove('hiddenScrollX');
|
|
|
|
childrenItemsContainer.classList.remove('smoothScrollX');
|
2019-11-06 03:43:39 -07:00
|
|
|
if (isList) {
|
2020-05-04 03:44:12 -07:00
|
|
|
childrenItemsContainer.classList.add('vertical-list');
|
|
|
|
childrenItemsContainer.classList.remove('vertical-wrap');
|
2019-11-06 03:43:39 -07:00
|
|
|
} else {
|
2020-05-04 03:44:12 -07:00
|
|
|
childrenItemsContainer.classList.add('vertical-wrap');
|
|
|
|
childrenItemsContainer.classList.remove('vertical-list');
|
2019-11-06 03:43:39 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
childrenItemsContainer.innerHTML = html;
|
|
|
|
imageLoader.lazyChildren(childrenItemsContainer);
|
2020-05-04 03:44:12 -07:00
|
|
|
if ('BoxSet' == item.Type) {
|
2018-10-22 15:05:09 -07:00
|
|
|
var collectionItemTypes = [{
|
2020-05-04 03:44:12 -07:00
|
|
|
name: globalize.translate('HeaderVideos'),
|
|
|
|
mediaType: 'Video'
|
2018-10-22 15:05:09 -07:00
|
|
|
}, {
|
2020-05-04 03:44:12 -07:00
|
|
|
name: globalize.translate('HeaderSeries'),
|
|
|
|
type: 'Series'
|
2018-10-22 15:05:09 -07:00
|
|
|
}, {
|
2020-05-04 03:44:12 -07:00
|
|
|
name: globalize.translate('HeaderAlbums'),
|
|
|
|
type: 'MusicAlbum'
|
2018-10-22 15:05:09 -07:00
|
|
|
}, {
|
2020-05-04 03:44:12 -07:00
|
|
|
name: globalize.translate('HeaderBooks'),
|
|
|
|
type: 'Book'
|
2018-10-22 15:05:09 -07:00
|
|
|
}];
|
2019-11-06 03:43:39 -07:00
|
|
|
renderCollectionItems(page, item, collectionItemTypes, result.Items);
|
2018-10-22 15:05:09 -07:00
|
|
|
}
|
2019-11-06 03:43:39 -07:00
|
|
|
});
|
|
|
|
|
2020-05-04 03:44:12 -07:00
|
|
|
if ('Season' == item.Type) {
|
|
|
|
page.querySelector('#childrenTitle').innerHTML = globalize.translate('HeaderEpisodes');
|
|
|
|
} else if ('Series' == item.Type) {
|
|
|
|
page.querySelector('#childrenTitle').innerHTML = globalize.translate('HeaderSeasons');
|
|
|
|
} else if ('MusicAlbum' == item.Type) {
|
|
|
|
page.querySelector('#childrenTitle').innerHTML = globalize.translate('HeaderTracks');
|
2019-11-06 03:43:39 -07:00
|
|
|
} else {
|
2020-05-04 03:44:12 -07:00
|
|
|
page.querySelector('#childrenTitle').innerHTML = globalize.translate('HeaderItems');
|
2019-11-06 03:43:39 -07:00
|
|
|
}
|
|
|
|
|
2020-05-04 03:44:12 -07:00
|
|
|
if ('MusicAlbum' == item.Type || 'Season' == item.Type) {
|
|
|
|
page.querySelector('.childrenSectionHeader').classList.add('hide');
|
|
|
|
page.querySelector('#childrenCollapsible').classList.add('verticalSection-extrabottompadding');
|
2019-11-06 03:43:39 -07:00
|
|
|
} else {
|
2020-05-04 03:44:12 -07:00
|
|
|
page.querySelector('.childrenSectionHeader').classList.remove('hide');
|
2019-11-06 03:43:39 -07:00
|
|
|
}
|
2018-10-22 15:05:09 -07:00
|
|
|
}
|
|
|
|
|
2020-03-01 07:33:41 -07:00
|
|
|
function renderItemsByName(page, item) {
|
2020-05-04 03:44:12 -07:00
|
|
|
require('scripts/itembynamedetailpage'.split(','), function () {
|
2019-11-06 03:43:39 -07:00
|
|
|
window.ItemsByName.renderItems(page, item);
|
|
|
|
});
|
2018-10-22 15:05:09 -07:00
|
|
|
}
|
|
|
|
|
2020-03-01 07:33:41 -07:00
|
|
|
function renderPlaylistItems(page, item) {
|
2020-05-04 03:44:12 -07:00
|
|
|
require('scripts/playlistedit'.split(','), function () {
|
2019-11-06 03:43:39 -07:00
|
|
|
PlaylistViewer.render(page, item);
|
|
|
|
});
|
2018-10-22 15:05:09 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function renderProgramsForChannel(page, result) {
|
2020-05-04 03:44:12 -07:00
|
|
|
var html = '';
|
2019-11-06 03:43:39 -07:00
|
|
|
var currentItems = [];
|
|
|
|
var currentStartDate = null;
|
|
|
|
|
|
|
|
for (var i = 0, length = result.Items.length; i < length; i++) {
|
|
|
|
var item = result.Items[i];
|
|
|
|
var itemStartDate = datetime.parseISO8601Date(item.StartDate);
|
|
|
|
|
|
|
|
if (!(currentStartDate && currentStartDate.toDateString() === itemStartDate.toDateString())) {
|
|
|
|
if (currentItems.length) {
|
|
|
|
html += '<div class="verticalSection verticalDetailSection">';
|
2019-12-09 16:32:22 -07:00
|
|
|
html += '<h2 class="sectionTitle padded-left">' + datetime.toLocaleDateString(currentStartDate, {
|
2020-05-04 03:44:12 -07:00
|
|
|
weekday: 'long',
|
|
|
|
month: 'long',
|
|
|
|
day: 'numeric'
|
|
|
|
}) + '</h2>';
|
2019-12-09 16:32:22 -07:00
|
|
|
html += '<div is="emby-itemscontainer" class="vertical-list padded-left padded-right">' + listView.getListViewHtml({
|
2019-11-06 03:43:39 -07:00
|
|
|
items: currentItems,
|
|
|
|
enableUserDataButtons: false,
|
|
|
|
showParentTitle: true,
|
|
|
|
image: false,
|
|
|
|
showProgramTime: true,
|
|
|
|
mediaInfo: false,
|
|
|
|
parentTitleWithTitle: true
|
2020-05-04 03:44:12 -07:00
|
|
|
}) + '</div></div>';
|
2019-11-06 03:43:39 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
currentStartDate = itemStartDate;
|
|
|
|
currentItems = [];
|
|
|
|
}
|
|
|
|
|
|
|
|
currentItems.push(item);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (currentItems.length) {
|
|
|
|
html += '<div class="verticalSection verticalDetailSection">';
|
2019-12-09 16:32:22 -07:00
|
|
|
html += '<h2 class="sectionTitle padded-left">' + datetime.toLocaleDateString(currentStartDate, {
|
2020-05-04 03:44:12 -07:00
|
|
|
weekday: 'long',
|
|
|
|
month: 'long',
|
|
|
|
day: 'numeric'
|
|
|
|
}) + '</h2>';
|
2019-12-09 16:32:22 -07:00
|
|
|
html += '<div is="emby-itemscontainer" class="vertical-list padded-left padded-right">' + listView.getListViewHtml({
|
2018-10-22 15:05:09 -07:00
|
|
|
items: currentItems,
|
2019-11-06 03:43:39 -07:00
|
|
|
enableUserDataButtons: false,
|
|
|
|
showParentTitle: true,
|
|
|
|
image: false,
|
|
|
|
showProgramTime: true,
|
|
|
|
mediaInfo: false,
|
|
|
|
parentTitleWithTitle: true
|
2020-05-04 03:44:12 -07:00
|
|
|
}) + '</div></div>';
|
2019-11-06 03:43:39 -07:00
|
|
|
}
|
|
|
|
|
2020-05-04 03:44:12 -07:00
|
|
|
page.querySelector('.programGuide').innerHTML = html;
|
2018-10-22 15:05:09 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function renderChannelGuide(page, apiClient, item) {
|
2020-05-04 03:44:12 -07:00
|
|
|
if ('TvChannel' === item.Type) {
|
|
|
|
page.querySelector('.programGuideSection').classList.remove('hide');
|
2019-11-06 03:43:39 -07:00
|
|
|
apiClient.getLiveTvPrograms({
|
|
|
|
ChannelIds: item.Id,
|
|
|
|
UserId: apiClient.getCurrentUserId(),
|
|
|
|
HasAired: false,
|
2020-05-04 03:44:12 -07:00
|
|
|
SortBy: 'StartDate',
|
2019-11-06 03:43:39 -07:00
|
|
|
EnableTotalRecordCount: false,
|
|
|
|
EnableImages: false,
|
|
|
|
ImageTypeLimit: 0,
|
|
|
|
EnableUserData: false
|
|
|
|
}).then(function (result) {
|
|
|
|
renderProgramsForChannel(page, result);
|
|
|
|
});
|
|
|
|
}
|
2018-10-22 15:05:09 -07:00
|
|
|
}
|
|
|
|
|
2020-03-01 07:33:41 -07:00
|
|
|
function renderSeriesSchedule(page, item) {
|
2018-10-22 15:05:09 -07:00
|
|
|
var apiClient = connectionManager.getApiClient(item.ServerId);
|
|
|
|
apiClient.getLiveTvPrograms({
|
|
|
|
UserId: apiClient.getCurrentUserId(),
|
2019-11-06 03:43:39 -07:00
|
|
|
HasAired: false,
|
2020-05-04 03:44:12 -07:00
|
|
|
SortBy: 'StartDate',
|
2019-11-06 03:43:39 -07:00
|
|
|
EnableTotalRecordCount: false,
|
|
|
|
EnableImages: false,
|
2018-10-22 15:05:09 -07:00
|
|
|
ImageTypeLimit: 0,
|
|
|
|
Limit: 50,
|
2019-11-06 03:43:39 -07:00
|
|
|
EnableUserData: false,
|
2018-10-22 15:05:09 -07:00
|
|
|
LibrarySeriesId: item.Id
|
2019-11-06 03:43:39 -07:00
|
|
|
}).then(function (result) {
|
|
|
|
if (result.Items.length) {
|
2020-05-04 03:44:12 -07:00
|
|
|
page.querySelector('#seriesScheduleSection').classList.remove('hide');
|
2019-11-06 03:43:39 -07:00
|
|
|
} else {
|
2020-05-04 03:44:12 -07:00
|
|
|
page.querySelector('#seriesScheduleSection').classList.add('hide');
|
2019-11-06 03:43:39 -07:00
|
|
|
}
|
|
|
|
|
2020-05-04 03:44:12 -07:00
|
|
|
page.querySelector('#seriesScheduleList').innerHTML = listView.getListViewHtml({
|
2018-10-22 15:05:09 -07:00
|
|
|
items: result.Items,
|
2019-11-06 03:43:39 -07:00
|
|
|
enableUserDataButtons: false,
|
|
|
|
showParentTitle: false,
|
|
|
|
image: false,
|
|
|
|
showProgramDateTime: true,
|
|
|
|
mediaInfo: false,
|
|
|
|
showTitle: true,
|
|
|
|
moreButton: false,
|
2020-05-04 03:44:12 -07:00
|
|
|
action: 'programdialog'
|
2019-11-06 03:43:39 -07:00
|
|
|
});
|
|
|
|
loading.hide();
|
|
|
|
});
|
2018-10-22 15:05:09 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function inferContext(item) {
|
2020-05-04 03:44:12 -07:00
|
|
|
if ('Movie' === item.Type || 'BoxSet' === item.Type) {
|
|
|
|
return 'movies';
|
2019-11-06 03:43:39 -07:00
|
|
|
}
|
|
|
|
|
2020-05-04 03:44:12 -07:00
|
|
|
if ('Series' === item.Type || 'Season' === item.Type || 'Episode' === item.Type) {
|
|
|
|
return 'tvshows';
|
2019-11-06 03:43:39 -07:00
|
|
|
}
|
|
|
|
|
2020-05-04 03:44:12 -07:00
|
|
|
if ('MusicArtist' === item.Type || 'MusicAlbum' === item.Type || 'Audio' === item.Type || 'AudioBook' === item.Type) {
|
|
|
|
return 'music';
|
2019-11-06 03:43:39 -07:00
|
|
|
}
|
|
|
|
|
2020-05-04 03:44:12 -07:00
|
|
|
if ('Program' === item.Type) {
|
|
|
|
return 'livetv';
|
2019-11-06 03:43:39 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
2018-10-22 15:05:09 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function filterItemsByCollectionItemType(items, typeInfo) {
|
2019-11-06 03:43:39 -07:00
|
|
|
return items.filter(function (item) {
|
|
|
|
if (typeInfo.mediaType) {
|
|
|
|
return item.MediaType == typeInfo.mediaType;
|
|
|
|
}
|
|
|
|
|
|
|
|
return item.Type == typeInfo.type;
|
|
|
|
});
|
2018-10-22 15:05:09 -07:00
|
|
|
}
|
|
|
|
|
2019-08-22 05:08:55 -07:00
|
|
|
function canPlaySomeItemInCollection(items) {
|
|
|
|
var i = 0;
|
2019-11-06 03:43:39 -07:00
|
|
|
|
2020-02-25 22:46:56 -07:00
|
|
|
for (var length = items.length; i < length; i++) {
|
2019-08-22 05:08:55 -07:00
|
|
|
if (playbackManager.canPlay(items[i])) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2019-11-06 03:43:39 -07:00
|
|
|
|
2019-08-22 05:08:55 -07:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-10-22 15:05:09 -07:00
|
|
|
function renderCollectionItems(page, parentItem, types, items) {
|
2020-05-04 03:44:12 -07:00
|
|
|
page.querySelector('.collectionItems').innerHTML = '';
|
2019-11-06 03:43:39 -07:00
|
|
|
var i;
|
|
|
|
var length;
|
|
|
|
|
2018-10-22 15:05:09 -07:00
|
|
|
for (i = 0, length = types.length; i < length; i++) {
|
2019-11-06 03:43:39 -07:00
|
|
|
var type = types[i];
|
|
|
|
var typeItems = filterItemsByCollectionItemType(items, type);
|
|
|
|
|
|
|
|
if (typeItems.length) {
|
|
|
|
renderCollectionItemType(page, parentItem, type, typeItems);
|
|
|
|
}
|
2018-10-22 15:05:09 -07:00
|
|
|
}
|
2019-11-06 03:43:39 -07:00
|
|
|
|
2018-10-22 15:05:09 -07:00
|
|
|
var otherType = {
|
2020-05-04 03:44:12 -07:00
|
|
|
name: globalize.translate('HeaderOtherItems')
|
2019-11-06 03:43:39 -07:00
|
|
|
};
|
|
|
|
var otherTypeItems = items.filter(function (curr) {
|
|
|
|
return !types.filter(function (t) {
|
|
|
|
return filterItemsByCollectionItemType([curr], t).length > 0;
|
|
|
|
}).length;
|
|
|
|
});
|
|
|
|
|
|
|
|
if (otherTypeItems.length) {
|
|
|
|
renderCollectionItemType(page, parentItem, otherType, otherTypeItems);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!items.length) {
|
|
|
|
renderCollectionItemType(page, parentItem, {
|
2020-05-04 03:44:12 -07:00
|
|
|
name: globalize.translate('HeaderItems')
|
2019-11-06 03:43:39 -07:00
|
|
|
}, items);
|
|
|
|
}
|
|
|
|
|
2020-05-04 03:44:12 -07:00
|
|
|
var containers = page.querySelectorAll('.collectionItemsContainer');
|
2019-11-06 03:43:39 -07:00
|
|
|
|
|
|
|
var notifyRefreshNeeded = function () {
|
|
|
|
renderChildren(page, parentItem);
|
|
|
|
};
|
|
|
|
|
|
|
|
for (i = 0, length = containers.length; i < length; i++) {
|
|
|
|
containers[i].notifyRefreshNeeded = notifyRefreshNeeded;
|
|
|
|
}
|
2019-08-22 05:08:55 -07:00
|
|
|
|
|
|
|
// if nothing in the collection can be played hide play and shuffle buttons
|
|
|
|
if (!canPlaySomeItemInCollection(items)) {
|
2020-05-04 03:44:12 -07:00
|
|
|
hideAll(page, 'btnPlay', false);
|
|
|
|
hideAll(page, 'btnShuffle', false);
|
2019-11-06 03:43:39 -07:00
|
|
|
}
|
2019-11-14 10:30:59 -07:00
|
|
|
|
|
|
|
// HACK: Call autoFocuser again because btnPlay may be hidden, but focused by reloadFromItem
|
|
|
|
// FIXME: Sometimes focus does not move until all (?) sections are loaded
|
2020-05-04 03:44:12 -07:00
|
|
|
require(['autoFocuser'], function (autoFocuser) {
|
2019-11-14 10:30:59 -07:00
|
|
|
autoFocuser.autoFocus(page);
|
|
|
|
});
|
2018-10-22 15:05:09 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function renderCollectionItemType(page, parentItem, type, items) {
|
2020-05-04 03:44:12 -07:00
|
|
|
var html = '';
|
2019-11-06 03:43:39 -07:00
|
|
|
html += '<div class="verticalSection">';
|
2019-12-09 16:32:22 -07:00
|
|
|
html += '<div class="sectionTitleContainer sectionTitleContainer-cards padded-left">';
|
2019-11-06 03:43:39 -07:00
|
|
|
html += '<h2 class="sectionTitle sectionTitle-cards">';
|
2020-05-04 03:44:12 -07:00
|
|
|
html += '<span>' + type.name + '</span>';
|
|
|
|
html += '</h2>';
|
2020-04-25 16:37:28 -07:00
|
|
|
html += '<button class="btnAddToCollection sectionTitleButton" type="button" is="paper-icon-button-light" style="margin-left:1em;"><span class="material-icons add"></span></button>';
|
2020-05-04 03:44:12 -07:00
|
|
|
html += '</div>';
|
2019-12-09 16:32:22 -07:00
|
|
|
html += '<div is="emby-itemscontainer" class="itemsContainer collectionItemsContainer vertical-wrap padded-left padded-right">';
|
2020-05-04 03:44:12 -07:00
|
|
|
var shape = 'MusicAlbum' == type.type ? getSquareShape(false) : getPortraitShape(false);
|
2018-10-22 15:05:09 -07:00
|
|
|
html += cardBuilder.getCardsHtml({
|
|
|
|
items: items,
|
|
|
|
shape: shape,
|
2019-11-06 03:43:39 -07:00
|
|
|
showTitle: true,
|
2020-05-04 03:44:12 -07:00
|
|
|
showYear: 'Video' === type.mediaType || 'Series' === type.type,
|
2019-11-06 03:43:39 -07:00
|
|
|
centerText: true,
|
|
|
|
lazy: true,
|
|
|
|
showDetailsMenu: true,
|
|
|
|
overlayMoreButton: true,
|
|
|
|
showAddToCollection: false,
|
|
|
|
showRemoveFromCollection: true,
|
2018-10-22 15:05:09 -07:00
|
|
|
collectionId: parentItem.Id
|
2019-11-06 03:43:39 -07:00
|
|
|
});
|
2020-05-04 03:44:12 -07:00
|
|
|
html += '</div>';
|
|
|
|
html += '</div>';
|
|
|
|
var collectionItems = page.querySelector('.collectionItems');
|
|
|
|
collectionItems.insertAdjacentHTML('beforeend', html);
|
2019-11-06 03:43:39 -07:00
|
|
|
imageLoader.lazyChildren(collectionItems);
|
2020-05-04 03:44:12 -07:00
|
|
|
collectionItems.querySelector('.btnAddToCollection').addEventListener('click', function () {
|
|
|
|
require(['alert'], function (alert) {
|
2018-10-22 15:05:09 -07:00
|
|
|
alert({
|
2020-05-04 03:44:12 -07:00
|
|
|
text: globalize.translate('AddItemToCollectionHelp'),
|
|
|
|
html: globalize.translate('AddItemToCollectionHelp') + '<br/><br/><a is="emby-linkbutton" class="button-link" target="_blank" href="https://web.archive.org/web/20181216120305/https://github.com/MediaBrowser/Wiki/wiki/Collections">' + globalize.translate('ButtonLearnMore') + '</a>'
|
2019-11-06 03:43:39 -07:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2018-10-22 15:05:09 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function renderMusicVideos(page, item, user) {
|
|
|
|
connectionManager.getApiClient(item.ServerId).getItems(user.Id, {
|
2020-05-04 03:44:12 -07:00
|
|
|
SortBy: 'SortName',
|
|
|
|
SortOrder: 'Ascending',
|
|
|
|
IncludeItemTypes: 'MusicVideo',
|
2019-11-06 03:43:39 -07:00
|
|
|
Recursive: true,
|
2020-05-04 03:44:12 -07:00
|
|
|
Fields: 'PrimaryImageAspectRatio,BasicSyncInfo,CanDelete,MediaSourceCount',
|
2018-10-22 15:05:09 -07:00
|
|
|
AlbumIds: item.Id
|
2019-11-06 03:43:39 -07:00
|
|
|
}).then(function (result) {
|
2018-10-22 15:05:09 -07:00
|
|
|
if (result.Items.length) {
|
2020-05-04 03:44:12 -07:00
|
|
|
page.querySelector('#musicVideosCollapsible').classList.remove('hide');
|
|
|
|
var musicVideosContent = page.querySelector('.musicVideosContent');
|
2019-11-06 03:43:39 -07:00
|
|
|
musicVideosContent.innerHTML = getVideosHtml(result.Items, user);
|
|
|
|
imageLoader.lazyChildren(musicVideosContent);
|
|
|
|
} else {
|
2020-05-04 03:44:12 -07:00
|
|
|
page.querySelector('#musicVideosCollapsible').classList.add('hide');
|
2019-11-06 03:43:39 -07:00
|
|
|
}
|
|
|
|
});
|
2018-10-22 15:05:09 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function renderAdditionalParts(page, item, user) {
|
2019-11-06 03:43:39 -07:00
|
|
|
connectionManager.getApiClient(item.ServerId).getAdditionalVideoParts(user.Id, item.Id).then(function (result) {
|
2018-10-22 15:05:09 -07:00
|
|
|
if (result.Items.length) {
|
2020-05-04 03:44:12 -07:00
|
|
|
page.querySelector('#additionalPartsCollapsible').classList.remove('hide');
|
|
|
|
var additionalPartsContent = page.querySelector('#additionalPartsContent');
|
2019-11-06 03:43:39 -07:00
|
|
|
additionalPartsContent.innerHTML = getVideosHtml(result.Items, user);
|
|
|
|
imageLoader.lazyChildren(additionalPartsContent);
|
|
|
|
} else {
|
2020-05-04 03:44:12 -07:00
|
|
|
page.querySelector('#additionalPartsCollapsible').classList.add('hide');
|
2019-11-06 03:43:39 -07:00
|
|
|
}
|
|
|
|
});
|
2018-10-22 15:05:09 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function renderScenes(page, item) {
|
|
|
|
var chapters = item.Chapters || [];
|
2019-11-06 03:43:39 -07:00
|
|
|
|
2018-10-22 15:05:09 -07:00
|
|
|
if (chapters.length && !chapters[0].ImageTag && (chapters = []), chapters.length) {
|
2020-05-04 03:44:12 -07:00
|
|
|
page.querySelector('#scenesCollapsible').classList.remove('hide');
|
|
|
|
var scenesContent = page.querySelector('#scenesContent');
|
2019-11-06 03:43:39 -07:00
|
|
|
|
2020-05-04 03:44:12 -07:00
|
|
|
require(['chaptercardbuilder'], function (chaptercardbuilder) {
|
2018-10-22 15:05:09 -07:00
|
|
|
chaptercardbuilder.buildChapterCards(item, chapters, {
|
|
|
|
itemsContainer: scenesContent,
|
2020-05-04 03:44:12 -07:00
|
|
|
backdropShape: 'overflowBackdrop',
|
|
|
|
squareShape: 'overflowSquare'
|
2019-11-06 03:43:39 -07:00
|
|
|
});
|
|
|
|
});
|
|
|
|
} else {
|
2020-05-04 03:44:12 -07:00
|
|
|
page.querySelector('#scenesCollapsible').classList.add('hide');
|
2019-11-06 03:43:39 -07:00
|
|
|
}
|
2018-10-22 15:05:09 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function getVideosHtml(items, user, limit, moreButtonClass) {
|
|
|
|
var html = cardBuilder.getCardsHtml({
|
|
|
|
items: items,
|
2020-05-04 03:44:12 -07:00
|
|
|
shape: 'auto',
|
2019-11-06 03:43:39 -07:00
|
|
|
showTitle: true,
|
2020-05-04 03:44:12 -07:00
|
|
|
action: 'play',
|
2019-11-06 03:43:39 -07:00
|
|
|
overlayText: false,
|
|
|
|
centerText: true,
|
|
|
|
showRuntime: true
|
2018-10-22 15:05:09 -07:00
|
|
|
});
|
2019-11-06 03:43:39 -07:00
|
|
|
|
|
|
|
if (limit && items.length > limit) {
|
2020-05-04 03:44:12 -07:00
|
|
|
html += '<p style="margin: 0;padding-left:5px;"><button is="emby-button" type="button" class="raised more ' + moreButtonClass + '">' + globalize.translate('ButtonMore') + '</button></p>';
|
2019-11-06 03:43:39 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return html;
|
2018-10-22 15:05:09 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function renderSpecials(page, item, user, limit) {
|
2019-11-06 03:43:39 -07:00
|
|
|
connectionManager.getApiClient(item.ServerId).getSpecialFeatures(user.Id, item.Id).then(function (specials) {
|
2020-05-04 03:44:12 -07:00
|
|
|
var specialsContent = page.querySelector('#specialsContent');
|
|
|
|
specialsContent.innerHTML = getVideosHtml(specials, user, limit, 'moreSpecials');
|
2019-11-06 03:43:39 -07:00
|
|
|
imageLoader.lazyChildren(specialsContent);
|
|
|
|
});
|
2018-10-22 15:05:09 -07:00
|
|
|
}
|
|
|
|
|
2020-03-01 07:33:41 -07:00
|
|
|
function renderCast(page, item) {
|
2019-11-06 03:43:39 -07:00
|
|
|
var people = (item.People || []).filter(function (p) {
|
2020-05-04 03:44:12 -07:00
|
|
|
return 'Director' !== p.Type;
|
2018-10-22 15:05:09 -07:00
|
|
|
});
|
2019-11-06 03:43:39 -07:00
|
|
|
|
|
|
|
if (!people.length) {
|
2020-05-04 03:44:12 -07:00
|
|
|
return void page.querySelector('#castCollapsible').classList.add('hide');
|
2019-11-06 03:43:39 -07:00
|
|
|
}
|
|
|
|
|
2020-05-04 03:44:12 -07:00
|
|
|
page.querySelector('#castCollapsible').classList.remove('hide');
|
|
|
|
var castContent = page.querySelector('#castContent');
|
2019-11-06 03:43:39 -07:00
|
|
|
|
2020-05-04 03:44:12 -07:00
|
|
|
require(['peoplecardbuilder'], function (peoplecardbuilder) {
|
2018-10-22 15:05:09 -07:00
|
|
|
peoplecardbuilder.buildPeopleCards(people, {
|
|
|
|
itemsContainer: castContent,
|
2019-11-06 03:43:39 -07:00
|
|
|
coverImage: true,
|
2018-10-22 15:05:09 -07:00
|
|
|
serverId: item.ServerId,
|
2020-05-04 03:44:12 -07:00
|
|
|
shape: 'overflowPortrait'
|
2019-11-06 03:43:39 -07:00
|
|
|
});
|
|
|
|
});
|
2018-10-22 15:05:09 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function itemDetailPage() {
|
|
|
|
var self = this;
|
2019-11-06 03:43:39 -07:00
|
|
|
self.setInitialCollapsibleState = setInitialCollapsibleState;
|
|
|
|
self.renderDetails = renderDetails;
|
|
|
|
self.renderCast = renderCast;
|
2018-10-22 15:05:09 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function bindAll(view, selector, eventName, fn) {
|
2019-11-06 03:43:39 -07:00
|
|
|
var i;
|
|
|
|
var length;
|
|
|
|
var elems = view.querySelectorAll(selector);
|
|
|
|
|
|
|
|
for (i = 0, length = elems.length; i < length; i++) {
|
|
|
|
elems[i].addEventListener(eventName, fn);
|
|
|
|
}
|
2018-10-22 15:05:09 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function onTrackSelectionsSubmit(e) {
|
2019-11-06 03:43:39 -07:00
|
|
|
e.preventDefault();
|
|
|
|
return false;
|
|
|
|
}
|
2018-10-22 15:05:09 -07:00
|
|
|
|
2019-11-06 03:43:39 -07:00
|
|
|
window.ItemDetailPage = new itemDetailPage();
|
|
|
|
return function (view, params) {
|
|
|
|
function reload(instance, page, params) {
|
|
|
|
loading.show();
|
|
|
|
var apiClient = params.serverId ? connectionManager.getApiClient(params.serverId) : ApiClient;
|
|
|
|
var promises = [getPromise(apiClient, params), apiClient.getCurrentUser()];
|
|
|
|
Promise.all(promises).then(function (responses) {
|
|
|
|
var item = responses[0];
|
|
|
|
var user = responses[1];
|
|
|
|
currentItem = item;
|
|
|
|
reloadFromItem(instance, page, params, item, user);
|
|
|
|
});
|
|
|
|
}
|
2018-10-22 15:05:09 -07:00
|
|
|
|
2019-11-06 03:43:39 -07:00
|
|
|
function splitVersions(instance, page, apiClient, params) {
|
2020-05-04 03:44:12 -07:00
|
|
|
require(['confirm'], function (confirm) {
|
|
|
|
confirm('Are you sure you wish to split the media sources into separate items?', 'Split Media Apart').then(function () {
|
2019-11-06 03:43:39 -07:00
|
|
|
loading.show();
|
|
|
|
apiClient.ajax({
|
2020-05-04 03:44:12 -07:00
|
|
|
type: 'DELETE',
|
|
|
|
url: apiClient.getUrl('Videos/' + params.id + '/AlternateSources')
|
2019-11-06 03:43:39 -07:00
|
|
|
}).then(function () {
|
|
|
|
loading.hide();
|
|
|
|
reload(instance, page, params);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
2018-10-22 15:05:09 -07:00
|
|
|
|
2019-11-06 03:43:39 -07:00
|
|
|
function getPlayOptions(startPosition) {
|
2020-05-04 03:44:12 -07:00
|
|
|
var audioStreamIndex = view.querySelector('.selectAudio').value || null;
|
2019-11-06 03:43:39 -07:00
|
|
|
return {
|
|
|
|
startPositionTicks: startPosition,
|
2020-05-04 03:44:12 -07:00
|
|
|
mediaSourceId: view.querySelector('.selectSource').value,
|
2019-11-06 03:43:39 -07:00
|
|
|
audioStreamIndex: audioStreamIndex,
|
2020-05-04 03:44:12 -07:00
|
|
|
subtitleStreamIndex: view.querySelector('.selectSubtitles').value
|
2019-11-06 03:43:39 -07:00
|
|
|
};
|
|
|
|
}
|
2018-10-22 15:05:09 -07:00
|
|
|
|
2019-11-06 03:43:39 -07:00
|
|
|
function playItem(item, startPosition) {
|
|
|
|
var playOptions = getPlayOptions(startPosition);
|
|
|
|
playOptions.items = [item];
|
|
|
|
playbackManager.play(playOptions);
|
|
|
|
}
|
2018-10-22 15:05:09 -07:00
|
|
|
|
2020-03-01 07:33:41 -07:00
|
|
|
function playTrailer() {
|
2019-11-06 03:43:39 -07:00
|
|
|
playbackManager.playTrailers(currentItem);
|
|
|
|
}
|
2018-10-22 15:05:09 -07:00
|
|
|
|
2019-11-06 03:43:39 -07:00
|
|
|
function playCurrentItem(button, mode) {
|
|
|
|
var item = currentItem;
|
2018-10-22 15:05:09 -07:00
|
|
|
|
2020-05-04 03:44:12 -07:00
|
|
|
if ('Program' === item.Type) {
|
2019-11-06 03:43:39 -07:00
|
|
|
var apiClient = connectionManager.getApiClient(item.ServerId);
|
|
|
|
return void apiClient.getLiveTvChannel(item.ChannelId, apiClient.getCurrentUserId()).then(function (channel) {
|
|
|
|
playbackManager.play({
|
|
|
|
items: [channel]
|
|
|
|
});
|
|
|
|
});
|
2018-10-22 15:05:09 -07:00
|
|
|
}
|
|
|
|
|
2020-05-04 03:44:12 -07:00
|
|
|
playItem(item, item.UserData && 'resume' === mode ? item.UserData.PlaybackPositionTicks : 0);
|
2019-11-06 03:43:39 -07:00
|
|
|
}
|
2018-10-22 15:05:09 -07:00
|
|
|
|
2019-11-06 03:43:39 -07:00
|
|
|
function onPlayClick() {
|
2020-05-04 03:44:12 -07:00
|
|
|
playCurrentItem(this, this.getAttribute('data-mode'));
|
2019-11-06 03:43:39 -07:00
|
|
|
}
|
2018-10-22 15:05:09 -07:00
|
|
|
|
2019-11-06 03:43:39 -07:00
|
|
|
function onInstantMixClick() {
|
|
|
|
playbackManager.instantMix(currentItem);
|
|
|
|
}
|
2018-10-22 15:05:09 -07:00
|
|
|
|
2019-11-06 03:43:39 -07:00
|
|
|
function onShuffleClick() {
|
|
|
|
playbackManager.shuffle(currentItem);
|
|
|
|
}
|
2018-10-22 15:05:09 -07:00
|
|
|
|
2019-11-06 03:43:39 -07:00
|
|
|
function onDeleteClick() {
|
2020-05-04 03:44:12 -07:00
|
|
|
require(['deleteHelper'], function (deleteHelper) {
|
2019-11-06 03:43:39 -07:00
|
|
|
deleteHelper.deleteItem({
|
|
|
|
item: currentItem,
|
|
|
|
navigate: true
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
2018-10-22 15:05:09 -07:00
|
|
|
|
2019-11-06 03:43:39 -07:00
|
|
|
function onCancelSeriesTimerClick() {
|
2020-05-04 03:44:12 -07:00
|
|
|
require(['recordingHelper'], function (recordingHelper) {
|
2019-11-06 03:43:39 -07:00
|
|
|
recordingHelper.cancelSeriesTimerWithConfirmation(currentItem.Id, currentItem.ServerId).then(function () {
|
2020-05-04 03:44:12 -07:00
|
|
|
Dashboard.navigate('livetv.html');
|
2019-11-06 03:43:39 -07:00
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function onCancelTimerClick() {
|
2020-05-04 03:44:12 -07:00
|
|
|
require(['recordingHelper'], function (recordingHelper) {
|
2019-11-06 03:43:39 -07:00
|
|
|
recordingHelper.cancelTimer(connectionManager.getApiClient(currentItem.ServerId), currentItem.TimerId).then(function () {
|
|
|
|
reload(self, view, params);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function onPlayTrailerClick() {
|
2020-03-01 07:33:41 -07:00
|
|
|
playTrailer();
|
2019-11-06 03:43:39 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function onDownloadClick() {
|
|
|
|
require(['fileDownloader'], function (fileDownloader) {
|
|
|
|
var downloadHref = apiClient.getItemDownloadUrl(currentItem.Id);
|
|
|
|
fileDownloader.download([{
|
|
|
|
url: downloadHref,
|
|
|
|
itemId: currentItem.Id,
|
|
|
|
serverId: currentItem.serverId
|
|
|
|
}]);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function onMoreCommandsClick() {
|
|
|
|
var button = this;
|
|
|
|
apiClient.getCurrentUser().then(function (user) {
|
|
|
|
itemContextMenu.show(getContextMenuOptions(currentItem, user, button)).then(function (result) {
|
|
|
|
if (result.deleted) {
|
|
|
|
appRouter.goHome();
|
|
|
|
} else if (result.updated) {
|
|
|
|
reload(self, view, params);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function onPlayerChange() {
|
|
|
|
renderTrackSelections(view, self, currentItem);
|
|
|
|
setTrailerButtonVisibility(view, currentItem);
|
|
|
|
}
|
2018-10-22 15:05:09 -07:00
|
|
|
|
2019-11-06 03:43:39 -07:00
|
|
|
function editImages() {
|
|
|
|
return new Promise(function (resolve, reject) {
|
2020-05-04 03:44:12 -07:00
|
|
|
require(['imageEditor'], function (imageEditor) {
|
2019-11-06 03:43:39 -07:00
|
|
|
imageEditor.show({
|
2019-07-28 06:51:02 -07:00
|
|
|
itemId: currentItem.Id,
|
2019-11-06 03:43:39 -07:00
|
|
|
serverId: currentItem.ServerId
|
|
|
|
}).then(resolve, reject);
|
2019-07-28 06:51:02 -07:00
|
|
|
});
|
2019-11-06 03:43:39 -07:00
|
|
|
});
|
|
|
|
}
|
2019-07-28 06:51:02 -07:00
|
|
|
|
2019-11-06 03:43:39 -07:00
|
|
|
function onWebSocketMessage(e, data) {
|
|
|
|
var msg = data;
|
2018-10-22 15:05:09 -07:00
|
|
|
|
2020-05-04 03:44:12 -07:00
|
|
|
if ('UserDataChanged' === msg.MessageType && currentItem && msg.Data.UserId == apiClient.getCurrentUserId()) {
|
2019-11-06 03:43:39 -07:00
|
|
|
var key = currentItem.UserData.Key;
|
|
|
|
var userData = msg.Data.UserDataList.filter(function (u) {
|
|
|
|
return u.Key == key;
|
|
|
|
})[0];
|
2018-10-22 15:05:09 -07:00
|
|
|
|
2019-11-06 03:43:39 -07:00
|
|
|
if (userData) {
|
|
|
|
currentItem.UserData = userData;
|
|
|
|
reloadPlayButtons(view, currentItem);
|
2020-03-01 07:33:41 -07:00
|
|
|
refreshImage(view, currentItem);
|
2019-11-06 03:43:39 -07:00
|
|
|
}
|
2018-10-22 15:05:09 -07:00
|
|
|
}
|
2019-11-06 03:43:39 -07:00
|
|
|
}
|
2018-10-22 15:05:09 -07:00
|
|
|
|
2019-11-06 03:43:39 -07:00
|
|
|
var currentItem;
|
|
|
|
var self = this;
|
|
|
|
var apiClient = params.serverId ? connectionManager.getApiClient(params.serverId) : ApiClient;
|
2020-05-04 03:44:12 -07:00
|
|
|
view.querySelectorAll('.btnPlay');
|
|
|
|
bindAll(view, '.btnPlay', 'click', onPlayClick);
|
|
|
|
bindAll(view, '.btnResume', 'click', onPlayClick);
|
|
|
|
bindAll(view, '.btnInstantMix', 'click', onInstantMixClick);
|
|
|
|
bindAll(view, '.btnShuffle', 'click', onShuffleClick);
|
|
|
|
bindAll(view, '.btnPlayTrailer', 'click', onPlayTrailerClick);
|
|
|
|
bindAll(view, '.btnCancelSeriesTimer', 'click', onCancelSeriesTimerClick);
|
|
|
|
bindAll(view, '.btnCancelTimer', 'click', onCancelTimerClick);
|
|
|
|
bindAll(view, '.btnDeleteItem', 'click', onDeleteClick);
|
|
|
|
bindAll(view, '.btnDownload', 'click', onDownloadClick);
|
|
|
|
view.querySelector('.trackSelections').addEventListener('submit', onTrackSelectionsSubmit);
|
|
|
|
view.querySelector('.btnSplitVersions').addEventListener('click', function () {
|
2019-11-06 03:43:39 -07:00
|
|
|
splitVersions(self, view, apiClient, params);
|
|
|
|
});
|
2020-05-04 03:44:12 -07:00
|
|
|
bindAll(view, '.btnMoreCommands', 'click', onMoreCommandsClick);
|
|
|
|
view.querySelector('.selectSource').addEventListener('change', function () {
|
2019-11-06 03:43:39 -07:00
|
|
|
renderVideoSelections(view, self._currentPlaybackMediaSources);
|
|
|
|
renderAudioSelections(view, self._currentPlaybackMediaSources);
|
|
|
|
renderSubtitleSelections(view, self._currentPlaybackMediaSources);
|
|
|
|
});
|
2020-05-04 03:44:12 -07:00
|
|
|
view.addEventListener('click', function (e) {
|
|
|
|
if (dom.parentWithClass(e.target, 'moreScenes')) {
|
2020-03-01 07:33:41 -07:00
|
|
|
renderScenes(view, currentItem);
|
2020-05-04 03:44:12 -07:00
|
|
|
} else if (dom.parentWithClass(e.target, 'morePeople')) {
|
2020-03-01 07:33:41 -07:00
|
|
|
renderCast(view, currentItem);
|
2020-05-04 03:44:12 -07:00
|
|
|
} else if (dom.parentWithClass(e.target, 'moreSpecials')) {
|
2019-11-06 03:43:39 -07:00
|
|
|
apiClient.getCurrentUser().then(function (user) {
|
|
|
|
renderSpecials(view, currentItem, user);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
2020-05-04 03:44:12 -07:00
|
|
|
view.querySelector('.detailImageContainer').addEventListener('click', function (e) {
|
|
|
|
if (dom.parentWithClass(e.target, 'itemDetailGalleryLink')) {
|
2019-11-06 03:43:39 -07:00
|
|
|
editImages().then(function () {
|
|
|
|
reload(self, view, params);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
2020-05-04 03:44:12 -07:00
|
|
|
view.addEventListener('viewshow', function (e) {
|
2019-11-06 03:43:39 -07:00
|
|
|
var page = this;
|
2020-01-13 13:36:23 -07:00
|
|
|
|
|
|
|
if (layoutManager.mobile) {
|
|
|
|
libraryMenu.setTransparentMenu(true);
|
|
|
|
}
|
2019-11-06 03:43:39 -07:00
|
|
|
|
|
|
|
if (e.detail.isRestored) {
|
|
|
|
if (currentItem) {
|
2020-04-30 11:15:39 -07:00
|
|
|
Emby.Page.setTitle('');
|
2019-11-06 03:43:39 -07:00
|
|
|
renderTrackSelections(page, self, currentItem, true);
|
2018-10-22 15:05:09 -07:00
|
|
|
}
|
2019-11-06 03:43:39 -07:00
|
|
|
} else {
|
|
|
|
reload(self, page, params);
|
2018-10-22 15:05:09 -07:00
|
|
|
}
|
2019-03-18 22:22:48 -07:00
|
|
|
|
2020-05-04 03:44:12 -07:00
|
|
|
events.on(apiClient, 'message', onWebSocketMessage);
|
|
|
|
events.on(playbackManager, 'playerchange', onPlayerChange);
|
2019-11-06 03:43:39 -07:00
|
|
|
});
|
2020-05-04 03:44:12 -07:00
|
|
|
view.addEventListener('viewbeforehide', function () {
|
|
|
|
events.off(apiClient, 'message', onWebSocketMessage);
|
|
|
|
events.off(playbackManager, 'playerchange', onPlayerChange);
|
2019-11-06 03:43:39 -07:00
|
|
|
libraryMenu.setTransparentMenu(false);
|
|
|
|
});
|
2020-05-04 03:44:12 -07:00
|
|
|
view.addEventListener('viewdestroy', function () {
|
2019-11-06 03:43:39 -07:00
|
|
|
currentItem = null;
|
|
|
|
self._currentPlaybackMediaSources = null;
|
|
|
|
self.currentRecordingFields = null;
|
|
|
|
});
|
|
|
|
};
|
2019-01-11 10:16:10 -07:00
|
|
|
});
|