From 76d3fcfbb6cb623da8589e462ae47ddb89c5b335 Mon Sep 17 00:00:00 2001 From: Claus Vium Date: Thu, 14 Feb 2019 18:59:52 +0100 Subject: [PATCH 1/7] Re-add configuration page for OpenSubtitles --- src/opensubtitles.html | 36 ++++++++++++++++++++++++++++++++++++ src/scripts/librarymenu.js | 5 +++++ src/scripts/opensubtitles.js | 36 ++++++++++++++++++++++++++++++++++++ src/scripts/site.js | 5 +++++ 4 files changed, 82 insertions(+) create mode 100644 src/opensubtitles.html create mode 100644 src/scripts/opensubtitles.js diff --git a/src/opensubtitles.html b/src/opensubtitles.html new file mode 100644 index 0000000000..33915b790d --- /dev/null +++ b/src/opensubtitles.html @@ -0,0 +1,36 @@ +
+ +
+ +
+ +
+ +
+ +
+ +
+ + +
+
+ + +
+ +
+ +
+ +
+ +
+
${SubtitleDownloadInstructions}
+
+
+ +
+
diff --git a/src/scripts/librarymenu.js b/src/scripts/librarymenu.js index 18fafa8bf6..8d65f9420b 100644 --- a/src/scripts/librarymenu.js +++ b/src/scripts/librarymenu.js @@ -297,6 +297,11 @@ define(["dom", "layoutManager", "inputManager", "connectionManager", "events", " icon: "swap_horiz", href: "encodingsettings.html", pageIds: ["encodingSettingsPage"] + }, { + name: "Open Subtitles", + href: "opensubtitles.html", + pageIds: ["openSubtitlesPage"], + icon: "closed_caption" }]; addPluginPagesToMainMenu(links, pluginItems, "server"); links.push({ diff --git a/src/scripts/opensubtitles.js b/src/scripts/opensubtitles.js new file mode 100644 index 0000000000..d06f8a44da --- /dev/null +++ b/src/scripts/opensubtitles.js @@ -0,0 +1,36 @@ +define(["loading", "fnchecked", "emby-linkbutton", "emby-input", "emby-checkbox", "emby-button"], function (loading) { + "use strict"; + + function loadPage(page, config) { + page.querySelector("#txtOpenSubtitleUsername").value = config.OpenSubtitlesUsername; + page.querySelector("#txtOpenSubtitlePassword").value = config.OpenSubtitlesPasswordHash || ""; + loading.hide(); + } + + function onSubmit(e__q) { + e__q.preventDefault(); + loading.show(); + var form = this; + ApiClient.getNamedConfiguration("subtitles").then(function (config) { + config.OpenSubtitlesUsername = form.querySelector("#txtOpenSubtitleUsername").value; + var newPassword = form.querySelector("#txtOpenSubtitlePassword").value; + + if (newPassword) { + config.OpenSubtitlesPasswordHash = newPassword; + } + + ApiClient.updateNamedConfiguration("subtitles", config).then(Dashboard.processServerConfigurationUpdateResult); + }); + return false; + } + + $(document).on("pageinit", "#openSubtitlesPage", function() { + $(".metadataSubtitlesForm").off("submit", onSubmit).on("submit", onSubmit) + }).on("pageshow", "#openSubtitlesPage", function() { + loading.show(); + var page = this; + ApiClient.getNamedConfiguration("subtitles").then(function (response) { + loadPage(page, response); + }); + }); +}); diff --git a/src/scripts/site.js b/src/scripts/site.js index 885529cdff..573464ec2c 100644 --- a/src/scripts/site.js +++ b/src/scripts/site.js @@ -512,6 +512,11 @@ var Dashboard = { dependencies: [], autoFocus: !1, roles: "admin" + }), defineRoute({ + path: "/opensubtitles.html", + dependencies: [], + autoFocus: !1, + roles: "admin" }), defineRoute({ path: "/forgotpassword.html", dependencies: ["emby-input", "emby-button"], From fbb793e4455275bc2f768c9456a95ba39d10ec63 Mon Sep 17 00:00:00 2001 From: Claus Vium Date: Thu, 14 Feb 2019 19:02:43 +0100 Subject: [PATCH 2/7] Hardcode Register string since ButtonRegister has been removed from strings --- src/opensubtitles.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/opensubtitles.html b/src/opensubtitles.html index 33915b790d..7c9902ea7f 100644 --- a/src/opensubtitles.html +++ b/src/opensubtitles.html @@ -17,7 +17,8 @@ From ec57b8c493545fe8b941d0f96bbdc5a374cfa08e Mon Sep 17 00:00:00 2001 From: Claus Vium Date: Thu, 14 Feb 2019 19:05:09 +0100 Subject: [PATCH 3/7] Removed some newlines and manual deuglification --- src/opensubtitles.html | 9 --------- src/scripts/opensubtitles.js | 4 ++-- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/src/opensubtitles.html b/src/opensubtitles.html index 7c9902ea7f..5174a1f1de 100644 --- a/src/opensubtitles.html +++ b/src/opensubtitles.html @@ -1,18 +1,12 @@ 
-
-
-
-
- -
@@ -21,17 +15,14 @@ Register
-
-
${SubtitleDownloadInstructions}
-
diff --git a/src/scripts/opensubtitles.js b/src/scripts/opensubtitles.js index d06f8a44da..99ec982dc1 100644 --- a/src/scripts/opensubtitles.js +++ b/src/scripts/opensubtitles.js @@ -7,8 +7,8 @@ define(["loading", "fnchecked", "emby-linkbutton", "emby-input", "emby-checkbox" loading.hide(); } - function onSubmit(e__q) { - e__q.preventDefault(); + function onSubmit(evt) { + evt.preventDefault(); loading.show(); var form = this; ApiClient.getNamedConfiguration("subtitles").then(function (config) { From 3e313972bc96d5cd7d34f3fb0911edb7339a3ccb Mon Sep 17 00:00:00 2001 From: Claus Vium Date: Fri, 15 Feb 2019 12:11:16 +0100 Subject: [PATCH 4/7] Add ButtonRegister string --- src/strings/en-us.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/strings/en-us.json b/src/strings/en-us.json index 801ae50280..17285da845 100644 --- a/src/strings/en-us.json +++ b/src/strings/en-us.json @@ -159,6 +159,7 @@ "ButtonReenable": "Re-enable", "ButtonRefresh": "Refresh", "ButtonRefreshGuideData": "Refresh Guide Data", + "ButtonRegister": "Register", "ButtonReject": "Reject", "ButtonRemote": "Remote", "ButtonRemoteControl": "Remote Control", @@ -2264,4 +2265,4 @@ "XmlTvSportsCategoriesHelp": "Programs with these categories will be displayed as sports programs. Separate multiple with '|'.", "Yes": "Yes", "Yesterday": "Yesterday" -} \ No newline at end of file +} From 7df3a87230c7da01deb48486dfe892cf64b2140d Mon Sep 17 00:00:00 2001 From: Claus Vium Date: Fri, 15 Feb 2019 12:11:58 +0100 Subject: [PATCH 5/7] Replace Register with ButtonRegister translation key --- src/opensubtitles.html | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/opensubtitles.html b/src/opensubtitles.html index 5174a1f1de..51e337ae63 100644 --- a/src/opensubtitles.html +++ b/src/opensubtitles.html @@ -11,8 +11,7 @@
From 53fbc24ac547fce2db8a08a683c4402284b537d8 Mon Sep 17 00:00:00 2001 From: Claus Vium Date: Sun, 17 Feb 2019 23:13:42 +0100 Subject: [PATCH 6/7] Exit fullscreen automatically when video playback stops --- .../emby-webcomponents/htmlvideoplayer/plugin.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/bower_components/emby-webcomponents/htmlvideoplayer/plugin.js b/src/bower_components/emby-webcomponents/htmlvideoplayer/plugin.js index 19b075b622..e723790583 100644 --- a/src/bower_components/emby-webcomponents/htmlvideoplayer/plugin.js +++ b/src/bower_components/emby-webcomponents/htmlvideoplayer/plugin.js @@ -1,4 +1,4 @@ -define(['browser', 'require', 'events', 'apphost', 'loading', 'dom', 'playbackManager', 'appRouter', 'appSettings', 'connectionManager', 'htmlMediaHelper', 'itemHelper'], function (browser, require, events, appHost, loading, dom, playbackManager, appRouter, appSettings, connectionManager, htmlMediaHelper, itemHelper) { +define(['browser', 'require', 'events', 'apphost', 'loading', 'dom', 'playbackManager', 'appRouter', 'appSettings', 'connectionManager', 'htmlMediaHelper', 'itemHelper', 'fullscreenManager'], function (browser, require, events, appHost, loading, dom, playbackManager, appRouter, appSettings, connectionManager, htmlMediaHelper, itemHelper, fullscreenManager) { "use strict"; var mediaManager; @@ -692,6 +692,7 @@ define(['browser', 'require', 'events', 'apphost', 'loading', 'dom', 'playbackMa dlg.parentNode.removeChild(dlg); } + fullscreenManager.exitFullscreen(); }; function onEnded() { From 9a7ede5536700c711884386af60dda22dae302b3 Mon Sep 17 00:00:00 2001 From: Claus Vium Date: Sun, 17 Feb 2019 23:29:31 +0100 Subject: [PATCH 7/7] Add fullscreen check to avoid errors in Chrome --- .../fullscreen/fullscreenmanager.js | 17 +++++++++++++---- .../htmlvideoplayer/plugin.js | 1 + 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/bower_components/emby-webcomponents/fullscreen/fullscreenmanager.js b/src/bower_components/emby-webcomponents/fullscreen/fullscreenmanager.js index d39d8fd3b6..5773e57d07 100644 --- a/src/bower_components/emby-webcomponents/fullscreen/fullscreenmanager.js +++ b/src/bower_components/emby-webcomponents/fullscreen/fullscreenmanager.js @@ -29,11 +29,14 @@ define(['events', 'dom'], function (events, dom) { } if (element.webkitEnterFullscreen) { element.webkitEnterFullscreen(); - } + } }; fullscreenManager.prototype.exitFullscreen = function () { + if (!this.isFullScreen()) { + return; + } if (document.exitFullscreen) { document.exitFullscreen(); } else if (document.mozCancelFullScreen) { @@ -47,9 +50,15 @@ define(['events', 'dom'], function (events, dom) { } }; + // TODO: use screenfull.js fullscreenManager.prototype.isFullScreen = function () { - - return document.fullscreen || document.mozFullScreen || document.webkitIsFullScreen || document.msFullscreenElement ? true : false; + return document.fullscreen || + document.mozFullScreen || + document.webkitIsFullScreen || + document.msFullscreenElement || /* IE/Edge syntax */ + document.fullscreenElement || /* Standard syntax */ + document.webkitFullscreenElement || /* Chrome, Safari and Opera syntax */ + document.mozFullScreenElement; /* Firefox syntax */ }; var manager = new fullscreenManager(); @@ -71,4 +80,4 @@ define(['events', 'dom'], function (events, dom) { }); return manager; -}); \ No newline at end of file +}); diff --git a/src/bower_components/emby-webcomponents/htmlvideoplayer/plugin.js b/src/bower_components/emby-webcomponents/htmlvideoplayer/plugin.js index e723790583..d25b49163b 100644 --- a/src/bower_components/emby-webcomponents/htmlvideoplayer/plugin.js +++ b/src/bower_components/emby-webcomponents/htmlvideoplayer/plugin.js @@ -692,6 +692,7 @@ define(['browser', 'require', 'events', 'apphost', 'loading', 'dom', 'playbackMa dlg.parentNode.removeChild(dlg); } + fullscreenManager.exitFullscreen(); };