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

223 lines
5.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 06:53:44 -07:00
Dashboard.setPageTitle(name);
2013-04-09 21:54:16 -07:00
2013-04-10 06:53:44 -07:00
renderImage(page, item);
2013-04-09 21:54:16 -07:00
2013-04-10 06:53:44 -07:00
renderDetails(page, item);
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 06:53:44 -07:00
renderFavorites(page, item);
LibraryBrowser.renderLinks(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 renderImage(page, item) {
2013-04-09 21:54:16 -07:00
2013-04-10 06:53:44 -07:00
$('#itemImage', page).html(LibraryBrowser.getDetailImageHtml(item));
}
2013-04-09 21:54:16 -07:00
2013-04-10 06:53:44 -07:00
function renderDetails(page, item) {
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 06:53:44 -07:00
var miscInfo = [];
2013-04-09 21:54:16 -07:00
2013-04-10 06:53:44 -07:00
if (item.ProductionYear) {
miscInfo.push(item.ProductionYear);
}
2013-04-09 21:54:16 -07:00
2013-04-10 06:53:44 -07:00
if (item.OfficialRating) {
miscInfo.push(item.OfficialRating);
}
2013-04-09 21:54:16 -07:00
2013-04-10 06:53:44 -07:00
if (item.RunTimeTicks) {
2013-04-09 21:54:16 -07:00
2013-04-10 06:53:44 -07:00
var minutes = item.RunTimeTicks / 600000000;
2013-04-09 21:54:16 -07:00
2013-04-10 06:53:44 -07:00
minutes = minutes || 1;
2013-04-09 21:54:16 -07:00
2013-04-10 06:53:44 -07:00
miscInfo.push(parseInt(minutes) + "min");
}
2013-04-09 21:54:16 -07:00
2013-04-10 06:53:44 -07:00
if (item.DisplayMediaType) {
miscInfo.push(item.DisplayMediaType);
}
2013-04-09 21:54:16 -07:00
2013-04-10 06:53:44 -07:00
if (item.VideoFormat && item.VideoFormat !== 'Standard') {
miscInfo.push(item.VideoFormat);
}
2013-04-09 21:54:16 -07:00
2013-04-10 06:53:44 -07:00
$('#itemMiscInfo', page).html(miscInfo.join('     '));
2013-04-09 21:54:16 -07:00
2013-04-10 06:53:44 -07:00
renderGenres(page, item);
renderStudios(page, item);
}
2013-04-09 21:54:16 -07:00
2013-04-10 06:53:44 -07:00
function renderStudios(page, item) {
if (item.Studios && item.Studios.length) {
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();
}
}
function renderFavorites(page, item) {
$('#itemRatings', page).html(LibraryBrowser.getUserRatingHtml(item));
}
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 06:53:44 -07:00
})(jQuery, document, LibraryBrowser);
2013-04-09 21:54:16 -07:00
2013-04-10 06:53:44 -07:00
var tvSeriesPage = {
2013-04-09 21:54:16 -07:00
2013-04-10 06:53:44 -07:00
setFavorite: function () {
var item = tvSeriesPage.item;
2013-04-09 21:54:16 -07:00
2013-04-10 06:53:44 -07:00
item.UserData = item.UserData || {};
2013-04-09 21:54:16 -07:00
2013-04-10 06:53:44 -07:00
var setting = !item.UserData.IsFavorite;
item.UserData.IsFavorite = setting;
2013-04-09 21:54:16 -07:00
2013-04-10 06:53:44 -07:00
ApiClient.updateFavoriteStatus(Dashboard.getCurrentUserId(), item.Id, setting);
2013-04-09 21:54:16 -07:00
2013-04-10 06:53:44 -07:00
renderFavorites(page, item);
},
2013-04-09 21:54:16 -07:00
2013-04-10 06:53:44 -07:00
setLike: function () {
2013-04-09 21:54:16 -07:00
2013-04-10 06:53:44 -07:00
var item = tvSeriesPage.item;
2013-04-09 21:54:16 -07:00
2013-04-10 06:53:44 -07:00
item.UserData = item.UserData || {};
2013-04-09 21:54:16 -07:00
2013-04-10 06:53:44 -07:00
item.UserData.Likes = true;
2013-04-09 21:54:16 -07:00
2013-04-10 06:53:44 -07:00
ApiClient.updateUserItemRating(Dashboard.getCurrentUserId(), item.Id, true);
2013-04-09 21:54:16 -07:00
2013-04-10 06:53:44 -07:00
renderFavorites(page, item);
},
2013-04-09 21:54:16 -07:00
2013-04-10 06:53:44 -07:00
clearLike: function () {
2013-04-09 21:54:16 -07:00
2013-04-10 06:53:44 -07:00
var item = tvSeriesPage.item;
2013-04-09 21:54:16 -07:00
2013-04-10 06:53:44 -07:00
item.UserData = item.UserData || {};
2013-04-09 21:54:16 -07:00
2013-04-10 06:53:44 -07:00
item.UserData.Likes = undefined;
2013-04-09 21:54:16 -07:00
2013-04-10 06:53:44 -07:00
ApiClient.clearUserItemRating(Dashboard.getCurrentUserId(), item.Id);
2013-04-09 21:54:16 -07:00
2013-04-10 06:53:44 -07:00
renderFavorites(page, item);
},
2013-04-09 21:54:16 -07:00
2013-04-10 06:53:44 -07:00
setDislike: function () {
var item = tvSeriesPage.item;
2013-04-09 21:54:16 -07:00
2013-04-10 06:53:44 -07:00
item.UserData = item.UserData || {};
2013-04-09 21:54:16 -07:00
2013-04-10 06:53:44 -07:00
item.UserData.Likes = false;
2013-04-09 21:54:16 -07:00
2013-04-10 06:53:44 -07:00
ApiClient.updateUserItemRating(Dashboard.getCurrentUserId(), item.Id, false);
2013-04-09 21:54:16 -07:00
2013-04-10 06:53:44 -07:00
renderFavorites(page, item);
},
2013-04-09 21:54:16 -07:00
2013-04-10 06:53:44 -07:00
setPlayed: function () {
var item = tvSeriesPage.item;
2013-04-09 21:54:16 -07:00
2013-04-10 06:53:44 -07:00
item.UserData = item.UserData || {};
2013-04-09 21:54:16 -07:00
2013-04-10 06:53:44 -07:00
var setting = !item.UserData.Played;
item.UserData.Played = setting;
2013-04-09 21:54:16 -07:00
2013-04-10 06:53:44 -07:00
ApiClient.updatePlayedStatus(Dashboard.getCurrentUserId(), item.Id, setting);
2013-04-09 21:54:16 -07:00
2013-04-10 06:53:44 -07:00
renderFavorites(page, item);
}
2013-04-09 21:54:16 -07:00
2013-04-10 06:53:44 -07:00
};