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

64 lines
1.7 KiB
JavaScript
Raw Normal View History

2013-04-14 20:37:07 -07:00
(function ($, document) {
2013-09-08 14:16:13 -07:00
$(document).on('pagebeforeshow', "#gamesRecommendedPage", function () {
2013-04-14 20:37:07 -07:00
2014-05-01 19:54:33 -07:00
var parentId = LibraryMenu.getTopParentId();
var userId = Dashboard.getCurrentUserId();
2014-05-01 19:54:33 -07:00
2013-09-08 14:16:13 -07:00
var page = this;
2013-04-14 20:37:07 -07:00
2013-09-08 14:16:13 -07:00
var options = {
2013-04-14 20:37:07 -07:00
IncludeItemTypes: "Game",
2014-05-21 20:35:18 -07:00
Limit: 8,
Fields: "PrimaryImageAspectRatio",
2014-05-01 19:54:33 -07:00
ParentId: parentId
2013-09-08 14:16:13 -07:00
};
2013-04-14 20:37:07 -07:00
ApiClient.getJSON(ApiClient.getUrl('Users/' + userId + '/Items/Latest', options)).done(function (items) {
2013-04-14 20:37:07 -07:00
2013-09-08 14:16:13 -07:00
$('#recentlyAddedItems', page).html(LibraryBrowser.getPosterViewHtml({
items: items,
2013-09-08 14:16:13 -07:00
transparent: true,
2014-05-29 12:34:20 -07:00
borderless: true,
shape: 'auto',
lazy: true
2014-08-01 19:34:45 -07:00
})).trigger('create').createCardMenus();
2013-04-14 20:37:07 -07:00
2013-09-08 14:16:13 -07:00
});
2013-04-14 20:37:07 -07:00
2013-09-08 14:16:13 -07:00
options = {
2013-04-14 20:37:07 -07:00
2013-09-08 14:16:13 -07:00
SortBy: "DatePlayed",
SortOrder: "Descending",
MediaTypes: "Game",
2014-05-21 20:35:18 -07:00
Limit: 8,
2013-09-08 14:16:13 -07:00
Recursive: true,
2014-04-03 15:50:04 -07:00
Filters: "IsPlayed",
2014-05-01 19:54:33 -07:00
Fields: "ItemCounts,AudioInfo,PrimaryImageAspectRatio",
ParentId: parentId
2013-09-08 14:16:13 -07:00
};
2013-04-14 20:37:07 -07:00
ApiClient.getItems(userId, options).done(function (result) {
2013-04-14 20:37:07 -07:00
2013-09-08 14:16:13 -07:00
if (result.Items.length) {
$('#recentlyPlayedSection', page).show();
} else {
$('#recentlyPlayedSection', page).hide();
}
2013-04-14 20:37:07 -07:00
2013-09-08 14:16:13 -07:00
$('#recentlyPlayedItems', page).html(LibraryBrowser.getPosterViewHtml({
items: result.Items,
transparent: true,
2014-05-29 12:34:20 -07:00
borderless: true,
shape: 'auto',
lazy: true
2014-08-01 19:34:45 -07:00
})).trigger('create').createCardMenus();
2013-09-08 14:16:13 -07:00
});
});
2013-04-14 20:37:07 -07:00
})(jQuery, document);