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

156 lines
4.8 KiB
JavaScript
Raw Normal View History

2013-04-10 10:36:34 -07:00
(function ($, document, LibraryBrowser) {
2013-03-27 15:29:37 -07:00
2013-04-10 10:36:34 -07:00
function reload(page) {
2013-03-27 15:29:37 -07:00
Dashboard.showLoadingMsg();
2013-04-10 10:36:34 -07:00
var getItemPromise;
2013-04-16 22:36:56 -07:00
var name = getParameterByName('person');
2013-03-27 15:29:37 -07:00
if (name) {
getItemPromise = ApiClient.getPerson(name);
2013-04-10 10:36:34 -07:00
} else {
2013-04-16 22:36:56 -07:00
name = getParameterByName('studio');
if (name) {
2013-04-16 22:36:56 -07:00
getItemPromise = ApiClient.getStudio(name);
2013-04-16 22:36:56 -07:00
} else {
2013-04-16 22:36:56 -07:00
name = getParameterByName('genre');
if (name) {
getItemPromise = ApiClient.getGenre(name);
}
else {
throw new Error('Invalid request');
}
}
2013-03-27 15:29:37 -07:00
}
var getUserDataPromise = ApiClient.getItembyNameUserData(Dashboard.getCurrentUserId(), name);
$.when(getItemPromise, getUserDataPromise).done(function (response1, response2) {
2013-03-27 15:29:37 -07:00
var item = response1[0];
var userdata = response2[0];
2013-04-16 22:36:56 -07:00
item.UserData = userdata;
name = item.Name;
2013-03-27 21:27:15 -07:00
2013-04-10 10:36:34 -07:00
$('#itemImage', page).html(LibraryBrowser.getDetailImageHtml(item));
2013-03-27 21:27:15 -07:00
2013-04-10 10:36:34 -07:00
Dashboard.setPageTitle(name);
$('#itemName', page).html(name);
2013-03-27 21:27:15 -07:00
2013-04-10 10:36:34 -07:00
renderDetails(page, item);
2013-04-16 22:36:56 -07:00
renderTabs(page, item);
2013-03-27 21:27:15 -07:00
2013-04-10 10:36:34 -07:00
Dashboard.hideLoadingMsg();
});
}
2013-03-27 21:27:15 -07:00
2013-04-16 22:36:56 -07:00
function renderTabs(page, item) {
if (item.Type !== "Person") {
return;
}
var url = ApiClient.getUrl("Users/" + Dashboard.getCurrentUserId() + "/Persons/" + item.Name + "/Counts");
$.getJSON(url).done(function (result) {
2013-04-16 23:03:47 -07:00
var html = '<fieldset data-role="controlgroup" data-type="horizontal" class="libraryTabs">';
2013-04-16 22:36:56 -07:00
html += '<legend></legend>';
if (result.MovieCount) {
2013-04-16 23:03:47 -07:00
html += '<input type="radio" name="ibnItems" id="radioMovies" value="on" data-mini="true">';
2013-04-16 22:36:56 -07:00
html += '<label for="radioMovies">Movies (' + result.MovieCount + ')</label>';
}
if (result.SeriesCount) {
2013-04-16 23:03:47 -07:00
html += '<input type="radio" name="ibnItems" id="radioShows" value="on" data-mini="true">';
2013-04-16 22:36:56 -07:00
html += '<label for="radioShows">TV Shows (' + result.SeriesCount + ')</label>';
}
if (result.EpisodeGuestStarCount) {
2013-04-16 23:03:47 -07:00
html += '<input type="radio" name="ibnItems" id="radioGuestStar" value="on" data-mini="true">';
2013-04-16 22:36:56 -07:00
html += '<label for="radioGuestStar">Guest Starred (' + result.EpisodeGuestStarCount + ')</label>';
}
if (result.GameCount) {
2013-04-16 23:03:47 -07:00
html += '<input type="radio" name="ibnItems" id="radioGames" value="on" data-mini="true">';
2013-04-16 22:36:56 -07:00
html += '<label for="radioGames">Games (' + result.SeriesCount + ')</label>';
}
html += '</fieldset>';
var elem = $('#items', page).html(html).trigger('create');
$('input:first', elem).attr("checked", "checked").checkboxradio("refresh").click();
});
}
2013-04-10 10:36:34 -07:00
function renderDetails(page, item) {
2013-03-27 21:27:15 -07:00
if (item.Overview || item.OverviewHtml) {
var overview = item.OverviewHtml || item.Overview;
$('#itemOverview', page).html(overview).show();
2013-04-10 10:36:34 -07:00
$('#itemOverview a').each(function () {
$(this).attr("target", "_blank");
2013-03-27 21:27:15 -07:00
});
} else {
$('#itemOverview', page).hide();
}
2013-04-10 10:36:34 -07:00
renderUserDataIcons(page, item);
2013-04-14 08:14:10 -07:00
LibraryBrowser.renderLinks($('#itemLinks', page), item);
2013-04-12 11:22:40 -07:00
if (item.Type == "Person" && item.PremiereDate) {
var birthday = parseISO8601Date(item.PremiereDate, { toLocal: true }).toDateString();
$('#itemBirthday', page).show().html("Birthday:&nbsp;&nbsp;" + birthday);
} else {
$('#itemBirthday', page).hide();
}
if (item.Type == "Person" && item.EndDate) {
var deathday = parseISO8601Date(item.EndDate, { toLocal: true }).toDateString();
$('#itemDeathDate', page).show().html("Death day:&nbsp;&nbsp;" + deathday);
} else {
$('#itemDeathDate', page).hide();
}
if (item.Type == "Person" && item.ProductionLocations && item.ProductionLocations.length) {
var gmap = '<a target="_blank" href="https://maps.google.com/maps?q=' + item.ProductionLocations[0] + '">' + item.ProductionLocations[0] + '</a>';
2013-04-12 11:40:48 -07:00
$('#itemBirthLocation', page).show().html("Birthplace:&nbsp;&nbsp;" + gmap).trigger('create');
2013-04-12 11:22:40 -07:00
} else {
$('#itemBirthLocation', page).hide();
}
2013-04-10 10:36:34 -07:00
}
2013-04-02 13:02:23 -07:00
2013-04-10 10:36:34 -07:00
function renderUserDataIcons(page, item) {
$('#itemRatings', page).html(LibraryBrowser.getUserDataIconsHtml(item));
}
2013-04-02 13:02:23 -07:00
2013-04-10 10:36:34 -07:00
$(document).on('pageshow', "#itemByNameDetailPage", function () {
reload(this);
});
2013-03-27 21:27:15 -07:00
2013-03-27 15:29:37 -07:00
2013-04-10 10:36:34 -07:00
})(jQuery, document, LibraryBrowser);