1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00
jellyfin-web/dashboard-ui/scripts/musicrecommended.js

95 lines
2.9 KiB
JavaScript
Raw Normal View History

2013-04-25 19:28:01 -04:00
(function ($, document) {
$(document).on('pagebeforeshow', "#musicRecommendedPage", function () {
var screenWidth = $(window).width();
var userId = Dashboard.getCurrentUserId();
2013-04-25 19:28:01 -04:00
var page = this;
2014-05-01 22:54:33 -04:00
var parentId = LibraryMenu.getTopParentId();
2013-04-25 19:28:01 -04:00
var options = {
IncludeItemTypes: "Audio",
2014-07-12 15:05:35 -04:00
Limit: screenWidth >= 1920 ? 18 : (screenWidth >= 1200 ? 10 : 12),
Fields: "PrimaryImageAspectRatio",
2014-05-01 22:54:33 -04:00
ParentId: parentId
2013-04-25 19:28:01 -04:00
};
ApiClient.getJSON(ApiClient.getUrl('Users/' + userId + '/Items/Latest', options)).done(function (items) {
2013-04-25 19:28:01 -04:00
$('#recentlyAddedSongs', page).html(LibraryBrowser.getPosterViewHtml({
items: items,
2013-12-27 16:20:27 -05:00
showUnplayedIndicator: false,
showChildCountIndicator: true,
2013-04-25 20:52:55 -04:00
shape: "square",
showTitle: true,
showParentTitle: true
})).createPosterItemMenus();
2013-04-25 20:52:55 -04:00
});
options = {
SortBy: "DatePlayed",
SortOrder: "Descending",
IncludeItemTypes: "Audio",
2014-07-12 15:05:35 -04:00
Limit: screenWidth >= 1920 ? 6 : (screenWidth >= 1200 ? 5 : 6),
2013-04-25 20:52:55 -04:00
Recursive: true,
Fields: "PrimaryImageAspectRatio,AudioInfo",
2014-05-01 22:54:33 -04:00
Filters: "IsPlayed",
ParentId: parentId
2013-04-25 20:52:55 -04: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 16:20:27 -05:00
showUnplayedIndicator: false,
2013-04-25 20:52:55 -04:00
shape: "square",
showTitle: true,
showParentTitle: true
})).createPosterItemMenus();
2013-04-25 20:52:55 -04:00
});
options = {
SortBy: "PlayCount",
SortOrder: "Descending",
IncludeItemTypes: "Audio",
2014-07-12 15:05:35 -04:00
Limit: screenWidth >= 1920 ? 12 : (screenWidth >= 1200 ? 10 : 12),
2013-04-25 20:52:55 -04:00
Recursive: true,
Fields: "PrimaryImageAspectRatio,AudioInfo",
2014-05-01 22:54:33 -04:00
Filters: "IsPlayed",
ParentId: parentId
2013-04-25 20:52:55 -04: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 16:20:27 -05:00
showUnplayedIndicator: false,
2013-04-25 20:52:55 -04:00
shape: "square",
showTitle: true,
showParentTitle: true
})).createPosterItemMenus();
2013-04-25 19:28:01 -04:00
});
});
})(jQuery, document);