2013-04-25 19:28:01 -04:00
|
|
|
|
(function ($, document) {
|
|
|
|
|
|
2015-04-13 01:12:02 -04:00
|
|
|
|
function itemsPerRow() {
|
2015-05-16 15:09:02 -04:00
|
|
|
|
|
2015-04-13 01:12:02 -04:00
|
|
|
|
var screenWidth = $(window).width();
|
|
|
|
|
|
2015-04-29 13:39:23 -04:00
|
|
|
|
return screenWidth >= 1920 ? 9 : (screenWidth >= 1200 ? 12 : (screenWidth >= 1000 ? 10 : 8));
|
2015-04-13 01:12:02 -04:00
|
|
|
|
}
|
|
|
|
|
|
2015-05-16 15:09:02 -04:00
|
|
|
|
function enableScrollX() {
|
2015-06-04 16:27:46 -04:00
|
|
|
|
return $.browser.mobile && AppInfo.enableAppLayouts;
|
2015-05-16 15:09:02 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getSquareShape() {
|
|
|
|
|
return enableScrollX() ? 'overflowSquare' : 'square';
|
|
|
|
|
}
|
|
|
|
|
|
2015-04-11 21:38:38 -04:00
|
|
|
|
function loadLatest(page, parentId) {
|
2013-04-25 19:28:01 -04:00
|
|
|
|
|
2015-06-17 11:39:46 -04:00
|
|
|
|
Dashboard.showLoadingMsg();
|
|
|
|
|
|
2014-07-05 01:21:13 -04:00
|
|
|
|
var userId = Dashboard.getCurrentUserId();
|
2014-02-17 16:35:08 -05:00
|
|
|
|
|
2013-04-25 19:28:01 -04:00
|
|
|
|
var options = {
|
|
|
|
|
IncludeItemTypes: "Audio",
|
2015-04-13 01:12:02 -04:00
|
|
|
|
Limit: itemsPerRow(),
|
2014-12-11 01:20:28 -05:00
|
|
|
|
Fields: "PrimaryImageAspectRatio,SyncInfo",
|
2014-11-30 14:01:33 -05:00
|
|
|
|
ParentId: parentId,
|
|
|
|
|
ImageTypeLimit: 1,
|
2014-12-01 07:43:34 -05:00
|
|
|
|
EnableImageTypes: "Primary,Backdrop,Banner,Thumb"
|
2013-04-25 19:28:01 -04:00
|
|
|
|
};
|
|
|
|
|
|
2014-07-05 01:21:13 -04:00
|
|
|
|
ApiClient.getJSON(ApiClient.getUrl('Users/' + userId + '/Items/Latest', options)).done(function (items) {
|
2013-04-25 19:28:01 -04:00
|
|
|
|
|
2015-06-28 11:43:49 -04:00
|
|
|
|
var elem = page.querySelector('#recentlyAddedSongs');
|
|
|
|
|
elem.innerHTML = LibraryBrowser.getPosterViewHtml({
|
2014-07-05 01:21:13 -04:00
|
|
|
|
items: items,
|
2013-12-27 16:20:27 -05:00
|
|
|
|
showUnplayedIndicator: false,
|
2015-05-11 15:59:59 -04:00
|
|
|
|
showLatestItemsPopup: false,
|
2015-05-16 15:09:02 -04:00
|
|
|
|
shape: getSquareShape(),
|
2013-04-25 20:52:55 -04:00
|
|
|
|
showTitle: true,
|
2015-07-26 17:02:23 -04:00
|
|
|
|
defaultAction: 'play',
|
2015-01-23 01:15:15 -05:00
|
|
|
|
showParentTitle: true,
|
2015-04-11 21:38:38 -04:00
|
|
|
|
lazy: true,
|
2015-07-06 03:06:09 -04:00
|
|
|
|
centerText: true,
|
2015-07-26 17:02:23 -04:00
|
|
|
|
overlayMoreButton: true
|
2015-04-11 21:38:38 -04:00
|
|
|
|
|
2015-06-28 11:43:49 -04:00
|
|
|
|
});
|
|
|
|
|
ImageLoader.lazyChildren(elem);
|
2013-04-25 20:52:55 -04:00
|
|
|
|
|
2015-06-17 11:39:46 -04:00
|
|
|
|
Dashboard.hideLoadingMsg();
|
2015-06-30 01:45:20 -04:00
|
|
|
|
|
|
|
|
|
LibraryBrowser.setLastRefreshed(page);
|
2013-04-25 20:52:55 -04:00
|
|
|
|
});
|
2015-04-11 21:38:38 -04:00
|
|
|
|
}
|
2013-04-25 20:52:55 -04:00
|
|
|
|
|
2015-04-11 21:38:38 -04:00
|
|
|
|
function loadRecentlyPlayed(page, parentId) {
|
|
|
|
|
|
|
|
|
|
var options = {
|
2013-04-25 20:52:55 -04:00
|
|
|
|
|
|
|
|
|
SortBy: "DatePlayed",
|
|
|
|
|
SortOrder: "Descending",
|
|
|
|
|
IncludeItemTypes: "Audio",
|
2015-04-13 01:12:02 -04:00
|
|
|
|
Limit: itemsPerRow(),
|
2013-04-25 20:52:55 -04:00
|
|
|
|
Recursive: true,
|
2014-12-11 01:20:28 -05:00
|
|
|
|
Fields: "PrimaryImageAspectRatio,AudioInfo,SyncInfo",
|
2014-05-01 22:54:33 -04:00
|
|
|
|
Filters: "IsPlayed",
|
2014-11-30 14:01:33 -05:00
|
|
|
|
ParentId: parentId,
|
|
|
|
|
ImageTypeLimit: 1,
|
2014-12-01 07:43:34 -05:00
|
|
|
|
EnableImageTypes: "Primary,Backdrop,Banner,Thumb"
|
2013-04-25 20:52:55 -04:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
ApiClient.getItems(Dashboard.getCurrentUserId(), options).done(function (result) {
|
|
|
|
|
|
2015-06-28 11:43:49 -04:00
|
|
|
|
var elem;
|
|
|
|
|
|
2013-04-25 20:52:55 -04:00
|
|
|
|
if (result.Items.length) {
|
2015-06-28 11:43:49 -04:00
|
|
|
|
elem = $('#recentlyPlayed', page).show()[0];
|
2013-04-25 20:52:55 -04:00
|
|
|
|
} else {
|
2015-06-28 11:43:49 -04:00
|
|
|
|
elem = $('#recentlyPlayed', page).hide()[0];
|
2013-04-25 20:52:55 -04:00
|
|
|
|
}
|
|
|
|
|
|
2015-06-28 11:43:49 -04:00
|
|
|
|
var itemsContainer = elem.querySelector('.itemsContainer');
|
|
|
|
|
itemsContainer.innerHTML = LibraryBrowser.getPosterViewHtml({
|
2013-04-25 20:52:55 -04:00
|
|
|
|
items: result.Items,
|
2013-12-27 16:20:27 -05:00
|
|
|
|
showUnplayedIndicator: false,
|
2015-05-16 15:09:02 -04:00
|
|
|
|
shape: getSquareShape(),
|
2013-04-25 20:52:55 -04:00
|
|
|
|
showTitle: true,
|
2014-09-01 16:10:54 -04:00
|
|
|
|
showParentTitle: true,
|
2015-01-23 01:15:15 -05:00
|
|
|
|
defaultAction: 'play',
|
2015-04-11 21:38:38 -04:00
|
|
|
|
lazy: true,
|
2015-07-06 03:06:09 -04:00
|
|
|
|
centerText: true,
|
|
|
|
|
overlayMoreButton: true
|
2014-09-01 16:10:54 -04:00
|
|
|
|
|
2015-06-28 11:43:49 -04:00
|
|
|
|
});
|
|
|
|
|
ImageLoader.lazyChildren(itemsContainer);
|
2013-04-25 20:52:55 -04:00
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
2015-04-11 21:38:38 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function loadFrequentlyPlayed(page, parentId) {
|
|
|
|
|
|
|
|
|
|
var options = {
|
2013-04-25 20:52:55 -04:00
|
|
|
|
|
|
|
|
|
SortBy: "PlayCount",
|
|
|
|
|
SortOrder: "Descending",
|
|
|
|
|
IncludeItemTypes: "Audio",
|
2015-04-13 01:12:02 -04:00
|
|
|
|
Limit: itemsPerRow(),
|
2013-04-25 20:52:55 -04:00
|
|
|
|
Recursive: true,
|
2014-12-11 01:20:28 -05:00
|
|
|
|
Fields: "PrimaryImageAspectRatio,AudioInfo,SyncInfo",
|
2014-05-01 22:54:33 -04:00
|
|
|
|
Filters: "IsPlayed",
|
2014-11-30 14:01:33 -05:00
|
|
|
|
ParentId: parentId,
|
|
|
|
|
ImageTypeLimit: 1,
|
2014-12-01 07:43:34 -05:00
|
|
|
|
EnableImageTypes: "Primary,Backdrop,Banner,Thumb"
|
2013-04-25 20:52:55 -04:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
ApiClient.getItems(Dashboard.getCurrentUserId(), options).done(function (result) {
|
|
|
|
|
|
2015-06-28 11:43:49 -04:00
|
|
|
|
var elem;
|
|
|
|
|
|
2013-04-25 20:52:55 -04:00
|
|
|
|
if (result.Items.length) {
|
2015-06-28 11:43:49 -04:00
|
|
|
|
elem = $('#topPlayed', page).show()[0];
|
2013-04-25 20:52:55 -04:00
|
|
|
|
} else {
|
2015-06-28 11:43:49 -04:00
|
|
|
|
elem = $('#topPlayed', page).hide()[0];
|
2013-04-25 20:52:55 -04:00
|
|
|
|
}
|
|
|
|
|
|
2015-06-28 11:43:49 -04:00
|
|
|
|
var itemsContainer = elem.querySelector('.itemsContainer');
|
|
|
|
|
itemsContainer.innerHTML = LibraryBrowser.getPosterViewHtml({
|
2013-04-25 20:52:55 -04:00
|
|
|
|
items: result.Items,
|
2013-12-27 16:20:27 -05:00
|
|
|
|
showUnplayedIndicator: false,
|
2015-05-16 15:09:02 -04:00
|
|
|
|
shape: getSquareShape(),
|
2013-04-25 20:52:55 -04:00
|
|
|
|
showTitle: true,
|
2014-09-01 16:10:54 -04:00
|
|
|
|
showParentTitle: true,
|
2015-01-23 01:15:15 -05:00
|
|
|
|
defaultAction: 'play',
|
2015-04-11 21:38:38 -04:00
|
|
|
|
lazy: true,
|
2015-07-06 03:06:09 -04:00
|
|
|
|
centerText: true,
|
|
|
|
|
overlayMoreButton: true
|
2014-09-01 16:10:54 -04:00
|
|
|
|
|
2015-06-28 11:43:49 -04:00
|
|
|
|
});
|
|
|
|
|
ImageLoader.lazyChildren(itemsContainer);
|
2013-04-25 19:28:01 -04:00
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
2015-04-11 21:38:38 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function loadPlaylists(page, parentId) {
|
|
|
|
|
|
|
|
|
|
var options = {
|
|
|
|
|
|
|
|
|
|
SortBy: "SortName",
|
|
|
|
|
SortOrder: "Ascending",
|
|
|
|
|
IncludeItemTypes: "Playlist",
|
|
|
|
|
Recursive: true,
|
2015-04-12 14:58:21 -04:00
|
|
|
|
ParentId: parentId,
|
2015-04-11 21:38:38 -04:00
|
|
|
|
Fields: "PrimaryImageAspectRatio,SortName,CumulativeRunTimeTicks,CanDelete,SyncInfo",
|
|
|
|
|
StartIndex: 0,
|
2015-04-13 01:12:02 -04:00
|
|
|
|
Limit: itemsPerRow()
|
2015-04-11 21:38:38 -04:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
ApiClient.getItems(Dashboard.getCurrentUserId(), options).done(function (result) {
|
|
|
|
|
|
|
|
|
|
var elem;
|
|
|
|
|
|
|
|
|
|
if (result.Items.length) {
|
2015-06-28 11:43:49 -04:00
|
|
|
|
elem = $('#playlists', page).show()[0];
|
2015-04-11 21:38:38 -04:00
|
|
|
|
} else {
|
2015-06-28 11:43:49 -04:00
|
|
|
|
elem = $('#playlists', page).hide()[0];
|
2015-04-11 21:38:38 -04:00
|
|
|
|
}
|
|
|
|
|
|
2015-06-28 11:43:49 -04:00
|
|
|
|
var itemsContainer = elem.querySelector('.itemsContainer');
|
|
|
|
|
itemsContainer.innerHTML = LibraryBrowser.getPosterViewHtml({
|
2015-04-11 21:38:38 -04:00
|
|
|
|
items: result.Items,
|
2015-05-16 15:09:02 -04:00
|
|
|
|
shape: getSquareShape(),
|
2015-04-11 21:38:38 -04:00
|
|
|
|
showTitle: true,
|
|
|
|
|
lazy: true,
|
2015-04-13 01:12:02 -04:00
|
|
|
|
defaultAction: 'play',
|
2015-04-11 21:38:38 -04:00
|
|
|
|
coverImage: true,
|
|
|
|
|
showItemCounts: true,
|
2015-07-06 03:06:09 -04:00
|
|
|
|
centerText: true,
|
|
|
|
|
overlayMoreButton: true
|
2015-04-11 21:38:38 -04:00
|
|
|
|
|
2015-06-28 11:43:49 -04:00
|
|
|
|
});
|
|
|
|
|
ImageLoader.lazyChildren(itemsContainer);
|
2015-04-11 21:38:38 -04:00
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-19 00:23:55 -04:00
|
|
|
|
$(document).on('pagebeforeshowready', "#musicRecommendedPage", function () {
|
2015-04-11 21:38:38 -04:00
|
|
|
|
|
|
|
|
|
var parentId = LibraryMenu.getTopParentId();
|
|
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
|
2015-06-28 10:45:21 -04:00
|
|
|
|
var containers = page.querySelectorAll('.itemsContainer');
|
2015-05-16 15:09:02 -04:00
|
|
|
|
if (enableScrollX()) {
|
2015-06-28 10:45:21 -04:00
|
|
|
|
$(containers).addClass('hiddenScrollX');
|
2015-05-16 15:09:02 -04:00
|
|
|
|
} else {
|
2015-06-28 10:45:21 -04:00
|
|
|
|
$(containers).removeClass('hiddenScrollX');
|
2015-05-16 15:09:02 -04:00
|
|
|
|
}
|
2015-06-29 22:52:23 -04:00
|
|
|
|
|
2015-06-30 01:45:20 -04:00
|
|
|
|
if (LibraryBrowser.needsRefresh(page)) {
|
2015-06-29 22:52:23 -04:00
|
|
|
|
loadLatest(page, parentId);
|
|
|
|
|
loadPlaylists(page, parentId);
|
|
|
|
|
loadRecentlyPlayed(page, parentId);
|
|
|
|
|
loadFrequentlyPlayed(page, parentId);
|
|
|
|
|
}
|
2013-04-25 19:28:01 -04:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
})(jQuery, document);
|