jellyfin-web/dashboard-ui/scripts/tvrecommended.js
2014-05-13 20:46:45 -04:00

86 lines
2.3 KiB
JavaScript

(function ($, document) {
function loadResume(page) {
var screenWidth = $(window).width();
var parentId = LibraryMenu.getTopParentId();
var options = {
SortBy: "DatePlayed",
SortOrder: "Descending",
IncludeItemTypes: "Episode",
Filters: "IsResumable",
Limit: screenWidth >= 1920 ? 5 : 4,
Recursive: true,
Fields: "PrimaryImageAspectRatio,SeriesInfo,UserData",
ExcludeLocationTypes: "Virtual",
ParentId: parentId
};
ApiClient.getItems(Dashboard.getCurrentUserId(), options).done(function (result) {
if (result.Items.length) {
$('#resumableSection', page).show();
} else {
$('#resumableSection', page).hide();
}
$('#resumableItems', page).html(LibraryBrowser.getPosterViewHtml({
items: result.Items,
shape: "backdrop",
showTitle: true,
showParentTitle: true,
overlayText: screenWidth >= 600
})).createPosterItemMenus();
});
}
function loadNextUp(page) {
var screenWidth = $(window).width();
var parentId = LibraryMenu.getTopParentId();
var options = {
Limit: 24,
Fields: "PrimaryImageAspectRatio,SeriesInfo,DateCreated",
UserId: Dashboard.getCurrentUserId(),
ExcludeLocationTypes: "Virtual",
ParentId: parentId
};
ApiClient.getNextUpEpisodes(options).done(function (result) {
if (result.Items.length) {
$('.noNextUpItems', page).hide();
} else {
$('.noNextUpItems', page).show();
}
$('#nextUpItems', page).html(LibraryBrowser.getPosterViewHtml({
items: result.Items,
shape: "backdrop",
showTitle: true,
showParentTitle: true,
overlayText: screenWidth >= 600
})).createPosterItemMenus();
});
}
$(document).on('pagebeforeshow', "#tvRecommendedPage", function () {
var page = this;
loadResume(page);
loadNextUp(page);
});
})(jQuery, document);