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

99 lines
3.0 KiB
JavaScript
Raw Normal View History

2013-04-25 16:28:01 -07:00
(function ($, document) {
$(document).on('pagebeforeshow', "#musicRecommendedPage", function () {
var screenWidth = $(window).width();
var userId = Dashboard.getCurrentUserId();
2013-04-25 16:28:01 -07:00
var page = this;
2014-05-01 19:54:33 -07:00
var parentId = LibraryMenu.getTopParentId();
2013-04-25 16:28:01 -07:00
var options = {
IncludeItemTypes: "Audio",
2014-08-11 07:15:53 -07:00
Limit: screenWidth >= 1920 ? 24 : (screenWidth >= 1600 ? 21 : (screenWidth >= 1200 ? 21 : 12)),
Fields: "PrimaryImageAspectRatio",
2014-05-01 19:54:33 -07:00
ParentId: parentId
2013-04-25 16:28:01 -07:00
};
ApiClient.getJSON(ApiClient.getUrl('Users/' + userId + '/Items/Latest', options)).done(function (items) {
2013-04-25 16:28:01 -07:00
$('#recentlyAddedSongs', page).html(LibraryBrowser.getPosterViewHtml({
items: items,
2013-12-27 14:20:27 -07:00
showUnplayedIndicator: false,
showChildCountIndicator: true,
2014-08-01 19:34:45 -07:00
shape: "homePageSquare",
2013-04-25 17:52:55 -07:00
showTitle: true,
showParentTitle: true
2014-08-01 19:34:45 -07:00
})).createCardMenus();
2013-04-25 17:52:55 -07:00
});
options = {
SortBy: "DatePlayed",
SortOrder: "Descending",
IncludeItemTypes: "Audio",
2014-08-11 07:15:53 -07:00
Limit: screenWidth >= 1920 ? 8 : (screenWidth >= 1600 ? 7 : (screenWidth >= 1200 ? 7 : 6)),
2013-04-25 17:52:55 -07:00
Recursive: true,
Fields: "PrimaryImageAspectRatio,AudioInfo",
2014-05-01 19:54:33 -07:00
Filters: "IsPlayed",
ParentId: parentId
2013-04-25 17:52:55 -07:00
};
ApiClient.getItems(Dashboard.getCurrentUserId(), options).done(function (result) {
if (result.Items.length) {
$('#recentlyPlayed', page).show();
} else {
$('#recentlyPlayed', page).hide();
}
$('#recentlyPlayedSongs', page).html(LibraryBrowser.getPosterViewHtml({
items: result.Items,
2013-12-27 14:20:27 -07:00
showUnplayedIndicator: false,
2014-08-01 19:34:45 -07:00
shape: "homePageSquare",
2013-04-25 17:52:55 -07:00
showTitle: true,
showParentTitle: true,
defaultAction: 'play'
2014-08-01 19:34:45 -07:00
})).createCardMenus();
2013-04-25 17:52:55 -07:00
});
options = {
SortBy: "PlayCount",
SortOrder: "Descending",
IncludeItemTypes: "Audio",
2014-08-11 07:15:53 -07:00
Limit: screenWidth >= 1920 ? 16 : (screenWidth >= 1600 ? 14 : (screenWidth >= 1200 ? 14 : 12)),
2013-04-25 17:52:55 -07:00
Recursive: true,
Fields: "PrimaryImageAspectRatio,AudioInfo",
2014-05-01 19:54:33 -07:00
Filters: "IsPlayed",
ParentId: parentId
2013-04-25 17:52:55 -07:00
};
ApiClient.getItems(Dashboard.getCurrentUserId(), options).done(function (result) {
if (result.Items.length) {
$('#topPlayed', page).show();
} else {
$('#topPlayed', page).hide();
}
$('#topPlayedSongs', page).html(LibraryBrowser.getPosterViewHtml({
items: result.Items,
2013-12-27 14:20:27 -07:00
showUnplayedIndicator: false,
2014-08-01 19:34:45 -07:00
shape: "homePageSquare",
2013-04-25 17:52:55 -07:00
showTitle: true,
showParentTitle: true,
defaultAction: 'play'
2014-08-01 19:34:45 -07:00
})).createCardMenus();
2013-04-25 16:28:01 -07:00
});
});
})(jQuery, document);