2013-04-01 08:59:56 -07:00
|
|
|
|
(function ($, document) {
|
|
|
|
|
|
2014-03-11 19:11:01 -07:00
|
|
|
|
function getRecommendationHtml(recommendation) {
|
2013-04-01 08:59:56 -07:00
|
|
|
|
|
2014-03-11 19:11:01 -07:00
|
|
|
|
var html = '';
|
2014-01-30 14:23:54 -07:00
|
|
|
|
|
2014-03-11 19:11:01 -07:00
|
|
|
|
var title = '';
|
2014-05-10 22:11:53 -07:00
|
|
|
|
|
2014-03-11 19:11:01 -07:00
|
|
|
|
switch (recommendation.RecommendationType) {
|
2014-05-10 22:11:53 -07:00
|
|
|
|
|
2014-03-11 19:11:01 -07:00
|
|
|
|
case 'SimilarToRecentlyPlayed':
|
2014-05-30 12:23:56 -07:00
|
|
|
|
title = Globalize.translate('RecommendationBecauseYouWatched').replace("{0}", recommendation.BaselineItemName);
|
2014-03-11 19:11:01 -07:00
|
|
|
|
break;
|
|
|
|
|
case 'SimilarToLikedItem':
|
2014-05-30 12:23:56 -07:00
|
|
|
|
title = Globalize.translate('RecommendationBecauseYouLike').replace("{0}", recommendation.BaselineItemName);
|
2014-03-11 19:11:01 -07:00
|
|
|
|
break;
|
|
|
|
|
case 'HasDirectorFromRecentlyPlayed':
|
|
|
|
|
case 'HasLikedDirector':
|
2014-05-30 12:23:56 -07:00
|
|
|
|
title = Globalize.translate('RecommendationDirectedBy').replace("{0}", recommendation.BaselineItemName);
|
2014-03-11 19:11:01 -07:00
|
|
|
|
break;
|
|
|
|
|
case 'HasActorFromRecentlyPlayed':
|
|
|
|
|
case 'HasLikedActor':
|
2014-05-30 12:23:56 -07:00
|
|
|
|
title = Globalize.translate('RecommendationStarring').replace("{0}", recommendation.BaselineItemName);
|
2014-03-11 19:11:01 -07:00
|
|
|
|
break;
|
|
|
|
|
}
|
2014-05-10 22:11:53 -07:00
|
|
|
|
|
2014-03-11 19:11:01 -07:00
|
|
|
|
html += '<h1 class="listHeader">' + title + '</h1>';
|
2013-04-01 08:59:56 -07:00
|
|
|
|
|
2014-11-18 19:45:12 -07:00
|
|
|
|
html += '<div>';
|
2014-03-11 19:11:01 -07:00
|
|
|
|
html += LibraryBrowser.getPosterViewHtml({
|
2014-07-04 22:21:13 -07:00
|
|
|
|
items: recommendation.Items,
|
2014-08-01 19:34:45 -07:00
|
|
|
|
lazy: true,
|
|
|
|
|
shape: 'homePagePortrait',
|
|
|
|
|
overlayText: true
|
2013-04-01 08:59:56 -07:00
|
|
|
|
});
|
2014-03-11 19:11:01 -07:00
|
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
|
|
return html;
|
|
|
|
|
}
|
2014-05-10 22:11:53 -07:00
|
|
|
|
|
2014-03-11 19:11:01 -07:00
|
|
|
|
$(document).on('pagebeforeshow', "#moviesRecommendedPage", function () {
|
2013-04-01 08:59:56 -07:00
|
|
|
|
|
2014-05-01 19:54:33 -07:00
|
|
|
|
var parentId = LibraryMenu.getTopParentId();
|
|
|
|
|
|
2014-03-11 19:11:01 -07:00
|
|
|
|
var screenWidth = $(window).width();
|
2013-04-01 08:59:56 -07:00
|
|
|
|
|
2014-03-11 19:11:01 -07:00
|
|
|
|
var page = this;
|
2014-05-10 22:11:53 -07:00
|
|
|
|
|
2014-03-11 19:11:01 -07:00
|
|
|
|
var options = {
|
2013-04-01 08:59:56 -07:00
|
|
|
|
|
|
|
|
|
SortBy: "DatePlayed",
|
|
|
|
|
SortOrder: "Descending",
|
|
|
|
|
IncludeItemTypes: "Movie",
|
|
|
|
|
Filters: "IsResumable",
|
2014-08-11 07:15:53 -07:00
|
|
|
|
Limit: screenWidth >= 1920 ? 10 : (screenWidth >= 1600 ? 8 : (screenWidth >= 1200 ? 6 : 3)),
|
2013-04-01 08:59:56 -07:00
|
|
|
|
Recursive: true,
|
2014-04-26 20:42:05 -07:00
|
|
|
|
Fields: "PrimaryImageAspectRatio",
|
2014-05-01 19:54:33 -07:00
|
|
|
|
CollapseBoxSetItems: false,
|
|
|
|
|
ParentId: parentId
|
2013-04-01 08:59:56 -07:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
ApiClient.getItems(Dashboard.getCurrentUserId(), options).done(function (result) {
|
|
|
|
|
|
|
|
|
|
if (result.Items.length) {
|
|
|
|
|
$('#resumableSection', page).show();
|
|
|
|
|
} else {
|
|
|
|
|
$('#resumableSection', page).hide();
|
|
|
|
|
}
|
2014-05-10 22:11:53 -07:00
|
|
|
|
|
2013-04-01 22:14:37 -07:00
|
|
|
|
$('#resumableItems', page).html(LibraryBrowser.getPosterViewHtml({
|
2013-04-01 08:59:56 -07:00
|
|
|
|
items: result.Items,
|
2013-12-22 10:16:24 -07:00
|
|
|
|
preferBackdrop: true,
|
2014-08-01 19:34:45 -07:00
|
|
|
|
shape: 'homePageBackdrop',
|
|
|
|
|
overlayText: true,
|
2014-07-04 22:21:13 -07:00
|
|
|
|
showTitle: true,
|
|
|
|
|
lazy: true
|
2014-05-10 22:11:53 -07:00
|
|
|
|
|
2014-08-01 19:34:45 -07:00
|
|
|
|
})).trigger('create').createCardMenus();
|
2013-04-01 08:59:56 -07:00
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
2014-03-11 19:11:01 -07:00
|
|
|
|
var url = ApiClient.getUrl("Movies/Recommendations", {
|
2014-05-10 22:11:53 -07:00
|
|
|
|
|
2014-03-11 19:11:01 -07:00
|
|
|
|
userId: Dashboard.getCurrentUserId(),
|
2014-07-04 22:21:13 -07:00
|
|
|
|
categoryLimit: screenWidth >= 1200 ? 4 : 3,
|
2014-10-20 13:23:40 -07:00
|
|
|
|
ItemLimit: screenWidth >= 1920 ? 10 : (screenWidth >= 1600 ? 7 : (screenWidth >= 1200 ? 7 : 7)),
|
2014-06-04 19:32:40 -07:00
|
|
|
|
Fields: "PrimaryImageAspectRatio"
|
2014-03-11 19:11:01 -07:00
|
|
|
|
});
|
2013-04-04 21:15:00 -07:00
|
|
|
|
|
2014-07-01 22:16:59 -07:00
|
|
|
|
ApiClient.getJSON(url).done(function (recommendations) {
|
2013-04-04 21:15:00 -07:00
|
|
|
|
|
2014-03-11 19:11:01 -07:00
|
|
|
|
if (!recommendations.length) {
|
2013-04-04 21:15:00 -07:00
|
|
|
|
|
2014-05-30 12:23:56 -07:00
|
|
|
|
$('.noItemsMessage', page).show();
|
|
|
|
|
$('.recommendations', page).html('');
|
2014-03-11 19:11:01 -07:00
|
|
|
|
return;
|
2013-04-04 21:15:00 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-03-11 19:11:01 -07:00
|
|
|
|
var html = recommendations.map(getRecommendationHtml).join('');
|
2013-04-04 21:15:00 -07:00
|
|
|
|
|
2014-05-30 12:23:56 -07:00
|
|
|
|
$('.noItemsMessage', page).hide();
|
2014-08-01 19:34:45 -07:00
|
|
|
|
$('.recommendations', page).html(html).trigger('create').createCardMenus();
|
2013-04-04 21:15:00 -07:00
|
|
|
|
});
|
2014-05-10 22:11:53 -07:00
|
|
|
|
|
2013-04-01 08:59:56 -07:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
})(jQuery, document);
|