2019-03-25 23:02:39 +00:00
|
|
|
define(['connectionManager', 'cardBuilder', 'appSettings', 'dom', 'apphost', 'layoutManager', 'imageLoader', 'globalize', 'itemShortcuts', 'itemHelper', 'appRouter', 'paper-icon-button-light', 'emby-itemscontainer', 'emby-scroller', 'emby-button', 'css!./homesections'], function (connectionManager, cardBuilder, appSettings, dom, appHost, layoutManager, imageLoader, globalize, itemShortcuts, itemHelper, appRouter) {
|
2019-01-10 15:39:37 +03:00
|
|
|
'use strict';
|
2018-10-23 01:05:09 +03:00
|
|
|
|
|
|
|
function getDefaultSection(index) {
|
|
|
|
switch (index) {
|
|
|
|
case 0:
|
2019-01-10 15:39:37 +03:00
|
|
|
return 'smalllibrarytiles';
|
2018-10-23 01:05:09 +03:00
|
|
|
case 1:
|
2019-01-10 15:39:37 +03:00
|
|
|
return 'resume';
|
2018-10-23 01:05:09 +03:00
|
|
|
case 2:
|
2019-01-10 15:39:37 +03:00
|
|
|
return 'resumeaudio';
|
2018-10-23 01:05:09 +03:00
|
|
|
case 3:
|
2019-01-10 15:39:37 +03:00
|
|
|
return 'livetv';
|
2018-10-23 01:05:09 +03:00
|
|
|
case 4:
|
2019-01-10 15:39:37 +03:00
|
|
|
return 'nextup';
|
2018-10-23 01:05:09 +03:00
|
|
|
case 5:
|
2019-01-10 15:39:37 +03:00
|
|
|
return 'latestmedia';
|
2018-10-23 01:05:09 +03:00
|
|
|
case 6:
|
2019-01-10 15:39:37 +03:00
|
|
|
return 'none';
|
2018-10-23 01:05:09 +03:00
|
|
|
default:
|
2019-01-10 15:39:37 +03:00
|
|
|
return '';
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function getAllSectionsToShow(userSettings, sectionCount) {
|
2019-01-10 15:39:37 +03:00
|
|
|
var sections = [];
|
|
|
|
for (var i = 0, length = sectionCount; i < length; i++) {
|
|
|
|
var section = userSettings.get('homesection' + i) || getDefaultSection(i);
|
|
|
|
if (section === 'folders') {
|
|
|
|
section = getDefaultSection(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
sections.push(section);
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
return sections;
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function loadSections(elem, apiClient, user, userSettings) {
|
2019-01-10 15:39:37 +03:00
|
|
|
return getUserViews(apiClient, user.Id).then(function (userViews) {
|
|
|
|
var html = '';
|
|
|
|
|
2019-05-09 17:55:00 -07:00
|
|
|
var sectionCount = 7;
|
|
|
|
for (var i = 0; i < sectionCount; i++) {
|
2019-01-10 15:39:37 +03:00
|
|
|
html += '<div class="verticalSection section' + i + '"></div>';
|
|
|
|
}
|
|
|
|
|
|
|
|
elem.innerHTML = html;
|
|
|
|
elem.classList.add('homeSectionsContainer');
|
|
|
|
|
|
|
|
var promises = [];
|
|
|
|
var sections = getAllSectionsToShow(userSettings, sectionCount);
|
2019-05-09 17:55:00 -07:00
|
|
|
for (var i = 0; i < sections.length; i++) {
|
2019-01-10 15:39:37 +03:00
|
|
|
promises.push(loadSection(elem, apiClient, user, userSettings, userViews, sections, i));
|
|
|
|
}
|
|
|
|
|
|
|
|
return Promise.all(promises).then(function () {
|
|
|
|
return resume(elem, {
|
|
|
|
refresh: true,
|
|
|
|
returnPromise: false
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function destroySections(elem) {
|
2019-01-10 15:39:37 +03:00
|
|
|
var elems = elem.querySelectorAll('.itemsContainer');
|
2019-05-09 17:55:00 -07:00
|
|
|
for (var i = 0; i < elems.length; i++) {
|
2019-01-10 15:39:37 +03:00
|
|
|
elems[i].fetchData = null;
|
|
|
|
elems[i].parentContainer = null;
|
|
|
|
elems[i].getItemsHtml = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
elem.innerHTML = '';
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function pause(elem) {
|
2019-01-10 15:39:37 +03:00
|
|
|
var elems = elem.querySelectorAll('.itemsContainer');
|
2019-05-09 17:55:00 -07:00
|
|
|
for (var i = 0; i < elems.length; i++) {
|
2019-01-10 15:39:37 +03:00
|
|
|
elems[i].pause();
|
|
|
|
}
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function resume(elem, options) {
|
2019-01-10 15:39:37 +03:00
|
|
|
var elems = elem.querySelectorAll('.itemsContainer');
|
|
|
|
var i, length;
|
|
|
|
var promises = [];
|
|
|
|
|
|
|
|
for (i = 0, length = elems.length; i < length; i++) {
|
|
|
|
promises.push(elems[i].resume(options));
|
|
|
|
}
|
|
|
|
|
2019-02-15 21:15:15 +01:00
|
|
|
var promise = Promise.all(promises);
|
2019-01-10 15:39:37 +03:00
|
|
|
if (!options || options.returnPromise !== false) {
|
|
|
|
return promise;
|
|
|
|
}
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function loadSection(page, apiClient, user, userSettings, userViews, allSections, index) {
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
var section = allSections[index];
|
|
|
|
var userId = user.Id;
|
|
|
|
|
|
|
|
var elem = page.querySelector('.section' + index);
|
|
|
|
|
|
|
|
if (section === 'latestmedia') {
|
|
|
|
loadRecentlyAdded(elem, apiClient, user, userViews);
|
2019-07-02 00:12:04 -07:00
|
|
|
} else if (section === 'librarytiles' || section === 'smalllibrarytiles' || section === 'smalllibrarytiles-automobile' || section === 'librarytiles-automobile') {
|
2019-01-20 00:39:31 +09:00
|
|
|
loadLibraryTiles(elem, apiClient, user, userSettings, 'smallBackdrop', userViews, allSections);
|
2019-07-02 00:12:04 -07:00
|
|
|
} else if (section === 'librarybuttons') {
|
2019-01-20 00:39:31 +09:00
|
|
|
loadlibraryButtons(elem, apiClient, user, userSettings, userViews, allSections);
|
2019-07-02 00:12:04 -07:00
|
|
|
} else if (section === 'resume') {
|
2019-01-10 15:39:37 +03:00
|
|
|
loadResumeVideo(elem, apiClient, userId);
|
2019-07-02 00:12:04 -07:00
|
|
|
} else if (section === 'resumeaudio') {
|
2019-01-10 15:39:37 +03:00
|
|
|
loadResumeAudio(elem, apiClient, userId);
|
2019-07-02 00:12:04 -07:00
|
|
|
} else if (section === 'activerecordings') {
|
2019-01-10 15:39:37 +03:00
|
|
|
loadLatestLiveTvRecordings(elem, true, apiClient, userId);
|
2019-07-02 00:12:04 -07:00
|
|
|
} else if (section === 'nextup') {
|
2019-01-10 15:39:37 +03:00
|
|
|
loadNextUp(elem, apiClient, userId);
|
2019-07-02 00:12:04 -07:00
|
|
|
} else if (section === 'onnow' || section === 'livetv') {
|
2019-01-10 15:39:37 +03:00
|
|
|
return loadOnNow(elem, apiClient, user);
|
2019-07-02 00:12:04 -07:00
|
|
|
} else {
|
2019-01-10 15:39:37 +03:00
|
|
|
elem.innerHTML = '';
|
|
|
|
return Promise.resolve();
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
2019-01-10 15:39:37 +03:00
|
|
|
return Promise.resolve();
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function getUserViews(apiClient, userId) {
|
2019-01-10 15:39:37 +03:00
|
|
|
return apiClient.getUserViews({}, userId || apiClient.getCurrentUserId()).then(function (result) {
|
|
|
|
return result.Items;
|
|
|
|
});
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function enableScrollX() {
|
2019-01-10 15:39:37 +03:00
|
|
|
return true;
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function getSquareShape() {
|
2019-01-10 15:39:37 +03:00
|
|
|
return enableScrollX() ? 'overflowSquare' : 'square';
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function getThumbShape() {
|
2019-01-10 15:39:37 +03:00
|
|
|
return enableScrollX() ? 'overflowBackdrop' : 'backdrop';
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function getPortraitShape() {
|
2019-01-10 15:39:37 +03:00
|
|
|
return enableScrollX() ? 'autooverflow' : 'auto';
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function getLibraryButtonsHtml(items) {
|
|
|
|
var html = "";
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
html += '<div class="verticalSection verticalSection-extrabottompadding">';
|
2019-02-03 02:41:16 +09:00
|
|
|
html += '<h2 class="sectionTitle sectionTitle-cards padded-left">' + globalize.translate('HeaderMyMedia') + '</h2>';
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
html += '<div is="emby-itemscontainer" class="itemsContainer padded-left padded-right vertical-wrap focuscontainer-x" data-multiselect="false">';
|
|
|
|
|
|
|
|
// "My Library" backgrounds
|
2018-10-23 01:05:09 +03:00
|
|
|
for (var i = 0, length = items.length; i < length; i++) {
|
2019-01-10 15:39:37 +03:00
|
|
|
var item = items[i];
|
|
|
|
var icon;
|
2018-10-23 01:05:09 +03:00
|
|
|
switch (item.CollectionType) {
|
|
|
|
case "movies":
|
2019-05-16 04:33:57 +03:00
|
|
|
icon = "video_library";
|
2018-10-23 01:05:09 +03:00
|
|
|
break;
|
|
|
|
case "music":
|
|
|
|
icon = "library_music";
|
|
|
|
break;
|
|
|
|
case "photos":
|
2019-05-16 04:33:57 +03:00
|
|
|
icon = "photo_library";
|
2018-10-23 01:05:09 +03:00
|
|
|
break;
|
|
|
|
case "livetv":
|
2019-01-10 15:39:37 +03:00
|
|
|
icon = "live_tv";
|
|
|
|
break;
|
2018-10-23 01:05:09 +03:00
|
|
|
case "tvshows":
|
2019-05-16 04:33:57 +03:00
|
|
|
icon = "tv";
|
2018-10-23 01:05:09 +03:00
|
|
|
break;
|
|
|
|
case "trailers":
|
|
|
|
icon = "local_movies";
|
|
|
|
break;
|
|
|
|
case "homevideos":
|
2019-05-17 21:29:31 +03:00
|
|
|
icon = "photo_library";
|
2019-01-10 15:39:37 +03:00
|
|
|
break;
|
2018-10-23 01:05:09 +03:00
|
|
|
case "musicvideos":
|
2019-05-16 04:33:57 +03:00
|
|
|
icon = "music_video";
|
2018-10-23 01:05:09 +03:00
|
|
|
break;
|
|
|
|
case "books":
|
2019-05-16 04:33:57 +03:00
|
|
|
icon = "library_books";
|
2019-01-10 15:39:37 +03:00
|
|
|
break;
|
2018-10-23 01:05:09 +03:00
|
|
|
case "channels":
|
2019-05-16 04:33:57 +03:00
|
|
|
icon = "videocam";
|
2019-01-10 15:39:37 +03:00
|
|
|
break;
|
2018-10-23 01:05:09 +03:00
|
|
|
case "playlists":
|
2019-05-16 04:33:57 +03:00
|
|
|
icon = "view_list";
|
2019-01-10 15:39:37 +03:00
|
|
|
break;
|
2018-10-23 01:05:09 +03:00
|
|
|
default:
|
2019-01-10 15:39:37 +03:00
|
|
|
icon = "folder";
|
|
|
|
break;
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2019-05-27 01:22:48 +03:00
|
|
|
html += '<a is="emby-linkbutton" href="' + appRouter.getRouteUrl(item) + '" class="raised homeLibraryButton"><i class="md-icon homeLibraryIcon">' + icon + '</i><span class="homeLibraryText">' + item.Name + '</span></a>';
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
html += '</div>';
|
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
return html;
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function loadlibraryButtons(elem, apiClient, user, userSettings, userViews) {
|
2019-01-16 17:47:32 +09:00
|
|
|
elem.classList.remove('verticalSection');
|
|
|
|
var html = getLibraryButtonsHtml(userViews);
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2019-01-16 18:31:34 +09:00
|
|
|
elem.innerHTML = html;
|
2019-01-16 17:47:32 +09:00
|
|
|
imageLoader.lazyChildren(elem);
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
2019-01-10 15:39:37 +03:00
|
|
|
/**
|
|
|
|
* Returns a random integer between min (inclusive) and max (inclusive)
|
|
|
|
* Using Math.round() will give you a non-uniform distribution!
|
|
|
|
*/
|
2018-10-23 01:05:09 +03:00
|
|
|
function getRandomInt(min, max) {
|
2019-01-10 15:39:37 +03:00
|
|
|
return Math.floor(Math.random() * (max - min + 1)) + min;
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function getFetchLatestItemsFn(serverId, parentId, collectionType) {
|
2019-01-10 15:39:37 +03:00
|
|
|
return function () {
|
|
|
|
var apiClient = connectionManager.getApiClient(serverId);
|
|
|
|
var limit = 16;
|
|
|
|
|
|
|
|
if (enableScrollX()) {
|
|
|
|
if (collectionType === 'music') {
|
|
|
|
limit = 30;
|
|
|
|
}
|
2019-05-09 17:55:00 -07:00
|
|
|
} else {
|
2019-01-10 15:39:37 +03:00
|
|
|
if (collectionType === 'tvshows') {
|
|
|
|
limit = 5;
|
|
|
|
} else if (collectionType === 'music') {
|
|
|
|
limit = 9;
|
|
|
|
} else {
|
|
|
|
limit = 8;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-23 01:05:09 +03:00
|
|
|
var options = {
|
|
|
|
Limit: limit,
|
|
|
|
Fields: "PrimaryImageAspectRatio,BasicSyncInfo",
|
|
|
|
ImageTypeLimit: 1,
|
|
|
|
EnableImageTypes: "Primary,Backdrop,Thumb",
|
|
|
|
ParentId: parentId
|
|
|
|
};
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
return apiClient.getLatestItems(options);
|
|
|
|
};
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function getLatestItemsHtmlFn(itemType, viewType) {
|
2019-01-10 15:39:37 +03:00
|
|
|
return function (items) {
|
|
|
|
var shape = itemType === 'Channel' || viewType === 'movies' ?
|
|
|
|
getPortraitShape() :
|
|
|
|
viewType === 'music' ?
|
|
|
|
getSquareShape() :
|
|
|
|
getThumbShape();
|
|
|
|
|
|
|
|
var cardLayout = false;
|
|
|
|
|
2018-10-23 01:05:09 +03:00
|
|
|
return cardBuilder.getCardsHtml({
|
|
|
|
items: items,
|
|
|
|
shape: shape,
|
2019-01-10 15:39:37 +03:00
|
|
|
preferThumb: viewType !== 'movies' && itemType !== 'Channel' && viewType !== 'music' ? 'auto' : null,
|
|
|
|
showUnplayedIndicator: false,
|
|
|
|
showChildCountIndicator: true,
|
|
|
|
context: 'home',
|
|
|
|
overlayText: false,
|
|
|
|
centerText: !cardLayout,
|
|
|
|
overlayPlayButton: viewType !== 'photos',
|
|
|
|
allowBottomPadding: !enableScrollX() && !cardLayout,
|
|
|
|
cardLayout: cardLayout,
|
|
|
|
showTitle: viewType !== 'photos',
|
|
|
|
showYear: viewType === 'movies' || viewType === 'tvshows' || !viewType,
|
|
|
|
showParentTitle: viewType === 'music' || viewType === 'tvshows' || !viewType || (cardLayout && (viewType === 'tvshows')),
|
2018-10-23 01:05:09 +03:00
|
|
|
lines: 2
|
2019-01-10 15:39:37 +03:00
|
|
|
});
|
|
|
|
};
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function renderLatestSection(elem, apiClient, user, parent) {
|
2019-01-10 15:39:37 +03:00
|
|
|
var html = '';
|
2019-05-09 17:55:00 -07:00
|
|
|
|
2019-01-10 15:39:37 +03:00
|
|
|
html += '<div class="sectionTitleContainer sectionTitleContainer-cards padded-left">';
|
|
|
|
if (!layoutManager.tv) {
|
|
|
|
html += '<a is="emby-linkbutton" href="' + appRouter.getRouteUrl(parent, {
|
|
|
|
section: 'latest'
|
|
|
|
}) + '" class="more button-flat button-flat-mini sectionTitleTextButton">';
|
|
|
|
html += '<h2 class="sectionTitle sectionTitle-cards">';
|
2019-02-03 02:41:16 +09:00
|
|
|
html += globalize.translate('LatestFromLibrary', parent.Name);
|
2019-01-10 15:39:37 +03:00
|
|
|
html += '</h2>';
|
|
|
|
html += '<i class="md-icon"></i>';
|
|
|
|
html += '</a>';
|
|
|
|
} else {
|
2019-02-03 02:41:16 +09:00
|
|
|
html += '<h2 class="sectionTitle sectionTitle-cards">' + globalize.translate('LatestFromLibrary', parent.Name) + '</h2>';
|
2019-01-10 15:39:37 +03:00
|
|
|
}
|
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
if (enableScrollX()) {
|
2019-07-02 00:12:04 -07:00
|
|
|
html += '<div is="emby-scroller" class="padded-top-focusscale padded-bottom-focusscale" data-mousewheel="false" data-centerfocus="true">';
|
|
|
|
html += '<div is="emby-itemscontainer" class="itemsContainer scrollSlider focuscontainer-x">';
|
2019-01-10 15:39:37 +03:00
|
|
|
} else {
|
2019-05-09 17:55:00 -07:00
|
|
|
html += '<div is="emby-itemscontainer" class="itemsContainer focuscontainer-x padded-left padded-right vertical-wrap">';
|
2019-01-10 15:39:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (enableScrollX()) {
|
|
|
|
html += '</div>';
|
|
|
|
}
|
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
elem.innerHTML = html;
|
|
|
|
|
|
|
|
var itemsContainer = elem.querySelector('.itemsContainer');
|
|
|
|
itemsContainer.fetchData = getFetchLatestItemsFn(apiClient.serverId(), parent.Id, parent.CollectionType);
|
|
|
|
itemsContainer.getItemsHtml = getLatestItemsHtmlFn(parent.Type, parent.CollectionType);
|
|
|
|
itemsContainer.parentContainer = elem;
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function loadRecentlyAdded(elem, apiClient, user, userViews) {
|
2019-01-10 15:39:37 +03:00
|
|
|
elem.classList.remove('verticalSection');
|
|
|
|
var excludeViewTypes = ['playlists', 'livetv', 'boxsets', 'channels'];
|
|
|
|
|
|
|
|
for (var i = 0, length = userViews.length; i < length; i++) {
|
2018-10-23 01:05:09 +03:00
|
|
|
var item = userViews[i];
|
2019-01-10 15:39:37 +03:00
|
|
|
if (user.Configuration.LatestItemsExcludes.indexOf(item.Id) !== -1) {
|
|
|
|
continue;
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
if (excludeViewTypes.indexOf(item.CollectionType || []) !== -1) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
var frag = document.createElement('div');
|
|
|
|
frag.classList.add('verticalSection');
|
|
|
|
frag.classList.add('hide');
|
|
|
|
elem.appendChild(frag);
|
|
|
|
|
|
|
|
renderLatestSection(frag, apiClient, user, item);
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function getRequirePromise(deps) {
|
2019-01-10 15:39:37 +03:00
|
|
|
return new Promise(function (resolve, reject) {
|
|
|
|
require(deps, resolve);
|
|
|
|
});
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function loadLibraryTiles(elem, apiClient, user, userSettings, shape, userViews, allSections) {
|
2019-01-10 15:39:37 +03:00
|
|
|
var html = '';
|
|
|
|
if (userViews.length) {
|
2019-07-02 00:12:04 -07:00
|
|
|
html += '<h2 class="sectionTitle sectionTitle-cards padded-left">' + globalize.translate('HeaderMyMedia') + '</h2>';
|
2019-05-09 17:55:00 -07:00
|
|
|
if (enableScrollX()) {
|
|
|
|
html += '<div is="emby-scroller" class="padded-top-focusscale padded-bottom-focusscale" data-mousewheel="false" data-centerfocus="true">';
|
2019-07-02 00:12:04 -07:00
|
|
|
html += '<div is="emby-itemscontainer" class="itemsContainer scrollSlider focuscontainer-x">';
|
2019-01-10 15:39:37 +03:00
|
|
|
} else {
|
2019-05-09 17:55:00 -07:00
|
|
|
html += '<div is="emby-itemscontainer" class="itemsContainer padded-left padded-right focuscontainer-x vertical-wrap">';
|
2019-01-10 15:39:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
html += cardBuilder.getCardsHtml({
|
|
|
|
items: userViews,
|
2019-05-09 17:55:00 -07:00
|
|
|
shape: enableScrollX() ? 'overflowSmallBackdrop' : shape,
|
2019-01-10 15:39:37 +03:00
|
|
|
showTitle: true,
|
|
|
|
centerText: true,
|
|
|
|
overlayText: false,
|
|
|
|
lazy: true,
|
|
|
|
transition: false,
|
2019-05-09 17:55:00 -07:00
|
|
|
allowBottomPadding: !enableScrollX()
|
2019-01-10 15:39:37 +03:00
|
|
|
});
|
|
|
|
|
2019-05-09 17:55:00 -07:00
|
|
|
if (enableScrollX()) {
|
2019-01-10 15:39:37 +03:00
|
|
|
html += '</div>';
|
|
|
|
}
|
|
|
|
html += '</div>';
|
|
|
|
}
|
|
|
|
|
2019-01-16 17:47:32 +09:00
|
|
|
elem.innerHTML = html;
|
|
|
|
imageLoader.lazyChildren(elem);
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function getContinueWatchingFetchFn(serverId) {
|
2019-01-10 15:39:37 +03:00
|
|
|
return function () {
|
|
|
|
var apiClient = connectionManager.getApiClient(serverId);
|
|
|
|
var screenWidth = dom.getWindowSize().innerWidth;
|
|
|
|
|
|
|
|
var limit;
|
|
|
|
if (enableScrollX()) {
|
|
|
|
limit = 12;
|
|
|
|
} else {
|
|
|
|
limit = screenWidth >= 1920 ? 8 : (screenWidth >= 1600 ? 8 : (screenWidth >= 1200 ? 9 : 6));
|
|
|
|
limit = Math.min(limit, 5);
|
|
|
|
}
|
|
|
|
|
2018-10-23 01:05:09 +03:00
|
|
|
var options = {
|
|
|
|
Limit: limit,
|
2019-01-10 15:39:37 +03:00
|
|
|
Recursive: true,
|
2018-10-23 01:05:09 +03:00
|
|
|
Fields: "PrimaryImageAspectRatio,BasicSyncInfo",
|
|
|
|
ImageTypeLimit: 1,
|
|
|
|
EnableImageTypes: "Primary,Backdrop,Thumb",
|
2019-01-10 15:39:37 +03:00
|
|
|
EnableTotalRecordCount: false,
|
|
|
|
MediaTypes: 'Video'
|
2018-10-23 01:05:09 +03:00
|
|
|
};
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
return apiClient.getResumableItems(apiClient.getCurrentUserId(), options);
|
|
|
|
};
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function getContinueWatchingItemsHtml(items) {
|
2019-01-10 15:39:37 +03:00
|
|
|
var cardLayout = false;
|
2018-10-23 01:05:09 +03:00
|
|
|
return cardBuilder.getCardsHtml({
|
|
|
|
items: items,
|
2019-01-10 15:39:37 +03:00
|
|
|
preferThumb: true,
|
2018-10-23 01:05:09 +03:00
|
|
|
shape: getThumbShape(),
|
2019-01-10 15:39:37 +03:00
|
|
|
overlayText: false,
|
|
|
|
showTitle: true,
|
|
|
|
showParentTitle: true,
|
|
|
|
lazy: true,
|
|
|
|
showDetailsMenu: true,
|
|
|
|
overlayPlayButton: true,
|
|
|
|
context: 'home',
|
|
|
|
centerText: !cardLayout,
|
|
|
|
allowBottomPadding: false,
|
|
|
|
cardLayout: cardLayout,
|
|
|
|
showYear: true,
|
2018-10-23 01:05:09 +03:00
|
|
|
lines: 2
|
2019-01-10 15:39:37 +03:00
|
|
|
});
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function loadResumeVideo(elem, apiClient, userId) {
|
2019-01-10 15:39:37 +03:00
|
|
|
var html = '';
|
|
|
|
|
2019-05-09 17:55:00 -07:00
|
|
|
html += '<h2 class="sectionTitle sectionTitle-cards padded-left">' + globalize.translate('HeaderContinueWatching') + '</h2>';
|
2019-01-10 15:39:37 +03:00
|
|
|
if (enableScrollX()) {
|
2019-07-02 00:12:04 -07:00
|
|
|
html += '<div is="emby-scroller" class="padded-top-focusscale padded-bottom-focusscale" data-mousewheel="false" data-centerfocus="true">';
|
2019-05-09 17:55:00 -07:00
|
|
|
html += '<div is="emby-itemscontainer" class="itemsContainer scrollSlider focuscontainer-x" data-monitor="videoplayback,markplayed">';
|
2019-01-10 15:39:37 +03:00
|
|
|
} else {
|
|
|
|
html += '<div is="emby-itemscontainer" class="itemsContainer padded-left padded-right vertical-wrap focuscontainer-x" data-monitor="videoplayback,markplayed">';
|
|
|
|
}
|
|
|
|
|
|
|
|
if (enableScrollX()) {
|
|
|
|
html += '</div>';
|
|
|
|
}
|
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
elem.classList.add('hide');
|
|
|
|
elem.innerHTML = html;
|
|
|
|
|
|
|
|
var itemsContainer = elem.querySelector('.itemsContainer');
|
|
|
|
itemsContainer.fetchData = getContinueWatchingFetchFn(apiClient.serverId());
|
|
|
|
itemsContainer.getItemsHtml = getContinueWatchingItemsHtml;
|
|
|
|
itemsContainer.parentContainer = elem;
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function getContinueListeningFetchFn(serverId) {
|
2019-01-10 15:39:37 +03:00
|
|
|
return function () {
|
|
|
|
var apiClient = connectionManager.getApiClient(serverId);
|
|
|
|
var screenWidth = dom.getWindowSize().innerWidth;
|
|
|
|
|
|
|
|
var limit;
|
|
|
|
if (enableScrollX()) {
|
|
|
|
limit = 12;
|
|
|
|
} else {
|
|
|
|
limit = screenWidth >= 1920 ? 8 : (screenWidth >= 1600 ? 8 : (screenWidth >= 1200 ? 9 : 6));
|
|
|
|
limit = Math.min(limit, 5);
|
|
|
|
}
|
|
|
|
|
2018-10-23 01:05:09 +03:00
|
|
|
var options = {
|
|
|
|
Limit: limit,
|
2019-01-10 15:39:37 +03:00
|
|
|
Recursive: true,
|
2018-10-23 01:05:09 +03:00
|
|
|
Fields: "PrimaryImageAspectRatio,BasicSyncInfo",
|
|
|
|
ImageTypeLimit: 1,
|
|
|
|
EnableImageTypes: "Primary,Backdrop,Thumb",
|
2019-01-10 15:39:37 +03:00
|
|
|
EnableTotalRecordCount: false,
|
|
|
|
MediaTypes: 'Audio'
|
2018-10-23 01:05:09 +03:00
|
|
|
};
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
return apiClient.getResumableItems(apiClient.getCurrentUserId(), options);
|
|
|
|
};
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function getContinueListeningItemsHtml(items) {
|
2019-01-10 15:39:37 +03:00
|
|
|
var cardLayout = false;
|
2018-10-23 01:05:09 +03:00
|
|
|
return cardBuilder.getCardsHtml({
|
|
|
|
items: items,
|
2019-01-10 15:39:37 +03:00
|
|
|
preferThumb: true,
|
2018-10-23 01:05:09 +03:00
|
|
|
shape: getThumbShape(),
|
2019-01-10 15:39:37 +03:00
|
|
|
overlayText: false,
|
|
|
|
showTitle: true,
|
|
|
|
showParentTitle: true,
|
|
|
|
lazy: true,
|
|
|
|
showDetailsMenu: true,
|
|
|
|
overlayPlayButton: true,
|
|
|
|
context: 'home',
|
|
|
|
centerText: !cardLayout,
|
|
|
|
allowBottomPadding: false,
|
|
|
|
cardLayout: cardLayout,
|
|
|
|
showYear: true,
|
2018-10-23 01:05:09 +03:00
|
|
|
lines: 2
|
2019-01-10 15:39:37 +03:00
|
|
|
});
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function loadResumeAudio(elem, apiClient, userId) {
|
2019-01-10 15:39:37 +03:00
|
|
|
var html = '';
|
|
|
|
|
2019-05-09 17:55:00 -07:00
|
|
|
html += '<h2 class="sectionTitle sectionTitle-cards padded-left">' + globalize.translate('HeaderContinueWatching') + '</h2>';
|
2019-01-10 15:39:37 +03:00
|
|
|
if (enableScrollX()) {
|
2019-07-02 00:12:04 -07:00
|
|
|
html += '<div is="emby-scroller" class="padded-top-focusscale padded-bottom-focusscale" data-mousewheel="false" data-centerfocus="true">';
|
2019-05-09 17:55:00 -07:00
|
|
|
html += '<div is="emby-itemscontainer" class="itemsContainer scrollSlider focuscontainer-x" data-monitor="audioplayback,markplayed">';
|
2019-01-10 15:39:37 +03:00
|
|
|
} else {
|
|
|
|
html += '<div is="emby-itemscontainer" class="itemsContainer padded-left padded-right vertical-wrap focuscontainer-x" data-monitor="audioplayback,markplayed">';
|
|
|
|
}
|
|
|
|
|
|
|
|
if (enableScrollX()) {
|
|
|
|
html += '</div>';
|
|
|
|
}
|
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
elem.classList.add('hide');
|
|
|
|
elem.innerHTML = html;
|
|
|
|
|
|
|
|
var itemsContainer = elem.querySelector('.itemsContainer');
|
|
|
|
itemsContainer.fetchData = getContinueListeningFetchFn(apiClient.serverId());
|
|
|
|
itemsContainer.getItemsHtml = getContinueListeningItemsHtml;
|
|
|
|
itemsContainer.parentContainer = elem;
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function getOnNowFetchFn(serverId) {
|
2019-01-10 15:39:37 +03:00
|
|
|
return function () {
|
2018-10-23 01:05:09 +03:00
|
|
|
var apiClient = connectionManager.getApiClient(serverId);
|
|
|
|
return apiClient.getLiveTvRecommendedPrograms({
|
|
|
|
userId: apiClient.getCurrentUserId(),
|
2019-01-10 15:39:37 +03:00
|
|
|
IsAiring: true,
|
2018-10-23 01:05:09 +03:00
|
|
|
limit: 24,
|
|
|
|
ImageTypeLimit: 1,
|
|
|
|
EnableImageTypes: "Primary,Thumb,Backdrop",
|
2019-01-10 15:39:37 +03:00
|
|
|
EnableTotalRecordCount: false,
|
2018-10-23 01:05:09 +03:00
|
|
|
Fields: "ChannelInfo,PrimaryImageAspectRatio"
|
2019-01-10 15:39:37 +03:00
|
|
|
});
|
|
|
|
};
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function getOnNowItemsHtml(items) {
|
2019-01-10 15:39:37 +03:00
|
|
|
var cardLayout = false;
|
2018-10-23 01:05:09 +03:00
|
|
|
return cardBuilder.getCardsHtml({
|
|
|
|
items: items,
|
2019-01-10 15:39:37 +03:00
|
|
|
preferThumb: 'auto',
|
|
|
|
inheritThumb: false,
|
|
|
|
shape: (enableScrollX() ? 'autooverflow' : 'auto'),
|
|
|
|
showParentTitleOrTitle: true,
|
|
|
|
showTitle: true,
|
|
|
|
centerText: true,
|
|
|
|
coverImage: true,
|
|
|
|
overlayText: false,
|
2018-10-23 01:05:09 +03:00
|
|
|
allowBottomPadding: !enableScrollX(),
|
2019-01-10 15:39:37 +03:00
|
|
|
showAirTime: true,
|
|
|
|
showChannelName: false,
|
|
|
|
showAirDateTime: false,
|
|
|
|
showAirEndTime: true,
|
2018-10-23 01:05:09 +03:00
|
|
|
defaultShape: getThumbShape(),
|
|
|
|
lines: 3,
|
2019-01-10 15:39:37 +03:00
|
|
|
overlayPlayButton: true
|
|
|
|
});
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function loadOnNow(elem, apiClient, user) {
|
2019-01-10 15:39:37 +03:00
|
|
|
if (!user.Policy.EnableLiveTvAccess) {
|
|
|
|
return Promise.resolve();
|
|
|
|
}
|
|
|
|
|
|
|
|
var userId = user.Id;
|
2019-07-02 15:46:54 -05:00
|
|
|
return apiClient.getLiveTvRecommendedPrograms({
|
2018-10-23 01:05:09 +03:00
|
|
|
userId: apiClient.getCurrentUserId(),
|
2019-01-10 15:39:37 +03:00
|
|
|
IsAiring: true,
|
2018-10-23 01:05:09 +03:00
|
|
|
limit: 1,
|
|
|
|
ImageTypeLimit: 1,
|
|
|
|
EnableImageTypes: "Primary,Thumb,Backdrop",
|
2019-01-10 15:39:37 +03:00
|
|
|
EnableTotalRecordCount: false,
|
2018-10-23 01:05:09 +03:00
|
|
|
Fields: "ChannelInfo,PrimaryImageAspectRatio"
|
2019-03-19 17:03:11 -07:00
|
|
|
}).then(function (result) {
|
2019-01-10 15:39:37 +03:00
|
|
|
var html = '';
|
2019-03-19 17:03:11 -07:00
|
|
|
if (result.Items.length) {
|
2019-01-10 15:39:37 +03:00
|
|
|
elem.classList.remove('padded-left');
|
|
|
|
elem.classList.remove('padded-right');
|
|
|
|
elem.classList.remove('padded-bottom');
|
|
|
|
elem.classList.remove('verticalSection');
|
|
|
|
|
|
|
|
html += '<div class="verticalSection">';
|
|
|
|
html += '<div class="sectionTitleContainer sectionTitleContainer-cards padded-left">';
|
2019-02-03 02:41:16 +09:00
|
|
|
html += '<h2 class="sectionTitle sectionTitle-cards">' + globalize.translate('LiveTV') + '</h2>';
|
2019-01-10 15:39:37 +03:00
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
if (enableScrollX()) {
|
|
|
|
html += '<div is="emby-scroller" class="padded-top-focusscale padded-bottom-focusscale" data-mousewheel="false" data-centerfocus="true" data-scrollbuttons="false">';
|
2019-07-02 00:12:04 -07:00
|
|
|
html += '<div class="padded-left padded-right padded-top padded-bottom scrollSlider focuscontainer-x">';
|
2019-03-19 17:03:11 -07:00
|
|
|
} else {
|
2019-07-02 00:12:04 -07:00
|
|
|
html += '<div class="padded-left padded-right padded-top padded-bottom focuscontainer-x">';
|
2019-01-10 15:39:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
html += '<a style="margin-left:.8em;margin-right:0;" is="emby-linkbutton" href="' + appRouter.getRouteUrl('livetv', {
|
2019-07-02 14:17:36 -05:00
|
|
|
serverId: apiClient.serverId(),
|
|
|
|
section: 'programs'
|
2019-02-03 02:41:16 +09:00
|
|
|
}) + '" class="raised"><span>' + globalize.translate('Programs') + '</span></a>';
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
html += '<a style="margin-left:.5em;margin-right:0;" is="emby-linkbutton" href="' + appRouter.getRouteUrl('livetv', {
|
2018-10-23 01:05:09 +03:00
|
|
|
serverId: apiClient.serverId(),
|
2019-01-10 15:39:37 +03:00
|
|
|
section: 'guide'
|
2019-02-03 02:41:16 +09:00
|
|
|
}) + '" class="raised"><span>' + globalize.translate('Guide') + '</span></a>';
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
html += '<a style="margin-left:.5em;margin-right:0;" is="emby-linkbutton" href="' + appRouter.getRouteUrl('recordedtv', {
|
2018-10-23 01:05:09 +03:00
|
|
|
serverId: apiClient.serverId()
|
2019-02-03 02:41:16 +09:00
|
|
|
}) + '" class="raised"><span>' + globalize.translate('Recordings') + '</span></a>';
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
html += '<a style="margin-left:.5em;margin-right:0;" is="emby-linkbutton" href="' + appRouter.getRouteUrl('livetv', {
|
2018-10-23 01:05:09 +03:00
|
|
|
serverId: apiClient.serverId(),
|
2019-01-10 15:39:37 +03:00
|
|
|
section: 'dvrschedule'
|
2019-02-03 02:41:16 +09:00
|
|
|
}) + '" class="raised"><span>' + globalize.translate('Schedule') + '</span></a>';
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2019-07-01 12:14:28 -05:00
|
|
|
html += '<a style="margin-left:.5em;margin-right:0;" is="emby-linkbutton" href="' + appRouter.getRouteUrl('livetv', {
|
|
|
|
serverId: apiClient.serverId(),
|
|
|
|
section: 'seriesrecording'
|
|
|
|
}) + '" class="raised"><span>' + globalize.translate('Series') + '</span></a>';
|
|
|
|
|
2019-01-10 15:39:37 +03:00
|
|
|
html += '</div>';
|
|
|
|
if (enableScrollX()) {
|
|
|
|
html += '</div>';
|
|
|
|
}
|
|
|
|
html += '</div>';
|
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
html += '<div class="verticalSection">';
|
|
|
|
html += '<div class="sectionTitleContainer sectionTitleContainer-cards padded-left">';
|
|
|
|
|
|
|
|
if (!layoutManager.tv) {
|
|
|
|
html += '<a is="emby-linkbutton" href="' + appRouter.getRouteUrl('livetv', {
|
|
|
|
serverId: apiClient.serverId(),
|
|
|
|
section: 'onnow'
|
|
|
|
}) + '" class="more button-flat button-flat-mini sectionTitleTextButton">';
|
|
|
|
html += '<h2 class="sectionTitle sectionTitle-cards">';
|
2019-02-03 02:41:16 +09:00
|
|
|
html += globalize.translate('HeaderOnNow');
|
2019-01-10 15:39:37 +03:00
|
|
|
html += '</h2>';
|
|
|
|
html += '<i class="md-icon"></i>';
|
|
|
|
html += '</a>';
|
|
|
|
|
|
|
|
} else {
|
2019-02-03 02:41:16 +09:00
|
|
|
html += '<h2 class="sectionTitle sectionTitle-cards">' + globalize.translate('HeaderOnNow') + '</h2>';
|
2019-01-10 15:39:37 +03:00
|
|
|
}
|
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
if (enableScrollX()) {
|
2019-07-02 00:12:04 -07:00
|
|
|
html += '<div is="emby-scroller" class="padded-top-focusscale padded-bottom-focusscale" data-mousewheel="false" data-centerfocus="true">';
|
|
|
|
html += '<div is="emby-itemscontainer" class="itemsContainer scrollSlider focuscontainer-x">'
|
2019-01-10 15:39:37 +03:00
|
|
|
} else {
|
2019-07-02 00:12:04 -07:00
|
|
|
html += '<div is="emby-itemscontainer" class="itemsContainer padded-left padded-right vertical-wrap focuscontainer-x">';
|
2019-01-10 15:39:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (enableScrollX()) {
|
|
|
|
html += '</div>';
|
|
|
|
}
|
|
|
|
|
|
|
|
html += '</div>';
|
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
elem.innerHTML = html;
|
|
|
|
|
|
|
|
var itemsContainer = elem.querySelector('.itemsContainer');
|
|
|
|
itemsContainer.parentContainer = elem;
|
|
|
|
itemsContainer.fetchData = getOnNowFetchFn(apiClient.serverId());
|
|
|
|
itemsContainer.getItemsHtml = getOnNowItemsHtml;
|
|
|
|
}
|
|
|
|
});
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function getNextUpFetchFn(serverId) {
|
2019-01-10 15:39:37 +03:00
|
|
|
return function () {
|
2018-10-23 01:05:09 +03:00
|
|
|
var apiClient = connectionManager.getApiClient(serverId);
|
|
|
|
return apiClient.getNextUpEpisodes({
|
|
|
|
Limit: enableScrollX() ? 24 : 15,
|
|
|
|
Fields: "PrimaryImageAspectRatio,SeriesInfo,DateCreated,BasicSyncInfo",
|
|
|
|
UserId: apiClient.getCurrentUserId(),
|
|
|
|
ImageTypeLimit: 1,
|
|
|
|
EnableImageTypes: "Primary,Backdrop,Banner,Thumb",
|
2019-01-10 15:39:37 +03:00
|
|
|
EnableTotalRecordCount: false
|
|
|
|
});
|
|
|
|
};
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function getNextUpItemsHtml(items) {
|
2019-01-10 15:39:37 +03:00
|
|
|
var cardLayout = false;
|
2018-10-23 01:05:09 +03:00
|
|
|
return cardBuilder.getCardsHtml({
|
|
|
|
items: items,
|
2019-01-10 15:39:37 +03:00
|
|
|
preferThumb: true,
|
2018-10-23 01:05:09 +03:00
|
|
|
shape: getThumbShape(),
|
2019-01-10 15:39:37 +03:00
|
|
|
overlayText: false,
|
|
|
|
showTitle: true,
|
|
|
|
showParentTitle: true,
|
|
|
|
lazy: true,
|
|
|
|
overlayPlayButton: true,
|
|
|
|
context: 'home',
|
|
|
|
centerText: !cardLayout,
|
2018-10-23 01:05:09 +03:00
|
|
|
allowBottomPadding: !enableScrollX(),
|
2019-01-10 15:39:37 +03:00
|
|
|
cardLayout: cardLayout
|
|
|
|
});
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function loadNextUp(elem, apiClient, userId) {
|
2019-01-10 15:39:37 +03:00
|
|
|
var html = '';
|
2019-05-09 17:55:00 -07:00
|
|
|
|
2019-01-10 15:39:37 +03:00
|
|
|
html += '<div class="sectionTitleContainer sectionTitleContainer-cards padded-left">';
|
|
|
|
if (!layoutManager.tv) {
|
|
|
|
html += '<a is="emby-linkbutton" href="' + appRouter.getRouteUrl('nextup', {
|
|
|
|
serverId: apiClient.serverId()
|
|
|
|
}) + '" class="button-flat button-flat-mini sectionTitleTextButton">';
|
|
|
|
html += '<h2 class="sectionTitle sectionTitle-cards">';
|
2019-02-03 02:41:16 +09:00
|
|
|
html += globalize.translate('HeaderNextUp');
|
2019-01-10 15:39:37 +03:00
|
|
|
html += '</h2>';
|
|
|
|
html += '<i class="md-icon"></i>';
|
|
|
|
html += '</a>';
|
|
|
|
} else {
|
2019-02-03 02:41:16 +09:00
|
|
|
html += '<h2 class="sectionTitle sectionTitle-cards">' + globalize.translate('HeaderNextUp') + '</h2>';
|
2019-01-10 15:39:37 +03:00
|
|
|
}
|
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
if (enableScrollX()) {
|
2019-07-02 00:12:04 -07:00
|
|
|
html += '<div is="emby-scroller" class="padded-top-focusscale padded-bottom-focusscale" data-mousewheel="false" data-centerfocus="true">';
|
2019-05-09 17:55:00 -07:00
|
|
|
html += '<div is="emby-itemscontainer" class="itemsContainer scrollSlider focuscontainer-x" data-monitor="videoplayback,markplayed">'
|
2019-01-10 15:39:37 +03:00
|
|
|
} else {
|
|
|
|
html += '<div is="emby-itemscontainer" class="itemsContainer padded-left padded-right vertical-wrap focuscontainer-x" data-monitor="videoplayback,markplayed">';
|
|
|
|
}
|
|
|
|
|
|
|
|
if (enableScrollX()) {
|
|
|
|
html += '</div>';
|
|
|
|
}
|
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
elem.classList.add('hide');
|
|
|
|
elem.innerHTML = html;
|
|
|
|
|
|
|
|
var itemsContainer = elem.querySelector('.itemsContainer');
|
|
|
|
itemsContainer.fetchData = getNextUpFetchFn(apiClient.serverId());
|
|
|
|
itemsContainer.getItemsHtml = getNextUpItemsHtml;
|
|
|
|
itemsContainer.parentContainer = elem;
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function getLatestRecordingsFetchFn(serverId, activeRecordingsOnly) {
|
2019-01-10 15:39:37 +03:00
|
|
|
return function () {
|
2018-10-23 01:05:09 +03:00
|
|
|
var apiClient = connectionManager.getApiClient(serverId);
|
|
|
|
return apiClient.getLiveTvRecordings({
|
|
|
|
userId: apiClient.getCurrentUserId(),
|
|
|
|
Limit: enableScrollX() ? 12 : 5,
|
|
|
|
Fields: "PrimaryImageAspectRatio,BasicSyncInfo",
|
2019-01-10 15:39:37 +03:00
|
|
|
EnableTotalRecordCount: false,
|
|
|
|
IsLibraryItem: activeRecordingsOnly ? null : false,
|
|
|
|
IsInProgress: activeRecordingsOnly ? true : null
|
|
|
|
});
|
|
|
|
};
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function getLatestRecordingItemsHtml(activeRecordingsOnly) {
|
2019-01-10 15:39:37 +03:00
|
|
|
return function (items) {
|
|
|
|
var cardLayout = false;
|
2018-10-23 01:05:09 +03:00
|
|
|
return cardBuilder.getCardsHtml({
|
|
|
|
items: items,
|
2019-01-10 15:39:37 +03:00
|
|
|
shape: enableScrollX() ? 'autooverflow' : 'auto',
|
|
|
|
showTitle: true,
|
|
|
|
showParentTitle: true,
|
|
|
|
coverImage: true,
|
|
|
|
lazy: true,
|
|
|
|
showDetailsMenu: true,
|
|
|
|
centerText: true,
|
|
|
|
overlayText: false,
|
|
|
|
showYear: true,
|
2018-10-23 01:05:09 +03:00
|
|
|
lines: 2,
|
|
|
|
overlayPlayButton: !activeRecordingsOnly,
|
|
|
|
allowBottomPadding: !enableScrollX(),
|
2019-01-10 15:39:37 +03:00
|
|
|
preferThumb: true,
|
|
|
|
cardLayout: false,
|
2018-10-23 01:05:09 +03:00
|
|
|
overlayMoreButton: activeRecordingsOnly,
|
2019-01-10 15:39:37 +03:00
|
|
|
action: activeRecordingsOnly ? 'none' : null,
|
2018-10-23 01:05:09 +03:00
|
|
|
centerPlayButton: activeRecordingsOnly
|
2019-01-10 15:39:37 +03:00
|
|
|
});
|
|
|
|
};
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function loadLatestLiveTvRecordings(elem, activeRecordingsOnly, apiClient, userId) {
|
2019-01-10 15:39:37 +03:00
|
|
|
var title = activeRecordingsOnly ?
|
2019-02-03 02:41:16 +09:00
|
|
|
globalize.translate('HeaderActiveRecordings') :
|
|
|
|
globalize.translate('HeaderLatestRecordings');
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
var html = '';
|
|
|
|
|
|
|
|
html += '<div class="sectionTitleContainer sectionTitleContainer-cards">';
|
|
|
|
html += '<h2 class="sectionTitle sectionTitle-cards padded-left">' + title + '</h2>';
|
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
if (enableScrollX()) {
|
2019-07-02 00:12:04 -07:00
|
|
|
html += '<div is="emby-scroller" class="padded-top-focusscale padded-bottom-focusscale" data-mousewheel="false" data-centerfocus="true">';
|
2019-05-09 17:55:00 -07:00
|
|
|
html += '<div is="emby-itemscontainer" class="itemsContainer scrollSlider focuscontainer-x">'
|
2019-01-10 15:39:37 +03:00
|
|
|
} else {
|
|
|
|
html += '<div is="emby-itemscontainer" class="itemsContainer padded-left padded-right vertical-wrap focuscontainer-x">';
|
|
|
|
}
|
|
|
|
|
|
|
|
if (enableScrollX()) {
|
|
|
|
html += '</div>';
|
|
|
|
}
|
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
elem.classList.add('hide');
|
|
|
|
elem.innerHTML = html;
|
|
|
|
|
|
|
|
var itemsContainer = elem.querySelector('.itemsContainer');
|
|
|
|
itemsContainer.fetchData = getLatestRecordingsFetchFn(apiClient.serverId(), activeRecordingsOnly);
|
|
|
|
itemsContainer.getItemsHtml = getLatestRecordingItemsHtml(activeRecordingsOnly);
|
|
|
|
itemsContainer.parentContainer = elem;
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2018-10-23 01:05:09 +03:00
|
|
|
return {
|
|
|
|
loadLibraryTiles: loadLibraryTiles,
|
|
|
|
getDefaultSection: getDefaultSection,
|
|
|
|
loadSections: loadSections,
|
|
|
|
destroySections: destroySections,
|
|
|
|
pause: pause,
|
|
|
|
resume: resume
|
2019-01-10 15:39:37 +03:00
|
|
|
};
|
2019-01-27 22:10:07 +01:00
|
|
|
});
|