diff --git a/dashboard-ui/scripts/librarybrowser.js b/dashboard-ui/scripts/librarybrowser.js index 60075ca7c..93796278c 100644 --- a/dashboard-ui/scripts/librarybrowser.js +++ b/dashboard-ui/scripts/librarybrowser.js @@ -70,6 +70,83 @@ return html; }, + getEpisodePosterViewHtml: function (options) { + + var items = options.items; + + var primaryImageAspectRatio = options.useAverageAspectRatio ? LibraryBrowser.getAveragePrimaryImageAspectRatio(items) : null; + + var html = ""; + + for (var i = 0, length = items.length; i < length; i++) { + var item = items[i]; + + var hasPrimaryImage = item.ImageTags && item.ImageTags.Primary; + + var href = item.url || (item.IsFolder ? (item.Id ? "itemList.html?parentId=" + item.Id : "#") : "itemdetails.html?id=" + item.Id); + + var showText = options.showTitle || !hasPrimaryImage || (item.Type !== 'Movie' && item.Type !== 'Series' && item.Type !== 'Season' && item.Type !== 'Trailer'); + + var cssClass = showText ? "posterViewItem posterViewItemWithDualText" : "posterViewItem posterViewItemWithNoText"; + + html += "
"; + + if (options.preferBackdrop && item.BackdropImageTags && item.BackdropImageTags.length) { + html += ""; + } else if (hasPrimaryImage) { + + var height = 300; + var width = primaryImageAspectRatio ? parseInt(height * primaryImageAspectRatio) : null; + + html += ""; + + } + else if (item.BackdropImageTags && item.BackdropImageTags.length) { + html += ""; + } + else { + html += ""; + } + + if (showText) { + html += "
"; + if (item.SeriesName != null) { + html += item.SeriesName; + html += "
"; + html += "
"; + } + if (item.ParentIndexNumber != null) { + html += item.ParentIndexNumber + "."; + } + if (item.IndexNumber != null) { + html += item.IndexNumber + " -"; + } + + html += " "+item.Name; + html += "
"; + } + + html += "
"; + } + + return html; + }, + getAveragePrimaryImageAspectRatio: function (items) { var values = []; diff --git a/dashboard-ui/scripts/tvrecommended.js b/dashboard-ui/scripts/tvrecommended.js index 3a02f5ee5..3341145eb 100644 --- a/dashboard-ui/scripts/tvrecommended.js +++ b/dashboard-ui/scripts/tvrecommended.js @@ -11,12 +11,12 @@ IncludeItemTypes: "Episode", Limit: 6, Recursive: true, - Fields: "PrimaryImageAspectRatio" + Fields: "PrimaryImageAspectRatio,SeriesInfo" }; ApiClient.getItems(Dashboard.getCurrentUserId(), options).done(function (result) { - $('#recentlyAddedItems', page).html(LibraryBrowser.getPosterViewHtml({ + $('#recentlyAddedItems', page).html(LibraryBrowser.getEpisodePosterViewHtml({ items: result.Items, useAverageAspectRatio: true })); @@ -32,7 +32,7 @@ Filters: "IsResumable", Limit: 6, Recursive: true, - Fields: "PrimaryImageAspectRatio" + Fields: "PrimaryImageAspectRatio,SeriesInfo" }; ApiClient.getItems(Dashboard.getCurrentUserId(), options).done(function (result) { @@ -43,7 +43,7 @@ $('#resumableSection', page).hide(); } - $('#resumableItems', page).html(LibraryBrowser.getPosterViewHtml({ + $('#resumableItems', page).html(LibraryBrowser.getEpisodePosterViewHtml({ items: result.Items, useAverageAspectRatio: true }));