2013-04-10 10:36:34 -07:00
|
|
|
|
(function ($, document, LibraryBrowser) {
|
2013-03-27 15:29:37 -07:00
|
|
|
|
|
2013-04-17 21:45:00 -07:00
|
|
|
|
var currentItem;
|
|
|
|
|
|
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
|
|
|
|
|
2013-04-13 12:24:34 -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');
|
|
|
|
|
|
2013-04-13 12:24:34 -07:00
|
|
|
|
if (name) {
|
2013-04-16 22:36:56 -07:00
|
|
|
|
|
2013-04-13 12:24:34 -07:00
|
|
|
|
getItemPromise = ApiClient.getStudio(name);
|
2013-04-16 22:36:56 -07:00
|
|
|
|
|
2013-04-13 12:24:34 -07:00
|
|
|
|
} else {
|
2013-04-16 22:36:56 -07:00
|
|
|
|
|
|
|
|
|
name = getParameterByName('genre');
|
|
|
|
|
|
2013-04-13 12:24:34 -07:00
|
|
|
|
if (name) {
|
|
|
|
|
getItemPromise = ApiClient.getGenre(name);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
throw new Error('Invalid request');
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-03-27 15:29:37 -07:00
|
|
|
|
}
|
|
|
|
|
|
2013-04-13 12:24:34 -07:00
|
|
|
|
var getUserDataPromise = ApiClient.getItembyNameUserData(Dashboard.getCurrentUserId(), name);
|
|
|
|
|
|
|
|
|
|
$.when(getItemPromise, getUserDataPromise).done(function (response1, response2) {
|
2013-03-27 15:29:37 -07:00
|
|
|
|
|
2013-04-13 12:24:34 -07:00
|
|
|
|
var item = response1[0];
|
|
|
|
|
var userdata = response2[0];
|
2013-04-16 22:36:56 -07:00
|
|
|
|
|
2013-04-17 21:45:00 -07:00
|
|
|
|
currentItem = item;
|
|
|
|
|
|
2013-04-13 12:24:34 -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) {
|
|
|
|
|
|
2013-04-17 09:46:52 -07:00
|
|
|
|
var promise;
|
2013-04-17 21:45:00 -07:00
|
|
|
|
|
2013-04-17 09:46:52 -07:00
|
|
|
|
if (item.Type == "Person") {
|
|
|
|
|
promise = ApiClient.getPersonItemCounts(Dashboard.getCurrentUserId(), item.Name);
|
|
|
|
|
}
|
|
|
|
|
else if (item.Type == "Genre") {
|
|
|
|
|
promise = ApiClient.getGenreItemCounts(Dashboard.getCurrentUserId(), item.Name);
|
|
|
|
|
}
|
|
|
|
|
else if (item.Type == "Studio") {
|
|
|
|
|
promise = ApiClient.getStudioItemCounts(Dashboard.getCurrentUserId(), item.Name);
|
|
|
|
|
} else {
|
|
|
|
|
throw new Error("Unknown item type: " + item.Type);
|
2013-04-16 22:36:56 -07:00
|
|
|
|
}
|
|
|
|
|
|
2013-04-17 09:46:52 -07:00
|
|
|
|
promise.done(function (result) {
|
2013-04-16 22:36:56 -07:00
|
|
|
|
|
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>';
|
|
|
|
|
}
|
2013-04-17 21:45:00 -07:00
|
|
|
|
|
2013-04-16 22:36:56 -07:00
|
|
|
|
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-17 21:45:00 -07:00
|
|
|
|
html += '<label for="radioGuestStar">Guest Star (' + result.EpisodeGuestStarCount + ')</label>';
|
2013-04-16 22:36:56 -07:00
|
|
|
|
}
|
|
|
|
|
|
2013-04-17 07:42:25 -07:00
|
|
|
|
if (result.TrailerCount) {
|
|
|
|
|
|
|
|
|
|
html += '<input type="radio" name="ibnItems" id="radioTrailers" value="on" data-mini="true">';
|
|
|
|
|
html += '<label for="radioTrailers">Trailers (' + result.TrailerCount + ')</label>';
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-16 22:36:56 -07:00
|
|
|
|
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>';
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-17 07:42:25 -07:00
|
|
|
|
if (result.AlbumCount) {
|
|
|
|
|
|
|
|
|
|
html += '<input type="radio" name="ibnItems" id="radioAlbums" value="on" data-mini="true">';
|
|
|
|
|
html += '<label for="radioAlbums">Albums (' + result.AlbumCount + ')</label>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (result.SongCount) {
|
|
|
|
|
|
|
|
|
|
html += '<input type="radio" name="ibnItems" id="radioSongs" value="on" data-mini="true">';
|
|
|
|
|
html += '<label for="radioSongs">Songs (' + result.SongCount + ')</label>';
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-16 22:36:56 -07:00
|
|
|
|
html += '</fieldset>';
|
|
|
|
|
|
2013-04-17 21:45:00 -07:00
|
|
|
|
var elem = $('#itemTabs', page).html(html).trigger('create');
|
|
|
|
|
|
|
|
|
|
bindRadioEvents(page);
|
|
|
|
|
|
|
|
|
|
$('input:first', elem).attr("checked", "checked").checkboxradio("refresh").trigger('click');
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function bindRadioEvents(page) {
|
|
|
|
|
|
|
|
|
|
$("#radioMovies", page).on("click", function () {
|
|
|
|
|
|
|
|
|
|
loadItems(page, { IncludeItemTypes: "Movie" });
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$("#radioShows", page).on("click", function () {
|
2013-04-16 22:36:56 -07:00
|
|
|
|
|
2013-04-17 21:45:00 -07:00
|
|
|
|
loadItems(page, { IncludeItemTypes: "Series" });
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$("#radioTrailers", page).on("click", function () {
|
|
|
|
|
|
|
|
|
|
loadItems(page, { IncludeItemTypes: "Trailer" });
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$("#radioGames", page).on("click", function () {
|
|
|
|
|
|
|
|
|
|
loadItems(page, { IncludeItemTypes: "Game" });
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$("#radioGuestStar", page).on("click", function () {
|
|
|
|
|
|
|
|
|
|
loadItems(page, { IncludeItemTypes: "Episode", PersonTypes: "GuestStar" });
|
2013-04-16 22:36:56 -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) {
|
|
|
|
|
|
2013-04-18 22:08:18 -07:00
|
|
|
|
try {
|
|
|
|
|
var birthday = parseISO8601Date(item.PremiereDate, { toLocal: true }).toDateString();
|
2013-04-12 11:22:40 -07:00
|
|
|
|
|
2013-04-18 22:08:18 -07:00
|
|
|
|
$('#itemBirthday', page).show().html("Birthday: " + birthday);
|
|
|
|
|
}
|
|
|
|
|
catch(err)
|
|
|
|
|
{
|
|
|
|
|
$('#itemBirthday', page).hide();
|
|
|
|
|
}
|
2013-04-12 11:22:40 -07:00
|
|
|
|
} else {
|
|
|
|
|
$('#itemBirthday', page).hide();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (item.Type == "Person" && item.EndDate) {
|
|
|
|
|
|
2013-04-18 22:08:18 -07:00
|
|
|
|
try {
|
|
|
|
|
var deathday = parseISO8601Date(item.EndDate, { toLocal: true }).toDateString();
|
2013-04-12 11:22:40 -07:00
|
|
|
|
|
2013-04-18 22:08:18 -07:00
|
|
|
|
$('#itemDeathDate', page).show().html("Death day: " + deathday);
|
|
|
|
|
}
|
|
|
|
|
catch (err) {
|
|
|
|
|
$('#itemBirthday', page).hide();
|
|
|
|
|
}
|
2013-04-12 11:22:40 -07:00
|
|
|
|
} else {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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 renderUserDataIcons(page, item) {
|
|
|
|
|
$('#itemRatings', page).html(LibraryBrowser.getUserDataIconsHtml(item));
|
|
|
|
|
}
|
2013-04-02 13:02:23 -07:00
|
|
|
|
|
2013-04-17 21:45:00 -07:00
|
|
|
|
function addCurrentItemToQuery(query) {
|
|
|
|
|
|
|
|
|
|
if (currentItem.Type == "Person") {
|
|
|
|
|
query.Person = currentItem.Name;
|
|
|
|
|
}
|
|
|
|
|
else if (currentItem.Type == "Genre") {
|
|
|
|
|
query.Genres = currentItem.Name;
|
|
|
|
|
}
|
|
|
|
|
else if (currentItem.Type == "Studio") {
|
|
|
|
|
query.Studios = currentItem.Name;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function loadItems(page, options) {
|
|
|
|
|
|
2013-04-17 22:13:44 -07:00
|
|
|
|
Dashboard.showLoadingMsg();
|
|
|
|
|
|
2013-04-17 21:45:00 -07:00
|
|
|
|
var query = {
|
|
|
|
|
|
|
|
|
|
SortBy: "SortName",
|
|
|
|
|
SortOrder: "Ascending",
|
|
|
|
|
IncludeItemTypes: "Movie",
|
|
|
|
|
Recursive: true,
|
|
|
|
|
Fields: "PrimaryImageAspectRatio,UserData,DisplayMediaType,ItemCounts,DateCreated",
|
|
|
|
|
Limit: LibraryBrowser.getDetaultPageSize(),
|
|
|
|
|
StartIndex: 0
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
query = $.extend(query, options || {});
|
|
|
|
|
|
|
|
|
|
addCurrentItemToQuery(query);
|
|
|
|
|
|
|
|
|
|
ApiClient.getItems(Dashboard.getCurrentUserId(), query).done(function (result) {
|
|
|
|
|
var html = '';
|
|
|
|
|
|
2013-04-19 09:28:06 -07:00
|
|
|
|
$('.listTopPaging', page).html(LibraryBrowser.getPagingHtml(query, result.TotalRecordCount, true)).trigger('create');
|
2013-04-17 21:45:00 -07:00
|
|
|
|
|
|
|
|
|
html += LibraryBrowser.getPosterDetailViewHtml({
|
|
|
|
|
items: result.Items,
|
|
|
|
|
useAverageAspectRatio: true
|
|
|
|
|
});
|
|
|
|
|
|
2013-04-19 09:28:06 -07:00
|
|
|
|
html += LibraryBrowser.getPagingHtml(query, result.TotalRecordCount);
|
2013-04-17 21:45:00 -07:00
|
|
|
|
|
2013-04-18 22:08:18 -07:00
|
|
|
|
$('#items', page).html(html).trigger('create');
|
2013-04-17 21:45:00 -07:00
|
|
|
|
|
2013-04-18 22:08:18 -07:00
|
|
|
|
$('.selectPage', page).on('change', function () {
|
2013-04-17 21:45:00 -07:00
|
|
|
|
|
|
|
|
|
query.StartIndex = (parseInt(this.value) - 1) * query.Limit;
|
|
|
|
|
loadItems(page, query);
|
|
|
|
|
});
|
|
|
|
|
|
2013-04-18 22:08:18 -07:00
|
|
|
|
$('.btnNextPage', page).on('click', function () {
|
2013-04-17 21:45:00 -07:00
|
|
|
|
|
|
|
|
|
query.StartIndex = query.StartIndex + query.Limit;
|
|
|
|
|
loadItems(page, query);
|
|
|
|
|
});
|
|
|
|
|
|
2013-04-18 22:08:18 -07:00
|
|
|
|
$('.btnPreviousPage', page).on('click', function () {
|
2013-04-17 21:45:00 -07:00
|
|
|
|
|
|
|
|
|
query.StartIndex = query.StartIndex - query.Limit;
|
|
|
|
|
loadItems(page, query);
|
|
|
|
|
});
|
2013-04-17 22:13:44 -07:00
|
|
|
|
|
|
|
|
|
Dashboard.hideLoadingMsg();
|
2013-04-17 21:45:00 -07:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-10 10:36:34 -07:00
|
|
|
|
$(document).on('pageshow', "#itemByNameDetailPage", function () {
|
2013-04-17 21:45:00 -07:00
|
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
|
|
|
|
|
reload(page);
|
|
|
|
|
|
|
|
|
|
}).on('pagehide', "#itemByNameDetailPage", function () {
|
|
|
|
|
|
|
|
|
|
currentItem = null;
|
2013-04-10 10:36:34 -07:00
|
|
|
|
});
|
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);
|