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);
|
|
|
|
|
|
|
|
|
|
$('#btnEditPeople', page).attr('href', 'edititempeople.html?' + query);
|
|
|
|
|
$('#btnEditImages', page).attr('href', 'edititemimages.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-02-21 14:44:10 -07:00
|
|
|
|
$.getJSON(ApiClient.getUrl("Items/" + item.Id + "/ExternalIdInfos")).done(function (idList) {
|
|
|
|
|
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
|
|
|
|
|
2013-08-06 09:48:27 -07:00
|
|
|
|
if (item.LocationType == "Offline") {
|
2013-11-27 12:04:19 -07:00
|
|
|
|
$('.saveButtonContainer', page).hide();
|
2013-08-06 09:48:27 -07:00
|
|
|
|
} else {
|
2013-11-27 12:04:19 -07:00
|
|
|
|
$('.saveButtonContainer', page).show();
|
2013-08-06 09:48:27 -07:00
|
|
|
|
}
|
|
|
|
|
|
2013-12-24 11:37:29 -07:00
|
|
|
|
$('#btnRefresh', page).buttonEnabled(true);
|
|
|
|
|
$('#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-17 18:45:41 -07:00
|
|
|
|
if (item.Type == "Person" || item.Type == "Studio" || item.Type == "MusicGenre" || item.Type == "Genre" || item.Type == "MusicArtist" || item.Type == "GameGenre" || item.Type == "TvChannel" || item.Type == "BoxSet") {
|
2013-08-02 13:36:44 -07:00
|
|
|
|
$('#btnEditPeople', page).hide();
|
2013-06-27 11:40:50 -07:00
|
|
|
|
} else {
|
2013-08-02 13:36:44 -07:00
|
|
|
|
$('#btnEditPeople', page).show();
|
2013-06-27 11:40:50 -07:00
|
|
|
|
}
|
2013-05-05 18:15:48 -07:00
|
|
|
|
|
2014-03-07 08:53:23 -07:00
|
|
|
|
if (item.Type == "BoxSet") {
|
|
|
|
|
$('#btnEditCollectionTitles', page).show();
|
|
|
|
|
} else {
|
|
|
|
|
$('#btnEditCollectionTitles', page).hide();
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-25 14:13:55 -07:00
|
|
|
|
Dashboard.getCurrentUser().done(function(user) {
|
|
|
|
|
|
|
|
|
|
if (user.Configuration.EnableContentDeletion &&
|
|
|
|
|
item.Type != "TvChannel" &&
|
|
|
|
|
item.Type != "Genre" &&
|
|
|
|
|
item.Type != "Studio" &&
|
|
|
|
|
item.Type != "MusicGenre" &&
|
|
|
|
|
item.Type != "GameGenre" &&
|
|
|
|
|
item.Type != "Person" &&
|
|
|
|
|
item.Type != "MusicArtist" &&
|
|
|
|
|
item.Type != "CollectionFolder") {
|
|
|
|
|
$('#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">';
|
|
|
|
|
html += '<label for="' + id + '">' + idInfo.Name + ' Id:</label>';
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
2013-08-17 16:25:23 -07:00
|
|
|
|
if (item.Path) {
|
|
|
|
|
$('#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();
|
|
|
|
|
$('#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();
|
|
|
|
|
$('#studiosCollapsible', page).show();
|
2013-11-24 16:37:38 -07:00
|
|
|
|
$('#fldOfficialRating', page).show();
|
|
|
|
|
$('#fldCustomRating', page).show();
|
|
|
|
|
}
|
|
|
|
|
|
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 == "AdultVideo" ||
|
|
|
|
|
item.Type == "Series" ||
|
|
|
|
|
item.Type == "Game" ||
|
|
|
|
|
item.Type == "BoxSet" ||
|
|
|
|
|
item.Type == "Person" ||
|
|
|
|
|
item.Type == "Book" ||
|
|
|
|
|
item.Type == "MusicAlbum" ||
|
|
|
|
|
item.Type == "MusicArtist") {
|
|
|
|
|
|
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") {
|
|
|
|
|
$('#lblPremiereDate', page).html('Date of birth');
|
|
|
|
|
$('#lblYear', page).html('Birth year');
|
|
|
|
|
$('#lblEndDate', page).html('Death date');
|
2013-07-29 11:33:48 -07:00
|
|
|
|
$('#fldPlaceOfBirth', page).show();
|
2013-07-05 17:19:44 -07:00
|
|
|
|
} else {
|
|
|
|
|
$('#lblPremiereDate', page).html('Release date');
|
|
|
|
|
$('#lblYear', page).html('Year');
|
|
|
|
|
$('#lblEndDate', page).html('End date');
|
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") {
|
|
|
|
|
$('#lblIndexNumber', page).html('Episode number');
|
2014-02-12 22:11:54 -07:00
|
|
|
|
} else if (item.Type == "Season") {
|
2013-05-05 18:15:48 -07:00
|
|
|
|
$('#lblIndexNumber', page).html('Season number');
|
2014-02-12 22:11:54 -07:00
|
|
|
|
} else if (item.Type == "Audio") {
|
2013-05-05 18:15:48 -07:00
|
|
|
|
$('#lblIndexNumber', page).html('Track number');
|
2014-02-12 22:11:54 -07:00
|
|
|
|
} else {
|
2013-05-05 18:15:48 -07:00
|
|
|
|
$('#lblIndexNumber', page).html('Number');
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$('#fldIndexNumber', page).hide();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (item.Type == "Audio" || item.Type == "Episode") {
|
|
|
|
|
$('#fldParentIndexNumber', page).show();
|
|
|
|
|
|
|
|
|
|
if (item.Type == "Episode") {
|
|
|
|
|
$('#lblParentIndexNumber', page).html('Season number');
|
2014-02-12 22:11:54 -07:00
|
|
|
|
} else if (item.Type == "Audio") {
|
2013-05-05 18:15:48 -07:00
|
|
|
|
$('#lblParentIndexNumber', page).html('Disc number');
|
2014-02-12 22:11:54 -07:00
|
|
|
|
} else {
|
2013-05-05 18:15:48 -07:00
|
|
|
|
$('#lblParentIndexNumber', page).html('Parent number');
|
|
|
|
|
}
|
|
|
|
|
} 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-01-03 13:43:44 -07:00
|
|
|
|
$('#labelDisplayOrder', page).html('Title display order:');
|
|
|
|
|
$('#selectDisplayOrder', page).html('<option value="SortName">Sort Name</option><option value="PremiereDate">Release Date</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);
|
|
|
|
|
|
|
|
|
|
populateRatings(result, select);
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
populateRatings(result, select);
|
|
|
|
|
|
|
|
|
|
select.val(item.CustomRating || "").selectmenu('refresh');
|
|
|
|
|
});
|
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
|
|
|
|
|
2013-06-08 20:04:41 -07:00
|
|
|
|
populateListView($('#listGenres', page), item.Genres);
|
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-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 || "");
|
2013-06-08 20:04:41 -07:00
|
|
|
|
$('#txtAirTime', page).val(convertTo24HourFormat(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
|
|
|
|
}
|
|
|
|
|
|
2013-06-08 20:04:41 -07:00
|
|
|
|
function convertTo24HourFormat(time) {
|
|
|
|
|
if (time == "")
|
|
|
|
|
return time;
|
2013-06-15 10:57:08 -07:00
|
|
|
|
var match = time.match(/^(\d+):(\d+)(.*)$/);
|
2013-06-19 06:54:45 -07:00
|
|
|
|
if (match) {
|
2013-06-15 10:57:08 -07:00
|
|
|
|
var hours = Number(match[1]);
|
|
|
|
|
var minutes = Number(match[2]);
|
|
|
|
|
var ampm = $.trim(match[3]);
|
|
|
|
|
ampm = ampm.toUpperCase();
|
|
|
|
|
if (ampm == "PM" && hours < 12) hours = hours + 12;
|
|
|
|
|
if (ampm == "AM" && hours == 12) hours = 0;
|
|
|
|
|
var sHours = hours.toString();
|
|
|
|
|
var sMinutes = minutes.toString();
|
|
|
|
|
if (hours < 10) sHours = "0" + sHours;
|
|
|
|
|
if (minutes < 10) sMinutes = "0" + sMinutes;
|
|
|
|
|
return sHours + ":" + sMinutes;
|
|
|
|
|
} else {
|
|
|
|
|
return time;
|
|
|
|
|
}
|
2013-06-08 20:04:41 -07:00
|
|
|
|
}
|
2013-06-15 10:57:08 -07:00
|
|
|
|
|
2013-06-08 20:04:41 -07:00
|
|
|
|
function convertTo12HourFormat(time) {
|
|
|
|
|
if (time == "")
|
|
|
|
|
return time;
|
|
|
|
|
var hours = Number(time.match(/^(\d+)/)[1]);
|
|
|
|
|
var minutes = Number(time.match(/:(\d+)/)[1]);
|
|
|
|
|
var ampm = "AM";
|
|
|
|
|
if (hours >= 12) {
|
|
|
|
|
ampm = "PM";
|
|
|
|
|
hours = hours - 12;
|
|
|
|
|
hours = hours == 0 ? 12 : hours;
|
|
|
|
|
}
|
|
|
|
|
hours = hours == 0 ? 12 : hours;
|
|
|
|
|
var sHours = hours.toString();
|
|
|
|
|
var sMinutes = minutes.toString();
|
|
|
|
|
if (hours < 10) sHours = "0" + sHours;
|
|
|
|
|
if (minutes < 10) sMinutes = "0" + sMinutes;
|
|
|
|
|
return sHours + ":" + sMinutes + " " + ampm;
|
|
|
|
|
}
|
2013-06-19 06:54:45 -07:00
|
|
|
|
|
2013-05-05 18:15:48 -07:00
|
|
|
|
function populateRatings(allParentalRatings, select) {
|
|
|
|
|
|
|
|
|
|
var html = "";
|
|
|
|
|
|
|
|
|
|
html += "<option value=''></option>";
|
|
|
|
|
|
|
|
|
|
var ratings = [];
|
|
|
|
|
var i, length, rating;
|
|
|
|
|
|
|
|
|
|
for (i = 0, length = allParentalRatings.length; i < length; i++) {
|
|
|
|
|
|
|
|
|
|
rating = allParentalRatings[i];
|
|
|
|
|
|
|
|
|
|
ratings.push({ Name: rating.Name, Value: rating.Name });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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>";
|
|
|
|
|
html += "<option value='Continuing'>Continuing</option>";
|
|
|
|
|
html += "<option value='Ended'>Ended</option>";
|
|
|
|
|
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;
|
|
|
|
|
var fieldTitle = $.trim(name.replace(/([A-Z])/g, ' $1'));
|
2013-06-14 22:30:48 -07:00
|
|
|
|
html += '<div data-role="fieldcontain">';
|
2013-09-13 08:26:43 -07:00
|
|
|
|
html += '<label for="lock' + value + '">' + fieldTitle + ':</label>';
|
|
|
|
|
html += '<select class="selectLockedField" id="lock' + value + '" data-role="slider" data-mini="true">';
|
|
|
|
|
html += '<option value="' + value + '">Off</option>';
|
2013-06-16 18:49:06 -07:00
|
|
|
|
html += '<option value="" selected="selected">On</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 = [
|
|
|
|
|
{ name: "Name" },
|
|
|
|
|
{ name: "Overview" },
|
|
|
|
|
{ name: "Genres" },
|
2013-09-23 07:02:56 -07:00
|
|
|
|
{ name: "Parental Rating", value: "OfficialRating" },
|
2013-09-13 08:26:43 -07:00
|
|
|
|
{ name: "People", value: "Cast" }
|
|
|
|
|
];
|
2013-09-23 13:27:49 -07:00
|
|
|
|
|
2013-09-13 08:26:43 -07:00
|
|
|
|
if (item.Type == "Person") {
|
|
|
|
|
metadatafields.push({ name: "Birth location", value: "ProductionLocations" });
|
|
|
|
|
} else {
|
|
|
|
|
metadatafields.push({ name: "Production Locations", value: "ProductionLocations" });
|
|
|
|
|
}
|
2013-09-23 13:27:49 -07:00
|
|
|
|
|
2013-09-13 08:26:43 -07:00
|
|
|
|
if (item.Type == "Series") {
|
|
|
|
|
metadatafields.push({ name: "Runtime" });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
metadatafields.push({ name: "Studios" });
|
|
|
|
|
metadatafields.push({ name: "Tags" });
|
2014-01-14 09:06:26 -07:00
|
|
|
|
metadatafields.push({ name: "Keywords" });
|
2013-12-14 17:26:01 -07:00
|
|
|
|
metadatafields.push({ name: "Images" });
|
2013-12-15 11:33:07 -07:00
|
|
|
|
metadatafields.push({ name: "Backdrops" });
|
2013-12-28 22:32:03 -07:00
|
|
|
|
|
2013-12-15 11:33:07 -07:00
|
|
|
|
if (item.Type == "Game") {
|
|
|
|
|
metadatafields.push({ name: "Screenshots" });
|
|
|
|
|
}
|
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
|
|
|
|
|
2013-12-28 22:32:03 -07:00
|
|
|
|
html += "<h1>Fields</h1>";
|
|
|
|
|
html += "<p>Slide a field to 'off' to lock it and prevent it's data from being changed.</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-02-12 22:11:54 -07:00
|
|
|
|
function performDelete(page) {
|
|
|
|
|
|
|
|
|
|
$('#btnDelete', page).buttonEnabled(false);
|
|
|
|
|
$('#btnRefresh', page).buttonEnabled(false);
|
|
|
|
|
$('.btnSave', page).buttonEnabled(false);
|
|
|
|
|
|
|
|
|
|
$('#refreshLoading', page).show();
|
|
|
|
|
|
|
|
|
|
var parentId = currentItem.ParentId;
|
|
|
|
|
|
|
|
|
|
ApiClient.deleteItem(currentItem.Id).done(function () {
|
|
|
|
|
|
|
|
|
|
var elem = $('#' + parentId)[0];
|
|
|
|
|
|
|
|
|
|
$('.libraryTree').jstree("select_node", elem, true)
|
|
|
|
|
.jstree("delete_node", '#' + currentItem.Id);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
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(),
|
|
|
|
|
Status: $('#selectStatus', form).val(),
|
2014-02-09 10:44:25 -07:00
|
|
|
|
AirDays: getSelectedAirDays(form),
|
2013-06-08 20:04:41 -07:00
|
|
|
|
AirTime: convertTo12HourFormat($('#txtAirTime', form).val()),
|
|
|
|
|
Genres: editableListViewValues($("#listGenres", form)),
|
|
|
|
|
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-04-26 20:42:05 -07:00
|
|
|
|
ApiClient.updateItem(item).done(function () {
|
2013-05-27 19:36:51 -07:00
|
|
|
|
|
|
|
|
|
Dashboard.alert('Item saved.');
|
|
|
|
|
|
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-02-17 20:02:41 -07:00
|
|
|
|
Dashboard.alert('The value entered is not correct. Please try again.');
|
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;
|
|
|
|
|
};
|
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;
|
|
|
|
|
|
|
|
|
|
$.getJSON(ApiClient.getUrl("Items/" + item.Id + "/ExternalIdInfos")).done(function (idList) {
|
|
|
|
|
|
|
|
|
|
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">';
|
|
|
|
|
html += '<label for="' + id + '">' + idInfo.Name + ' Id:</label>';
|
|
|
|
|
|
|
|
|
|
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-03-13 20:23:58 -07:00
|
|
|
|
var friendlyName = item.Type == "BoxSet" ? "Collection" : item.Type == "MusicArtist" ? "Artist" : item.Type == "MusicAlbum" ? "Album" : item.Type;
|
2014-03-01 15:34:27 -07:00
|
|
|
|
|
|
|
|
|
$('.identificationHeader', page).html('Identify ' + friendlyName);
|
|
|
|
|
|
|
|
|
|
$('.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) {
|
|
|
|
|
Dashboard.alert('Please enter a name or an external Id.');
|
|
|
|
|
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-03-01 15:34:27 -07:00
|
|
|
|
$.ajax({
|
|
|
|
|
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];
|
|
|
|
|
|
|
|
|
|
$.ajax({
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
2013-05-05 18:15:48 -07:00
|
|
|
|
$(document).on('pageinit', "#editItemMetadataPage", function () {
|
|
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
|
2013-05-22 12:49:12 -07:00
|
|
|
|
$('#btnRefresh', this).on('click', function () {
|
|
|
|
|
|
2013-12-24 11:37:29 -07:00
|
|
|
|
$('#btnDelete', page).buttonEnabled(false);
|
|
|
|
|
$('#btnRefresh', page).buttonEnabled(false);
|
|
|
|
|
$('.btnSave', page).buttonEnabled(false);
|
2013-05-22 12:49:12 -07:00
|
|
|
|
|
|
|
|
|
$('#refreshLoading', page).show();
|
|
|
|
|
|
2014-02-12 22:11:54 -07:00
|
|
|
|
var force = $('#selectRefreshMode', page).val() == 'all';
|
2013-07-22 10:23:48 -07:00
|
|
|
|
|
2014-04-26 20:42:05 -07:00
|
|
|
|
ApiClient.refreshItem(currentItem.Id, force, true).done(function () {
|
2013-05-22 12:49:12 -07:00
|
|
|
|
|
|
|
|
|
reload(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
|
|
|
|
function getRandomInt(min, max) {
|
|
|
|
|
return Math.floor(Math.random() * (max - min + 1) + min);
|
|
|
|
|
}
|
2013-10-18 14:12:05 -07:00
|
|
|
|
|
2014-02-12 22:11:54 -07:00
|
|
|
|
$('#btnDelete', this).on('click', function () {
|
2014-01-28 18:45:35 -07:00
|
|
|
|
|
|
|
|
|
if (currentItem.LocationType != "Remote" && currentItem.LocationType != "Virtual") {
|
2014-02-12 22:11:54 -07:00
|
|
|
|
$('.deletePath', page).html((currentItem.Path || ''));
|
2014-01-28 18:45:35 -07:00
|
|
|
|
|
2014-02-12 22:11:54 -07:00
|
|
|
|
var val1 = getRandomInt(6, 12);
|
|
|
|
|
var val2 = getRandomInt(8, 16);
|
2013-10-18 14:12:05 -07:00
|
|
|
|
|
2014-02-12 22:11:54 -07:00
|
|
|
|
$('#challengeValueText', page).html(val1 + ' * ' + val2 + ':');
|
2013-10-18 14:12:05 -07:00
|
|
|
|
|
2014-02-12 22:11:54 -07:00
|
|
|
|
var val = val1 * val2;
|
2013-10-18 14:12:05 -07:00
|
|
|
|
|
2014-02-12 22:11:54 -07:00
|
|
|
|
$('#fldChallengeValue', page).val(val);
|
2013-10-18 14:12:05 -07:00
|
|
|
|
|
2014-02-12 22:11:54 -07:00
|
|
|
|
$('#popupConfirmDelete', page).popup('open');
|
2013-11-24 16:37:38 -07:00
|
|
|
|
|
2014-02-12 22:11:54 -07:00
|
|
|
|
} else {
|
2013-10-18 14:12:05 -07:00
|
|
|
|
|
2014-02-12 22:11:54 -07:00
|
|
|
|
var msg = "<p>Are you sure you wish to delete this item from your library?</p>";
|
2013-10-18 14:12:05 -07:00
|
|
|
|
|
2014-02-12 22:11:54 -07:00
|
|
|
|
Dashboard.confirm(msg, "Confirm Deletion", function (result) {
|
2013-10-18 14:12:05 -07:00
|
|
|
|
|
2014-02-12 22:11:54 -07:00
|
|
|
|
if (result) {
|
|
|
|
|
|
|
|
|
|
performDelete(page);
|
|
|
|
|
}
|
2013-10-18 14:12:05 -07:00
|
|
|
|
|
2014-02-12 22:11:54 -07:00
|
|
|
|
});
|
|
|
|
|
}
|
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
|
|
|
|
|
2014-02-09 16:08:01 -07:00
|
|
|
|
if (data.itemType == "livetvservice") {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2014-02-12 22:11:54 -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);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}).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);
|
|
|
|
|
|
2013-05-05 18:15:48 -07:00
|
|
|
|
});
|
|
|
|
|
|
2013-08-02 13:36:44 -07:00
|
|
|
|
})(jQuery, document, window);
|
|
|
|
|
|