(function ($, document, LibraryBrowser, window) { var currentItem; function reload(page) { var id = getParameterByName('id'); Dashboard.showLoadingMsg(); ApiClient.getItem(Dashboard.getCurrentUserId(), id).done(function (item) { currentItem = item; var name = item.Name; if (item.IndexNumber != null) { name = item.IndexNumber + " - " + name; } if (item.ParentIndexNumber != null) { name = item.ParentIndexNumber + "." + name; } $('#itemImage', page).html(LibraryBrowser.getDetailImageHtml(item)); Dashboard.setPageTitle(name); $('#itemName', page).html(name); if (item.SeriesName || item.Album) { var seriesName = item.SeriesName || item.Album; $('#seriesName', page).html(seriesName).show(); } setInitialCollapsibleState(page, item); renderDetails(page, item); if (MediaPlayer.canPlay(item)) { $('#btnPlayMenu', page).show(); $('#playButtonShadow', page).show(); } else { $('#btnPlayMenu', page).hide(); $('#playButtonShadow', page).hide(); } Dashboard.hideLoadingMsg(); }); } function setInitialCollapsibleState(page, 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(); } } function renderDetails(page, item) { 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(LibraryBrowser.getStarRatingHtml(item)).show().attr('title', item.CommunityRating); } else { $('#itemCommunityRating', page).hide(); } $('#itemMiscInfo', page).html(LibraryBrowser.getMiscInfoHtml(item)); LibraryBrowser.renderGenres($('#itemGenres', page), item); LibraryBrowser.renderStudios($('#itemStudios', page), item); renderUserDataIcons(page, item); renderLinks(page, item); } function renderLinks(page, item) { if (item.ProviderIds) { $('#itemLinks', page).html(LibraryBrowser.getLinksHtml(item)); } else { $('#itemLinks', page).hide(); } } function renderUserDataIcons(page, item) { $('#itemRatings', page).html(LibraryBrowser.getUserDataIconsHtml(item)); } function renderScenes(page, item) { var html = ''; var chapters = item.Chapters || {}; for (var i = 0, length = chapters.length; i < length; i++) { var chapter = chapters[i]; var chapterName = chapter.Name || "Chapter " + i; html += '
'; } $('#scenesContent', page).html(html); } function renderGallery(page, item) { var imageTags = item.ImageTags || {}; var html = ''; if (imageTags.Logo) { html += createGalleryImage(item.Id, "Logo", item.ImageTags.Logo); } if (imageTags.Thumb) { html += createGalleryImage(item.Id, "Thumb", item.ImageTags.Thumb); } if (imageTags.Art) { html += createGalleryImage(item.Id, "Art", item.ImageTags.Art); } if (imageTags.Menu) { html += createGalleryImage(item.Id, "Menu", item.ImageTags.Menu); } if (imageTags.Disc) { html += createGalleryImage(item.Id, "Disc", item.ImageTags.Disc); } if (imageTags.Box) { html += createGalleryImage(item.Id, "Box", item.ImageTags.Box); } if (item.BackdropImageTags) { for (var i = 0, length = item.BackdropImageTags.length; i < length; i++) { html += createGalleryImage(item.Id, "Backdrop", item.BackdropImageTags[0], i); } } $('#galleryContent', page).html(html).trigger('create'); } function createGalleryImage(itemId, type, tag, index) { var downloadWidth = 400; var lightboxWidth = 800; var html = ''; if (typeof (index) == "undefined") index = 0; html += '' + type + '
'; html += '