var ItemDetailPage = { onPageShow: function () { ItemDetailPage.reload(); $('#mediaInfoCollapsible', this).on('expand', ItemDetailPage.onMediaInfoExpand); $('#scenesCollapsible', this).on('expand', ItemDetailPage.onScenesExpand); $('#specialsCollapsible', this).on('expand', ItemDetailPage.onSpecialsExpand); $('#trailersCollapsible', this).on('expand', ItemDetailPage.onTrailersExpand); $('#castCollapsible', this).on('expand', ItemDetailPage.onCastExpand); $('#galleryCollapsible', this).on('expand', ItemDetailPage.onGalleryExpand); }, onPageHide: function () { $('#mediaInfoCollapsible', this).off('expand', ItemDetailPage.onMediaInfoExpand); $('#scenesCollapsible', this).off('expand', ItemDetailPage.onScenesExpand); $('#specialsCollapsible', this).off('expand', ItemDetailPage.onSpecialsExpand); $('#trailersCollapsible', this).off('expand', ItemDetailPage.onTrailersExpand); $('#castCollapsible', this).off('expand', ItemDetailPage.onCastExpand); $('#galleryCollapsible', this).off('expand', ItemDetailPage.onGalleryExpand); ItemDetailPage.item = null; }, reload: function () { var id = getParameterByName('id'); Dashboard.showLoadingMsg(); ApiClient.getItem(Dashboard.getCurrentUserId(), id).done(ItemDetailPage.renderItem); }, renderItem: function (item) { ItemDetailPage.item = item; var page = $.mobile.activePage; ItemDetailPage.item = item; var name = item.Name; if (item.IndexNumber != null) { name = item.IndexNumber + " - " + name; } if (item.ParentIndexNumber != null) { name = item.ParentIndexNumber + "." + name; } Dashboard.setPageTitle(name); ItemDetailPage.renderImage(item); ItemDetailPage.renderOverviewBlock(item); ItemDetailPage.renderGallery(item); if (!item.MediaStreams || !item.MediaStreams.length) { $('#mediaInfoCollapsible', page).hide(); } else { $('#mediaInfoCollapsible', page).show(); } if (!item.Chapters || !item.Chapters.length) { $('#scenesCollapsible', page).hide(); } else { $('#scenesCollapsible', page).show(); } if (!item.LocalTrailerCount || item.LocalTrailerCount == 0) { $('#trailersCollapsible', page).hide(); } else { $('#trailersCollapsible', page).show(); } if (!item.SpecialFeatureCount || item.SpecialFeatureCount == 0) { $('#specialsCollapsible', page).hide(); } else { $('#specialsCollapsible', page).show(); } if (!item.People || !item.People.length) { $('#castCollapsible', page).hide(); } else { $('#castCollapsible', page).show(); } $('#itemName', page).html(name); if (item.SeriesName || item.Album) { var series_name = item.SeriesName || item.Album; $('#seriesName', page).html(series_name).show(); } ItemDetailPage.renderFav(item); LibraryBrowser.renderLinks(item); Dashboard.hideLoadingMsg(); }, renderImage: function (item) { var page = $.mobile.activePage; var imageTags = item.ImageTags || {}; var html = ''; var url; var useBackgroundColor; if (imageTags.Primary) { url = ApiClient.getImageUrl(item.Id, { type: "Primary", width: 800, tag: item.ImageTags.Primary }); } else if (item.BackdropImageTags && item.BackdropImageTags.length) { url = ApiClient.getImageUrl(item.Id, { type: "Backdrop", width: 800, tag: item.BackdropImageTags[0] }); } else if (imageTags.Thumb) { url = ApiClient.getImageUrl(item.Id, { type: "Thumb", width: 800, tag: item.ImageTags.Thumb }); } else if (imageTags.Disc) { url = ApiClient.getImageUrl(item.Id, { type: "Disc", width: 800, tag: item.ImageTags.Disc }); } else if (item.MediaType == "Audio") { url = "css/images/items/detail/audio.png"; useBackgroundColor = true; } else if (item.MediaType == "Game") { url = "css/images/items/detail/game.png"; useBackgroundColor = true; } else { url = "css/images/items/detail/video.png"; useBackgroundColor = true; } if (url) { var style = useBackgroundColor ? "background-color:" + LibraryBrowser.getMetroColor(item.Id) + ";" : ""; html += ""; } $('#itemImage', page).html(html); }, renderOverviewBlock: function (item) { var page = $.mobile.activePage; if (item.Taglines && item.Taglines.length) { $('#itemTagline', page).html(item.Taglines[0]).show(); } else { $('#itemTagline', page).hide(); } if (item.Overview || item.OverviewHtml) { var overview = item.OverviewHtml || item.Overview; $('#itemOverview', page).html(overview).show(); $('#itemOverview a').each(function () { $(this).attr("target", "_blank"); }); } else { $('#itemOverview', page).hide(); } if (item.CommunityRating) { $('#itemCommunityRating', page).html(ItemDetailPage.getStarRating(item)).show().attr('title', item.CommunityRating); } else { $('#itemCommunityRating', page).hide(); } if (MediaPlayer.canPlay(item)) { $('#btnPlay', page).show(); $('#playButtonShadow', page).show(); } else { $('#btnPlay', page).hide(); $('#playButtonShadow', page).hide(); } var miscInfo = []; if (item.ProductionYear) { miscInfo.push(item.ProductionYear); } if (item.OfficialRating) { miscInfo.push(item.OfficialRating); } if (item.RunTimeTicks) { var minutes = item.RunTimeTicks / 600000000; minutes = minutes || 1; miscInfo.push(parseInt(minutes) + "min"); } if (item.DisplayMediaType) { miscInfo.push(item.DisplayMediaType); } if (item.VideoFormat && item.VideoFormat !== 'Standard') { miscInfo.push(item.VideoFormat); } $('#itemMiscInfo', page).html(miscInfo.join(' ')); ItemDetailPage.renderGenres(item); ItemDetailPage.renderStudios(item); }, renderGenres: function (item) { var page = $.mobile.activePage; if (item.Genres && item.Genres.length) { var elem = $('#itemGenres', page).show(); var html = 'Genres: '; for (var i = 0, length = item.Genres.length; i < length; i++) { if (i > 0) { html += ' / '; } html += '' + item.Genres[i] + ''; } elem.html(html).trigger('create'); } else { $('#itemGenres', page).hide(); } }, renderStudios: function (item) { var page = $.mobile.activePage; if (item.Studios && item.Studios.length) { var elem = $('#itemStudios', page).show(); var html = 'Studios: '; for (var i = 0, length = item.Studios.length; i < length; i++) { if (i > 0) { html += ' / '; } html += '' + item.Studios[i] + ''; } elem.html(html).trigger('create'); } else { $('#itemStudios', page).hide(); } }, getStarRating: function (item) { var rating = item.CommunityRating; var html = ""; for (var i = 1; i <= 10; i++) { if (rating < i - 1) { html += "
"; } else if (rating < i) { html += ""; } else { html += ""; } } return html; }, onScenesExpand: function () { if (ItemDetailPage.item) { ItemDetailPage.renderScenes(ItemDetailPage.item); $(this).off('expand', ItemDetailPage.onScenesExpand); } }, renderScenes: function (item) { var html = ''; var page = $.mobile.activePage; var chapters = item.Chapters || {}; for (var i = 0, length = chapters.length; i < length; i++) { var chapter = chapters[i]; var chapter_name = chapter.Name || "Chapter " + i; html += ''; } $('#scenesContent', page).html(html); }, play: function (startPosition) { MediaPlayer.play([ItemDetailPage.item], startPosition); }, onGalleryExpand: function () { if (ItemDetailPage.item) { ItemDetailPage.renderGallery(ItemDetailPage.item); $(this).off('expand', ItemDetailPage.onGalleryExpand); } }, renderGallery: function (item) { var page = $.mobile.activePage; var imageTags = item.ImageTags || {}; var html = ''; if (imageTags.Logo) { html += ItemDetailPage.createGalleryImage(item.Id, "Logo", item.ImageTags.Logo); } if (imageTags.Thumb) { html += ItemDetailPage.createGalleryImage(item.Id, "Thumb", item.ImageTags.Thumb); } if (imageTags.Art) { html += ItemDetailPage.createGalleryImage(item.Id, "Art", item.ImageTags.Art); } if (imageTags.Menu) { html += ItemDetailPage.createGalleryImage(item.Id, "Menu", item.ImageTags.Menu); } if (imageTags.Disc) { html += ItemDetailPage.createGalleryImage(item.Id, "Disc", item.ImageTags.Disc); } if (imageTags.Box) { html += ItemDetailPage.createGalleryImage(item.Id, "Box", item.ImageTags.Box); } if (item.BackdropImageTags) { for (var i = 0, length = item.BackdropImageTags.length; i < length; i++) { html += ItemDetailPage.createGalleryImage(item.Id, "Backdrop", item.BackdropImageTags[0], i); } } $('#galleryContent', page).html(html).trigger('create'); }, createGalleryImage: function (itemId, type, tag, index) { var downloadWidth = 400; var lightboxWidth = 800; var html = ''; if (typeof (index) == "undefined") index = 0; html += 'Type | '; html += 'Codec | '; html += 'Language | '; html += 'Resolution | '; html += 'Channels | '; html += 'Bitrate | '; html += 'Framerate | '; html += 'Flags | '; html += '||||
---|---|---|---|---|---|---|---|---|---|---|---|
' + type + ' | '; html += '' + stream.Codec + ' | '; if (stream.Language) { hasLanguage = true; html += '' + stream.Language + ' | '; } else html += ''; if (stream.Type == "Video") { html += ' | ' + stream.Width + '/' + stream.Height + ' (' + stream.AspectRatio + ') | '; } else { html += ''; } if (stream.Channels) { html += ' | ' + stream.Channels + 'ch ' + stream.SampleRate + ' khz | '; } else { html += ''; } html += ' | ' + stream.BitRate + ' | '; if (stream.Type == "Video") { var framerate = stream.AverageFrameRate || stream.RealFrameRate; html += '' + framerate + ' | '; } else { html += ''; } var notes = new Array(); if (stream.IsExternal) notes.push("external file"); if (stream.IsDefault) notes.push("Default"); if (stream.IsForced) notes.push("Forced"); html += ' | ' + notes.join(', ') + ' | '; html += '