jellyfin-web/dashboard-ui/scripts/indexpage.js

176 lines
5.3 KiB
JavaScript
Raw Normal View History

(function ($, document, apiClient) {
2013-02-20 18:33:05 -07:00
2014-05-07 11:38:50 -07:00
function fillSeriesSpotlight(elem, item, nextUp) {
var html = '<h1 class="spotlightTitle">' + item.Name + '</h1>';
var imgUrl = ApiClient.getImageUrl(item.Id, {
type: "Backdrop",
tag: item.BackdropImageTags[0]
});
html += '<div class="spotlight" style="background-image:url(\'' + imgUrl + '\');">';
imgUrl = ApiClient.getImageUrl(item.Id, {
type: "Primary",
tag: item.ImageTags.Primary,
EnableImageEnhancers: false
});
html += '<div class="spotlightContent">';
html += '<div class="spotlightPoster" style="background-image:url(\'' + imgUrl + '\');">';
html += '<div class="spotlightContentInner">';
html += '<p>' + LibraryBrowser.getMiscInfoHtml(item) + '</p>';
html += '<p>' + (item.Overview || '') + '</p>';
html += '</div>';
html += '</div>';
html += '</div>';
if (nextUp && nextUp.ImageTags && nextUp.ImageTags.Primary) {
html += '<div class="spotlightContent rightSpotlightContent">';
imgUrl = ApiClient.getImageUrl(nextUp.Id, {
type: "Primary",
tag: nextUp.ImageTags.Primary,
EnableImageEnhancers: false
});
html += '<div class="spotlightPoster" style="background-image:url(\'' + imgUrl + '\');">';
html += '<div class="spotlightContentInner">';
html += LibraryBrowser.getPosterViewDisplayName(nextUp);
html += '</div>';
html += '</div>';
html += '</div>';
}
html += '</div>';
html += '<div class="spotlightPlaceHolder"></div>';
$(elem).html(html);
}
function reloadSpotlight(page, allPromise) {
var options = {
SortBy: "Random",
SortOrder: "Descending",
Limit: 1,
Recursive: true,
IncludeItemTypes: "Series",
ImageTypes: "Backdrop,Primary",
Fields: "Overview"
};
ApiClient.getItems(Dashboard.getCurrentUserId(), options).done(function (result) {
allPromise.done(function () {
var index = 0;
$('.spotlightContainer', page).each(function () {
var elem = this;
var item = result.Items[index];
index++;
if (item && item.Type == 'Series') {
options = {
Limit: 1,
UserId: Dashboard.getCurrentUserId(),
SeriesId: item.Id
};
ApiClient.getNextUpEpisodes(options).done(function (nextUpResult) {
fillSeriesSpotlight(elem, item, nextUpResult.Items[0]);
});
} else {
$(this).hide();
}
});
});
});
}
2014-05-01 19:54:33 -07:00
$(document).on('pagebeforeshow', "#indexPage", function () {
2013-08-06 12:21:42 -07:00
2014-05-01 19:54:33 -07:00
var screenWidth = $(window).width();
2013-02-20 18:33:05 -07:00
2014-05-01 19:54:33 -07:00
var page = this;
2013-02-20 18:33:05 -07:00
2014-05-07 11:38:50 -07:00
$('.spotlightContainer', page).empty();
2014-05-01 19:54:33 -07:00
var options = {
2013-04-04 10:27:36 -07:00
2014-05-01 19:54:33 -07:00
SortBy: "DatePlayed",
SortOrder: "Descending",
MediaTypes: "Video",
Filters: "IsResumable",
2014-05-04 22:05:43 -07:00
Limit: screenWidth >= 1920 ? 5 : (screenWidth >= 1440 ? 4 : 3),
2014-05-01 19:54:33 -07:00
Recursive: true,
Fields: "PrimaryImageAspectRatio",
CollapseBoxSetItems: false,
2014-05-03 16:38:23 -07:00
ExcludeLocationTypes: "Virtual"
2014-05-01 19:54:33 -07:00
};
2014-05-07 11:38:50 -07:00
var promise1 = ApiClient.getItems(Dashboard.getCurrentUserId(), options).done(function (result) {
2014-05-01 19:54:33 -07:00
if (result.Items.length) {
$('#resumableSection', page).show();
} else {
$('#resumableSection', page).hide();
}
2013-11-20 14:08:12 -07:00
2014-05-01 19:54:33 -07:00
$('#resumableItems', page).html(LibraryBrowser.getPosterViewHtml({
items: result.Items,
preferBackdrop: true,
shape: 'backdrop',
2014-05-09 12:43:06 -07:00
overlayText: screenWidth >= 600,
2014-05-06 19:28:19 -07:00
showTitle: true,
showParentTitle: true
2013-04-04 10:27:36 -07:00
2014-05-01 19:54:33 -07:00
})).createPosterItemMenus();
2013-08-06 12:21:42 -07:00
});
2013-04-04 10:27:36 -07:00
2014-05-01 19:54:33 -07:00
options = {
SortBy: "DateCreated",
SortOrder: "Descending",
2014-05-07 11:38:50 -07:00
Limit: screenWidth >= 2400 ? 21 : (screenWidth >= 1920 ? 15 : (screenWidth >= 1440 ? 12 : (screenWidth >= 800 ? 12 : 8))),
2014-05-01 19:54:33 -07:00
Recursive: true,
Fields: "PrimaryImageAspectRatio",
Filters: "IsUnplayed,IsNotFolder",
CollapseBoxSetItems: false,
2014-05-03 16:38:23 -07:00
ExcludeLocationTypes: "Virtual,Remote"
2013-08-06 12:21:42 -07:00
};
2014-05-07 11:38:50 -07:00
var promise2 = ApiClient.getItems(Dashboard.getCurrentUserId(), options).done(function (result) {
2013-04-04 10:27:36 -07:00
2014-05-01 19:54:33 -07:00
$('#recentlyAddedItems', page).html(LibraryBrowser.getPosterViewHtml({
2014-05-03 16:38:23 -07:00
items: result.Items,
2014-05-01 19:54:33 -07:00
preferThumb: true,
shape: 'backdrop',
showTitle: true,
centerText: true
2013-04-04 10:27:36 -07:00
2014-05-01 19:54:33 -07:00
})).createPosterItemMenus();
2013-04-04 10:27:36 -07:00
});
2014-05-07 11:38:50 -07:00
//var allPromise = $.when(promise1, promise2);
//reloadSpotlight(page, allPromise);
2013-07-23 05:29:28 -07:00
});
})(jQuery, document, ApiClient);