2013-05-05 18:15:48 -07:00
|
|
|
|
(function ($, document, window) {
|
|
|
|
|
|
2013-08-02 13:36:44 -07:00
|
|
|
|
var currentItem;
|
|
|
|
|
|
2013-12-28 09:58:13 -07:00
|
|
|
|
var languagesPromise;
|
|
|
|
|
var countriesPromise;
|
|
|
|
|
|
|
|
|
|
function ensureLanguagePromises() {
|
|
|
|
|
languagesPromise = languagesPromise || ApiClient.getCultures();
|
|
|
|
|
countriesPromise = countriesPromise || ApiClient.getCountries();
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-02 13:36:44 -07:00
|
|
|
|
function updateTabs(page, item) {
|
|
|
|
|
|
|
|
|
|
var query = MetadataEditor.getEditQueryString(item);
|
|
|
|
|
|
|
|
|
|
$('#btnEditImages', page).attr('href', 'edititemimages.html?' + query);
|
2014-05-16 21:24:10 -07:00
|
|
|
|
$('#btnEditSubtitles', page).attr('href', 'edititemsubtitles.html?' + query);
|
2014-03-07 08:53:23 -07:00
|
|
|
|
$('#btnEditCollectionTitles', page).attr('href', 'editcollectionitems.html?' + query);
|
2013-08-02 13:36:44 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function reload(page) {
|
|
|
|
|
|
|
|
|
|
Dashboard.showLoadingMsg();
|
|
|
|
|
|
2013-12-28 09:58:13 -07:00
|
|
|
|
ensureLanguagePromises();
|
|
|
|
|
|
|
|
|
|
var promise1 = MetadataEditor.getItemPromise();
|
|
|
|
|
var promise2 = languagesPromise;
|
|
|
|
|
var promise3 = countriesPromise;
|
|
|
|
|
|
|
|
|
|
$.when(promise1, promise2, promise3).done(function (response1, response2, response3) {
|
|
|
|
|
|
|
|
|
|
var item = response1[0];
|
2014-03-01 15:34:27 -07:00
|
|
|
|
|
2014-02-23 20:27:13 -07:00
|
|
|
|
currentItem = item;
|
|
|
|
|
|
|
|
|
|
if (item.Type == "UserRootFolder") {
|
|
|
|
|
$('.editPageInnerContent', page).hide();
|
|
|
|
|
return;
|
|
|
|
|
} else {
|
|
|
|
|
$('.editPageInnerContent', page).show();
|
|
|
|
|
}
|
2013-12-28 09:58:13 -07:00
|
|
|
|
var languages = response2[0];
|
|
|
|
|
var countries = response3[0];
|
|
|
|
|
|
2014-07-01 22:16:59 -07:00
|
|
|
|
ApiClient.getJSON(ApiClient.getUrl("Items/" + item.Id + "/ExternalIdInfos")).done(function (idList) {
|
2014-02-21 14:44:10 -07:00
|
|
|
|
loadExternalIds(page, item, idList);
|
|
|
|
|
});
|
|
|
|
|
|
2013-12-28 09:58:13 -07:00
|
|
|
|
Dashboard.populateLanguages($('#selectLanguage', page), languages);
|
|
|
|
|
Dashboard.populateCountries($('#selectCountry', page), countries);
|
2013-08-02 13:36:44 -07:00
|
|
|
|
|
2014-07-04 22:21:13 -07:00
|
|
|
|
$('.btnRefresh', page).buttonEnabled(true);
|
2013-12-24 11:37:29 -07:00
|
|
|
|
$('#btnDelete', page).buttonEnabled(true);
|
|
|
|
|
$('.btnSave', page).buttonEnabled(true);
|
2013-05-22 12:49:12 -07:00
|
|
|
|
|
|
|
|
|
$('#refreshLoading', page).hide();
|
|
|
|
|
|
2013-05-22 09:52:22 -07:00
|
|
|
|
LibraryBrowser.renderName(item, $('.itemName', page), true);
|
2013-08-02 13:36:44 -07:00
|
|
|
|
|
|
|
|
|
updateTabs(page, item);
|
2013-05-05 18:15:48 -07:00
|
|
|
|
|
|
|
|
|
setFieldVisibilities(page, item);
|
|
|
|
|
fillItemInfo(page, item);
|
2013-07-29 11:33:48 -07:00
|
|
|
|
|
2014-03-07 08:53:23 -07:00
|
|
|
|
if (item.Type == "BoxSet") {
|
|
|
|
|
$('#btnEditCollectionTitles', page).show();
|
|
|
|
|
} else {
|
|
|
|
|
$('#btnEditCollectionTitles', page).hide();
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-16 20:17:14 -07:00
|
|
|
|
if (item.MediaType == "Video" && item.LocationType == "FileSystem" && item.Type !== 'TvChannel') {
|
2014-05-16 21:24:10 -07:00
|
|
|
|
$('#btnEditSubtitles', page).show();
|
|
|
|
|
} else {
|
|
|
|
|
$('#btnEditSubtitles', page).hide();
|
|
|
|
|
}
|
|
|
|
|
|
2014-08-28 17:49:25 -07:00
|
|
|
|
if (item.MediaType == 'Photo') {
|
|
|
|
|
$('#btnEditImages', page).hide();
|
|
|
|
|
} else {
|
|
|
|
|
$('#btnEditImages', page).show();
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-24 14:45:21 -07:00
|
|
|
|
if (item.MediaType == "Video" && item.Type != "Episode") {
|
|
|
|
|
$('#fldShortOverview', page).show();
|
|
|
|
|
} else {
|
|
|
|
|
$('#fldShortOverview', page).hide();
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-28 19:30:20 -07:00
|
|
|
|
if (item.MediaType == "Video" && item.Type != "Episode") {
|
|
|
|
|
$('#fldTagline', page).show();
|
|
|
|
|
} else {
|
|
|
|
|
$('#fldTagline', page).hide();
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-16 12:16:29 -07:00
|
|
|
|
Dashboard.getCurrentUser().done(function (user) {
|
|
|
|
|
|
2014-10-06 16:58:46 -07:00
|
|
|
|
var moreCommands = LibraryBrowser.getMoreCommands(item, user);
|
|
|
|
|
|
|
|
|
|
if (moreCommands.indexOf('delete') != -1) {
|
2014-03-25 14:13:55 -07:00
|
|
|
|
$('#fldDelete', page).show();
|
|
|
|
|
} else {
|
|
|
|
|
$('#fldDelete', page).hide();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Dashboard.hideLoadingMsg();
|
|
|
|
|
});
|
|
|
|
|
|
2013-05-05 18:15:48 -07:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-21 14:44:10 -07:00
|
|
|
|
function onExternalIdChange() {
|
|
|
|
|
|
|
|
|
|
var formatString = this.getAttribute('data-formatstring');
|
|
|
|
|
var buttonClass = this.getAttribute('data-buttonclass');
|
|
|
|
|
|
|
|
|
|
if (this.value) {
|
|
|
|
|
$('.' + buttonClass).attr('href', formatString.replace('{0}', this.value));
|
|
|
|
|
} else {
|
|
|
|
|
$('.' + buttonClass).attr('href', '#');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function loadExternalIds(page, item, externalIds) {
|
|
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
|
|
|
|
|
|
var providerIds = item.ProviderIds || {};
|
|
|
|
|
|
|
|
|
|
for (var i = 0, length = externalIds.length; i < length; i++) {
|
|
|
|
|
|
|
|
|
|
var idInfo = externalIds[i];
|
|
|
|
|
|
|
|
|
|
var id = "txt1" + idInfo.Key;
|
|
|
|
|
var buttonId = "btnOpen1" + idInfo.Key;
|
|
|
|
|
var formatString = idInfo.UrlFormatString || '';
|
|
|
|
|
|
|
|
|
|
html += '<div data-role="fieldcontain">';
|
2014-08-24 08:48:06 -07:00
|
|
|
|
var idLabel = Globalize.translate('LabelDynamicExternalId').replace('{0}', idInfo.Name);
|
|
|
|
|
html += '<label for="' + id + '">' + idLabel + '</label>';
|
2014-02-21 14:44:10 -07:00
|
|
|
|
|
|
|
|
|
html += '<div style="display: inline-block; width: 250px;">';
|
|
|
|
|
|
|
|
|
|
var value = providerIds[idInfo.Key] || '';
|
|
|
|
|
|
|
|
|
|
html += '<input class="txtExternalId" value="' + value + '" data-providerkey="' + idInfo.Key + '" data-formatstring="' + formatString + '" data-buttonclass="' + buttonId + '" id="' + id + '" data-mini="true" />';
|
|
|
|
|
|
|
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
|
|
if (formatString) {
|
|
|
|
|
html += '<a class="' + buttonId + '" href="#" target="_blank" data-icon="arrow-r" data-inline="true" data-iconpos="notext" data-role="button" style="float: none; width: 1.75em"></a>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
html += '</div>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var elem = $('.externalIds', page).html(html).trigger('create');
|
|
|
|
|
|
|
|
|
|
$('.txtExternalId', elem).on('change', onExternalIdChange).trigger('change');
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-05 18:15:48 -07:00
|
|
|
|
function setFieldVisibilities(page, item) {
|
2013-05-22 09:52:22 -07:00
|
|
|
|
|
2014-09-28 09:50:33 -07:00
|
|
|
|
if (item.Path && item.LocationType != 'Remote') {
|
2013-08-17 16:25:23 -07:00
|
|
|
|
$('#fldPath', page).show();
|
|
|
|
|
} else {
|
|
|
|
|
$('#fldPath', page).hide();
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-13 11:37:44 -07:00
|
|
|
|
if (item.Type == "Series") {
|
|
|
|
|
$('#fldSeriesRuntime', page).show();
|
|
|
|
|
} else {
|
|
|
|
|
$('#fldSeriesRuntime', page).hide();
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-05 18:15:48 -07:00
|
|
|
|
if (item.Type == "Series" || item.Type == "Person") {
|
|
|
|
|
$('#fldEndDate', page).show();
|
|
|
|
|
} else {
|
|
|
|
|
$('#fldEndDate', page).hide();
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-27 18:59:26 -07:00
|
|
|
|
if (item.Type == "Movie" || item.MediaType == "Game" || item.MediaType == "Trailer" || item.Type == "MusicVideo") {
|
2013-05-05 18:15:48 -07:00
|
|
|
|
$('#fldBudget', page).show();
|
|
|
|
|
$('#fldRevenue', page).show();
|
|
|
|
|
} else {
|
|
|
|
|
$('#fldBudget', page).hide();
|
|
|
|
|
$('#fldRevenue', page).hide();
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-16 09:03:28 -07:00
|
|
|
|
if (item.Type == "MusicAlbum") {
|
|
|
|
|
$('#albumAssociationMessage', page).show();
|
|
|
|
|
} else {
|
|
|
|
|
$('#albumAssociationMessage', page).hide();
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-22 15:01:37 -07:00
|
|
|
|
if (item.MediaType == "Game") {
|
|
|
|
|
$('#fldPlayers', page).show();
|
|
|
|
|
} else {
|
|
|
|
|
$('#fldPlayers', page).hide();
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-22 15:42:21 -07:00
|
|
|
|
if (item.Type == "Movie" || item.Type == "Trailer" || item.Type == "MusicVideo" || item.Type == "Series" || item.Type == "Game") {
|
2013-05-22 15:01:37 -07:00
|
|
|
|
$('#fldCriticRating', page).show();
|
|
|
|
|
$('#fldCriticRatingSummary', page).show();
|
|
|
|
|
} else {
|
|
|
|
|
$('#fldCriticRating', page).hide();
|
|
|
|
|
$('#fldCriticRatingSummary', page).hide();
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-14 22:01:58 -07:00
|
|
|
|
if (item.Type == "Movie") {
|
|
|
|
|
$('#fldAwardSummary', page).show();
|
|
|
|
|
} else {
|
|
|
|
|
$('#fldAwardSummary', page).hide();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (item.Type == "Movie" || item.Type == "Trailer") {
|
|
|
|
|
$('#fldMetascore', page).show();
|
|
|
|
|
} else {
|
|
|
|
|
$('#fldMetascore', page).hide();
|
|
|
|
|
}
|
|
|
|
|
|
2013-06-08 20:04:41 -07:00
|
|
|
|
if (item.Type == "Series") {
|
|
|
|
|
$('#fldStatus', page).show();
|
|
|
|
|
$('#fldAirDays', page).show();
|
|
|
|
|
$('#fldAirTime', page).show();
|
|
|
|
|
} else {
|
|
|
|
|
$('#fldStatus', page).hide();
|
|
|
|
|
$('#fldAirDays', page).hide();
|
|
|
|
|
$('#fldAirTime', page).hide();
|
|
|
|
|
}
|
2013-05-22 15:01:37 -07:00
|
|
|
|
|
2014-03-17 18:45:41 -07:00
|
|
|
|
if (item.MediaType == "Video" && item.Type != "TvChannel") {
|
2013-07-29 05:34:46 -07:00
|
|
|
|
$('#fld3dFormat', page).show();
|
|
|
|
|
} else {
|
|
|
|
|
$('#fld3dFormat', page).hide();
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-22 15:01:37 -07:00
|
|
|
|
if (item.Type == "Audio") {
|
2013-07-10 13:10:55 -07:00
|
|
|
|
$('#fldAlbumArtist', page).show();
|
|
|
|
|
} else {
|
|
|
|
|
$('#fldAlbumArtist', page).hide();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (item.Type == "Audio" || item.Type == "MusicVideo") {
|
2013-05-22 15:01:37 -07:00
|
|
|
|
$('#fldArtist', page).show();
|
|
|
|
|
$('#fldAlbum', page).show();
|
|
|
|
|
} else {
|
|
|
|
|
$('#fldArtist', page).hide();
|
|
|
|
|
$('#fldAlbum', page).hide();
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-08 13:33:24 -07:00
|
|
|
|
if (item.Type == "Episode") {
|
|
|
|
|
$('#collapsibleDvdEpisodeInfo', page).show();
|
|
|
|
|
} else {
|
|
|
|
|
$('#collapsibleDvdEpisodeInfo', page).hide();
|
2013-12-10 13:42:42 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (item.Type == "Episode" && item.ParentIndexNumber == 0) {
|
|
|
|
|
$('#collapsibleSpecialEpisodeInfo', page).show();
|
|
|
|
|
} else {
|
2013-12-08 13:33:24 -07:00
|
|
|
|
$('#collapsibleSpecialEpisodeInfo', page).hide();
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-17 18:45:41 -07:00
|
|
|
|
if (item.Type == "Person" || item.Type == "Genre" || item.Type == "Studio" || item.Type == "GameGenre" || item.Type == "MusicGenre" || item.Type == "TvChannel") {
|
2013-07-05 17:19:44 -07:00
|
|
|
|
$('#fldCommunityRating', page).hide();
|
2013-10-13 07:37:17 -07:00
|
|
|
|
$('#fldCommunityVoteCount', page).hide();
|
2013-07-05 17:19:44 -07:00
|
|
|
|
$('#genresCollapsible', page).hide();
|
2014-05-16 12:16:29 -07:00
|
|
|
|
$('#peopleCollapsible', page).hide();
|
2013-07-05 17:19:44 -07:00
|
|
|
|
$('#studiosCollapsible', page).hide();
|
2013-11-24 16:37:38 -07:00
|
|
|
|
|
2014-03-17 18:45:41 -07:00
|
|
|
|
if (item.Type == "TvChannel") {
|
2013-11-24 16:37:38 -07:00
|
|
|
|
$('#fldOfficialRating', page).show();
|
|
|
|
|
} else {
|
|
|
|
|
$('#fldOfficialRating', page).hide();
|
|
|
|
|
}
|
|
|
|
|
$('#fldCustomRating', page).hide();
|
2013-07-05 17:19:44 -07:00
|
|
|
|
} else {
|
|
|
|
|
$('#fldCommunityRating', page).show();
|
2013-10-13 07:37:17 -07:00
|
|
|
|
$('#fldCommunityVoteCount', page).show();
|
2013-07-05 17:19:44 -07:00
|
|
|
|
$('#genresCollapsible', page).show();
|
2014-05-16 12:16:29 -07:00
|
|
|
|
$('#peopleCollapsible', page).show();
|
2013-07-05 17:19:44 -07:00
|
|
|
|
$('#studiosCollapsible', page).show();
|
2013-11-24 16:37:38 -07:00
|
|
|
|
$('#fldOfficialRating', page).show();
|
|
|
|
|
$('#fldCustomRating', page).show();
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-01 17:28:16 -07:00
|
|
|
|
if (item.Type == "Movie" || item.Type == "Trailer" || item.Type == "MusicArtist") {
|
2014-07-05 08:01:29 -07:00
|
|
|
|
$('#countriesCollapsible', page).show();
|
|
|
|
|
} else {
|
|
|
|
|
$('#countriesCollapsible', page).hide();
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-17 18:45:41 -07:00
|
|
|
|
if (item.Type == "TvChannel") {
|
2013-11-24 16:37:38 -07:00
|
|
|
|
$('#tagsCollapsible', page).hide();
|
|
|
|
|
$('#metadataSettingsCollapsible', page).hide();
|
|
|
|
|
$('#fldPremiereDate', page).hide();
|
|
|
|
|
$('#fldSortName', page).hide();
|
|
|
|
|
$('#fldDateAdded', page).hide();
|
|
|
|
|
$('#fldYear', page).hide();
|
|
|
|
|
} else {
|
|
|
|
|
$('#tagsCollapsible', page).show();
|
|
|
|
|
$('#metadataSettingsCollapsible', page).show();
|
|
|
|
|
$('#fldPremiereDate', page).show();
|
|
|
|
|
$('#fldSortName', page).show();
|
|
|
|
|
$('#fldDateAdded', page).show();
|
|
|
|
|
$('#fldYear', page).show();
|
2014-03-01 10:53:56 -07:00
|
|
|
|
}
|
2014-03-01 15:34:27 -07:00
|
|
|
|
|
2014-03-08 11:17:05 -07:00
|
|
|
|
if (item.Type == "Movie" ||
|
|
|
|
|
item.Type == "Trailer" ||
|
|
|
|
|
item.Type == "Series" ||
|
|
|
|
|
item.Type == "Game" ||
|
|
|
|
|
item.Type == "BoxSet" ||
|
|
|
|
|
item.Type == "Person" ||
|
|
|
|
|
item.Type == "Book" ||
|
|
|
|
|
item.Type == "MusicAlbum" ||
|
|
|
|
|
item.Type == "MusicArtist") {
|
2014-05-16 12:16:29 -07:00
|
|
|
|
|
2014-03-01 10:53:56 -07:00
|
|
|
|
$('#btnIdentify', page).show();
|
|
|
|
|
} else {
|
|
|
|
|
$('#btnIdentify', page).hide();
|
2013-07-05 17:19:44 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-01-14 09:06:26 -07:00
|
|
|
|
if (item.Type == "Movie" || item.Type == "Trailer" || item.Type == "BoxSet") {
|
|
|
|
|
$('#keywordsCollapsible', page).show();
|
|
|
|
|
} else {
|
|
|
|
|
$('#keywordsCollapsible', page).hide();
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-17 18:45:41 -07:00
|
|
|
|
if (item.MediaType == "Video" && item.Type != "TvChannel") {
|
2014-01-19 11:08:31 -07:00
|
|
|
|
$('#fldSourceType', page).show();
|
2013-12-02 08:47:24 -07:00
|
|
|
|
} else {
|
|
|
|
|
$('#fldSourceType', page).hide();
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-05 17:19:44 -07:00
|
|
|
|
if (item.Type == "Person") {
|
2014-08-24 08:48:06 -07:00
|
|
|
|
$('#lblPremiereDate', page).html(Globalize.translate('LabelBirthDate'));
|
|
|
|
|
$('#lblYear', page).html(Globalize.translate('LabelBirthYear'));
|
|
|
|
|
$('#lblEndDate', page).html(Globalize.translate('LabelDeathDate'));
|
2013-07-29 11:33:48 -07:00
|
|
|
|
$('#fldPlaceOfBirth', page).show();
|
2013-07-05 17:19:44 -07:00
|
|
|
|
} else {
|
2014-08-24 08:48:06 -07:00
|
|
|
|
$('#lblPremiereDate', page).html(Globalize.translate('LabelReleaseDate'));
|
|
|
|
|
$('#lblYear', page).html(Globalize.translate('LabelYear'));
|
|
|
|
|
$('#lblEndDate', page).html(Globalize.translate('LabelEndDate'));
|
2013-07-29 11:33:48 -07:00
|
|
|
|
$('#fldPlaceOfBirth', page).hide();
|
2013-07-05 17:19:44 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-03-17 18:45:41 -07:00
|
|
|
|
if (item.MediaType == "Video" && item.Type != "TvChannel") {
|
2013-05-05 18:15:48 -07:00
|
|
|
|
$('#fldOriginalAspectRatio', page).show();
|
|
|
|
|
} else {
|
|
|
|
|
$('#fldOriginalAspectRatio', page).hide();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (item.Type == "Audio" || item.Type == "Episode" || item.Type == "Season") {
|
|
|
|
|
$('#fldIndexNumber', page).show();
|
|
|
|
|
|
|
|
|
|
if (item.Type == "Episode") {
|
2014-08-24 08:48:06 -07:00
|
|
|
|
$('#lblIndexNumber', page).html(Globalize.translate('LabelEpisodeNumber'));
|
2014-02-12 22:11:54 -07:00
|
|
|
|
} else if (item.Type == "Season") {
|
2014-08-24 08:48:06 -07:00
|
|
|
|
$('#lblIndexNumber', page).html(Globalize.translate('LabelSeasonNumber'));
|
2014-02-12 22:11:54 -07:00
|
|
|
|
} else if (item.Type == "Audio") {
|
2014-08-24 08:48:06 -07:00
|
|
|
|
$('#lblIndexNumber', page).html(Globalize.translate('LabelTrackNumber'));
|
2014-02-12 22:11:54 -07:00
|
|
|
|
} else {
|
2014-08-24 08:48:06 -07:00
|
|
|
|
$('#lblIndexNumber', page).html(Globalize.translate('LabelNumber'));
|
2013-05-05 18:15:48 -07:00
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$('#fldIndexNumber', page).hide();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (item.Type == "Audio" || item.Type == "Episode") {
|
|
|
|
|
$('#fldParentIndexNumber', page).show();
|
|
|
|
|
|
|
|
|
|
if (item.Type == "Episode") {
|
2014-08-24 08:48:06 -07:00
|
|
|
|
$('#lblParentIndexNumber', page).html(Globalize.translate('LabelSeasonNumber'));
|
2014-02-12 22:11:54 -07:00
|
|
|
|
} else if (item.Type == "Audio") {
|
2014-08-24 08:48:06 -07:00
|
|
|
|
$('#lblParentIndexNumber', page).html(Globalize.translate('LabelDiscNumber'));
|
2014-02-12 22:11:54 -07:00
|
|
|
|
} else {
|
2014-08-24 08:48:06 -07:00
|
|
|
|
$('#lblParentIndexNumber', page).html(Globalize.translate('LabelParentNumber'));
|
2013-05-05 18:15:48 -07:00
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$('#fldParentIndexNumber', page).hide();
|
|
|
|
|
}
|
2014-01-03 13:32:27 -07:00
|
|
|
|
|
|
|
|
|
if (item.Type == "Series") {
|
|
|
|
|
$('#fldDisplaySpecialsInline', page).show();
|
|
|
|
|
} else {
|
|
|
|
|
$('#fldDisplaySpecialsInline', page).hide();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (item.Type == "BoxSet") {
|
|
|
|
|
$('#fldDisplayOrder', page).show();
|
|
|
|
|
|
2014-08-24 08:48:06 -07:00
|
|
|
|
$('#labelDisplayOrder', page).html(Globalize.translate('LabelTitleDisplayOrder'));
|
|
|
|
|
$('#selectDisplayOrder', page).html('<option value="SortName">'+Globalize.translate('OptionSortName')+'</option><option value="PremiereDate">'+Globalize.translate('OptionReleaseDate')+'</option>').selectmenu('refresh');
|
2014-01-03 13:32:27 -07:00
|
|
|
|
} else {
|
2014-01-03 19:35:41 -07:00
|
|
|
|
$('#selectDisplayOrder', page).html('').selectmenu('refresh');
|
2014-01-03 13:32:27 -07:00
|
|
|
|
$('#fldDisplayOrder', page).hide();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var displaySettingFields = $('.fldDisplaySetting', page);
|
|
|
|
|
if (displaySettingFields.filter(function (index) {
|
|
|
|
|
|
|
|
|
|
return displaySettingFields[index].style.display != 'none';
|
|
|
|
|
|
|
|
|
|
}).length) {
|
|
|
|
|
$('#collapsibleDisplaySettings', page).show();
|
|
|
|
|
} else {
|
|
|
|
|
$('#collapsibleDisplaySettings', page).hide();
|
|
|
|
|
}
|
2013-05-05 18:15:48 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function fillItemInfo(page, item) {
|
|
|
|
|
|
|
|
|
|
ApiClient.getParentalRatings().done(function (result) {
|
2013-05-22 09:52:22 -07:00
|
|
|
|
|
2013-05-05 18:15:48 -07:00
|
|
|
|
var select = $('#selectOfficialRating', page);
|
|
|
|
|
|
2014-07-27 15:01:29 -07:00
|
|
|
|
populateRatings(result, select, item.OfficialRating);
|
2013-05-05 18:15:48 -07:00
|
|
|
|
|
|
|
|
|
select.val(item.OfficialRating || "").selectmenu('refresh');
|
2013-05-22 09:52:22 -07:00
|
|
|
|
|
2013-05-05 18:15:48 -07:00
|
|
|
|
select = $('#selectCustomRating', page);
|
|
|
|
|
|
2014-07-27 15:01:29 -07:00
|
|
|
|
populateRatings(result, select, item.CustomRating);
|
2013-05-05 18:15:48 -07:00
|
|
|
|
|
|
|
|
|
select.val(item.CustomRating || "").selectmenu('refresh');
|
|
|
|
|
});
|
2014-07-27 15:01:29 -07:00
|
|
|
|
|
2013-06-08 20:04:41 -07:00
|
|
|
|
var selectStatus = $('#selectStatus', page);
|
|
|
|
|
populateStatus(selectStatus);
|
|
|
|
|
selectStatus.val(item.Status || "").selectmenu('refresh');
|
2013-06-19 06:54:45 -07:00
|
|
|
|
|
2013-07-29 05:34:46 -07:00
|
|
|
|
$('#select3dFormat', page).val(item.Video3DFormat || "").selectmenu('refresh');
|
|
|
|
|
|
2014-02-12 22:11:54 -07:00
|
|
|
|
$('.chkAirDay', page).each(function () {
|
2014-02-09 10:44:25 -07:00
|
|
|
|
|
|
|
|
|
this.checked = (item.AirDays || []).indexOf(this.getAttribute('data-day')) != -1;
|
|
|
|
|
|
|
|
|
|
}).checkboxradio('refresh');
|
2014-02-12 22:11:54 -07:00
|
|
|
|
|
2014-05-16 12:16:29 -07:00
|
|
|
|
populateListView($('#listCountries', page), item.ProductionLocations || []);
|
2013-06-08 20:04:41 -07:00
|
|
|
|
populateListView($('#listGenres', page), item.Genres);
|
2014-06-04 09:15:44 -07:00
|
|
|
|
populatePeople(page, item.People || []);
|
2013-11-24 16:37:38 -07:00
|
|
|
|
|
|
|
|
|
populateListView($('#listStudios', page), (item.Studios || []).map(function (element) { return element.Name || ''; }));
|
|
|
|
|
|
2013-06-08 20:04:41 -07:00
|
|
|
|
populateListView($('#listTags', page), item.Tags);
|
2014-01-14 09:06:26 -07:00
|
|
|
|
populateListView($('#listKeywords', page), item.Keywords);
|
|
|
|
|
|
2014-02-18 22:21:03 -07:00
|
|
|
|
var lockData = (item.LockData || false);
|
|
|
|
|
var chkLockData = $("#chkLockData", page).attr('checked', lockData).checkboxradio('refresh');
|
|
|
|
|
if (chkLockData.checked()) {
|
2013-06-19 06:54:45 -07:00
|
|
|
|
$('#providerSettingsContainer', page).hide();
|
2014-02-18 22:21:03 -07:00
|
|
|
|
} else {
|
|
|
|
|
$('#providerSettingsContainer', page).show();
|
2013-06-14 22:30:48 -07:00
|
|
|
|
}
|
2013-09-13 08:26:43 -07:00
|
|
|
|
populateInternetProviderSettings(page, item, item.LockedFields);
|
2013-12-28 22:32:03 -07:00
|
|
|
|
|
2013-12-10 14:26:30 -07:00
|
|
|
|
$("#chkDisplaySpecialsInline", page).checked(item.DisplaySpecialsWithSeasons || false).checkboxradio('refresh');
|
2013-06-19 06:54:45 -07:00
|
|
|
|
|
2013-08-17 16:25:23 -07:00
|
|
|
|
$('#txtPath', page).val(item.Path || '');
|
2013-05-05 18:15:48 -07:00
|
|
|
|
$('#txtName', page).val(item.Name || "");
|
2013-06-08 20:04:41 -07:00
|
|
|
|
$('#txtOverview', page).val(item.Overview || "");
|
2014-06-24 14:45:21 -07:00
|
|
|
|
$('#txtShortOverview', page).val(item.ShortOverview || "");
|
2014-07-16 20:17:14 -07:00
|
|
|
|
$('#txtTagline', page).val((item.Taglines && item.Taglines.length ? item.Taglines[0] : ''));
|
2014-03-24 10:54:45 -07:00
|
|
|
|
$('#txtSortName', page).val(item.ForcedSortName || "");
|
2013-05-05 18:15:48 -07:00
|
|
|
|
$('#txtDisplayMediaType', page).val(item.DisplayMediaType || "");
|
|
|
|
|
$('#txtCommunityRating', page).val(item.CommunityRating || "");
|
2013-10-13 07:37:17 -07:00
|
|
|
|
$('#txtCommunityVoteCount', page).val(item.VoteCount || "");
|
2013-05-05 18:15:48 -07:00
|
|
|
|
$('#txtHomePageUrl', page).val(item.HomePageUrl || "");
|
|
|
|
|
|
2014-01-14 22:01:58 -07:00
|
|
|
|
$('#txtAwardSummary', page).val(item.AwardSummary || "");
|
|
|
|
|
$('#txtMetascore', page).val(item.Metascore || "");
|
|
|
|
|
|
2013-05-05 18:15:48 -07:00
|
|
|
|
$('#txtBudget', page).val(item.Budget || "");
|
|
|
|
|
$('#txtRevenue', page).val(item.Revenue || "");
|
|
|
|
|
|
|
|
|
|
$('#txtCriticRating', page).val(item.CriticRating || "");
|
|
|
|
|
$('#txtCriticRatingSummary', page).val(item.CriticRatingSummary || "");
|
|
|
|
|
|
2013-07-01 17:44:00 -07:00
|
|
|
|
$('#txtIndexNumber', page).val(('IndexNumber' in item) ? item.IndexNumber : "");
|
|
|
|
|
$('#txtParentIndexNumber', page).val(('ParentIndexNumber' in item) ? item.ParentIndexNumber : "");
|
2013-05-22 15:01:37 -07:00
|
|
|
|
$('#txtPlayers', page).val(item.Players || "");
|
|
|
|
|
|
2013-12-10 13:42:42 -07:00
|
|
|
|
$('#txtAbsoluteEpisodeNumber', page).val(('AbsoluteEpisodeNumber' in item) ? item.AbsoluteEpisodeNumber : "");
|
2013-12-08 13:33:24 -07:00
|
|
|
|
$('#txtDvdEpisodeNumber', page).val(('DvdEpisodeNumber' in item) ? item.DvdEpisodeNumber : "");
|
|
|
|
|
$('#txtDvdSeasonNumber', page).val(('DvdSeasonNumber' in item) ? item.DvdSeasonNumber : "");
|
|
|
|
|
$('#txtAirsBeforeSeason', page).val(('AirsBeforeSeasonNumber' in item) ? item.AirsBeforeSeasonNumber : "");
|
|
|
|
|
$('#txtAirsAfterSeason', page).val(('AirsAfterSeasonNumber' in item) ? item.AirsAfterSeasonNumber : "");
|
2013-12-14 18:17:57 -07:00
|
|
|
|
$('#txtAirsBeforeEpisode', page).val(('AirsBeforeEpisodeNumber' in item) ? item.AirsBeforeEpisodeNumber : "");
|
2013-12-08 13:33:24 -07:00
|
|
|
|
|
2013-05-22 15:01:37 -07:00
|
|
|
|
$('#txtAlbum', page).val(item.Album || "");
|
|
|
|
|
$('#txtAlbumArtist', page).val(item.AlbumArtist || "");
|
|
|
|
|
|
2014-01-03 13:43:44 -07:00
|
|
|
|
$('#selectDisplayOrder', page).val(item.DisplayOrder).selectmenu('refresh');
|
2014-01-03 13:32:27 -07:00
|
|
|
|
|
2013-05-22 15:01:37 -07:00
|
|
|
|
var artists = item.Artists || [];
|
2013-09-05 12:00:50 -07:00
|
|
|
|
$('#txtArtist', page).val(artists.join(';'));
|
2013-05-05 18:15:48 -07:00
|
|
|
|
|
|
|
|
|
var date;
|
|
|
|
|
|
2013-09-03 07:26:17 -07:00
|
|
|
|
if (item.DateCreated) {
|
|
|
|
|
try {
|
|
|
|
|
date = parseISO8601Date(item.DateCreated, { toLocal: true });
|
|
|
|
|
|
|
|
|
|
$('#txtDateAdded', page).val(date.toISOString().slice(0, 10));
|
2014-02-12 22:11:54 -07:00
|
|
|
|
} catch (e) {
|
2013-09-03 07:26:17 -07:00
|
|
|
|
$('#txtDateAdded', page).val('');
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$('#txtDateAdded', page).val('');
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-05 18:15:48 -07:00
|
|
|
|
if (item.PremiereDate) {
|
|
|
|
|
try {
|
|
|
|
|
date = parseISO8601Date(item.PremiereDate, { toLocal: true });
|
|
|
|
|
|
|
|
|
|
$('#txtPremiereDate', page).val(date.toISOString().slice(0, 10));
|
2014-02-12 22:11:54 -07:00
|
|
|
|
} catch (e) {
|
2013-05-05 18:15:48 -07:00
|
|
|
|
$('#txtPremiereDate', page).val('');
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$('#txtPremiereDate', page).val('');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (item.EndDate) {
|
|
|
|
|
try {
|
|
|
|
|
date = parseISO8601Date(item.EndDate, { toLocal: true });
|
|
|
|
|
|
|
|
|
|
$('#txtEndDate', page).val(date.toISOString().slice(0, 10));
|
2014-02-12 22:11:54 -07:00
|
|
|
|
} catch (e) {
|
2013-05-05 18:15:48 -07:00
|
|
|
|
$('#txtEndDate', page).val('');
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$('#txtEndDate', page).val('');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$('#txtProductionYear', page).val(item.ProductionYear || "");
|
2014-07-16 20:17:14 -07:00
|
|
|
|
$('#txtAirTime', page).val(item.AirTime || "");
|
2013-05-05 18:15:48 -07:00
|
|
|
|
|
2013-07-29 11:33:48 -07:00
|
|
|
|
var placeofBirth = item.ProductionLocations && item.ProductionLocations.length ? item.ProductionLocations[0] : '';
|
|
|
|
|
$('#txtPlaceOfBirth', page).val(placeofBirth);
|
|
|
|
|
|
2013-05-05 18:15:48 -07:00
|
|
|
|
$('#txtOriginalAspectRatio', page).val(item.AspectRatio || "");
|
2013-05-22 15:01:37 -07:00
|
|
|
|
|
2013-12-28 09:58:13 -07:00
|
|
|
|
$('#selectLanguage', page).val(item.PreferredMetadataLanguage || "").selectmenu('refresh');
|
|
|
|
|
$('#selectCountry', page).val(item.PreferredMetadataCountryCode || "").selectmenu('refresh');
|
|
|
|
|
|
2013-09-13 11:37:44 -07:00
|
|
|
|
if (item.RunTimeTicks) {
|
|
|
|
|
|
|
|
|
|
var minutes = item.RunTimeTicks / 600000000;
|
2013-09-23 13:27:49 -07:00
|
|
|
|
|
2013-09-26 07:47:57 -07:00
|
|
|
|
$('#txtSeriesRuntime', page).val(Math.round(minutes));
|
2013-09-13 11:37:44 -07:00
|
|
|
|
} else {
|
|
|
|
|
$('#txtSeriesRuntime', page).val("");
|
|
|
|
|
}
|
2013-05-05 18:15:48 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-06-04 09:15:44 -07:00
|
|
|
|
function populatePeople(page, people) {
|
2014-05-16 12:16:29 -07:00
|
|
|
|
|
|
|
|
|
var lastType = '';
|
|
|
|
|
var html = '';
|
|
|
|
|
|
2014-06-04 09:15:44 -07:00
|
|
|
|
var elem = $('#peopleList', page);
|
|
|
|
|
|
2014-05-16 12:16:29 -07:00
|
|
|
|
for (var i = 0, length = people.length; i < length; i++) {
|
|
|
|
|
|
|
|
|
|
var person = people[i];
|
|
|
|
|
|
2014-08-24 08:48:06 -07:00
|
|
|
|
var type = person.Type || Globalize.translate('PersonTypePerson');
|
2014-05-16 12:16:29 -07:00
|
|
|
|
|
|
|
|
|
if (type != lastType) {
|
|
|
|
|
html += '<li data-role="list-divider">' + type + '</li>';
|
|
|
|
|
lastType = type;
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-04 09:15:44 -07:00
|
|
|
|
html += '<li><a class="btnEditPerson" href="#" data-index="' + i + '">';
|
2014-05-16 12:16:29 -07:00
|
|
|
|
|
2014-07-16 20:17:14 -07:00
|
|
|
|
html += '<h3>' + (person.Name || '') + '</h3>';
|
2014-05-16 12:16:29 -07:00
|
|
|
|
|
|
|
|
|
if (person.Role && person.Role != lastType) {
|
|
|
|
|
html += '<p>' + (person.Role) + '</p>';
|
|
|
|
|
}
|
|
|
|
|
html += '</a>';
|
|
|
|
|
|
2014-07-16 20:17:14 -07:00
|
|
|
|
html += '<a class="btnDeletePerson" href="#" data-icon="delete" data-index="' + i + '">' + Globalize.translate('Delete') + '</a>';
|
2014-05-16 12:16:29 -07:00
|
|
|
|
|
|
|
|
|
html += '</li>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
elem.html(html).listview('refresh');
|
|
|
|
|
|
|
|
|
|
$('.btnDeletePerson', elem).on('click', function () {
|
|
|
|
|
|
|
|
|
|
var index = parseInt(this.getAttribute('data-index'));
|
|
|
|
|
currentItem.People.splice(index, 1);
|
|
|
|
|
|
2014-06-04 09:15:44 -07:00
|
|
|
|
populatePeople(page, currentItem.People);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('.btnEditPerson', elem).on('click', function () {
|
|
|
|
|
|
|
|
|
|
var index = parseInt(this.getAttribute('data-index'));
|
|
|
|
|
|
|
|
|
|
editPerson(page, currentItem.People[index], index);
|
2014-05-16 12:16:29 -07:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-04 09:15:44 -07:00
|
|
|
|
function editPerson(page, person, index) {
|
|
|
|
|
|
|
|
|
|
$('#popupEditPerson', page).popup("open");
|
|
|
|
|
|
|
|
|
|
$('#txtPersonName', page).val(person.Name || '');
|
|
|
|
|
$('#selectPersonType', page).val(person.Type || '').selectmenu('refresh');
|
|
|
|
|
$('#txtPersonRole', page).val(person.Role || '');
|
|
|
|
|
|
|
|
|
|
if (index == null) {
|
|
|
|
|
index = '';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$("#fldPersonIndex", page).val(index);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function savePersonInfo(page) {
|
|
|
|
|
|
|
|
|
|
$('#popupEditPerson', page).popup("close");
|
|
|
|
|
|
|
|
|
|
var index = $("#fldPersonIndex", page).val();
|
|
|
|
|
var person;
|
|
|
|
|
|
|
|
|
|
var isNew = true;
|
|
|
|
|
|
|
|
|
|
if (index) {
|
|
|
|
|
|
|
|
|
|
isNew = false;
|
|
|
|
|
index = parseInt(index);
|
|
|
|
|
|
|
|
|
|
person = currentItem.People[index];
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
person = {};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
person.Name = $('#txtPersonName', page).val();
|
|
|
|
|
person.Type = $('#selectPersonType', page).val();
|
|
|
|
|
person.Role = $('#txtPersonRole', page).val();
|
|
|
|
|
|
|
|
|
|
if (isNew) {
|
|
|
|
|
currentItem.People.push(person);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
populatePeople(page, currentItem.People);
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-27 15:01:29 -07:00
|
|
|
|
function populateRatings(allParentalRatings, select, currentValue) {
|
2013-05-05 18:15:48 -07:00
|
|
|
|
|
|
|
|
|
var html = "";
|
|
|
|
|
|
|
|
|
|
html += "<option value=''></option>";
|
|
|
|
|
|
|
|
|
|
var ratings = [];
|
|
|
|
|
var i, length, rating;
|
|
|
|
|
|
2014-07-27 15:01:29 -07:00
|
|
|
|
var currentValueFound = false;
|
|
|
|
|
|
2013-05-05 18:15:48 -07:00
|
|
|
|
for (i = 0, length = allParentalRatings.length; i < length; i++) {
|
|
|
|
|
|
|
|
|
|
rating = allParentalRatings[i];
|
|
|
|
|
|
|
|
|
|
ratings.push({ Name: rating.Name, Value: rating.Name });
|
2014-07-27 15:01:29 -07:00
|
|
|
|
|
|
|
|
|
if (rating.Name == currentValue) {
|
|
|
|
|
currentValueFound = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (currentValue && !currentValueFound) {
|
|
|
|
|
ratings.push({ Name: currentValue, Value: currentValue });
|
2013-05-05 18:15:48 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (i = 0, length = ratings.length; i < length; i++) {
|
|
|
|
|
|
|
|
|
|
rating = ratings[i];
|
|
|
|
|
|
|
|
|
|
html += "<option value='" + rating.Value + "'>" + rating.Name + "</option>";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
select.html(html).selectmenu("refresh");
|
|
|
|
|
}
|
2013-05-22 09:52:22 -07:00
|
|
|
|
|
2013-06-08 20:04:41 -07:00
|
|
|
|
function populateStatus(select) {
|
|
|
|
|
var html = "";
|
|
|
|
|
|
|
|
|
|
html += "<option value=''></option>";
|
2014-07-16 20:17:14 -07:00
|
|
|
|
html += "<option value='Continuing'>" + Globalize.translate('OptionContinuing') + "</option>";
|
|
|
|
|
html += "<option value='Ended'>" + Globalize.translate('OptionEnded') + "</option>";
|
2013-06-08 20:04:41 -07:00
|
|
|
|
select.html(html).selectmenu("refresh");
|
|
|
|
|
}
|
2013-06-19 06:54:45 -07:00
|
|
|
|
|
2013-06-11 21:09:37 -07:00
|
|
|
|
function populateListView(list, items, sortCallback) {
|
2013-07-29 07:30:01 -07:00
|
|
|
|
items = items || [];
|
2013-06-19 06:54:45 -07:00
|
|
|
|
if (typeof (sortCallback) === 'undefined') {
|
2013-06-11 21:09:37 -07:00
|
|
|
|
items.sort(function (a, b) { return a.toLowerCase().localeCompare(b.toLowerCase()); });
|
|
|
|
|
} else {
|
|
|
|
|
items = sortCallback(items);
|
|
|
|
|
}
|
2013-06-08 20:04:41 -07:00
|
|
|
|
var html = '';
|
|
|
|
|
for (var i = 0; i < items.length; i++) {
|
2013-11-28 11:27:29 -07:00
|
|
|
|
html += '<li data-mini="true"><a class="data">' + items[i] + '</a><a href="#" onclick="EditItemMetadataPage.removeElementFromListview(this)" class="btnRemoveFromEditorList"></a></li>';
|
2013-06-08 20:04:41 -07:00
|
|
|
|
}
|
|
|
|
|
list.html(html).listview('refresh');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function editableListViewValues(list) {
|
|
|
|
|
return list.find('a.data').map(function () { return $(this).text(); }).get();
|
|
|
|
|
}
|
2013-06-14 22:30:48 -07:00
|
|
|
|
|
|
|
|
|
function generateSliders(fields, type) {
|
|
|
|
|
var html = '';
|
|
|
|
|
for (var i = 0; i < fields.length; i++) {
|
2013-09-23 13:27:49 -07:00
|
|
|
|
|
2013-06-14 22:30:48 -07:00
|
|
|
|
var field = fields[i];
|
2013-09-13 08:26:43 -07:00
|
|
|
|
var name = field.name;
|
|
|
|
|
var value = field.value || field.name;
|
2013-06-14 22:30:48 -07:00
|
|
|
|
html += '<div data-role="fieldcontain">';
|
2014-07-16 20:17:14 -07:00
|
|
|
|
html += '<label for="lock' + value + '">' + name + '</label>';
|
2013-09-13 08:26:43 -07:00
|
|
|
|
html += '<select class="selectLockedField" id="lock' + value + '" data-role="slider" data-mini="true">';
|
2014-07-16 20:17:14 -07:00
|
|
|
|
html += '<option value="' + value + '">' + Globalize.translate('OptionOff') + '</option>';
|
|
|
|
|
html += '<option value="" selected="selected">' + Globalize.translate('OptionOn') + '</option>';
|
2013-06-14 22:30:48 -07:00
|
|
|
|
html += '</select>';
|
|
|
|
|
html += '</div>';
|
|
|
|
|
}
|
|
|
|
|
return html;
|
|
|
|
|
}
|
2014-02-12 22:11:54 -07:00
|
|
|
|
|
2013-09-13 08:26:43 -07:00
|
|
|
|
function populateInternetProviderSettings(page, item, lockedFields) {
|
2013-06-14 22:30:48 -07:00
|
|
|
|
var container = $('#providerSettingsContainer', page);
|
|
|
|
|
lockedFields = lockedFields || new Array();
|
2013-09-23 13:27:49 -07:00
|
|
|
|
|
2013-09-13 08:26:43 -07:00
|
|
|
|
var metadatafields = [
|
2014-07-16 20:17:14 -07:00
|
|
|
|
{ name: Globalize.translate('OptionName'), value: "Name" },
|
|
|
|
|
{ name: Globalize.translate('OptionOverview'), value: "Overview" },
|
|
|
|
|
{ name: Globalize.translate('OptionGenres'), value: "Genres" },
|
|
|
|
|
{ name: Globalize.translate('OptionParentalRating'), value: "OfficialRating" },
|
|
|
|
|
{ name: Globalize.translate('OptionPeople'), value: "Cast" }
|
2013-09-13 08:26:43 -07:00
|
|
|
|
];
|
2013-09-23 13:27:49 -07:00
|
|
|
|
|
2013-09-13 08:26:43 -07:00
|
|
|
|
if (item.Type == "Person") {
|
2014-07-16 20:17:14 -07:00
|
|
|
|
metadatafields.push({ name: Globalize.translate('OptionBirthLocation'), value: "ProductionLocations" });
|
2013-09-13 08:26:43 -07:00
|
|
|
|
} else {
|
2014-07-16 20:17:14 -07:00
|
|
|
|
metadatafields.push({ name: Globalize.translate('OptionProductionLocations'), value: "ProductionLocations" });
|
2013-09-13 08:26:43 -07:00
|
|
|
|
}
|
2013-09-23 13:27:49 -07:00
|
|
|
|
|
2013-09-13 08:26:43 -07:00
|
|
|
|
if (item.Type == "Series") {
|
2014-07-16 20:17:14 -07:00
|
|
|
|
metadatafields.push({ name: Globalize.translate('OptionRuntime'), value: "Runtime" });
|
2013-09-13 08:26:43 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-07-16 20:17:14 -07:00
|
|
|
|
metadatafields.push({ name: Globalize.translate('OptionStudios'), value: "Studios" });
|
|
|
|
|
metadatafields.push({ name: Globalize.translate('OptionTags'), value: "Tags" });
|
|
|
|
|
metadatafields.push({ name: Globalize.translate('OptionKeywords'), value: "Keywords" });
|
|
|
|
|
metadatafields.push({ name: Globalize.translate('OptionImages'), value: "Images" });
|
|
|
|
|
metadatafields.push({ name: Globalize.translate('OptionBackdrops'), value: "Backdrops" });
|
2013-12-28 22:32:03 -07:00
|
|
|
|
|
2013-12-15 11:33:07 -07:00
|
|
|
|
if (item.Type == "Game") {
|
2014-07-16 20:17:14 -07:00
|
|
|
|
metadatafields.push({ name: Globalize.translate('OptionScreenshots'), value: "Screenshots" });
|
2013-12-15 11:33:07 -07:00
|
|
|
|
}
|
2013-12-28 22:32:03 -07:00
|
|
|
|
|
2013-06-14 22:30:48 -07:00
|
|
|
|
var html = '';
|
2013-09-23 13:27:49 -07:00
|
|
|
|
|
2014-07-16 20:17:14 -07:00
|
|
|
|
html += "<h1>" + Globalize.translate('HeaderFields') + "</h1>";
|
|
|
|
|
html += "<p>" + Globalize.translate('HeaderFieldsHelp') + "</p>";
|
2013-06-14 22:30:48 -07:00
|
|
|
|
html += generateSliders(metadatafields, 'Fields');
|
|
|
|
|
container.html(html).trigger('create');
|
|
|
|
|
for (var fieldIndex = 0; fieldIndex < lockedFields.length; fieldIndex++) {
|
|
|
|
|
var field = lockedFields[fieldIndex];
|
|
|
|
|
$('#lock' + field).val(field).slider('refresh');
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-02-12 22:11:54 -07:00
|
|
|
|
|
2014-02-09 10:44:25 -07:00
|
|
|
|
function getSelectedAirDays(form) {
|
2014-02-12 22:11:54 -07:00
|
|
|
|
return $('.chkAirDay:checked', form).map(function () {
|
2014-02-09 10:44:25 -07:00
|
|
|
|
return this.getAttribute('data-day');
|
|
|
|
|
}).get();
|
|
|
|
|
}
|
2013-06-14 22:30:48 -07:00
|
|
|
|
|
2014-10-06 16:58:46 -07:00
|
|
|
|
function onDeleted(id) {
|
|
|
|
|
|
|
|
|
|
var elem = $('#' + id)[0];
|
2014-02-12 22:11:54 -07:00
|
|
|
|
|
2014-10-06 16:58:46 -07:00
|
|
|
|
$('.libraryTree').jstree("select_node", elem, true)
|
|
|
|
|
.jstree("delete_node", '#' + id);
|
2014-02-12 22:11:54 -07:00
|
|
|
|
}
|
|
|
|
|
|
2013-05-05 18:15:48 -07:00
|
|
|
|
function editItemMetadataPage() {
|
2013-05-27 19:36:51 -07:00
|
|
|
|
|
2013-05-05 18:15:48 -07:00
|
|
|
|
var self = this;
|
|
|
|
|
|
2013-05-22 09:52:22 -07:00
|
|
|
|
self.onSubmit = function () {
|
2013-05-05 18:15:48 -07:00
|
|
|
|
|
2013-05-27 19:36:51 -07:00
|
|
|
|
var form = this;
|
|
|
|
|
|
|
|
|
|
var item = {
|
2013-08-02 13:36:44 -07:00
|
|
|
|
Id: currentItem.Id,
|
2013-05-27 19:36:51 -07:00
|
|
|
|
Name: $('#txtName', form).val(),
|
2014-03-24 10:54:45 -07:00
|
|
|
|
ForcedSortName: $('#txtSortName', form).val(),
|
2013-05-27 19:36:51 -07:00
|
|
|
|
DisplayMediaType: $('#txtDisplayMediaType', form).val(),
|
|
|
|
|
CommunityRating: $('#txtCommunityRating', form).val(),
|
2013-12-08 10:57:18 -07:00
|
|
|
|
VoteCount: $('#txtCommunityVoteCount', form).val(),
|
2013-05-27 19:36:51 -07:00
|
|
|
|
HomePageUrl: $('#txtHomePageUrl', form).val(),
|
|
|
|
|
Budget: $('#txtBudget', form).val(),
|
|
|
|
|
Revenue: $('#txtRevenue', form).val(),
|
|
|
|
|
CriticRating: $('#txtCriticRating', form).val(),
|
|
|
|
|
CriticRatingSummary: $('#txtCriticRatingSummary', form).val(),
|
2014-03-04 22:41:58 -07:00
|
|
|
|
IndexNumber: $('#txtIndexNumber', form).val() || null,
|
2013-12-10 14:26:30 -07:00
|
|
|
|
DisplaySpecialsWithSeasons: $('#chkDisplaySpecialsInline', form).checked(),
|
2013-12-10 13:42:42 -07:00
|
|
|
|
AbsoluteEpisodeNumber: $('#txtAbsoluteEpisodeNumber', form).val(),
|
|
|
|
|
DvdEpisodeNumber: $('#txtDvdEpisodeNumber', form).val(),
|
|
|
|
|
DvdSeasonNumber: $('#txtDvdSeasonNumber', form).val(),
|
|
|
|
|
AirsBeforeSeasonNumber: $('#txtAirsBeforeSeason', form).val(),
|
|
|
|
|
AirsAfterSeasonNumber: $('#txtAirsAfterSeason', form).val(),
|
2013-12-14 18:17:57 -07:00
|
|
|
|
AirsBeforeEpisodeNumber: $('#txtAirsBeforeEpisode', form).val(),
|
2014-03-04 22:41:58 -07:00
|
|
|
|
ParentIndexNumber: $('#txtParentIndexNumber', form).val() || null,
|
2014-01-03 13:32:27 -07:00
|
|
|
|
DisplayOrder: $('#selectDisplayOrder', form).val(),
|
2013-05-27 19:36:51 -07:00
|
|
|
|
Players: $('#txtPlayers', form).val(),
|
|
|
|
|
Album: $('#txtAlbum', form).val(),
|
|
|
|
|
AlbumArtist: $('#txtAlbumArtist', form).val(),
|
2013-09-05 12:00:50 -07:00
|
|
|
|
Artists: $('#txtArtist', form).val().split(';'),
|
2014-01-14 22:01:58 -07:00
|
|
|
|
Metascore: $('#txtMetascore', form).val(),
|
|
|
|
|
AwardSummary: $('#txtAwardSummary', form).val(),
|
2013-06-08 20:04:41 -07:00
|
|
|
|
Overview: $('#txtOverview', form).val(),
|
2014-06-24 14:45:21 -07:00
|
|
|
|
ShortOverview: $('#txtShortOverview', form).val(),
|
2013-06-08 20:04:41 -07:00
|
|
|
|
Status: $('#selectStatus', form).val(),
|
2014-02-09 10:44:25 -07:00
|
|
|
|
AirDays: getSelectedAirDays(form),
|
2014-07-16 20:17:14 -07:00
|
|
|
|
AirTime: $('#txtAirTime', form).val(),
|
2013-06-08 20:04:41 -07:00
|
|
|
|
Genres: editableListViewValues($("#listGenres", form)),
|
2014-05-16 12:16:29 -07:00
|
|
|
|
ProductionLocations: editableListViewValues($("#listCountries", form)),
|
2013-06-08 20:04:41 -07:00
|
|
|
|
Tags: editableListViewValues($("#listTags", form)),
|
2014-01-14 09:06:26 -07:00
|
|
|
|
Keywords: editableListViewValues($("#listKeywords", form)),
|
2013-06-19 06:54:45 -07:00
|
|
|
|
Studios: editableListViewValues($("#listStudios", form)).map(function (element) { return { Name: element }; }),
|
2013-06-14 22:30:48 -07:00
|
|
|
|
|
2013-07-29 11:33:48 -07:00
|
|
|
|
PremiereDate: $('#txtPremiereDate', form).val() || null,
|
2013-09-03 07:26:17 -07:00
|
|
|
|
DateCreated: $('#txtDateAdded', form).val() || null,
|
2013-08-02 13:36:44 -07:00
|
|
|
|
EndDate: $('#txtEndDate', form).val() || null,
|
2013-05-27 19:36:51 -07:00
|
|
|
|
ProductionYear: $('#txtProductionYear', form).val(),
|
|
|
|
|
AspectRatio: $('#txtOriginalAspectRatio', form).val(),
|
2013-07-29 05:34:46 -07:00
|
|
|
|
Video3DFormat: $('#select3dFormat', form).val(),
|
2013-06-14 22:30:48 -07:00
|
|
|
|
|
2013-05-27 19:36:51 -07:00
|
|
|
|
OfficialRating: $('#selectOfficialRating', form).val(),
|
|
|
|
|
CustomRating: $('#selectCustomRating', form).val(),
|
2013-06-09 00:50:35 -07:00
|
|
|
|
People: currentItem.People,
|
2014-02-18 22:21:03 -07:00
|
|
|
|
LockData: $("#chkLockData", form).prop('checked'),
|
2013-09-13 08:26:43 -07:00
|
|
|
|
LockedFields: $('.selectLockedField', form).map(function () {
|
2013-06-14 22:30:48 -07:00
|
|
|
|
var value = $(this).val();
|
|
|
|
|
if (value != '') return value;
|
2014-02-09 14:11:11 -07:00
|
|
|
|
}).get()
|
2013-05-27 19:36:51 -07:00
|
|
|
|
};
|
|
|
|
|
|
2014-02-21 14:44:10 -07:00
|
|
|
|
item.ProviderIds = $.extend({}, currentItem.ProviderIds || {});
|
|
|
|
|
|
|
|
|
|
$('.txtExternalId', form).each(function () {
|
|
|
|
|
|
|
|
|
|
var providerkey = this.getAttribute('data-providerkey');
|
2014-02-12 22:11:54 -07:00
|
|
|
|
|
2014-02-21 14:44:10 -07:00
|
|
|
|
item.ProviderIds[providerkey] = this.value;
|
2014-02-09 14:11:11 -07:00
|
|
|
|
});
|
|
|
|
|
|
2013-12-28 09:58:13 -07:00
|
|
|
|
item.PreferredMetadataLanguage = $('#selectLanguage', form).val();
|
|
|
|
|
item.PreferredMetadataCountryCode = $('#selectCountry', form).val();
|
|
|
|
|
|
2013-07-29 11:33:48 -07:00
|
|
|
|
if (currentItem.Type == "Person") {
|
|
|
|
|
|
|
|
|
|
var placeOfBirth = $('#txtPlaceOfBirth', form).val();
|
|
|
|
|
|
|
|
|
|
item.ProductionLocations = placeOfBirth ? [placeOfBirth] : [];
|
|
|
|
|
}
|
2013-09-23 13:27:49 -07:00
|
|
|
|
|
2013-09-13 11:37:44 -07:00
|
|
|
|
if (currentItem.Type == "Series") {
|
2013-09-23 13:27:49 -07:00
|
|
|
|
|
2013-09-13 11:37:44 -07:00
|
|
|
|
// 600000000
|
|
|
|
|
var seriesRuntime = $('#txtSeriesRuntime', form).val();
|
|
|
|
|
item.RunTimeTicks = seriesRuntime ? (seriesRuntime * 600000000) : null;
|
|
|
|
|
}
|
2013-07-29 11:33:48 -07:00
|
|
|
|
|
2014-06-28 19:30:20 -07:00
|
|
|
|
var tagline = $('#txtTagline', form).val();
|
|
|
|
|
item.Taglines = tagline ? [tagline] : [];
|
|
|
|
|
|
2014-04-26 20:42:05 -07:00
|
|
|
|
ApiClient.updateItem(item).done(function () {
|
2013-05-27 19:36:51 -07:00
|
|
|
|
|
2014-07-16 20:17:14 -07:00
|
|
|
|
Dashboard.alert(Globalize.translate('MessageItemSaved'));
|
2013-05-27 19:36:51 -07:00
|
|
|
|
|
2014-03-04 22:41:58 -07:00
|
|
|
|
MetadataEditor.getItemPromise().done(function (i) {
|
|
|
|
|
$(form).parents('.page').trigger('itemsaved', [i]);
|
|
|
|
|
});
|
|
|
|
|
|
2013-05-27 19:36:51 -07:00
|
|
|
|
});
|
2013-05-05 18:15:48 -07:00
|
|
|
|
|
|
|
|
|
return false;
|
2013-06-19 06:54:45 -07:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
self.addElementToEditableListview = function (source, sortCallback) {
|
2013-06-11 21:09:37 -07:00
|
|
|
|
var input = $(source).parent().find('input[type="text"], select');
|
2013-06-09 00:50:35 -07:00
|
|
|
|
var text = input.val();
|
|
|
|
|
input.val('');
|
|
|
|
|
if (text == '') return;
|
|
|
|
|
var list = $(source).parents('[data-role="editableListviewContainer"]').find('ul[data-role="listview"]');
|
|
|
|
|
var items = editableListViewValues(list);
|
|
|
|
|
items.push(text);
|
2013-06-11 21:09:37 -07:00
|
|
|
|
populateListView(list, items, sortCallback);
|
2013-06-09 00:50:35 -07:00
|
|
|
|
};
|
2013-06-19 06:54:45 -07:00
|
|
|
|
|
2013-06-14 22:30:48 -07:00
|
|
|
|
self.setProviderSettingsContainerVisibility = function (source) {
|
2014-02-11 20:46:27 -07:00
|
|
|
|
if (!$(source).prop('checked')) {
|
2013-06-14 22:30:48 -07:00
|
|
|
|
$('#providerSettingsContainer').show();
|
|
|
|
|
} else {
|
|
|
|
|
$('#providerSettingsContainer').hide();
|
|
|
|
|
}
|
|
|
|
|
};
|
2013-06-19 06:54:45 -07:00
|
|
|
|
|
|
|
|
|
self.removeElementFromListview = function (source) {
|
2013-06-09 00:50:35 -07:00
|
|
|
|
var list = $(source).parents('ul[data-role="listview"]');
|
|
|
|
|
$(source).parent().remove();
|
|
|
|
|
list.listview('refresh');
|
|
|
|
|
};
|
2014-02-12 22:11:54 -07:00
|
|
|
|
|
|
|
|
|
self.onDeleteFormSubmitted = function () {
|
|
|
|
|
|
|
|
|
|
var page = $(this).parents('.page');
|
|
|
|
|
|
|
|
|
|
if ($('#fldChallengeValue', page).val() != $('#txtDeleteTest', page).val()) {
|
2014-07-16 20:17:14 -07:00
|
|
|
|
Dashboard.alert(Globalize.translate('MessageValueNotCorrect'));
|
2014-02-12 22:11:54 -07:00
|
|
|
|
} else {
|
|
|
|
|
performDelete(page);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
};
|
2014-03-01 15:34:27 -07:00
|
|
|
|
|
|
|
|
|
self.onIdentificationFormSubmitted = function () {
|
|
|
|
|
|
|
|
|
|
var page = $(this).parents('.page');
|
|
|
|
|
|
|
|
|
|
searchForIdentificationResults(page);
|
|
|
|
|
return false;
|
|
|
|
|
};
|
2014-06-04 09:15:44 -07:00
|
|
|
|
|
2014-07-04 22:21:13 -07:00
|
|
|
|
self.onRefreshFormSubmit = function () {
|
2014-07-03 19:22:57 -07:00
|
|
|
|
var page = $(this).parents('.page');
|
|
|
|
|
|
|
|
|
|
refreshFromPopupOptions(page);
|
|
|
|
|
return false;
|
|
|
|
|
};
|
|
|
|
|
|
2014-06-04 09:15:44 -07:00
|
|
|
|
self.onPersonInfoFormSubmit = function () {
|
|
|
|
|
|
|
|
|
|
var page = $(this).parents('.page');
|
|
|
|
|
|
|
|
|
|
savePersonInfo(page);
|
|
|
|
|
return false;
|
|
|
|
|
};
|
2013-05-05 18:15:48 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
window.EditItemMetadataPage = new editItemMetadataPage();
|
|
|
|
|
|
2014-03-01 15:34:27 -07:00
|
|
|
|
function showIdentificationForm(page) {
|
|
|
|
|
|
|
|
|
|
var item = currentItem;
|
|
|
|
|
|
2014-07-01 22:16:59 -07:00
|
|
|
|
ApiClient.getJSON(ApiClient.getUrl("Items/" + item.Id + "/ExternalIdInfos")).done(function (idList) {
|
2014-03-01 15:34:27 -07:00
|
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
|
|
|
|
|
|
var providerIds = item.ProviderIds || {};
|
|
|
|
|
|
|
|
|
|
for (var i = 0, length = idList.length; i < length; i++) {
|
|
|
|
|
|
|
|
|
|
var idInfo = idList[i];
|
|
|
|
|
|
|
|
|
|
var id = "txtLookup" + idInfo.Key;
|
|
|
|
|
|
|
|
|
|
html += '<div data-role="fieldcontain">';
|
2014-08-24 08:48:06 -07:00
|
|
|
|
|
|
|
|
|
var idLabel = Globalize.translate('LabelDynamicExternalId').replace('{0}', idInfo.Name);
|
|
|
|
|
html += '<label for="' + id + '">' + idLabel + '</label>';
|
2014-03-01 15:34:27 -07:00
|
|
|
|
|
|
|
|
|
var value = providerIds[idInfo.Key] || '';
|
|
|
|
|
|
|
|
|
|
html += '<input class="txtLookupId" value="' + value + '" data-providerkey="' + idInfo.Key + '" id="' + id + '" data-mini="true" />';
|
|
|
|
|
|
|
|
|
|
html += '</div>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$('#txtLookupName', page).val(item.Name);
|
2014-03-02 08:42:21 -07:00
|
|
|
|
|
2014-03-01 15:34:27 -07:00
|
|
|
|
if (item.Type == "Person" || item.Type == "BoxSet") {
|
|
|
|
|
|
|
|
|
|
$('.fldLookupYear', page).hide();
|
|
|
|
|
$('#txtLookupYear', page).val('');
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
$('.fldLookupYear', page).show();
|
|
|
|
|
$('#txtLookupYear', page).val(item.ProductionYear);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$('.identifyProviderIds', page).html(html).trigger('create');
|
|
|
|
|
|
2014-08-24 08:48:06 -07:00
|
|
|
|
$('.identificationHeader', page).html(Globalize.translate('HeaderIdentify'));
|
2014-03-01 15:34:27 -07:00
|
|
|
|
|
|
|
|
|
$('.popupIdentifyForm', page).show();
|
|
|
|
|
$('.identificationSearchResults', page).hide();
|
|
|
|
|
$('.btnSearchAgain', page).hide();
|
|
|
|
|
|
|
|
|
|
$('.popupIdentify', page).popup('open');
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function searchForIdentificationResults(page) {
|
|
|
|
|
|
|
|
|
|
var lookupInfo = {
|
|
|
|
|
ProviderIds: {}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
$('.identifyField', page).each(function () {
|
|
|
|
|
|
|
|
|
|
var value = this.value;
|
|
|
|
|
|
|
|
|
|
if (value) {
|
|
|
|
|
|
|
|
|
|
if (this.type == 'number') {
|
|
|
|
|
value = parseInt(value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
lookupInfo[this.getAttribute('data-lookup')] = value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var hasId = false;
|
|
|
|
|
|
|
|
|
|
$('.txtLookupId', page).each(function () {
|
|
|
|
|
|
|
|
|
|
var value = this.value;
|
|
|
|
|
|
|
|
|
|
if (value) {
|
|
|
|
|
hasId = true;
|
|
|
|
|
}
|
|
|
|
|
lookupInfo.ProviderIds[this.getAttribute('data-providerkey')] = value;
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (!hasId && !lookupInfo.Name) {
|
2014-07-16 20:17:14 -07:00
|
|
|
|
Dashboard.alert(Globalize.translate('MessagePleaseEnterNameOrId'));
|
2014-03-01 15:34:27 -07:00
|
|
|
|
return;
|
|
|
|
|
}
|
2014-03-04 22:41:58 -07:00
|
|
|
|
|
2014-03-02 08:42:21 -07:00
|
|
|
|
if (currentItem.GameSystem) {
|
|
|
|
|
lookupInfo.GameSystem = currentItem.GameSystem;
|
|
|
|
|
}
|
2014-03-01 15:34:27 -07:00
|
|
|
|
|
|
|
|
|
lookupInfo = {
|
|
|
|
|
SearchInfo: lookupInfo,
|
|
|
|
|
IncludeDisabledProviders: true
|
|
|
|
|
};
|
|
|
|
|
|
2014-03-02 08:42:21 -07:00
|
|
|
|
Dashboard.showLoadingMsg();
|
|
|
|
|
|
2014-07-01 22:16:59 -07:00
|
|
|
|
ApiClient.ajax({
|
2014-03-01 15:34:27 -07:00
|
|
|
|
type: "POST",
|
|
|
|
|
url: ApiClient.getUrl("Items/RemoteSearch/" + currentItem.Type),
|
|
|
|
|
data: JSON.stringify(lookupInfo),
|
|
|
|
|
contentType: "application/json"
|
|
|
|
|
|
|
|
|
|
}).done(function (results) {
|
|
|
|
|
|
2014-03-02 08:42:21 -07:00
|
|
|
|
Dashboard.hideLoadingMsg();
|
2014-03-01 15:34:27 -07:00
|
|
|
|
showIdentificationSearchResults(page, results);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getSearchImageDisplayUrl(url, provider) {
|
|
|
|
|
return ApiClient.getUrl("Items/RemoteSearch/Image", { imageUrl: url, ProviderName: provider });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function showIdentificationSearchResults(page, results) {
|
|
|
|
|
|
|
|
|
|
$('.popupIdentifyForm', page).hide();
|
|
|
|
|
$('.identificationSearchResults', page).show();
|
|
|
|
|
$('.btnSearchAgain', page).show();
|
|
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
|
|
|
|
|
|
for (var i = 0, length = results.length; i < length; i++) {
|
|
|
|
|
|
|
|
|
|
var result = results[i];
|
|
|
|
|
|
|
|
|
|
var cssClass = "searchImageContainer remoteImageContainer";
|
|
|
|
|
|
|
|
|
|
if (currentItem.Type == "Episode") {
|
|
|
|
|
cssClass += " searchBackdropImageContainer";
|
|
|
|
|
}
|
|
|
|
|
else if (currentItem.Type == "MusicAlbum" || currentItem.Type == "MusicArtist") {
|
|
|
|
|
cssClass += " searchDiscImageContainer";
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
cssClass += " searchPosterImageContainer";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
html += '<div class="' + cssClass + '">';
|
|
|
|
|
|
|
|
|
|
if (result.ImageUrl) {
|
|
|
|
|
var displayUrl = getSearchImageDisplayUrl(result.ImageUrl, result.SearchProviderName);
|
|
|
|
|
|
2014-03-02 08:42:21 -07:00
|
|
|
|
html += '<a href="#" class="searchImage" data-index="' + i + '" style="background-image:url(\'' + displayUrl + '\');">';
|
2014-03-01 15:34:27 -07:00
|
|
|
|
} else {
|
2014-03-02 08:42:21 -07:00
|
|
|
|
|
2014-03-02 11:01:46 -07:00
|
|
|
|
html += '<a href="#" class="searchImage" data-index="' + i + '" style="background-image:url(\'css/images/items/list/remotesearch.png\');background-position: center center;">';
|
2014-03-01 15:34:27 -07:00
|
|
|
|
}
|
|
|
|
|
html += '</a>';
|
|
|
|
|
|
|
|
|
|
html += '<div class="remoteImageDetails">';
|
|
|
|
|
html += result.Name;
|
|
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
|
|
html += '<div class="remoteImageDetails">';
|
|
|
|
|
html += result.ProductionYear || ' ';
|
|
|
|
|
html += '</div>';
|
2014-03-04 22:41:58 -07:00
|
|
|
|
|
2014-03-02 22:11:03 -07:00
|
|
|
|
if (result.GameSystem) {
|
|
|
|
|
html += '<div class="remoteImageDetails">';
|
|
|
|
|
html += result.GameSystem;
|
|
|
|
|
html += '</div>';
|
|
|
|
|
}
|
2014-03-01 15:34:27 -07:00
|
|
|
|
|
|
|
|
|
html += '</div>';
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-02 08:42:21 -07:00
|
|
|
|
var elem = $('.identificationSearchResultList', page).html(html).trigger('create');
|
|
|
|
|
|
|
|
|
|
$('.searchImage', elem).on('click', function () {
|
|
|
|
|
|
|
|
|
|
Dashboard.showLoadingMsg();
|
2014-03-04 22:41:58 -07:00
|
|
|
|
|
2014-03-02 08:42:21 -07:00
|
|
|
|
var index = parseInt(this.getAttribute('data-index'));
|
|
|
|
|
|
|
|
|
|
var currentResult = results[index];
|
|
|
|
|
|
2014-07-01 22:16:59 -07:00
|
|
|
|
ApiClient.ajax({
|
2014-03-02 08:42:21 -07:00
|
|
|
|
type: "POST",
|
|
|
|
|
url: ApiClient.getUrl("Items/RemoteSearch/Apply/" + currentItem.Id),
|
|
|
|
|
data: JSON.stringify(currentResult),
|
|
|
|
|
contentType: "application/json"
|
|
|
|
|
|
|
|
|
|
}).done(function () {
|
|
|
|
|
|
|
|
|
|
Dashboard.hideLoadingMsg();
|
|
|
|
|
|
|
|
|
|
$('.popupIdentify', page).popup('close');
|
|
|
|
|
|
|
|
|
|
reload(page);
|
|
|
|
|
});
|
|
|
|
|
});
|
2014-03-01 15:34:27 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-07-03 19:22:57 -07:00
|
|
|
|
function performAdvancedRefresh(page) {
|
2013-05-05 18:15:48 -07:00
|
|
|
|
|
2014-07-03 19:22:57 -07:00
|
|
|
|
$('.popupAdvancedRefresh', page).popup('open');
|
2013-05-05 18:15:48 -07:00
|
|
|
|
|
2014-07-03 19:22:57 -07:00
|
|
|
|
$('#selectMetadataRefreshMode', page).val('all').selectmenu('refresh');
|
|
|
|
|
$('#selectImageRefreshMode', page).val('missing').selectmenu('refresh');
|
|
|
|
|
}
|
2014-07-04 22:21:13 -07:00
|
|
|
|
|
2014-10-20 13:23:40 -07:00
|
|
|
|
function performSimpleRefresh(page) {
|
|
|
|
|
|
|
|
|
|
refreshWithOptions(page, {
|
|
|
|
|
|
|
|
|
|
Recursive: true,
|
|
|
|
|
ImageRefreshMode: 'FullRefresh',
|
|
|
|
|
MetadataRefreshMode: 'FullRefresh',
|
|
|
|
|
ReplaceAllMetadata: true
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-03 19:22:57 -07:00
|
|
|
|
function refreshFromPopupOptions(page) {
|
2014-07-04 22:21:13 -07:00
|
|
|
|
|
2014-07-03 19:22:57 -07:00
|
|
|
|
var metadataRefreshMode = $('#selectMetadataRefreshMode', page).val();
|
|
|
|
|
var imageRefreshMode = $('#selectImageRefreshMode', page).val();
|
|
|
|
|
|
|
|
|
|
refreshWithOptions(page, {
|
|
|
|
|
|
|
|
|
|
Recursive: true,
|
|
|
|
|
ImageRefreshMode: imageRefreshMode == 'none' ? 'None' : 'FullRefresh',
|
2014-07-04 22:21:13 -07:00
|
|
|
|
MetadataRefreshMode: metadataRefreshMode == 'none' ? 'None' : (metadataRefreshMode == 'local' ? 'ValidationOnly' : 'FullRefresh'),
|
2014-07-18 12:07:28 -07:00
|
|
|
|
ReplaceAllImages: imageRefreshMode == 'all',
|
2014-07-03 19:22:57 -07:00
|
|
|
|
ReplaceAllMetadata: metadataRefreshMode == 'all'
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('.popupAdvancedRefresh', page).popup('close');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function refreshWithOptions(page, options) {
|
|
|
|
|
$('#refreshLoading', page).show();
|
|
|
|
|
|
|
|
|
|
$('#btnDelete', page).buttonEnabled(false);
|
2014-07-04 22:21:13 -07:00
|
|
|
|
$('.btnRefresh', page).buttonEnabled(false);
|
2014-07-03 19:22:57 -07:00
|
|
|
|
$('.btnSave', page).buttonEnabled(false);
|
2013-05-22 12:49:12 -07:00
|
|
|
|
|
2014-07-03 19:22:57 -07:00
|
|
|
|
ApiClient.refreshItem(currentItem.Id, options).done(function () {
|
2013-05-22 12:49:12 -07:00
|
|
|
|
|
2014-07-03 19:22:57 -07:00
|
|
|
|
reload(page);
|
|
|
|
|
});
|
|
|
|
|
}
|
2013-05-22 12:49:12 -07:00
|
|
|
|
|
2014-07-03 19:22:57 -07:00
|
|
|
|
$(document).on('pageinit', "#editItemMetadataPage", function () {
|
2013-07-22 10:23:48 -07:00
|
|
|
|
|
2014-07-03 19:22:57 -07:00
|
|
|
|
var page = this;
|
2014-06-14 19:24:04 -07:00
|
|
|
|
|
2014-07-04 22:21:13 -07:00
|
|
|
|
$('.btnRefreshAdvanced', this).on('click', function () {
|
2014-07-03 19:22:57 -07:00
|
|
|
|
|
2014-07-04 22:21:13 -07:00
|
|
|
|
performAdvancedRefresh(page);
|
2013-05-22 12:49:12 -07:00
|
|
|
|
});
|
|
|
|
|
|
2014-10-20 13:23:40 -07:00
|
|
|
|
$('.btnSimpleRefresh', this).on('click', function () {
|
|
|
|
|
|
|
|
|
|
performSimpleRefresh(page);
|
|
|
|
|
});
|
|
|
|
|
|
2014-03-01 15:34:27 -07:00
|
|
|
|
$('#btnIdentify', page).on('click', function () {
|
|
|
|
|
|
|
|
|
|
showIdentificationForm(page);
|
|
|
|
|
});
|
|
|
|
|
|
2014-03-02 08:42:21 -07:00
|
|
|
|
$('.btnSearchAgain', page).on('click', function () {
|
|
|
|
|
|
2014-03-01 15:34:27 -07:00
|
|
|
|
$('.popupIdentifyForm', page).show();
|
|
|
|
|
$('.identificationSearchResults', page).hide();
|
|
|
|
|
$('.btnSearchAgain', page).hide();
|
|
|
|
|
});
|
|
|
|
|
|
2014-02-12 22:11:54 -07:00
|
|
|
|
$('#btnDelete', this).on('click', function () {
|
2014-10-06 16:58:46 -07:00
|
|
|
|
LibraryBrowser.deleteItem(currentItem.Id);
|
2013-10-18 14:12:05 -07:00
|
|
|
|
});
|
|
|
|
|
|
2013-08-02 13:36:44 -07:00
|
|
|
|
$('.libraryTree', page).on('itemclicked', function (event, data) {
|
2013-05-05 18:15:48 -07:00
|
|
|
|
|
2013-08-02 13:36:44 -07:00
|
|
|
|
if (data.id != currentItem.Id) {
|
2013-05-05 18:15:48 -07:00
|
|
|
|
|
2013-08-02 13:36:44 -07:00
|
|
|
|
MetadataEditor.currentItemId = data.id;
|
|
|
|
|
MetadataEditor.currentItemName = data.itemName;
|
|
|
|
|
MetadataEditor.currentItemType = data.itemType;
|
|
|
|
|
//Dashboard.navigate('edititemmetadata.html?id=' + data.id);
|
|
|
|
|
|
2013-12-24 11:37:29 -07:00
|
|
|
|
//$.mobile.urlHistory.ignoreNextHashChange = true;
|
2013-08-02 13:36:44 -07:00
|
|
|
|
window.location.hash = 'editItemMetadataPage?id=' + data.id;
|
2013-05-05 18:15:48 -07:00
|
|
|
|
|
2013-08-02 13:36:44 -07:00
|
|
|
|
reload(page);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2014-06-04 09:15:44 -07:00
|
|
|
|
$("#btnAddPerson", page).on('click', function (event, data) {
|
|
|
|
|
|
|
|
|
|
editPerson(page, {});
|
|
|
|
|
});
|
|
|
|
|
|
2013-08-02 13:36:44 -07:00
|
|
|
|
}).on('pagebeforeshow', "#editItemMetadataPage", function () {
|
2013-05-05 18:15:48 -07:00
|
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
|
2013-08-02 13:36:44 -07:00
|
|
|
|
reload(page);
|
|
|
|
|
|
2014-10-06 16:58:46 -07:00
|
|
|
|
$(LibraryBrowser).on('itemdeleting.editor', function (e, itemId) {
|
|
|
|
|
|
|
|
|
|
if (currentItem && currentItem.Id == itemId) {
|
|
|
|
|
Dashboard.navigate('edititemmetadata.html');
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}).on('pagehide', "#editItemMetadataPage", function () {
|
|
|
|
|
|
|
|
|
|
$(LibraryBrowser).off('itemdeleting.editor');
|
|
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
|
|
|
|
|
reload(page);
|
|
|
|
|
|
2013-05-05 18:15:48 -07:00
|
|
|
|
});
|
|
|
|
|
|
2013-08-02 13:36:44 -07:00
|
|
|
|
})(jQuery, document, window);
|
|
|
|
|
|