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

72 lines
2.1 KiB
JavaScript
Raw Normal View History

2016-11-24 23:58:38 -07:00
define(['jQuery', 'imageLoader'], function ($, imageLoader) {
2016-10-22 22:11:46 -07:00
'use strict';
2013-04-14 20:37:07 -07:00
2015-08-31 23:22:46 -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-11-10 20:41:19 -07:00
Limit: 18,
Fields: "PrimaryImageAspectRatio",
2014-11-30 12:01:33 -07:00
ParentId: parentId,
ImageTypeLimit: 1,
2014-12-01 05:43:34 -07:00
EnableImageTypes: "Primary,Backdrop,Banner,Thumb"
2013-09-08 14:16:13 -07:00
};
2013-04-14 20:37:07 -07:00
2015-12-14 08:43:03 -07:00
ApiClient.getJSON(ApiClient.getUrl('Users/' + userId + '/Items/Latest', options)).then(function (items) {
2013-04-14 20:37:07 -07:00
2015-12-14 08:43:03 -07:00
var recentlyAddedItems = page.querySelector('#recentlyAddedItems');
recentlyAddedItems.innerHTML = 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
2015-12-14 08:43:03 -07:00
});
2016-11-24 23:58:38 -07:00
imageLoader.lazyChildren(recentlyAddedItems);
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-11-10 20:41:19 -07:00
Limit: 18,
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",
2014-11-30 12:01:33 -07:00
ParentId: parentId,
ImageTypeLimit: 1,
2014-12-01 05:43:34 -07:00
EnableImageTypes: "Primary,Backdrop,Banner,Thumb"
2013-09-08 14:16:13 -07:00
};
2013-04-14 20:37:07 -07:00
2015-12-14 08:43:03 -07:00
ApiClient.getItems(userId, options).then(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
2015-12-14 08:43:03 -07:00
var recentlyPlayedItems = page.querySelector('#recentlyPlayedItems');
recentlyPlayedItems.innerHTML = LibraryBrowser.getPosterViewHtml({
2013-09-08 14:16:13 -07:00
items: result.Items,
transparent: true,
2014-05-29 12:34:20 -07:00
borderless: true,
shape: 'auto',
lazy: true
2015-12-14 08:43:03 -07:00
});
2016-11-24 23:58:38 -07:00
imageLoader.lazyChildren(recentlyPlayedItems);
2013-09-08 14:16:13 -07:00
});
});
2013-04-14 20:37:07 -07:00
});