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

911 lines
27 KiB
JavaScript
Raw Normal View History

2013-04-10 14:14:25 -07:00
(function ($, document, LibraryBrowser, window) {
2013-02-20 18:33:05 -07:00
2013-04-10 14:14:25 -07:00
var currentItem;
2013-02-20 18:33:05 -07:00
2013-04-10 14:14:25 -07:00
function reload(page) {
2013-03-06 16:28:43 -07:00
2013-02-20 18:33:05 -07:00
var id = getParameterByName('id');
Dashboard.showLoadingMsg();
2013-04-10 14:14:25 -07:00
ApiClient.getItem(Dashboard.getCurrentUserId(), id).done(function (item) {
2013-02-20 18:33:05 -07:00
2013-04-10 14:14:25 -07:00
currentItem = item;
2013-02-20 18:33:05 -07:00
2013-04-22 07:44:11 -07:00
renderHeader(page, item);
2013-04-10 14:14:25 -07:00
$('#itemImage', page).html(LibraryBrowser.getDetailImageHtml(item));
2013-05-04 21:49:49 -07:00
LibraryBrowser.renderName(item, $('.itemName', page));
LibraryBrowser.renderParentName(item, $('.parentName', page));
2013-04-10 14:14:25 -07:00
2013-04-23 07:46:27 -07:00
var context = getContext(item);
setInitialCollapsibleState(page, item, context);
renderDetails(page, item, context);
LibraryBrowser.renderDetailPageBackdrop(page, item);
2013-02-20 18:33:05 -07:00
2013-04-10 14:14:25 -07:00
if (MediaPlayer.canPlay(item)) {
$('#playButtonContainer', page).show();
2013-04-10 14:14:25 -07:00
} else {
$('#playButtonContainer', page).hide();
2013-04-10 14:14:25 -07:00
}
2013-04-17 18:32:38 -07:00
2013-05-04 21:49:49 -07:00
Dashboard.getCurrentUser().done(function (user) {
if (user.Configuration.IsAdministrator) {
$('#editButtonContainer', page).show();
} else {
$('#editButtonContainer', page).hide();
}
});
2013-04-30 20:28:26 -07:00
$(".autoNumeric").autoNumeric('init');
2013-05-10 05:18:07 -07:00
if (ApiClient.isWebSocketOpen()) {
2013-05-21 20:59:55 -07:00
ApiClient.sendWebSocketMessage("Context", [item.Type, item.Id, item.Name, context].join('|'));
2013-05-10 05:18:07 -07:00
}
2013-04-10 14:14:25 -07:00
Dashboard.hideLoadingMsg();
});
}
2013-04-24 13:28:42 -07:00
2013-04-23 07:46:27 -07:00
function getContext(item) {
// should return either movies, tv, music or games
2013-04-24 13:28:42 -07:00
2013-04-23 07:46:27 -07:00
if (item.Type == "Episode" || item.Type == "Series" || item.Type == "Season") {
return "tv";
}
if (item.Type == "Movie" || item.Type == "Trailer" || item.Type == "BoxSet") {
return "movies";
}
if (item.Type == "Audio" || item.Type == "MusicAlbum" || item.Type == "MusicArtist" || item.Type == "Artist" || item.Type == "MusicVideo") {
2013-04-23 07:46:27 -07:00
return "music";
}
if (item.MediaType == "Game") {
return "games";
}
return "";
}
2013-04-22 07:44:11 -07:00
function renderHeader(page, item) {
2013-04-28 11:47:19 -07:00
$('.itemTabs', page).hide();
2013-04-22 08:10:54 -07:00
if (item.Type == "MusicAlbum") {
$('#albumTabs', page).show();
}
if (item.Type == "MusicVideo") {
$('#musicVideoTabs', page).show();
}
2013-04-22 07:44:11 -07:00
if (item.Type == "Audio") {
$('#songTabs', page).show();
}
if (item.Type == "Movie") {
$('#movieTabs', page).show();
}
2013-04-24 13:28:42 -07:00
if (item.MediaType == "Game") {
$('#gameTabs', page).show();
2013-04-28 11:47:19 -07:00
}
if (item.Type == "GamePlatform") {
$('#gameSystemTabs', page).show();
2013-04-24 13:28:42 -07:00
}
2013-04-22 07:44:11 -07:00
if (item.Type == "BoxSet") {
$('#boxsetTabs', page).show();
}
2013-04-28 11:47:19 -07:00
2013-04-22 07:44:11 -07:00
if (item.Type == "Trailer") {
$('#trailerTabs', page).show();
}
2013-04-28 11:47:19 -07:00
2013-04-22 07:44:11 -07:00
if (item.Type == "Episode" || item.Type == "Season" || item.Type == "Series") {
$('#tvShowsTabs', page).show();
}
}
2013-04-23 07:46:27 -07:00
function setInitialCollapsibleState(page, item, context) {
2013-04-14 08:14:10 -07:00
if (item.ChildCount) {
2013-05-18 15:48:19 -07:00
$('#childrenCollapsible', page).removeClass('hide');
2013-04-22 07:44:11 -07:00
renderChildren(page, item);
2013-04-22 20:56:11 -07:00
}
else {
2013-05-18 15:48:19 -07:00
$('#childrenCollapsible', page).addClass('hide');
2013-04-22 07:44:11 -07:00
}
2013-05-15 20:39:15 -07:00
if (item.MediaStreams && item.MediaStreams.length) {
2013-04-22 07:44:11 -07:00
renderMediaInfo(page, item);
2013-03-26 16:57:18 -07:00
}
if (!item.Chapters || !item.Chapters.length) {
2013-03-26 14:32:01 -07:00
$('#scenesCollapsible', page).hide();
} else {
2013-03-26 15:53:06 -07:00
$('#scenesCollapsible', page).show();
2013-05-11 23:05:51 -07:00
renderScenes(page, item, 6);
}
if (!item.LocalTrailerCount || item.LocalTrailerCount == 0) {
2013-05-18 15:48:19 -07:00
$('#trailersCollapsible', page).addClass('hide');
2013-03-26 14:32:01 -07:00
} else {
2013-05-18 15:48:19 -07:00
$('#trailersCollapsible', page).removeClass('hide');
2013-04-22 07:44:11 -07:00
renderTrailers(page, item);
}
if (!item.SpecialFeatureCount || item.SpecialFeatureCount == 0) {
2013-05-18 15:48:19 -07:00
$('#specialsCollapsible', page).addClass('hide');
2013-03-26 14:32:01 -07:00
} else {
2013-05-18 15:48:19 -07:00
$('#specialsCollapsible', page).removeClass('hide');
2013-05-11 23:05:51 -07:00
renderSpecials(page, item, 6);
}
2013-03-26 22:20:46 -07:00
if (!item.People || !item.People.length) {
$('#castCollapsible', page).hide();
} else {
$('#castCollapsible', page).show();
2013-05-11 23:05:51 -07:00
renderCast(page, item, context, 10);
2013-03-26 22:20:46 -07:00
}
2013-04-24 09:03:10 -07:00
$('#themeSongsCollapsible', page).hide();
$('#themeVideosCollapsible', page).hide();
2013-04-24 09:03:10 -07:00
renderThemeSongs(page, item);
renderThemeVideos(page, item);
2013-05-11 23:05:51 -07:00
renderCriticReviews(page, item, 1);
2013-04-10 14:14:25 -07:00
}
2013-04-23 07:46:27 -07:00
function renderDetails(page, item, context) {
2013-02-20 18:33:05 -07:00
renderSimilarItems(page, item);
renderSiblingLinks(page, item);
2013-02-20 18:33:05 -07:00
if (item.Taglines && item.Taglines.length) {
$('#itemTagline', page).html(item.Taglines[0]).show();
} else {
$('#itemTagline', page).hide();
}
LibraryBrowser.renderOverview($('.itemOverview', page), item);
2013-02-20 18:33:05 -07:00
2013-05-05 21:50:40 -07:00
if (item.CommunityRating || item.CriticRating) {
$('.itemCommunityRating', page).html(LibraryBrowser.getRatingHtml(item)).show();
2013-02-20 18:33:05 -07:00
} else {
$('.itemCommunityRating', page).hide();
2013-02-20 18:33:05 -07:00
}
if (item.Type != "Episode" && item.Type != "Movie") {
2013-05-04 12:53:13 -07:00
var premiereDateElem = $('#itemPremiereDate', page).show();
LibraryBrowser.renderPremiereDate(premiereDateElem, item);
} else {
$('#itemPremiereDate', page).hide();
}
2013-04-12 08:25:00 -07:00
LibraryBrowser.renderBudget($('#itemBudget', page), item);
2013-04-18 07:05:38 -07:00
LibraryBrowser.renderRevenue($('#itemRevenue', page), item);
2013-04-12 08:25:00 -07:00
$('.itemMiscInfo', page).html(LibraryBrowser.getMiscInfoHtml(item));
2013-02-20 18:33:05 -07:00
LibraryBrowser.renderGenres($('.itemGenres', page), item, context);
LibraryBrowser.renderStudios($('.itemStudios', page), item, context);
2013-04-10 14:14:25 -07:00
renderUserDataIcons(page, item);
LibraryBrowser.renderLinks($('.itemExternalLinks', page), item);
$('.criticRatingScore', page).html((item.CriticRating || '0') + '%');
2013-05-06 20:00:24 -07:00
2013-05-05 21:50:40 -07:00
if (item.CriticRatingSummary) {
$('#criticRatingSummary', page).show();
$('.criticRatingSummaryText', page).html(item.CriticRatingSummary);
2013-05-05 21:50:40 -07:00
} else {
$('#criticRatingSummary', page).hide();
}
2013-05-06 20:00:24 -07:00
renderTags(page, item);
2013-05-14 22:04:12 -07:00
renderSeriesAirTime(page, item, context);
2013-05-16 20:24:41 -07:00
if (item.Players) {
$('#players', page).show().html(item.Players + ' Player');
} else {
$('#players', page).hide();
}
if (item.Type == "Audio" && item.Artists && item.Artists.length) {
$('#artist', page).show().html('Artist:&nbsp;&nbsp;<a class="textlink" href="itembynamedetails.html?context=music&artist=' + ApiClient.encodeName(item.Artists[0]) + '">' + item.Artists[0] + '</a>').trigger('create');
} else {
$('#artist', page).hide();
}
2013-05-28 13:01:33 -07:00
var detailsSection = $('#detailsSection', page);
var elem = $('.detailSectionContent', detailsSection)[0];
var text = elem.textContent || elem.innerText;
if (!text.trim()) {
detailsSection.addClass('hide');
} else {
detailsSection.removeClass('hide');
}
if (item.Path) {
$('.itemPath', page).show().html('Path:&nbsp;&nbsp;' + '<span style="font-size:13px;">' + item.Path + '</span>');
} else {
$('.itemPath', page).hide();
}
2013-05-15 06:57:13 -07:00
}
2013-05-15 15:55:24 -07:00
function renderSiblingLinks(page, item) {
$('.lnkSibling', page).addClass('hide');
if ((item.Type != "Episode" && item.Type != "Season" && item.Type != "Audio") || item.IndexNumber == null) {
return;
}
var friendly = item.Type == "Audio" ? "song" : item.Type.toLowerCase();
ApiClient.getItems(Dashboard.getCurrentUserId(), {
AdjacentTo: item.Id,
ParentId: item.ParentId
}).done(function (result) {
for (var i = 0, length = result.Items.length; i < length; i++) {
var curr = result.Items[i];
if (curr.IndexNumber == null) {
continue;
}
if (curr.IndexNumber < item.IndexNumber) {
$('.lnkPreviousItem', page).removeClass('hide').attr('href', 'itemdetails.html?id=' + curr.Id).html('← Previous ' + friendly);
}
else if (curr.IndexNumber > item.IndexNumber) {
$('.lnkNextItem', page).removeClass('hide').attr('href', 'itemdetails.html?id=' + curr.Id).html('Next ' + friendly + ' →');
}
}
});
}
function renderSimilarItems(page, item) {
2013-05-15 15:55:24 -07:00
var promise;
2013-05-15 15:55:24 -07:00
var options = {
userId: Dashboard.getCurrentUserId(),
2013-06-03 19:02:49 -07:00
limit: item.Type == "MusicAlbum" ? 6 : 8,
fields: "PrimaryImageAspectRatio,DateCreated,UserData"
};
2013-05-28 13:01:33 -07:00
if (item.Type == "Movie") {
promise = ApiClient.getSimilarMovies(item.Id, options);
}
else if (item.Type == "Trailer") {
promise = ApiClient.getSimilarTrailers(item.Id, options);
}
else if (item.Type == "MusicAlbum") {
promise = ApiClient.getSimilarAlbums(item.Id, options);
}
else if (item.Type == "Series") {
promise = ApiClient.getSimilarShows(item.Id, options);
}
else if (item.MediaType == "Game") {
promise = ApiClient.getSimilarGames(item.Id, options);
} else {
2013-05-15 15:55:24 -07:00
$('#similarCollapsible', page).hide();
return;
}
promise.done(function (result) {
2013-05-15 15:55:24 -07:00
if (!result.Items.length) {
$('#similarCollapsible', page).hide();
return;
}
var elem = $('#similarCollapsible', page).show();
$('.detailSectionHeader', elem).html('If you like ' + item.Name + ', check these out...');
var html = LibraryBrowser.getPosterViewHtml({
items: result.Items,
2013-05-16 13:46:18 -07:00
useAverageAspectRatio: item.MediaType != "Game",
2013-05-15 15:55:24 -07:00
showNewIndicator: true,
shape: item.Type == "MusicAlbum" ? "square" : "portrait"
});
$('#similarContent', page).html(html);
});
}
2013-05-15 06:57:13 -07:00
function renderSeriesAirTime(page, item, context) {
2013-05-15 15:55:24 -07:00
2013-05-15 06:57:13 -07:00
if (item.Type != "Series") {
$('#seriesAirTime', page).hide();
return;
}
var html = item.Status == 'Ended' ? 'Aired' : 'Airs';
2013-05-15 15:55:24 -07:00
if (item.AirDays && item.AirDays.length) {
html += item.AirDays.length == 7 ? 'daily' : ' ' + item.AirDays.map(function (a) {
2013-05-15 06:57:13 -07:00
return a + "s";
}).join(',');
}
2013-05-15 15:55:24 -07:00
2013-05-15 06:57:13 -07:00
if (item.Studios.length) {
html += ' on <a class="textlink" href="itembynamedetails.html?context=' + context + '&studio=' + ApiClient.encodeName(item.Studios[0].Name) + '">' + item.Studios[0].Name + '</a>';
}
if (item.AirTime) {
html += ' at ' + item.AirTime;
}
$('#seriesAirTime', page).show().html(html).trigger('create');
2013-05-06 20:00:24 -07:00
}
function renderTags(page, item) {
if (item.Tags && item.Tags.length) {
var html = '';
for (var i = 0, length = item.Tags.length; i < length; i++) {
html += '<div class="itemTag">' + item.Tags[i] + '</div>';
}
$('.itemTags', page).show().html(html);
2013-05-06 20:00:24 -07:00
} else {
$('.itemTags', page).hide();
2013-05-06 20:00:24 -07:00
}
2013-04-10 14:14:25 -07:00
}
2013-04-22 07:44:11 -07:00
function renderChildren(page, item) {
2013-05-15 06:57:13 -07:00
var sortBy = item.Type == "Boxset" ? "ProductionYear,SortName" : "SortName";
2013-05-15 15:55:24 -07:00
2013-04-22 07:44:11 -07:00
ApiClient.getItems(Dashboard.getCurrentUserId(), {
ParentId: getParameterByName('id'),
2013-05-15 06:57:13 -07:00
SortBy: sortBy,
2013-04-25 20:31:10 -07:00
Fields: "PrimaryImageAspectRatio,ItemCounts,DisplayMediaType,DateCreated,UserData,AudioInfo"
2013-04-22 07:44:11 -07:00
}).done(function (result) {
2013-04-22 13:06:43 -07:00
if (item.Type == "MusicAlbum") {
2013-04-22 07:44:11 -07:00
$('#childrenContent', page).html(LibraryBrowser.getSongTableHtml(result.Items, { showArtist: true })).trigger('create');
2013-04-22 13:06:43 -07:00
} else {
2013-04-28 11:47:19 -07:00
2013-05-04 11:21:29 -07:00
var shape = "smallPoster";
2013-05-04 11:21:29 -07:00
if (item.Type == "Season") {
shape = "smallBackdrop";
}
2013-04-28 11:47:19 -07:00
2013-04-22 13:06:43 -07:00
var html = LibraryBrowser.getPosterDetailViewHtml({
items: result.Items,
2013-04-28 11:47:19 -07:00
useAverageAspectRatio: true,
shape: shape
2013-04-22 13:06:43 -07:00
});
$('#childrenContent', page).html(html);
}
2013-04-22 07:44:11 -07:00
});
if (item.Type == "Season") {
$('#childrenTitle', page).html('Episodes (' + item.ChildCount + ')');
}
else if (item.Type == "Series") {
$('#childrenTitle', page).html('Seasons (' + item.ChildCount + ')');
}
else if (item.Type == "BoxSet") {
$('#childrenTitle', page).html('Movies (' + item.ChildCount + ')');
}
2013-04-22 08:10:54 -07:00
else if (item.Type == "MusicAlbum") {
2013-04-22 13:06:43 -07:00
$('#childrenTitle', page).html('Tracks (' + item.ChildCount + ')');
2013-04-22 08:10:54 -07:00
}
2013-04-28 11:47:19 -07:00
else if (item.Type == "GamePlatform") {
$('#childrenTitle', page).html('Games (' + item.ChildCount + ')');
}
2013-04-22 07:44:11 -07:00
else {
$('#childrenTitle', page).html('Items (' + item.ChildCount + ')');
}
}
2013-04-10 14:14:25 -07:00
function renderUserDataIcons(page, item) {
$('.userDataIcons', page).html(LibraryBrowser.getUserDataIconsHtml(item));
2013-04-10 14:14:25 -07:00
}
2013-04-24 13:28:42 -07:00
2013-05-11 23:05:51 -07:00
function renderCriticReviews(page, item, limit) {
if (item.Type != "Movie" && item.Type != "Trailer" && item.Type != "MusicVideo") {
$('#criticReviewsCollapsible', page).hide();
return;
}
2013-05-11 23:05:51 -07:00
var options = {};
if (limit) {
options.limit = limit;
}
ApiClient.getCriticReviews(item.Id, options).done(function (result) {
if (result.TotalRecordCount || item.CriticRatingSummary) {
2013-05-11 23:05:51 -07:00
$('#criticReviewsCollapsible', page).show();
renderCriticReviewsContent(page, result, limit);
} else {
$('#criticReviewsCollapsible', page).hide();
}
});
}
function renderCriticReviewsContent(page, result, limit) {
var html = '';
var reviews = result.ItemReviews;
for (var i = 0, length = reviews.length; i < length; i++) {
var review = reviews[i];
html += '<div class="criticReview">';
html += '<div class="reviewScore">';
if (review.Score != null) {
html += review.Score;
}
else if (review.Likes != null) {
if (review.Likes) {
html += '<img src="css/images/fresh.png" />';
} else {
html += '<img src="css/images/rotten.png" />';
}
}
2013-05-11 23:05:51 -07:00
html += '</div>';
html += '<div class="reviewCaption">' + review.Caption + '</div>';
var vals = [];
if (review.ReviewerName) {
vals.push(review.ReviewerName);
}
if (review.Publisher) {
vals.push(review.Publisher);
}
html += '<div class="reviewerName">' + vals.join(', ') + '.';
if (review.Date) {
try {
var date = parseISO8601Date(review.Date, true).toLocaleDateString();
html += '<span class="reviewDate">' + date + '</span>';
}
catch (error) {
}
}
html += '</div>';
if (review.Url) {
html += '<div class="reviewLink"><a class="textlink" href="' + review.Url + '" target="_blank">Full review</a></div>';
}
html += '</div>';
}
if (limit && result.TotalRecordCount > limit) {
html += '<p style="margin: .5em 0 0;padding-left: .5em;"><button class="moreCriticReviews" data-inline="true" data-mini="true">More ...</button></p>';
}
$('#criticReviewsContent', page).html(html).trigger('create');
}
function renderThemeSongs(page, item) {
2013-04-24 13:28:42 -07:00
ApiClient.getThemeSongs(Dashboard.getCurrentUserId(), item.Id).done(function (result) {
if (result.Items.length) {
2013-04-24 13:28:42 -07:00
$('#themeSongsCollapsible', page).show();
$('#themeSongsContent', page).html(LibraryBrowser.getSongTableHtml(result.Items, { showArtist: true, showAlbum: true })).trigger('create');
} else {
$('#themeSongsCollapsible', page).hide();
}
});
2013-04-24 09:03:10 -07:00
}
2013-02-20 18:33:05 -07:00
function renderThemeVideos(page, item) {
2013-04-28 10:21:56 -07:00
ApiClient.getThemeVideos(Dashboard.getCurrentUserId(), item.Id).done(function (result) {
if (result.Items.length) {
2013-04-28 10:21:56 -07:00
$('#themeVideosCollapsible', page).show();
$('#themeVideosContent', page).html(getVideosHtml(result.Items)).trigger('create');
} else {
$('#themeVideosCollapsible', page).hide();
}
});
2013-04-28 10:21:56 -07:00
}
2013-05-11 23:05:51 -07:00
function renderScenes(page, item, limit) {
2013-02-20 18:33:05 -07:00
var html = '';
2013-04-10 14:14:25 -07:00
2013-05-11 23:05:51 -07:00
var chapters = item.Chapters || [];
2013-02-20 18:33:05 -07:00
for (var i = 0, length = chapters.length; i < length; i++) {
2013-05-11 23:05:51 -07:00
if (limit && i >= limit) {
break;
}
var chapter = chapters[i];
2013-04-10 10:11:23 -07:00
var chapterName = chapter.Name || "Chapter " + i;
2013-05-03 13:50:13 -07:00
html += '<a class="posterItem smallBackdropPosterItem" href="#play-Chapter-' + i + '" onclick="ItemDetailPage.play(' + chapter.StartPositionTicks + ');">';
var imgUrl;
if (chapter.ImageTag) {
2013-05-03 13:50:13 -07:00
imgUrl = ApiClient.getImageUrl(item.Id, {
2013-04-22 07:44:11 -07:00
width: 400,
tag: chapter.ImageTag,
type: "Chapter",
index: i
});
} else {
2013-05-03 13:50:13 -07:00
imgUrl = "css/images/items/list/chapter.png";
}
2013-02-20 18:33:05 -07:00
2013-05-03 13:50:13 -07:00
html += '<div class="posterItemImage" style="background-image:url(\'' + imgUrl + '\');"></div>';
html += '<div class="posterItemText">' + chapterName + '</div>';
html += '<div class="posterItemText">';
2013-02-20 18:33:05 -07:00
2013-03-26 15:53:06 -07:00
html += ticks_to_human(chapter.StartPositionTicks);
html += '</div>';
html += '</a>';
2013-02-20 18:33:05 -07:00
}
2013-05-11 23:05:51 -07:00
if (limit && chapters.length > limit) {
html += '<p style="margin: .5em 0 0;padding-left: .5em;"><button class="moreScenes" data-inline="true" data-mini="true">More ...</button></p>';
}
$('#scenesContent', page).html(html).trigger('create');
2013-04-10 14:14:25 -07:00
}
2013-03-06 16:28:43 -07:00
2013-04-10 14:14:25 -07:00
function renderMediaInfo(page, item) {
2013-03-26 14:32:01 -07:00
2013-03-26 16:57:18 -07:00
var html = '';
for (var i = 0, length = item.MediaStreams.length; i < length; i++) {
var stream = item.MediaStreams[i];
2013-04-09 11:01:39 -07:00
if (stream.Type == "Data") {
continue;
}
2013-04-09 11:38:58 -07:00
var type;
if (item.MediaType == "Audio" && stream.Type == "Video") {
type = "Embedded Image";
} else {
type = stream.Type;
}
2013-04-09 11:38:58 -07:00
html += '<div class="mediaInfoStream">';
2013-03-26 16:57:18 -07:00
2013-05-15 20:39:15 -07:00
html += '<span class="mediaInfoStreamType">' + type + ':</span>';
2013-04-09 19:28:24 -07:00
2013-05-15 20:39:15 -07:00
var attributes = [];
2013-04-09 19:28:24 -07:00
2013-04-09 11:38:58 -07:00
if (stream.Codec) {
2013-05-15 20:39:15 -07:00
attributes.push('<span class="mediaInfoAttribute">' + stream.Codec + '</span>');
2013-04-09 11:38:58 -07:00
}
if (stream.Profile) {
2013-05-15 20:39:15 -07:00
attributes.push('<span class="mediaInfoAttribute">' + stream.Profile + '</span>');
2013-04-09 11:38:58 -07:00
}
if (stream.Level) {
2013-05-15 20:39:15 -07:00
attributes.push('<span class="mediaInfoAttribute">Level ' + stream.Level + '</span>');
2013-04-09 11:38:58 -07:00
}
if (stream.Language) {
2013-05-15 20:39:15 -07:00
attributes.push('<span class="mediaInfoAttribute">' + stream.Language + '</span>');
2013-04-09 11:38:58 -07:00
}
2013-05-15 20:39:15 -07:00
2013-04-09 11:38:58 -07:00
if (stream.Width) {
2013-05-15 20:39:15 -07:00
attributes.push('<span class="mediaInfoAttribute">' + stream.Width + '</span>');
2013-04-09 11:38:58 -07:00
}
2013-05-15 20:39:15 -07:00
2013-04-09 11:38:58 -07:00
if (stream.Height) {
2013-05-15 20:39:15 -07:00
attributes.push('<span class="mediaInfoAttribute">' + stream.Height + '</span>');
2013-04-09 11:38:58 -07:00
}
2013-05-15 20:39:15 -07:00
2013-04-09 11:38:58 -07:00
if (stream.AspectRatio) {
2013-05-15 20:39:15 -07:00
attributes.push('<span class="mediaInfoAttribute">' + stream.AspectRatio + '</span>');
2013-04-09 11:38:58 -07:00
}
2013-05-15 20:39:15 -07:00
2013-04-18 09:12:07 -07:00
if (stream.BitRate) {
2013-05-15 20:39:15 -07:00
attributes.push('<span class="mediaInfoAttribute">' + (parseInt(stream.BitRate / 1000)) + ' kbps</span>');
}
2013-05-15 20:39:15 -07:00
if (stream.Channels) {
2013-05-15 20:39:15 -07:00
attributes.push('<span class="mediaInfoAttribute">' + stream.Channels + ' ch</span>');
2013-03-26 16:57:18 -07:00
}
2013-05-15 20:39:15 -07:00
2013-04-09 12:38:19 -07:00
if (stream.SampleRate) {
2013-05-15 20:39:15 -07:00
attributes.push('<span class="mediaInfoAttribute">' + stream.SampleRate + ' khz</span>');
2013-04-09 12:38:19 -07:00
}
2013-04-09 11:38:58 -07:00
var framerate = stream.AverageFrameRate || stream.RealFrameRate;
2013-04-09 19:28:24 -07:00
2013-04-09 11:38:58 -07:00
if (framerate) {
2013-05-15 20:39:15 -07:00
attributes.push('<span class="mediaInfoAttribute">' + framerate + '</span>');
2013-04-09 11:38:58 -07:00
}
2013-04-09 19:28:24 -07:00
2013-04-09 12:38:19 -07:00
if (stream.PixelFormat) {
2013-05-15 20:39:15 -07:00
attributes.push('<span class="mediaInfoAttribute">' + stream.PixelFormat + '</span>');
2013-04-09 12:38:19 -07:00
}
2013-05-15 20:39:15 -07:00
if (stream.IsDefault) {
attributes.push('<span class="mediaInfoAttribute">Default</span>');
2013-04-09 11:38:58 -07:00
}
2013-05-15 20:39:15 -07:00
if (stream.IsForced) {
attributes.push('<span class="mediaInfoAttribute">Forced</span>');
}
if (stream.IsExternal) {
attributes.push('<span class="mediaInfoAttribute">External</span>');
2013-03-26 16:57:18 -07:00
}
2013-05-15 20:39:15 -07:00
html += attributes.join('&nbsp;&#149;&nbsp;');
2013-04-09 11:38:58 -07:00
html += '</div>';
2013-02-20 18:33:05 -07:00
}
2013-03-26 16:57:18 -07:00
$('#mediaInfoContent', page).html(html).trigger('create');
2013-04-10 14:14:25 -07:00
}
2013-05-11 23:05:51 -07:00
function getVideosHtml(items, limit, moreButtonClass) {
2013-04-28 10:21:56 -07:00
var html = '';
2013-04-28 10:21:56 -07:00
for (var i = 0, length = items.length; i < length; i++) {
2013-05-11 23:05:51 -07:00
if (limit && i >= limit) {
break;
}
2013-04-28 10:21:56 -07:00
var item = items[i];
2013-05-11 23:05:51 -07:00
var cssClass = "posterItem smallBackdropPosterItem";
html += '<a class="' + cssClass + '" href="#" onclick="MediaPlayer.playById(\'' + item.Id + '\');">';
2013-04-28 10:21:56 -07:00
var imageTags = item.ImageTags || {};
2013-04-28 10:39:16 -07:00
var imgUrl;
2013-04-28 10:21:56 -07:00
if (imageTags.Primary) {
2013-03-29 07:12:14 -07:00
2013-04-28 10:39:16 -07:00
imgUrl = ApiClient.getImageUrl(item.Id, {
2013-04-28 10:21:56 -07:00
maxwidth: 500,
tag: imageTags.Primary,
type: "primary"
});
2013-04-28 10:21:56 -07:00
} else {
2013-04-28 10:39:16 -07:00
imgUrl = "css/images/items/detail/video.png";
2013-04-28 10:21:56 -07:00
}
2013-04-28 10:39:16 -07:00
html += '<div class="posterItemImage" style="background-image:url(\'' + imgUrl + '\');"></div>';
html += '<div class="posterItemText">' + item.Name + '</div>';
html += '<div class="posterItemText">';
2013-04-28 10:21:56 -07:00
if (item.RunTimeTicks != "") {
html += ticks_to_human(item.RunTimeTicks);
}
else {
html += "&nbsp;";
}
html += '</div>';
2013-04-28 10:21:56 -07:00
html += '</a>';
2013-04-28 10:21:56 -07:00
}
2013-05-11 23:05:51 -07:00
if (limit && items.length > limit) {
html += '<p style="margin: .5em 0 0;padding-left: .5em;"><button class="' + moreButtonClass + '" data-inline="true" data-mini="true">More ...</button></p>';
}
2013-04-28 10:21:56 -07:00
return html;
}
2013-05-11 23:05:51 -07:00
function renderSpecials(page, item, limit) {
2013-04-28 10:21:56 -07:00
ApiClient.getSpecialFeatures(Dashboard.getCurrentUserId(), item.Id).done(function (specials) {
2013-05-11 23:05:51 -07:00
$('#specialsContent', page).html(getVideosHtml(specials, limit, "moreSpecials")).trigger('create');
});
2013-04-10 14:14:25 -07:00
}
2013-04-10 14:14:25 -07:00
function renderTrailers(page, item) {
2013-04-10 14:14:25 -07:00
ApiClient.getLocalTrailers(Dashboard.getCurrentUserId(), item.Id).done(function (trailers) {
2013-04-28 10:21:56 -07:00
$('#trailersContent', page).html(getVideosHtml(trailers));
});
2013-04-10 14:14:25 -07:00
}
2013-03-26 22:20:46 -07:00
2013-05-11 23:05:51 -07:00
function renderCast(page, item, context, limit) {
2013-03-26 22:20:46 -07:00
var html = '';
2013-04-10 14:14:25 -07:00
var casts = item.People || [];
2013-03-26 22:20:46 -07:00
for (var i = 0, length = casts.length; i < length; i++) {
2013-05-11 23:05:51 -07:00
if (limit && i >= limit) {
break;
}
2013-04-22 07:44:11 -07:00
var cast = casts[i];
2013-03-26 22:20:46 -07:00
2013-05-11 23:05:51 -07:00
html += '<a class="tileItem smallPosterTileItem" href="itembynamedetails.html?context=' + context + '&person=' + ApiClient.encodeName(cast.Name) + '">';
var imgUrl;
if (cast.PrimaryImageTag) {
imgUrl = ApiClient.getPersonImageUrl(cast.Name, {
width: 130,
tag: cast.PrimaryImageTag,
type: "primary"
});
} else {
imgUrl = "css/images/items/list/person.png";
}
html += '<div class="tileImage" style="background-image:url(\'' + imgUrl + '\');"></div>';
html += '<div class="tileContent">';
html += '<p>' + cast.Name + '</p>';
var role = cast.Role ? "as " + cast.Role : cast.Type;
if (role == "GuestStar") {
role = "Guest star";
}
2013-05-11 23:05:51 -07:00
role = role || "";
var maxlength = 40;
if (role.length > maxlength) {
role = role.substring(0, maxlength - 3) + '...';
}
html += '<p>' + role + '</p>';
2013-05-11 23:05:51 -07:00
html += '</div>';
html += '</a>';
2013-03-26 22:20:46 -07:00
}
2013-05-11 23:05:51 -07:00
if (limit && casts.length > limit) {
html += '<p style="margin: .5em 0 0;padding-left: .5em;"><button class="morePeople" data-inline="true" data-mini="true">More ...</button></p>';
}
$('#castContent', page).html(html).trigger('create');
2013-04-10 14:14:25 -07:00
}
2013-04-14 08:14:10 -07:00
2013-04-10 14:14:25 -07:00
function play(startPosition) {
2013-03-28 22:51:45 -07:00
2013-04-10 14:14:25 -07:00
MediaPlayer.play([currentItem], startPosition);
}
2013-03-28 22:51:45 -07:00
2013-04-10 14:14:25 -07:00
$(document).on('pageinit', "#itemDetailPage", function () {
2013-03-29 07:12:14 -07:00
2013-04-10 14:14:25 -07:00
var page = this;
2013-04-04 10:27:36 -07:00
2013-04-10 14:14:25 -07:00
$('#btnPlay', page).on('click', function () {
var userdata = currentItem.UserData || {};
2013-04-30 10:45:51 -07:00
LibraryBrowser.showPlayMenu(this, currentItem.Id, currentItem.MediaType, userdata.PlaybackPositionTicks);
2013-04-14 08:14:10 -07:00
});
$('#btnEdit', page).on('click', function () {
2013-05-22 09:52:22 -07:00
Dashboard.navigate("edititemmetadata.html?id=" + currentItem.Id);
});
2013-05-28 18:45:39 -07:00
$('#btnRemote', page).on('click', function () {
2013-05-30 12:58:07 -07:00
RemoteControl.showMenu({
item: currentItem,
context: getContext(currentItem),
themeSongs: $('#themeSongsCollapsible:visible', page).length > 0,
themeVideos: $('#themeVideosCollapsible:visible', page).length > 0
});
2013-05-28 18:45:39 -07:00
});
2013-04-10 14:14:25 -07:00
}).on('pageshow', "#itemDetailPage", function () {
2013-03-28 22:51:45 -07:00
2013-04-10 14:14:25 -07:00
var page = this;
2013-03-28 22:51:45 -07:00
2013-05-11 23:05:51 -07:00
$(page).on("click.moreScenes", ".moreScenes", function () {
renderScenes(page, currentItem);
}).on("click.morePeople", ".morePeople", function () {
renderCast(page, currentItem, getContext(currentItem));
}).on("click.moreSpecials", ".moreSpecials", function () {
renderSpecials(page, currentItem);
}).on("click.moreCriticReviews", ".moreCriticReviews", function () {
renderCriticReviews(page, currentItem);
});
2013-04-10 14:14:25 -07:00
reload(page);
2013-03-28 22:51:45 -07:00
2013-04-10 14:14:25 -07:00
}).on('pagehide', "#itemDetailPage", function () {
2013-04-10 14:14:25 -07:00
currentItem = null;
2013-05-11 23:05:51 -07:00
var page = this;
$(page).off("click.moreScenes").off("click.morePeople").off("click.moreSpecials").off("click.moreCriticReviews");
2013-04-10 14:14:25 -07:00
});
2013-04-14 08:14:10 -07:00
2013-04-10 14:14:25 -07:00
function itemDetailPage() {
2013-04-10 14:14:25 -07:00
var self = this;
2013-04-10 14:14:25 -07:00
self.play = play;
2013-04-09 11:38:58 -07:00
}
2013-03-28 22:51:45 -07:00
2013-04-10 14:14:25 -07:00
window.ItemDetailPage = new itemDetailPage();
2013-02-20 18:33:05 -07:00
2013-04-10 14:14:25 -07:00
})(jQuery, document, LibraryBrowser, window);