2016-03-18 21:26:17 -07:00
|
|
|
define(['jQuery'], function ($) {
|
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();
|
2014-07-04 22:21:13 -07:00
|
|
|
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
|
|
|
|
2014-07-04 22:21:13 -07:00
|
|
|
IncludeItemTypes: "Game",
|
2014-11-10 20:41:19 -07:00
|
|
|
Limit: 18,
|
2014-07-04 22:21:13 -07:00
|
|
|
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({
|
2014-07-04 22:21:13 -07:00
|
|
|
items: items,
|
2013-09-08 14:16:13 -07:00
|
|
|
transparent: true,
|
2014-05-29 12:34:20 -07:00
|
|
|
borderless: true,
|
2014-06-30 19:29:27 -07:00
|
|
|
shape: 'auto',
|
|
|
|
lazy: true
|
|
|
|
|
2015-12-14 08:43:03 -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,
|
2014-06-30 19:29:27 -07:00
|
|
|
shape: 'auto',
|
|
|
|
lazy: true
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
});
|
|
|
|
ImageLoader.lazyChildren(recentlyPlayedItems);
|
2013-09-08 14:16:13 -07:00
|
|
|
});
|
|
|
|
|
|
|
|
});
|
2013-04-14 20:37:07 -07:00
|
|
|
|
2016-03-18 21:26:17 -07:00
|
|
|
});
|