diff --git a/dashboard-ui/css/metadataeditor.css b/dashboard-ui/css/metadataeditor.css index 5e7cf01310..53ee6065fc 100644 --- a/dashboard-ui/css/metadataeditor.css +++ b/dashboard-ui/css/metadataeditor.css @@ -207,11 +207,35 @@ margin-right: 10px; } +.subtitleViewerContent { + overflow: auto; + width: 200px; + height: 200px; +} + +@media all and (min-width: 400px) { + + .subtitleViewerContent { + width: 300px; + } +} + +@media all and (min-width: 500px) { + + .subtitleViewerContent { + width: 400px; + } +} + @media all and (min-width: 600px) { .popupIdentify { width: 400px; } + + .subtitleViewerContent { + width: 500px; + } } @media all and (min-width: 700px) { @@ -223,6 +247,10 @@ .popupIdentify { width: 500px; } + + .subtitleViewerContent { + width: 600px; + } } @media all and (min-width: 800px) { @@ -344,6 +372,10 @@ .popupIdentify form, .identificationSearchResults { height: 350px; } + + .subtitleViewerContent { + height: 400px; + } } @media all and (min-height: 600px) { @@ -355,6 +387,10 @@ .collectionItemSearchResults { max-height: 70%; } + + .subtitleViewerContent { + height: 500px; + } } @media all and (min-height: 700px) { @@ -366,6 +402,10 @@ .collectionItemSearchResults { max-height: 75%; } + + .subtitleViewerContent { + height: 600px; + } } @media all and (min-height: 800px) { diff --git a/dashboard-ui/edititemimages.html b/dashboard-ui/edititemimages.html index cb786817a5..87eb27f2c0 100644 --- a/dashboard-ui/edititemimages.html +++ b/dashboard-ui/edititemimages.html @@ -18,6 +18,7 @@
${TabMetadata} + ${TabImages}
diff --git a/dashboard-ui/edititemmetadata.html b/dashboard-ui/edititemmetadata.html index e5db2b8047..688be41ee4 100644 --- a/dashboard-ui/edititemmetadata.html +++ b/dashboard-ui/edititemmetadata.html @@ -17,6 +17,7 @@
${TabMetadata} + ${TabImages}
diff --git a/dashboard-ui/edititemsubtitles.html b/dashboard-ui/edititemsubtitles.html new file mode 100644 index 0000000000..efb70d4b53 --- /dev/null +++ b/dashboard-ui/edititemsubtitles.html @@ -0,0 +1,61 @@ + + + + ${TitleMediaBrowser} + + +
+
+
+
+
    +
+
+
+
+

 

+
+ + +
+
+
+
+

${HeaderSearchForSubtitles}

+ +
+
+ + +
+ +
+
+
+
+ +
+ +
+
+ +
+ Close +
+

+            
+
+ + + +
+ + diff --git a/dashboard-ui/scripts/edititemimages.js b/dashboard-ui/scripts/edititemimages.js index ddb1d4f271..eba486b3ea 100644 --- a/dashboard-ui/scripts/edititemimages.js +++ b/dashboard-ui/scripts/edititemimages.js @@ -13,6 +13,7 @@ var query = MetadataEditor.getEditQueryString(item); $('#btnEditMetadata', page).attr('href', 'edititemmetadata.html?' + query); + $('#btnEditSubtitles', page).attr('href', 'edititemsubtitles.html?' + query); $('#btnEditCollectionTitles', page).attr('href', 'editcollectionitems.html?' + query); } @@ -274,6 +275,12 @@ $('#btnEditCollectionTitles', page).hide(); } + if (item.MediaType == "Video" && item.LocationType == "FileSystem") { + $('#btnEditSubtitles', page).show(); + } else { + $('#btnEditSubtitles', page).hide(); + } + ApiClient.getRemoteImageProviders(getBaseRemoteOptions()).done(function (providers) { if (providers.length) { diff --git a/dashboard-ui/scripts/edititemmetadata.js b/dashboard-ui/scripts/edititemmetadata.js index 2c51c76e5b..ac28f527c8 100644 --- a/dashboard-ui/scripts/edititemmetadata.js +++ b/dashboard-ui/scripts/edititemmetadata.js @@ -15,6 +15,7 @@ var query = MetadataEditor.getEditQueryString(item); $('#btnEditImages', page).attr('href', 'edititemimages.html?' + query); + $('#btnEditSubtitles', page).attr('href', 'edititemsubtitles.html?' + query); $('#btnEditCollectionTitles', page).attr('href', 'editcollectionitems.html?' + query); } @@ -75,6 +76,12 @@ $('#btnEditCollectionTitles', page).hide(); } + if (item.MediaType == "Video" && item.LocationType == "FileSystem") { + $('#btnEditSubtitles', page).show(); + } else { + $('#btnEditSubtitles', page).hide(); + } + Dashboard.getCurrentUser().done(function (user) { if (user.Configuration.EnableContentDeletion && diff --git a/dashboard-ui/scripts/edititemsubtitles.js b/dashboard-ui/scripts/edititemsubtitles.js new file mode 100644 index 0000000000..96557dbc21 --- /dev/null +++ b/dashboard-ui/scripts/edititemsubtitles.js @@ -0,0 +1,352 @@ +(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; + + $.ajax({ + + type: "POST", + url: ApiClient.getUrl(url) + + }).done(function () { + + Dashboard.alert('The download has been queued.'); + }); + } + + function deleteLocalSubtitle(page, index) { + + var msg = "Are you sure you wish to delete this subtitle file?"; + + Dashboard.confirm(msg, "Confirm Deletion", function (result) { + + if (result) { + + Dashboard.showLoadingMsg(); + + var url = 'Videos/' + currentItem.Id + '/Subtitles/' + index; + + $.ajax({ + + type: "DELETE", + url: ApiClient.getUrl(url) + + }).done(function () { + + reload(page); + }); + + } + }); + } + + function fillSubtitleList(page, item) { + + var html = ''; + + var elem = $('.subtitleList', page).html(html).trigger('create'); + + $('.btnViewSubtitles', elem).on('click', function () { + + var index = this.getAttribute('data-index'); + + showLocalSubtitles(page, index); + + }); + + $('.btnDelete', elem).on('click', function () { + + var index = this.getAttribute('data-index'); + + deleteLocalSubtitle(page, index); + + }); + } + + function fillLanguages(page, languages) { + + $('#selectLanguage', page).html(languages.map(function (l) { + + return ''; + + })).selectmenu('refresh'); + + Dashboard.getCurrentUser().done(function (user) { + + var lang = user.Configuration.SubtitleLanguagePreference; + + if (lang) { + $('#selectLanguage', page).val(lang).selectmenu('refresh'); + } + }); + } + + function renderSearchResults(page, results) { + + var lastProvider = ''; + var html = ''; + + if (!results.length) { + + $('.noSearchResults', page).show(); + $('.subtitleResults', page).html(''); + Dashboard.hideLoadingMsg(); + return; + } + + $('.noSearchResults', page).hide(); + + html += ''; + var elem = $('.subtitleResults', page).html(html).trigger('create'); + + $('.btnViewSubtitle', elem).on('click', function () { + + var id = this.getAttribute('data-subid'); + showRemoteSubtitles(page, id); + }); + + $('.btnDownload', elem).on('click', function () { + + var id = this.getAttribute('data-subid'); + downloadRemoteSubtitles(page, id); + }); + + Dashboard.hideLoadingMsg(); + } + + function searchForSubtitles(page, language) { + + Dashboard.showLoadingMsg(); + + var url = ApiClient.getUrl('Items/' + currentItem.Id + '/RemoteSearch/Subtitles/' + language); + + $.getJSON(url).done(function (results) { + + renderSearchResults(page, results); + }); + } + + function reload(page) { + + $('.noSearchResults', page).hide(); + + MetadataEditor.getItemPromise().done(function (item) { + + currentItem = item; + + LibraryBrowser.renderName(item, $('.itemName', page), true); + + updateTabs(page, item); + + fillSubtitleList(page, item); + + Dashboard.hideLoadingMsg(); + }); + } + + function onWebSocketMessageReceived(e, data) { + + var msg = data; + + if (msg.MessageType === "LibraryChanged") { + + if (msg.Data.ItemsUpdated.indexOf(currentItem.Id) != -1) { + + console.log('Item updated - reloading subtitles'); + reload($.mobile.activePage); + } + } + } + + $(document).on('pageinit', "#editItemSubtitlesPage", function () { + + var page = this; + + $('.libraryTree', page).on('itemclicked', function (event, data) { + + if (data.itemType == "livetvservice") { + return; + } + + if (data.id != currentItem.Id) { + + MetadataEditor.currentItemId = data.id; + MetadataEditor.currentItemName = data.itemName; + MetadataEditor.currentItemType = data.itemType; + //Dashboard.navigate('edititemmetadata.html?id=' + data.id); + + //$.mobile.urlHistory.ignoreNextHashChange = true; + window.location.hash = 'editItemSubtitlesPage?id=' + data.id; + + reload(page); + } + }); + + }).on('pagebeforeshow', "#editItemSubtitlesPage", function () { + + var page = this; + + $('.subtitleResults', page).empty(); + + Dashboard.showLoadingMsg(); + + reload(page); + + ApiClient.getCultures().done(function (languages) { + + fillLanguages(page, languages); + }); + + $(ApiClient).on("websocketmessage", onWebSocketMessageReceived); + + }).on('pagehide', "#editItemSubtitlesPage", function () { + + var page = this; + + currentItem = null; + + $(ApiClient).off("websocketmessage", onWebSocketMessageReceived); + }); + + window.EditItemSubtitlesPage = { + + onSearchSubmit: function () { + + var form = this; + + var lang = $('#selectLanguage', form).val(); + + searchForSubtitles($(form).parents('.page'), lang); + + return false; + } + }; + +})(jQuery, window, document); \ No newline at end of file diff --git a/dashboard-ui/scripts/site.js b/dashboard-ui/scripts/site.js index e13d8b8849..e987b1c03c 100644 --- a/dashboard-ui/scripts/site.js +++ b/dashboard-ui/scripts/site.js @@ -1330,6 +1330,8 @@ $(ApiClient).on("websocketopen", Dashboard.onWebSocketOpened).on("websocketmessa $(function () { + ApiClient.currentUserId(Dashboard.getCurrentUserId()); + var videoPlayerHtml = '