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

135 lines
3.5 KiB
JavaScript
Raw Normal View History

2013-04-10 06:53:44 -07:00
(function ($, document, LibraryBrowser) {
2013-04-09 21:54:16 -07:00
2013-04-10 06:53:44 -07:00
var currentItem;
2013-04-09 21:54:16 -07:00
2013-04-10 06:53:44 -07:00
function reload(page) {
2013-04-09 21:54:16 -07:00
2013-04-10 06:53:44 -07:00
var id = getParameterByName('id');
2013-04-09 21:54:16 -07:00
2013-04-10 06:53:44 -07:00
Dashboard.showLoadingMsg();
2013-04-09 21:54:16 -07:00
2013-04-10 06:53:44 -07:00
ApiClient.getItem(Dashboard.getCurrentUserId(), id).done(function (item) {
2013-04-09 21:54:16 -07:00
2013-04-10 06:53:44 -07:00
currentItem = item;
2013-04-09 21:54:16 -07:00
2013-04-10 06:53:44 -07:00
var name = item.Name;
2013-04-09 21:54:16 -07:00
2013-04-10 10:11:23 -07:00
$('#itemImage', page).html(LibraryBrowser.getDetailImageHtml(item));
2013-04-09 21:54:16 -07:00
2013-04-10 10:11:23 -07:00
Dashboard.setPageTitle(name);
2013-04-09 21:54:16 -07:00
2013-04-10 06:53:44 -07:00
$('#itemName', page).html(name);
2013-04-09 21:54:16 -07:00
2013-04-10 10:11:23 -07:00
renderDetails(page, item);
2013-04-09 21:54:16 -07:00
2013-04-10 06:53:44 -07:00
Dashboard.hideLoadingMsg();
});
}
2013-04-09 21:54:16 -07:00
2013-04-10 06:53:44 -07:00
function renderDetails(page, item) {
2013-04-10 10:11:23 -07:00
2013-04-10 06:53:44 -07:00
if (item.Taglines && item.Taglines.length) {
$('#itemTagline', page).html(item.Taglines[0]).show();
} else {
$('#itemTagline', page).hide();
}
2013-04-09 21:54:16 -07:00
2013-04-10 06:53:44 -07:00
if (item.Overview || item.OverviewHtml) {
var overview = item.OverviewHtml || item.Overview;
2013-04-09 21:54:16 -07:00
2013-04-10 06:53:44 -07:00
$('#itemOverview', page).html(overview).show();
$('#itemOverview a').each(function () {
$(this).attr("target", "_blank");
});
} else {
$('#itemOverview', page).hide();
}
2013-04-09 21:54:16 -07:00
2013-04-10 06:53:44 -07:00
if (item.CommunityRating) {
$('#itemCommunityRating', page).html(LibraryBrowser.getStarRatingHtml(item)).show().attr('title', item.CommunityRating);
} else {
$('#itemCommunityRating', page).hide();
}
2013-04-09 21:54:16 -07:00
2013-04-10 10:11:23 -07:00
$('#itemMiscInfo', page).html(LibraryBrowser.getMiscInfoHtml(item));
2013-04-09 21:54:16 -07:00
2013-04-10 10:11:23 -07:00
renderGenres(page, item);
renderStudios(page, item);
renderUserDataIcons(page, item);
renderLinks(page, item);
}
function renderLinks(page, item) {
if (item.ProviderIds) {
2013-04-09 21:54:16 -07:00
2013-04-10 10:11:23 -07:00
$('#itemLinks', page).html(LibraryBrowser.getLinksHtml(item));
2013-04-09 21:54:16 -07:00
2013-04-10 10:11:23 -07:00
} else {
$('#itemLinks', page).hide();
2013-04-10 06:53:44 -07:00
}
}
2013-04-09 21:54:16 -07:00
2013-04-10 06:53:44 -07:00
function renderStudios(page, item) {
2013-04-10 10:11:23 -07:00
2013-04-10 06:53:44 -07:00
if (item.Studios && item.Studios.length) {
2013-04-10 10:11:23 -07:00
2013-04-10 06:53:44 -07:00
var elem = $('#itemStudios', page).show();
2013-04-09 21:54:16 -07:00
2013-04-10 06:53:44 -07:00
var html = 'Studios:  ';
2013-04-09 21:54:16 -07:00
2013-04-10 06:53:44 -07:00
for (var i = 0, length = item.Studios.length; i < length; i++) {
2013-04-09 21:54:16 -07:00
2013-04-10 06:53:44 -07:00
if (i > 0) {
html += '&nbsp;&nbsp;/&nbsp;&nbsp;';
}
2013-04-09 21:54:16 -07:00
2013-04-10 06:53:44 -07:00
html += '<a href="itembynamedetails.html?studio=' + item.Studios[i] + '">' + item.Studios[i] + '</a>';
}
2013-04-09 21:54:16 -07:00
2013-04-10 06:53:44 -07:00
elem.html(html).trigger('create');
2013-04-09 21:54:16 -07:00
2013-04-10 06:53:44 -07:00
} else {
$('#itemStudios', page).hide();
}
}
2013-04-09 21:54:16 -07:00
2013-04-10 06:53:44 -07:00
function renderGenres(page, item) {
if (item.Genres && item.Genres.length) {
var elem = $('#itemGenres', page).show();
2013-04-09 21:54:16 -07:00
2013-04-10 06:53:44 -07:00
var html = 'Genres:&nbsp;&nbsp;';
2013-04-09 21:54:16 -07:00
2013-04-10 06:53:44 -07:00
for (var i = 0, length = item.Genres.length; i < length; i++) {
2013-04-09 21:54:16 -07:00
2013-04-10 06:53:44 -07:00
if (i > 0) {
html += '&nbsp;&nbsp;/&nbsp;&nbsp;';
}
2013-04-09 21:54:16 -07:00
2013-04-10 06:53:44 -07:00
html += '<a href="itembynamedetails.html?genre=' + item.Genres[i] + '">' + item.Genres[i] + '</a>';
}
2013-04-09 21:54:16 -07:00
2013-04-10 06:53:44 -07:00
elem.html(html).trigger('create');
2013-04-09 21:54:16 -07:00
2013-04-10 06:53:44 -07:00
} else {
$('#itemGenres', page).hide();
}
}
2013-04-10 10:11:23 -07:00
function renderUserDataIcons(page, item) {
$('#itemRatings', page).html(LibraryBrowser.getUserDataIconsHtml(item));
2013-04-10 06:53:44 -07:00
}
2013-04-09 21:54:16 -07:00
2013-04-10 06:53:44 -07:00
$(document).on('pageshow', "#tvSeriesPage", function () {
2013-04-09 21:54:16 -07:00
2013-04-10 06:53:44 -07:00
reload(this);
2013-04-09 21:54:16 -07:00
2013-04-10 06:53:44 -07:00
}).on('pagehide', "#tvSeriesPage", function () {
2013-04-09 21:54:16 -07:00
2013-04-10 06:53:44 -07:00
currentItem = null;
});
2013-04-09 21:54:16 -07:00
2013-04-10 10:11:23 -07:00
})(jQuery, document, LibraryBrowser);