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

109 lines
3.2 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;
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 {
name = getParameterByName('studio');
if (name) {
getItemPromise = ApiClient.getStudio(name);
} else {
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];
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-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-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:  " + 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:  " + 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);