(function ($, window, document) {
var currentItem;
function updateTabs(page, item) {
var query = MetadataEditor.getEditQueryString(item);
$('#btnEditMetadata', page).attr('href', 'edititemmetadata.html?' + query);
$('#btnEditImages', page).attr('href', 'edititemimages.html?' + query);
}
function showLocalSubtitles(page, index) {
Dashboard.showLoadingMsg();
var popup = $('.popupSubtitleViewer', page).popup('open');
$('.subtitleContent', page).html('');
var url = 'Videos/' + currentItem.Id + '/Subtitles/' + index;
$.get(ApiClient.getUrl(url)).done(function (result) {
$('.subtitleContent', page).html(result);
Dashboard.hideLoadingMsg();
popup.popup('reposition', {});
});
}
function showRemoteSubtitles(page, id) {
Dashboard.showLoadingMsg();
var popup = $('.popupSubtitleViewer', page).popup('open');
$('.subtitleContent', page).html('\nLoading...\n\n\n');
var url = 'Providers/Subtitles/Subtitles/' + id;
$.get(ApiClient.getUrl(url)).done(function (result) {
$('.subtitleContent', page).html(result);
Dashboard.hideLoadingMsg();
popup.popup('reposition', {});
});
}
function downloadRemoteSubtitles(page, id) {
var url = 'Items/' + currentItem.Id + '/RemoteSearch/Subtitles/' + id;
ApiClient.ajax({
type: "POST",
url: ApiClient.getUrl(url)
}).done(function () {
Dashboard.alert(Globalize.translate('MessageDownloadQueued'));
});
}
function deleteLocalSubtitle(page, index) {
var msg = Globalize.translate('MessageAreYouSureDeleteSubtitles');
Dashboard.confirm(msg, Globalize.translate('HeaderConfirmDeletion'), function (result) {
if (result) {
Dashboard.showLoadingMsg();
var url = 'Videos/' + currentItem.Id + '/Subtitles/' + index;
ApiClient.ajax({
type: "DELETE",
url: ApiClient.getUrl(url)
}).done(function () {
reload(page);
});
}
});
}
function fillSubtitleList(page, item) {
var streams = item.MediaStreams || [];
var subs = streams.filter(function (s) {
return s.Type == 'Subtitle';
});
var html = '';
if (subs.length) {
html += '
';
html += '
' + (s.Language || Globalize.translate('LabelUnknownLanaguage')) + '
'; if (s.IsDefault || s.IsForced) { var atts = []; if (s.IsDefault) { atts.push('Default'); } if (s.IsForced) { atts.push('Forced'); } itemHtml += '' + atts.join(', ') + '
'; } if (s.Path) { itemHtml += '' + (s.Path) + '
'; } itemHtml += ''; if (s.Path) { itemHtml += '' + Globalize.translate('Delete') + ''; } else { itemHtml += ' '; } itemHtml += '' + (result.Format) + '
'; if (result.Comment) { html += '' + (result.Comment) + '
'; } html += '