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-03-27 15:29:37 -07:00
|
|
|
|
var person = getParameterByName('person');
|
|
|
|
|
|
|
|
|
|
if (person) {
|
2013-04-10 10:36:34 -07:00
|
|
|
|
getItemPromise = ApiClient.getPerson(person);
|
2013-03-27 15:29:37 -07:00
|
|
|
|
}
|
|
|
|
|
|
2013-04-10 10:36:34 -07:00
|
|
|
|
else if (getParameterByName('studio')) {
|
|
|
|
|
getItemPromise = ApiClient.getStudio(getParameterByName('studio'));
|
|
|
|
|
}
|
|
|
|
|
else if (getParameterByName('genre')) {
|
|
|
|
|
getItemPromise = ApiClient.getGenre(getParameterByName('genre'));
|
|
|
|
|
} else {
|
|
|
|
|
throw new Error('Invalid request');
|
2013-03-27 15:29:37 -07:00
|
|
|
|
}
|
|
|
|
|
|
2013-04-10 10:36:34 -07:00
|
|
|
|
getItemPromise.done(function (item) {
|
2013-03-27 15:29:37 -07:00
|
|
|
|
|
2013-04-10 10:36:34 -07:00
|
|
|
|
var 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);
|
|
|
|
|
renderLinks(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: " + 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 renderLinks(page, item) {
|
|
|
|
|
if (item.ProviderIds) {
|
2013-04-02 13:02:23 -07:00
|
|
|
|
|
2013-04-10 10:36:34 -07:00
|
|
|
|
$('#itemLinks', page).html(LibraryBrowser.getLinksHtml(item));
|
2013-04-02 13:02:23 -07:00
|
|
|
|
|
2013-04-10 10:36:34 -07:00
|
|
|
|
} else {
|
|
|
|
|
$('#itemLinks', page).hide();
|
|
|
|
|
}
|
|
|
|
|
}
|
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);
|