mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Merge remote-tracking branch 'upstream/master' into deinterlace-improvements
This commit is contained in:
commit
077c02282f
221 changed files with 13279 additions and 13706 deletions
|
@ -2,4 +2,3 @@ node_modules
|
||||||
dist
|
dist
|
||||||
.idea
|
.idea
|
||||||
.vscode
|
.vscode
|
||||||
src/libraries
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ module.exports = {
|
||||||
],
|
],
|
||||||
rules: {
|
rules: {
|
||||||
'block-spacing': ['error'],
|
'block-spacing': ['error'],
|
||||||
'brace-style': ['error', "1tbs", { "allowSingleLine": true }],
|
'brace-style': ['error', '1tbs', { 'allowSingleLine': true }],
|
||||||
'comma-dangle': ['error', 'never'],
|
'comma-dangle': ['error', 'never'],
|
||||||
'comma-spacing': ['error'],
|
'comma-spacing': ['error'],
|
||||||
'eol-last': ['error'],
|
'eol-last': ['error'],
|
||||||
|
@ -41,7 +41,7 @@ module.exports = {
|
||||||
'no-multiple-empty-lines': ['error', { 'max': 1 }],
|
'no-multiple-empty-lines': ['error', { 'max': 1 }],
|
||||||
'no-trailing-spaces': ['error'],
|
'no-trailing-spaces': ['error'],
|
||||||
'no-unused-expressions': ['error', { 'allowShortCircuit': true, 'allowTernary': true, 'allowTaggedTemplates': true }],
|
'no-unused-expressions': ['error', { 'allowShortCircuit': true, 'allowTernary': true, 'allowTaggedTemplates': true }],
|
||||||
"no-unused-vars": ["error", { "vars": "all", "args": "none", "ignoreRestSiblings": true }],
|
'no-unused-vars': ['error', { 'vars': 'all', 'args': 'none', 'ignoreRestSiblings': true }],
|
||||||
'one-var': ['error', 'never'],
|
'one-var': ['error', 'never'],
|
||||||
'padded-blocks': ['error', 'never'],
|
'padded-blocks': ['error', 'never'],
|
||||||
'quotes': ['error', 'single', { 'avoidEscape': true, 'allowTemplateLiterals': false }],
|
'quotes': ['error', 'single', { 'avoidEscape': true, 'allowTemplateLiterals': false }],
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
- [Thibault Nocchi](https://github.com/ThibaultNocchi)
|
- [Thibault Nocchi](https://github.com/ThibaultNocchi)
|
||||||
- [MrTimscampi](https://github.com/MrTimscampi)
|
- [MrTimscampi](https://github.com/MrTimscampi)
|
||||||
- [Sarab Singh](https://github.com/sarab97)
|
- [Sarab Singh](https://github.com/sarab97)
|
||||||
|
- [GuilhermeHideki](https://github.com/GuilhermeHideki)
|
||||||
- [Andrei Oanca](https://github.com/OancaAndrei)
|
- [Andrei Oanca](https://github.com/OancaAndrei)
|
||||||
- [Cromefire_](https://github.com/cromefire)
|
- [Cromefire_](https://github.com/cromefire)
|
||||||
|
|
||||||
|
|
86
package.json
86
package.json
|
@ -5,9 +5,9 @@
|
||||||
"repository": "https://github.com/jellyfin/jellyfin-web",
|
"repository": "https://github.com/jellyfin/jellyfin-web",
|
||||||
"license": "GPL-2.0-or-later",
|
"license": "GPL-2.0-or-later",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/core": "^7.11.0",
|
"@babel/core": "^7.11.1",
|
||||||
"@babel/eslint-parser": "^7.11.0",
|
"@babel/eslint-parser": "^7.11.3",
|
||||||
"@babel/eslint-plugin": "^7.11.0",
|
"@babel/eslint-plugin": "^7.11.3",
|
||||||
"@babel/plugin-proposal-class-properties": "^7.10.1",
|
"@babel/plugin-proposal-class-properties": "^7.10.1",
|
||||||
"@babel/plugin-proposal-private-methods": "^7.10.1",
|
"@babel/plugin-proposal-private-methods": "^7.10.1",
|
||||||
"@babel/plugin-transform-modules-amd": "^7.10.5",
|
"@babel/plugin-transform-modules-amd": "^7.10.5",
|
||||||
|
@ -17,10 +17,10 @@
|
||||||
"babel-loader": "^8.0.6",
|
"babel-loader": "^8.0.6",
|
||||||
"browser-sync": "^2.26.12",
|
"browser-sync": "^2.26.12",
|
||||||
"copy-webpack-plugin": "^5.1.1",
|
"copy-webpack-plugin": "^5.1.1",
|
||||||
"css-loader": "^4.1.1",
|
"css-loader": "^4.2.1",
|
||||||
"cssnano": "^4.1.10",
|
"cssnano": "^4.1.10",
|
||||||
"del": "^5.1.0",
|
"del": "^5.1.0",
|
||||||
"eslint": "^6.8.0",
|
"eslint": "^7.6.0",
|
||||||
"eslint-plugin-compat": "^3.5.1",
|
"eslint-plugin-compat": "^3.5.1",
|
||||||
"eslint-plugin-eslint-comments": "^3.2.0",
|
"eslint-plugin-eslint-comments": "^3.2.0",
|
||||||
"eslint-plugin-import": "^2.21.2",
|
"eslint-plugin-import": "^2.21.2",
|
||||||
|
@ -38,7 +38,7 @@
|
||||||
"gulp-postcss": "^8.0.0",
|
"gulp-postcss": "^8.0.0",
|
||||||
"gulp-sass": "^4.0.2",
|
"gulp-sass": "^4.0.2",
|
||||||
"gulp-sourcemaps": "^2.6.5",
|
"gulp-sourcemaps": "^2.6.5",
|
||||||
"gulp-terser": "^1.2.1",
|
"gulp-terser": "^1.3.2",
|
||||||
"html-webpack-plugin": "^4.3.0",
|
"html-webpack-plugin": "^4.3.0",
|
||||||
"lazypipe": "^1.0.2",
|
"lazypipe": "^1.0.2",
|
||||||
"node-sass": "^4.13.1",
|
"node-sass": "^4.13.1",
|
||||||
|
@ -63,7 +63,7 @@
|
||||||
"fast-text-encoding": "^1.0.3",
|
"fast-text-encoding": "^1.0.3",
|
||||||
"flv.js": "^1.5.0",
|
"flv.js": "^1.5.0",
|
||||||
"headroom.js": "^0.11.0",
|
"headroom.js": "^0.11.0",
|
||||||
"hls.js": "^0.14.7",
|
"hls.js": "^0.14.8",
|
||||||
"howler": "^2.2.0",
|
"howler": "^2.2.0",
|
||||||
"intersection-observer": "^0.11.0",
|
"intersection-observer": "^0.11.0",
|
||||||
"jellyfin-apiclient": "^1.4.1",
|
"jellyfin-apiclient": "^1.4.1",
|
||||||
|
@ -80,7 +80,7 @@
|
||||||
"sortablejs": "^1.10.2",
|
"sortablejs": "^1.10.2",
|
||||||
"swiper": "^5.4.5",
|
"swiper": "^5.4.5",
|
||||||
"webcomponents.js": "^0.7.24",
|
"webcomponents.js": "^0.7.24",
|
||||||
"whatwg-fetch": "^3.2.0"
|
"whatwg-fetch": "^3.4.0"
|
||||||
},
|
},
|
||||||
"babel": {
|
"babel": {
|
||||||
"presets": [
|
"presets": [
|
||||||
|
@ -107,9 +107,13 @@
|
||||||
"src/components/dialogHelper/dialogHelper.js",
|
"src/components/dialogHelper/dialogHelper.js",
|
||||||
"src/components/directorybrowser/directorybrowser.js",
|
"src/components/directorybrowser/directorybrowser.js",
|
||||||
"src/components/displaySettings/displaySettings.js",
|
"src/components/displaySettings/displaySettings.js",
|
||||||
|
"src/components/favoriteitems.js",
|
||||||
"src/components/fetchhelper.js",
|
"src/components/fetchhelper.js",
|
||||||
"src/components/filterdialog/filterdialog.js",
|
"src/components/filterdialog/filterdialog.js",
|
||||||
|
"src/components/focusManager.js",
|
||||||
"src/components/groupedcards.js",
|
"src/components/groupedcards.js",
|
||||||
|
"src/components/guide/guide.js",
|
||||||
|
"src/components/guide/guide-settings.js",
|
||||||
"src/components/homeScreenSettings/homeScreenSettings.js",
|
"src/components/homeScreenSettings/homeScreenSettings.js",
|
||||||
"src/components/homesections/homesections.js",
|
"src/components/homesections/homesections.js",
|
||||||
"src/components/htmlMediaHelper.js",
|
"src/components/htmlMediaHelper.js",
|
||||||
|
@ -123,9 +127,12 @@
|
||||||
"src/components/itemHelper.js",
|
"src/components/itemHelper.js",
|
||||||
"src/components/itemidentifier/itemidentifier.js",
|
"src/components/itemidentifier/itemidentifier.js",
|
||||||
"src/components/itemMediaInfo/itemMediaInfo.js",
|
"src/components/itemMediaInfo/itemMediaInfo.js",
|
||||||
|
"src/components/itemsrefresher.js",
|
||||||
|
"src/components/layoutManager.js",
|
||||||
"src/components/lazyLoader/lazyLoaderIntersectionObserver.js",
|
"src/components/lazyLoader/lazyLoaderIntersectionObserver.js",
|
||||||
"src/components/libraryoptionseditor/libraryoptionseditor.js",
|
"src/components/libraryoptionseditor/libraryoptionseditor.js",
|
||||||
"src/components/listview/listview.js",
|
"src/components/listview/listview.js",
|
||||||
|
"src/components/loading/loading.js",
|
||||||
"src/components/maintabsmanager.js",
|
"src/components/maintabsmanager.js",
|
||||||
"src/components/mediainfo/mediainfo.js",
|
"src/components/mediainfo/mediainfo.js",
|
||||||
"src/components/mediaLibraryCreator/mediaLibraryCreator.js",
|
"src/components/mediaLibraryCreator/mediaLibraryCreator.js",
|
||||||
|
@ -138,6 +145,7 @@
|
||||||
"src/components/playback/mediasession.js",
|
"src/components/playback/mediasession.js",
|
||||||
"src/components/playback/nowplayinghelper.js",
|
"src/components/playback/nowplayinghelper.js",
|
||||||
"src/components/playback/playbackorientation.js",
|
"src/components/playback/playbackorientation.js",
|
||||||
|
"src/components/playback/playbackmanager.js",
|
||||||
"src/components/playback/playerSelectionMenu.js",
|
"src/components/playback/playerSelectionMenu.js",
|
||||||
"src/components/playback/playersettingsmenu.js",
|
"src/components/playback/playersettingsmenu.js",
|
||||||
"src/components/playback/playmethodhelper.js",
|
"src/components/playback/playmethodhelper.js",
|
||||||
|
@ -149,20 +157,41 @@
|
||||||
"src/components/playlisteditor/playlisteditor.js",
|
"src/components/playlisteditor/playlisteditor.js",
|
||||||
"src/components/playmenu.js",
|
"src/components/playmenu.js",
|
||||||
"src/components/prompt/prompt.js",
|
"src/components/prompt/prompt.js",
|
||||||
|
"src/components/recordingcreator/recordingbutton.js",
|
||||||
|
"src/components/recordingcreator/recordingcreator.js",
|
||||||
|
"src/components/recordingcreator/seriesrecordingeditor.js",
|
||||||
|
"src/components/recordingcreator/recordinghelper.js",
|
||||||
"src/components/refreshdialog/refreshdialog.js",
|
"src/components/refreshdialog/refreshdialog.js",
|
||||||
|
"src/components/remotecontrol/remotecontrol.js",
|
||||||
"src/components/sanatizefilename.js",
|
"src/components/sanatizefilename.js",
|
||||||
"src/components/scrollManager.js",
|
"src/components/scrollManager.js",
|
||||||
|
"src/plugins/htmlAudioPlayer/plugin.js",
|
||||||
|
"src/plugins/chromecastPlayer/plugin.js",
|
||||||
|
"src/components/slideshow/slideshow.js",
|
||||||
|
"src/components/sortmenu/sortmenu.js",
|
||||||
"src/plugins/htmlVideoPlayer/plugin.js",
|
"src/plugins/htmlVideoPlayer/plugin.js",
|
||||||
|
"src/plugins/logoScreensaver/plugin.js",
|
||||||
|
"src/plugins/playAccessValidation/plugin.js",
|
||||||
"src/components/search/searchfields.js",
|
"src/components/search/searchfields.js",
|
||||||
"src/components/search/searchresults.js",
|
"src/components/search/searchresults.js",
|
||||||
"src/components/settingshelper.js",
|
"src/components/settingshelper.js",
|
||||||
"src/components/shortcuts.js",
|
"src/components/shortcuts.js",
|
||||||
|
"src/components/subtitleeditor/subtitleeditor.js",
|
||||||
|
"src/components/subtitlesync/subtitlesync.js",
|
||||||
"src/components/subtitlesettings/subtitleappearancehelper.js",
|
"src/components/subtitlesettings/subtitleappearancehelper.js",
|
||||||
"src/components/subtitlesettings/subtitlesettings.js",
|
"src/components/subtitlesettings/subtitlesettings.js",
|
||||||
"src/components/syncPlay/groupSelectionMenu.js",
|
"src/components/syncPlay/groupSelectionMenu.js",
|
||||||
"src/components/syncPlay/playbackPermissionManager.js",
|
"src/components/syncPlay/playbackPermissionManager.js",
|
||||||
"src/components/syncPlay/syncPlayManager.js",
|
"src/components/syncPlay/syncPlayManager.js",
|
||||||
"src/components/syncPlay/timeSyncManager.js",
|
"src/components/syncPlay/timeSyncManager.js",
|
||||||
|
"src/components/tabbedview/tabbedview.js",
|
||||||
|
"src/components/viewManager/viewManager.js",
|
||||||
|
"src/components/tvproviders/schedulesdirect.js",
|
||||||
|
"src/components/tvproviders/xmltv.js",
|
||||||
|
"src/components/toast/toast.js",
|
||||||
|
"src/components/upnextdialog/upnextdialog.js",
|
||||||
|
"src/components/viewContainer.js",
|
||||||
|
"src/components/castSenderApi.js",
|
||||||
"src/controllers/session/addServer/index.js",
|
"src/controllers/session/addServer/index.js",
|
||||||
"src/controllers/session/forgotPassword/index.js",
|
"src/controllers/session/forgotPassword/index.js",
|
||||||
"src/controllers/session/redeemPassword/index.js",
|
"src/controllers/session/redeemPassword/index.js",
|
||||||
|
@ -185,11 +214,16 @@
|
||||||
"src/controllers/music/musicplaylists.js",
|
"src/controllers/music/musicplaylists.js",
|
||||||
"src/controllers/music/musicrecommended.js",
|
"src/controllers/music/musicrecommended.js",
|
||||||
"src/controllers/music/songs.js",
|
"src/controllers/music/songs.js",
|
||||||
"src/controllers/dashboard/mediaLibrary.js",
|
"src/controllers/dashboard/library.js",
|
||||||
"src/controllers/dashboard/metadataImages.js",
|
"src/controllers/dashboard/metadataImages.js",
|
||||||
"src/controllers/dashboard/metadatanfo.js",
|
"src/controllers/dashboard/metadatanfo.js",
|
||||||
"src/controllers/dashboard/networking.js",
|
"src/controllers/dashboard/networking.js",
|
||||||
|
"src/controllers/dashboard/notifications/notification.js",
|
||||||
|
"src/controllers/dashboard/notifications/notifications.js",
|
||||||
"src/controllers/dashboard/playback.js",
|
"src/controllers/dashboard/playback.js",
|
||||||
|
"src/controllers/dashboard/plugins/add/index.js",
|
||||||
|
"src/controllers/dashboard/plugins/installed/index.js",
|
||||||
|
"src/controllers/dashboard/plugins/available/index.js",
|
||||||
"src/controllers/dashboard/plugins/repositories/index.js",
|
"src/controllers/dashboard/plugins/repositories/index.js",
|
||||||
"src/controllers/dashboard/scheduledtasks/scheduledtask.js",
|
"src/controllers/dashboard/scheduledtasks/scheduledtask.js",
|
||||||
"src/controllers/dashboard/scheduledtasks/scheduledtasks.js",
|
"src/controllers/dashboard/scheduledtasks/scheduledtasks.js",
|
||||||
|
@ -201,11 +235,31 @@
|
||||||
"src/controllers/dashboard/users/userparentalcontrol.js",
|
"src/controllers/dashboard/users/userparentalcontrol.js",
|
||||||
"src/controllers/dashboard/users/userpasswordpage.js",
|
"src/controllers/dashboard/users/userpasswordpage.js",
|
||||||
"src/controllers/dashboard/users/userprofilespage.js",
|
"src/controllers/dashboard/users/userprofilespage.js",
|
||||||
|
"src/controllers/home.js",
|
||||||
|
"src/controllers/list.js",
|
||||||
|
"src/controllers/edititemmetadata.js",
|
||||||
|
"src/controllers/favorites.js",
|
||||||
|
"src/controllers/hometab.js",
|
||||||
|
"src/controllers/movies/moviecollections.js",
|
||||||
|
"src/controllers/movies/moviegenres.js",
|
||||||
|
"src/controllers/movies/movies.js",
|
||||||
|
"src/controllers/movies/moviesrecommended.js",
|
||||||
|
"src/controllers/movies/movietrailers.js",
|
||||||
|
"src/controllers/playback/nowplaying.js",
|
||||||
|
"src/controllers/playback/videoosd.js",
|
||||||
"src/controllers/itemDetails/index.js",
|
"src/controllers/itemDetails/index.js",
|
||||||
"src/controllers/playback/queue/index.js",
|
"src/controllers/playback/queue/index.js",
|
||||||
"src/controllers/playback/video/index.js",
|
"src/controllers/playback/video/index.js",
|
||||||
"src/controllers/searchpage.js",
|
"src/controllers/searchpage.js",
|
||||||
|
"src/controllers/livetv/livetvguide.js",
|
||||||
"src/controllers/livetvtuner.js",
|
"src/controllers/livetvtuner.js",
|
||||||
|
"src/controllers/livetvstatus.js",
|
||||||
|
"src/controllers/livetvguideprovider.js",
|
||||||
|
"src/controllers/livetvsettings.js",
|
||||||
|
"src/controllers/livetv/livetvrecordings.js",
|
||||||
|
"src/controllers/livetv/livetvschedule.js",
|
||||||
|
"src/controllers/livetv/livetvseriestimers.js",
|
||||||
|
"src/controllers/livetv/livetvchannels.js",
|
||||||
"src/controllers/shows/episodes.js",
|
"src/controllers/shows/episodes.js",
|
||||||
"src/controllers/shows/tvgenres.js",
|
"src/controllers/shows/tvgenres.js",
|
||||||
"src/controllers/shows/tvlatest.js",
|
"src/controllers/shows/tvlatest.js",
|
||||||
|
@ -244,6 +298,9 @@
|
||||||
"src/elements/emby-tabs/emby-tabs.js",
|
"src/elements/emby-tabs/emby-tabs.js",
|
||||||
"src/elements/emby-textarea/emby-textarea.js",
|
"src/elements/emby-textarea/emby-textarea.js",
|
||||||
"src/elements/emby-toggle/emby-toggle.js",
|
"src/elements/emby-toggle/emby-toggle.js",
|
||||||
|
"src/libraries/screensavermanager.js",
|
||||||
|
"src/libraries/navdrawer/navdrawer.js",
|
||||||
|
"src/libraries/scroller.js",
|
||||||
"src/plugins/backdropScreensaver/plugin.js",
|
"src/plugins/backdropScreensaver/plugin.js",
|
||||||
"src/plugins/bookPlayer/plugin.js",
|
"src/plugins/bookPlayer/plugin.js",
|
||||||
"src/plugins/bookPlayer/tableOfContents.js",
|
"src/plugins/bookPlayer/tableOfContents.js",
|
||||||
|
@ -261,14 +318,24 @@
|
||||||
"src/scripts/filesystem.js",
|
"src/scripts/filesystem.js",
|
||||||
"src/scripts/globalize.js",
|
"src/scripts/globalize.js",
|
||||||
"src/scripts/imagehelper.js",
|
"src/scripts/imagehelper.js",
|
||||||
|
"src/scripts/itembynamedetailpage.js",
|
||||||
"src/scripts/inputManager.js",
|
"src/scripts/inputManager.js",
|
||||||
|
"src/scripts/autoThemes.js",
|
||||||
|
"src/scripts/themeManager.js",
|
||||||
"src/scripts/keyboardNavigation.js",
|
"src/scripts/keyboardNavigation.js",
|
||||||
|
"src/scripts/libraryMenu.js",
|
||||||
"src/scripts/libraryBrowser.js",
|
"src/scripts/libraryBrowser.js",
|
||||||
|
"src/scripts/livetvcomponents.js",
|
||||||
|
"src/scripts/mouseManager.js",
|
||||||
"src/scripts/multiDownload.js",
|
"src/scripts/multiDownload.js",
|
||||||
"src/scripts/playlists.js",
|
"src/scripts/playlists.js",
|
||||||
|
"src/scripts/scrollHelper.js",
|
||||||
|
"src/scripts/serverNotifications.js",
|
||||||
|
"src/scripts/routes.js",
|
||||||
"src/scripts/settings/appSettings.js",
|
"src/scripts/settings/appSettings.js",
|
||||||
"src/scripts/settings/userSettings.js",
|
"src/scripts/settings/userSettings.js",
|
||||||
"src/scripts/settings/webSettings.js",
|
"src/scripts/settings/webSettings.js",
|
||||||
|
"src/scripts/shell.js",
|
||||||
"src/scripts/taskbutton.js",
|
"src/scripts/taskbutton.js",
|
||||||
"src/scripts/themeLoader.js",
|
"src/scripts/themeLoader.js",
|
||||||
"src/scripts/touchHelper.js"
|
"src/scripts/touchHelper.js"
|
||||||
|
@ -298,6 +365,7 @@
|
||||||
"Firefox ESR"
|
"Firefox ESR"
|
||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
"start": "yarn serve",
|
||||||
"serve": "gulp serve --development",
|
"serve": "gulp serve --development",
|
||||||
"prepare": "gulp --production",
|
"prepare": "gulp --production",
|
||||||
"build:development": "gulp --development",
|
"build:development": "gulp --development",
|
||||||
|
|
33
scripts/duplicates.py
Normal file
33
scripts/duplicates.py
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
import json
|
||||||
|
|
||||||
|
# load every string in the source language
|
||||||
|
# print all duplicate values to a file
|
||||||
|
|
||||||
|
cwd = os.getcwd()
|
||||||
|
source = cwd + '/../src/strings/en-us.json'
|
||||||
|
|
||||||
|
reverse = {}
|
||||||
|
duplicates = {}
|
||||||
|
|
||||||
|
with open(source) as en:
|
||||||
|
strings = json.load(en)
|
||||||
|
for key, value in strings.items():
|
||||||
|
if value not in reverse:
|
||||||
|
reverse[value] = [key]
|
||||||
|
else:
|
||||||
|
reverse[value].append(key)
|
||||||
|
|
||||||
|
for key, value in reverse.items():
|
||||||
|
if len(value) > 1:
|
||||||
|
duplicates[key] = value
|
||||||
|
|
||||||
|
print('LENGTH: ' + str(len(duplicates)))
|
||||||
|
with open('duplicates.txt', 'w') as out:
|
||||||
|
for item in duplicates:
|
||||||
|
out.write(json.dumps(item) + ': ')
|
||||||
|
out.write(json.dumps(duplicates[item]) + '\n')
|
||||||
|
out.close()
|
||||||
|
|
||||||
|
print('DONE')
|
|
@ -11,7 +11,7 @@ langlst = os.listdir(langdir)
|
||||||
|
|
||||||
keys = []
|
keys = []
|
||||||
|
|
||||||
with open('scout.txt', 'r') as f:
|
with open('unused.txt', 'r') as f:
|
||||||
for line in f:
|
for line in f:
|
||||||
keys.append(line.strip('\n'))
|
keys.append(line.strip('\n'))
|
||||||
|
|
|
@ -236,12 +236,6 @@
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.layout-desktop .searchTabButton,
|
|
||||||
.layout-mobile .searchTabButton,
|
|
||||||
.layout-tv .headerSearchButton {
|
|
||||||
display: none !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.mainDrawer-scrollContainer {
|
.mainDrawer-scrollContainer {
|
||||||
padding-bottom: 10vh;
|
padding-bottom: 10vh;
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ import 'formDialogStyle';
|
||||||
};
|
};
|
||||||
|
|
||||||
if (parseFloat(updatedSchedule.StartHour) >= parseFloat(updatedSchedule.EndHour)) {
|
if (parseFloat(updatedSchedule.StartHour) >= parseFloat(updatedSchedule.EndHour)) {
|
||||||
return void alert(globalize.translate('ErrorMessageStartHourGreaterThanEnd'));
|
return void alert(globalize.translate('ErrorStartHourGreaterThanEnd'));
|
||||||
}
|
}
|
||||||
|
|
||||||
context.submitted = true;
|
context.submitted = true;
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
define(['loading', 'globalize', 'events', 'viewManager', 'skinManager', 'backdrop', 'browser', 'page', 'appSettings', 'apphost', 'connectionManager'], function (loading, globalize, events, viewManager, skinManager, backdrop, browser, page, appSettings, appHost, connectionManager) {
|
define(['loading', 'globalize', 'events', 'viewManager', 'skinManager', 'backdrop', 'browser', 'page', 'appSettings', 'apphost', 'connectionManager'], function (loading, globalize, events, viewManager, skinManager, backdrop, browser, page, appSettings, appHost, connectionManager) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
viewManager = viewManager.default || viewManager;
|
||||||
|
browser = browser.default || browser;
|
||||||
|
loading = loading.default || loading;
|
||||||
|
|
||||||
var appRouter = {
|
var appRouter = {
|
||||||
showLocalLogin: function (serverId, manualLogin) {
|
showLocalLogin: function (serverId, manualLogin) {
|
||||||
var pageName = manualLogin ? 'manuallogin' : 'login';
|
var pageName = manualLogin ? 'manuallogin' : 'login';
|
||||||
|
@ -34,7 +38,7 @@ define(['loading', 'globalize', 'events', 'viewManager', 'skinManager', 'backdro
|
||||||
switch (result.State) {
|
switch (result.State) {
|
||||||
case 'SignedIn':
|
case 'SignedIn':
|
||||||
loading.hide();
|
loading.hide();
|
||||||
skinManager.loadUserSkin();
|
Emby.Page.goHome();
|
||||||
break;
|
break;
|
||||||
case 'ServerSignIn':
|
case 'ServerSignIn':
|
||||||
result.ApiClient.getPublicUsers().then(function (users) {
|
result.ApiClient.getPublicUsers().then(function (users) {
|
||||||
|
@ -147,7 +151,6 @@ define(['loading', 'globalize', 'events', 'viewManager', 'skinManager', 'backdro
|
||||||
if (typeof route.path === 'string') {
|
if (typeof route.path === 'string') {
|
||||||
loadContentUrl(ctx, next, route, currentRequest);
|
loadContentUrl(ctx, next, route, currentRequest);
|
||||||
} else {
|
} else {
|
||||||
// ? TODO
|
|
||||||
next();
|
next();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -285,12 +288,9 @@ define(['loading', 'globalize', 'events', 'viewManager', 'skinManager', 'backdro
|
||||||
|
|
||||||
connectionManager.connect({
|
connectionManager.connect({
|
||||||
enableAutoLogin: appSettings.enableAutoLogin()
|
enableAutoLogin: appSettings.enableAutoLogin()
|
||||||
|
|
||||||
}).then(function (result) {
|
}).then(function (result) {
|
||||||
firstConnectionResult = result;
|
firstConnectionResult = result;
|
||||||
|
|
||||||
options = options || {};
|
options = options || {};
|
||||||
|
|
||||||
page({
|
page({
|
||||||
click: options.click !== false,
|
click: options.click !== false,
|
||||||
hashbang: options.hashbang !== false
|
hashbang: options.hashbang !== false
|
||||||
|
@ -342,7 +342,7 @@ define(['loading', 'globalize', 'events', 'viewManager', 'skinManager', 'backdro
|
||||||
|
|
||||||
if (route.isDefaultRoute) {
|
if (route.isDefaultRoute) {
|
||||||
console.debug('appRouter - loading skin home page');
|
console.debug('appRouter - loading skin home page');
|
||||||
loadUserSkinWithOptions(ctx);
|
Emby.Page.goHome();
|
||||||
return;
|
return;
|
||||||
} else if (route.roles) {
|
} else if (route.roles) {
|
||||||
validateRoles(apiClient, route.roles).then(function () {
|
validateRoles(apiClient, route.roles).then(function () {
|
||||||
|
@ -356,15 +356,6 @@ define(['loading', 'globalize', 'events', 'viewManager', 'skinManager', 'backdro
|
||||||
callback();
|
callback();
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadUserSkinWithOptions(ctx) {
|
|
||||||
require(['queryString'], function (queryString) {
|
|
||||||
var params = queryString.parse(ctx.querystring);
|
|
||||||
skinManager.loadUserSkin({
|
|
||||||
start: params.start
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function validateRoles(apiClient, roles) {
|
function validateRoles(apiClient, roles) {
|
||||||
return Promise.all(roles.split(',').map(function (role) {
|
return Promise.all(roles.split(',').map(function (role) {
|
||||||
return validateRole(apiClient, role);
|
return validateRole(apiClient, role);
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
define(['appSettings', 'browser', 'events', 'htmlMediaHelper', 'webSettings', 'globalize'], function (appSettings, browser, events, htmlMediaHelper, webSettings, globalize) {
|
define(['appSettings', 'browser', 'events', 'htmlMediaHelper', 'webSettings', 'globalize'], function (appSettings, browser, events, htmlMediaHelper, webSettings, globalize) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
browser = browser.default || browser;
|
||||||
|
|
||||||
function getBaseProfileOptions(item) {
|
function getBaseProfileOptions(item) {
|
||||||
var disableHlsVideoAudioCodecs = [];
|
var disableHlsVideoAudioCodecs = [];
|
||||||
|
|
||||||
|
@ -277,7 +279,7 @@ define(['appSettings', 'browser', 'events', 'htmlMediaHelper', 'webSettings', 'g
|
||||||
features.push('targetblank');
|
features.push('targetblank');
|
||||||
features.push('screensaver');
|
features.push('screensaver');
|
||||||
|
|
||||||
webSettings.enableMultiServer().then(enabled => {
|
webSettings.getMultiServer().then(enabled => {
|
||||||
if (enabled) features.push('multiserver');
|
if (enabled) features.push('multiserver');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -407,13 +409,6 @@ define(['appSettings', 'browser', 'events', 'htmlMediaHelper', 'webSettings', 'g
|
||||||
getPushTokenInfo: function () {
|
getPushTokenInfo: function () {
|
||||||
return {};
|
return {};
|
||||||
},
|
},
|
||||||
setThemeColor: function (color) {
|
|
||||||
var metaThemeColor = document.querySelector('meta[name=theme-color]');
|
|
||||||
|
|
||||||
if (metaThemeColor) {
|
|
||||||
metaThemeColor.setAttribute('content', color);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
setUserScalable: function (scalable) {
|
setUserScalable: function (scalable) {
|
||||||
if (!browser.tv) {
|
if (!browser.tv) {
|
||||||
var att = scalable ? 'width=device-width, initial-scale=1, minimum-scale=1, user-scalable=yes' : 'width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no';
|
var att = scalable ? 'width=device-width, initial-scale=1, minimum-scale=1, user-scalable=yes' : 'width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no';
|
||||||
|
|
|
@ -1,34 +1,28 @@
|
||||||
define([], function() {
|
class CastSenderApi {
|
||||||
'use strict';
|
load() {
|
||||||
|
if (window.appMode === 'cordova' || window.appMode === 'android') {
|
||||||
if (window.appMode === 'cordova' || window.appMode === 'android') {
|
window.chrome = window.chrome || {};
|
||||||
return {
|
return Promise.resolve();
|
||||||
load: function () {
|
} else {
|
||||||
window.chrome = window.chrome || {};
|
let ccLoaded = false;
|
||||||
|
if (ccLoaded) {
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
};
|
|
||||||
} else {
|
|
||||||
var ccLoaded = false;
|
|
||||||
return {
|
|
||||||
load: function () {
|
|
||||||
if (ccLoaded) {
|
|
||||||
return Promise.resolve();
|
|
||||||
}
|
|
||||||
|
|
||||||
return new Promise(function (resolve, reject) {
|
return new Promise(function (resolve) {
|
||||||
var fileref = document.createElement('script');
|
const fileref = document.createElement('script');
|
||||||
fileref.setAttribute('type', 'text/javascript');
|
fileref.setAttribute('type', 'text/javascript');
|
||||||
|
|
||||||
fileref.onload = function () {
|
fileref.onload = function () {
|
||||||
ccLoaded = true;
|
ccLoaded = true;
|
||||||
resolve();
|
resolve();
|
||||||
};
|
};
|
||||||
|
|
||||||
fileref.setAttribute('src', 'https://www.gstatic.com/cv/js/sender/v1/cast_sender.js');
|
fileref.setAttribute('src', 'https://www.gstatic.com/cv/js/sender/v1/cast_sender.js');
|
||||||
document.querySelector('head').appendChild(fileref);
|
document.querySelector('head').appendChild(fileref);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
|
export default CastSenderApi;
|
||||||
|
|
|
@ -200,7 +200,7 @@ import 'flexStyles';
|
||||||
}
|
}
|
||||||
|
|
||||||
function centerFocus(elem, horiz, on) {
|
function centerFocus(elem, horiz, on) {
|
||||||
import('scrollHelper').then(scrollHelper => {
|
import('scrollHelper').then((scrollHelper) => {
|
||||||
const fn = on ? 'on' : 'off';
|
const fn = on ? 'on' : 'off';
|
||||||
scrollHelper.centerFocus[fn](elem, horiz);
|
scrollHelper.centerFocus[fn](elem, horiz);
|
||||||
});
|
});
|
||||||
|
|
|
@ -354,7 +354,7 @@ import 'scrollStyles';
|
||||||
}
|
}
|
||||||
|
|
||||||
function centerFocus(elem, horiz, on) {
|
function centerFocus(elem, horiz, on) {
|
||||||
import('scrollHelper').then(scrollHelper => {
|
import('scrollHelper').then((scrollHelper) => {
|
||||||
const fn = on ? 'on' : 'off';
|
const fn = on ? 'on' : 'off';
|
||||||
scrollHelper.centerFocus[fn](elem, horiz);
|
scrollHelper.centerFocus[fn](elem, horiz);
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import browser from 'browser';
|
import browser from 'browser';
|
||||||
import layoutManager from 'layoutManager';
|
import layoutManager from 'layoutManager';
|
||||||
import appSettings from 'appSettings';
|
|
||||||
import pluginManager from 'pluginManager';
|
import pluginManager from 'pluginManager';
|
||||||
import appHost from 'apphost';
|
import appHost from 'apphost';
|
||||||
import focusManager from 'focusManager';
|
import focusManager from 'focusManager';
|
||||||
|
@ -16,17 +15,22 @@ import 'emby-button';
|
||||||
|
|
||||||
/* eslint-disable indent */
|
/* eslint-disable indent */
|
||||||
|
|
||||||
function fillThemes(select, isDashboard) {
|
function fillThemes(context, userSettings) {
|
||||||
select.innerHTML = skinManager.getThemes().map(t => {
|
const select = context.querySelector('#selectTheme');
|
||||||
let value = t.id;
|
|
||||||
if (t.isDefault && !isDashboard) {
|
|
||||||
value = '';
|
|
||||||
} else if (t.isDefaultServerDashboard && isDashboard) {
|
|
||||||
value = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
return `<option value="${value}">${t.name}</option>`;
|
skinManager.getThemes().then(themes => {
|
||||||
}).join('');
|
select.innerHTML = themes.map(t => {
|
||||||
|
return `<option value="${t.id}">${t.name}</option>`;
|
||||||
|
}).join('');
|
||||||
|
|
||||||
|
// get default theme
|
||||||
|
var defaultTheme = themes.find(theme => {
|
||||||
|
return theme.default;
|
||||||
|
});
|
||||||
|
|
||||||
|
// set the current theme
|
||||||
|
select.value = userSettings.theme() || defaultTheme.id;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadScreensavers(context, userSettings) {
|
function loadScreensavers(context, userSettings) {
|
||||||
|
@ -46,6 +50,7 @@ import 'emby-button';
|
||||||
selectScreensaver.innerHTML = options.map(o => {
|
selectScreensaver.innerHTML = options.map(o => {
|
||||||
return `<option value="${o.value}">${o.name}</option>`;
|
return `<option value="${o.value}">${o.name}</option>`;
|
||||||
}).join('');
|
}).join('');
|
||||||
|
|
||||||
selectScreensaver.value = userSettings.screensaver();
|
selectScreensaver.value = userSettings.screensaver();
|
||||||
|
|
||||||
if (!selectScreensaver.value) {
|
if (!selectScreensaver.value) {
|
||||||
|
@ -54,57 +59,6 @@ import 'emby-button';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadSoundEffects(context, userSettings) {
|
|
||||||
const selectSoundEffects = context.querySelector('.selectSoundEffects');
|
|
||||||
const options = pluginManager.ofType('soundeffects').map(plugin => {
|
|
||||||
return {
|
|
||||||
name: plugin.name,
|
|
||||||
value: plugin.id
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
options.unshift({
|
|
||||||
name: globalize.translate('None'),
|
|
||||||
value: 'none'
|
|
||||||
});
|
|
||||||
|
|
||||||
selectSoundEffects.innerHTML = options.map(o => {
|
|
||||||
return `<option value="${o.value}">${o.name}</option>`;
|
|
||||||
}).join('');
|
|
||||||
selectSoundEffects.value = userSettings.soundEffects();
|
|
||||||
|
|
||||||
if (!selectSoundEffects.value) {
|
|
||||||
// TODO: set the default instead of none
|
|
||||||
selectSoundEffects.value = 'none';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function loadSkins(context, userSettings) {
|
|
||||||
const selectSkin = context.querySelector('.selectSkin');
|
|
||||||
|
|
||||||
const options = pluginManager.ofType('skin').map(plugin => {
|
|
||||||
return {
|
|
||||||
name: plugin.name,
|
|
||||||
value: plugin.id
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
selectSkin.innerHTML = options.map(o => {
|
|
||||||
return `<option value="${o.value}">${o.name}</option>`;
|
|
||||||
}).join('');
|
|
||||||
selectSkin.value = userSettings.skin();
|
|
||||||
|
|
||||||
if (!selectSkin.value && options.length) {
|
|
||||||
selectSkin.value = options[0].value;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (options.length > 1 && appHost.supports('skins')) {
|
|
||||||
context.querySelector('.selectSkinContainer').classList.remove('hide');
|
|
||||||
} else {
|
|
||||||
context.querySelector('.selectSkinContainer').classList.add('hide');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function showOrHideMissingEpisodesField(context) {
|
function showOrHideMissingEpisodesField(context) {
|
||||||
if (browser.tizen || browser.web0s) {
|
if (browser.tizen || browser.web0s) {
|
||||||
context.querySelector('.fldDisplayMissingEpisodes').classList.add('hide');
|
context.querySelector('.fldDisplayMissingEpisodes').classList.add('hide');
|
||||||
|
@ -115,12 +69,6 @@ import 'emby-button';
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadForm(context, user, userSettings) {
|
function loadForm(context, user, userSettings) {
|
||||||
if (user.Policy.IsAdministrator) {
|
|
||||||
context.querySelector('.selectDashboardThemeContainer').classList.remove('hide');
|
|
||||||
} else {
|
|
||||||
context.querySelector('.selectDashboardThemeContainer').classList.add('hide');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (appHost.supports('displaylanguage')) {
|
if (appHost.supports('displaylanguage')) {
|
||||||
context.querySelector('.languageSection').classList.remove('hide');
|
context.querySelector('.languageSection').classList.remove('hide');
|
||||||
} else {
|
} else {
|
||||||
|
@ -139,18 +87,6 @@ import 'emby-button';
|
||||||
context.querySelector('.learnHowToContributeContainer').classList.add('hide');
|
context.querySelector('.learnHowToContributeContainer').classList.add('hide');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (appHost.supports('runatstartup')) {
|
|
||||||
context.querySelector('.fldAutorun').classList.remove('hide');
|
|
||||||
} else {
|
|
||||||
context.querySelector('.fldAutorun').classList.add('hide');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (appHost.supports('soundeffects')) {
|
|
||||||
context.querySelector('.fldSoundEffects').classList.remove('hide');
|
|
||||||
} else {
|
|
||||||
context.querySelector('.fldSoundEffects').classList.add('hide');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (appHost.supports('screensaver')) {
|
if (appHost.supports('screensaver')) {
|
||||||
context.querySelector('.selectScreensaverContainer').classList.remove('hide');
|
context.querySelector('.selectScreensaverContainer').classList.remove('hide');
|
||||||
} else {
|
} else {
|
||||||
|
@ -173,16 +109,8 @@ import 'emby-button';
|
||||||
context.querySelector('.fldThemeVideo').classList.add('hide');
|
context.querySelector('.fldThemeVideo').classList.add('hide');
|
||||||
}
|
}
|
||||||
|
|
||||||
context.querySelector('.chkRunAtStartup').checked = appSettings.runAtStartup();
|
fillThemes(context, userSettings);
|
||||||
|
|
||||||
const selectTheme = context.querySelector('#selectTheme');
|
|
||||||
const selectDashboardTheme = context.querySelector('#selectDashboardTheme');
|
|
||||||
|
|
||||||
fillThemes(selectTheme);
|
|
||||||
fillThemes(selectDashboardTheme, true);
|
|
||||||
loadScreensavers(context, userSettings);
|
loadScreensavers(context, userSettings);
|
||||||
loadSoundEffects(context, userSettings);
|
|
||||||
loadSkins(context, userSettings);
|
|
||||||
|
|
||||||
context.querySelector('.chkDisplayMissingEpisodes').checked = user.Configuration.DisplayMissingEpisodes || false;
|
context.querySelector('.chkDisplayMissingEpisodes').checked = user.Configuration.DisplayMissingEpisodes || false;
|
||||||
|
|
||||||
|
@ -198,9 +126,6 @@ import 'emby-button';
|
||||||
|
|
||||||
context.querySelector('#txtLibraryPageSize').value = userSettings.libraryPageSize();
|
context.querySelector('#txtLibraryPageSize').value = userSettings.libraryPageSize();
|
||||||
|
|
||||||
selectDashboardTheme.value = userSettings.dashboardTheme() || '';
|
|
||||||
selectTheme.value = userSettings.theme() || '';
|
|
||||||
|
|
||||||
context.querySelector('.selectLayout').value = layoutManager.getSavedLayout() || '';
|
context.querySelector('.selectLayout').value = layoutManager.getSavedLayout() || '';
|
||||||
|
|
||||||
showOrHideMissingEpisodesField(context);
|
showOrHideMissingEpisodesField(context);
|
||||||
|
@ -209,8 +134,6 @@ import 'emby-button';
|
||||||
}
|
}
|
||||||
|
|
||||||
function saveUser(context, user, userSettingsInstance, apiClient) {
|
function saveUser(context, user, userSettingsInstance, apiClient) {
|
||||||
appSettings.runAtStartup(context.querySelector('.chkRunAtStartup').checked);
|
|
||||||
|
|
||||||
user.Configuration.DisplayMissingEpisodes = context.querySelector('.chkDisplayMissingEpisodes').checked;
|
user.Configuration.DisplayMissingEpisodes = context.querySelector('.chkDisplayMissingEpisodes').checked;
|
||||||
|
|
||||||
if (appHost.supports('displaylanguage')) {
|
if (appHost.supports('displaylanguage')) {
|
||||||
|
@ -221,15 +144,11 @@ import 'emby-button';
|
||||||
|
|
||||||
userSettingsInstance.enableThemeSongs(context.querySelector('#chkThemeSong').checked);
|
userSettingsInstance.enableThemeSongs(context.querySelector('#chkThemeSong').checked);
|
||||||
userSettingsInstance.enableThemeVideos(context.querySelector('#chkThemeVideo').checked);
|
userSettingsInstance.enableThemeVideos(context.querySelector('#chkThemeVideo').checked);
|
||||||
userSettingsInstance.dashboardTheme(context.querySelector('#selectDashboardTheme').value);
|
|
||||||
userSettingsInstance.theme(context.querySelector('#selectTheme').value);
|
userSettingsInstance.theme(context.querySelector('#selectTheme').value);
|
||||||
userSettingsInstance.soundEffects(context.querySelector('.selectSoundEffects').value);
|
|
||||||
userSettingsInstance.screensaver(context.querySelector('.selectScreensaver').value);
|
userSettingsInstance.screensaver(context.querySelector('.selectScreensaver').value);
|
||||||
|
|
||||||
userSettingsInstance.libraryPageSize(context.querySelector('#txtLibraryPageSize').value);
|
userSettingsInstance.libraryPageSize(context.querySelector('#txtLibraryPageSize').value);
|
||||||
|
|
||||||
userSettingsInstance.skin(context.querySelector('.selectSkin').value);
|
|
||||||
|
|
||||||
userSettingsInstance.enableFastFadein(context.querySelector('#chkFadein').checked);
|
userSettingsInstance.enableFastFadein(context.querySelector('#chkFadein').checked);
|
||||||
userSettingsInstance.enableBlurhash(context.querySelector('#chkBlurhash').checked);
|
userSettingsInstance.enableBlurhash(context.querySelector('#chkBlurhash').checked);
|
||||||
userSettingsInstance.enableBackdrops(context.querySelector('#chkBackdrops').checked);
|
userSettingsInstance.enableBackdrops(context.querySelector('#chkBackdrops').checked);
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
<form style="margin: 0 auto;">
|
<form style="margin: 0 auto;">
|
||||||
|
|
||||||
<h2 class="sectionTitle">
|
<h2 class="sectionTitle">
|
||||||
${Display}
|
${Display}
|
||||||
</h2>
|
</h2>
|
||||||
|
@ -123,26 +122,14 @@
|
||||||
<div class="fieldDescription">${LabelPleaseRestart}</div>
|
<div class="fieldDescription">${LabelPleaseRestart}</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="selectContainer hide selectSkinContainer">
|
|
||||||
<select is="emby-select" class="selectSkin" label="${LabelSkin}"></select>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="selectContainer">
|
<div class="selectContainer">
|
||||||
<select id="selectTheme" is="emby-select" label="${LabelTheme}"></select>
|
<select id="selectTheme" is="emby-select" label="${LabelTheme}"></select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="selectContainer selectDashboardThemeContainer hide">
|
|
||||||
<select id="selectDashboardTheme" is="emby-select" label="${LabelDashboardTheme}"></select>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="selectContainer hide selectScreensaverContainer">
|
<div class="selectContainer hide selectScreensaverContainer">
|
||||||
<select is="emby-select" class="selectScreensaver" label="${LabelScreensaver}"></select>
|
<select is="emby-select" class="selectScreensaver" label="${LabelScreensaver}"></select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="selectContainer fldSoundEffects hide">
|
|
||||||
<select is="emby-select" class="selectSoundEffects" label="${LabelSoundEffects}"></select>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="inputContainer inputContainer-withDescription">
|
<div class="inputContainer inputContainer-withDescription">
|
||||||
<input is="emby-input" type="number" id="txtLibraryPageSize" pattern="[0-9]*" required="required" min="0" max="1000" step="1" label="${LabelLibraryPageSize}" />
|
<input is="emby-input" type="number" id="txtLibraryPageSize" pattern="[0-9]*" required="required" min="0" max="1000" step="1" label="${LabelLibraryPageSize}" />
|
||||||
<div class="fieldDescription">${LabelLibraryPageSizeHelp}</div>
|
<div class="fieldDescription">${LabelLibraryPageSizeHelp}</div>
|
||||||
|
@ -159,9 +146,9 @@
|
||||||
<div class="checkboxContainer checkboxContainer-withDescription">
|
<div class="checkboxContainer checkboxContainer-withDescription">
|
||||||
<label>
|
<label>
|
||||||
<input type="checkbox" is="emby-checkbox" id="chkBlurhash" />
|
<input type="checkbox" is="emby-checkbox" id="chkBlurhash" />
|
||||||
<span>${EnableBlurhash}</span>
|
<span>${EnableBlurHash}</span>
|
||||||
</label>
|
</label>
|
||||||
<div class="fieldDescription checkboxFieldDescription">${EnableBlurhashHelp}</div>
|
<div class="fieldDescription checkboxFieldDescription">${EnableBlurHashHelp}</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="checkboxContainer checkboxContainer-withDescription">
|
<div class="checkboxContainer checkboxContainer-withDescription">
|
||||||
|
@ -196,13 +183,6 @@
|
||||||
<div class="fieldDescription checkboxFieldDescription">${EnableThemeVideosHelp}</div>
|
<div class="fieldDescription checkboxFieldDescription">${EnableThemeVideosHelp}</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="checkboxContainer hide fldAutorun">
|
|
||||||
<label>
|
|
||||||
<input type="checkbox" is="emby-checkbox" class="chkRunAtStartup" />
|
|
||||||
<span>${RunAtStartup}</span>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="checkboxContainer checkboxContainer-withDescription fldDisplayMissingEpisodes hide">
|
<div class="checkboxContainer checkboxContainer-withDescription fldDisplayMissingEpisodes hide">
|
||||||
<label>
|
<label>
|
||||||
<input type="checkbox" is="emby-checkbox" class="chkDisplayMissingEpisodes" />
|
<input type="checkbox" is="emby-checkbox" class="chkDisplayMissingEpisodes" />
|
||||||
|
|
|
@ -1,5 +1,14 @@
|
||||||
define(['loading', 'libraryBrowser', 'cardBuilder', 'dom', 'apphost', 'imageLoader', 'globalize', 'layoutManager', 'scrollStyles', 'emby-itemscontainer'], function (loading, libraryBrowser, cardBuilder, dom, appHost, imageLoader, globalize, layoutManager) {
|
import loading from 'loading';
|
||||||
'use strict';
|
import cardBuilder from 'cardBuilder';
|
||||||
|
import dom from 'dom';
|
||||||
|
import appHost from 'apphost';
|
||||||
|
import imageLoader from 'imageLoader';
|
||||||
|
import globalize from 'globalize';
|
||||||
|
import layoutManager from 'layoutManager';
|
||||||
|
import 'scrollStyles';
|
||||||
|
import 'emby-itemscontainer';
|
||||||
|
|
||||||
|
/* eslint-disable indent */
|
||||||
|
|
||||||
function enableScrollX() {
|
function enableScrollX() {
|
||||||
return !layoutManager.desktop;
|
return !layoutManager.desktop;
|
||||||
|
@ -94,8 +103,8 @@ define(['loading', 'libraryBrowser', 'cardBuilder', 'dom', 'apphost', 'imageLoad
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadSection(elem, userId, topParentId, section, isSingleSection) {
|
function loadSection(elem, userId, topParentId, section, isSingleSection) {
|
||||||
var screenWidth = dom.getWindowSize().innerWidth;
|
const screenWidth = dom.getWindowSize().innerWidth;
|
||||||
var options = {
|
const options = {
|
||||||
SortBy: 'SortName',
|
SortBy: 'SortName',
|
||||||
SortOrder: 'Ascending',
|
SortOrder: 'Ascending',
|
||||||
Filters: 'IsFavorite',
|
Filters: 'IsFavorite',
|
||||||
|
@ -118,7 +127,7 @@ define(['loading', 'libraryBrowser', 'cardBuilder', 'dom', 'apphost', 'imageLoad
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var promise;
|
let promise;
|
||||||
|
|
||||||
if (section.types === 'MusicArtist') {
|
if (section.types === 'MusicArtist') {
|
||||||
promise = ApiClient.getArtists(userId, options);
|
promise = ApiClient.getArtists(userId, options);
|
||||||
|
@ -128,7 +137,7 @@ define(['loading', 'libraryBrowser', 'cardBuilder', 'dom', 'apphost', 'imageLoad
|
||||||
}
|
}
|
||||||
|
|
||||||
return promise.then(function (result) {
|
return promise.then(function (result) {
|
||||||
var html = '';
|
let html = '';
|
||||||
|
|
||||||
if (result.Items.length) {
|
if (result.Items.length) {
|
||||||
if (html += '<div class="sectionTitleContainer sectionTitleContainer-cards padded-left">', !layoutManager.tv && options.Limit && result.Items.length >= options.Limit) {
|
if (html += '<div class="sectionTitleContainer sectionTitleContainer-cards padded-left">', !layoutManager.tv && options.Limit && result.Items.length >= options.Limit) {
|
||||||
|
@ -144,7 +153,7 @@ define(['loading', 'libraryBrowser', 'cardBuilder', 'dom', 'apphost', 'imageLoad
|
||||||
|
|
||||||
html += '</div>';
|
html += '</div>';
|
||||||
if (enableScrollX()) {
|
if (enableScrollX()) {
|
||||||
var scrollXClass = 'scrollX hiddenScrollX';
|
let scrollXClass = 'scrollX hiddenScrollX';
|
||||||
if (layoutManager.tv) {
|
if (layoutManager.tv) {
|
||||||
scrollXClass += ' smoothScrollX';
|
scrollXClass += ' smoothScrollX';
|
||||||
}
|
}
|
||||||
|
@ -154,7 +163,7 @@ define(['loading', 'libraryBrowser', 'cardBuilder', 'dom', 'apphost', 'imageLoad
|
||||||
html += '<div is="emby-itemscontainer" class="itemsContainer vertical-wrap padded-left padded-right">';
|
html += '<div is="emby-itemscontainer" class="itemsContainer vertical-wrap padded-left padded-right">';
|
||||||
}
|
}
|
||||||
|
|
||||||
var cardLayout = appHost.preferVisualCards && section.autoCardLayout && section.showTitle;
|
let cardLayout = appHost.preferVisualCards && section.autoCardLayout && section.showTitle;
|
||||||
cardLayout = false;
|
cardLayout = false;
|
||||||
html += cardBuilder.getCardsHtml(result.Items, {
|
html += cardBuilder.getCardsHtml(result.Items, {
|
||||||
preferThumb: section.preferThumb,
|
preferThumb: section.preferThumb,
|
||||||
|
@ -179,10 +188,10 @@ define(['loading', 'libraryBrowser', 'cardBuilder', 'dom', 'apphost', 'imageLoad
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadSections(page, userId, topParentId, types) {
|
export function loadSections(page, userId, topParentId, types) {
|
||||||
loading.show();
|
loading.show();
|
||||||
var sections = getSections();
|
let sections = getSections();
|
||||||
var sectionid = getParameterByName('sectionid');
|
const sectionid = getParameterByName('sectionid');
|
||||||
|
|
||||||
if (sectionid) {
|
if (sectionid) {
|
||||||
sections = sections.filter(function (s) {
|
sections = sections.filter(function (s) {
|
||||||
|
@ -196,24 +205,22 @@ define(['loading', 'libraryBrowser', 'cardBuilder', 'dom', 'apphost', 'imageLoad
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
var i;
|
let elem = page.querySelector('.favoriteSections');
|
||||||
var length;
|
|
||||||
var elem = page.querySelector('.favoriteSections');
|
|
||||||
|
|
||||||
if (!elem.innerHTML) {
|
if (!elem.innerHTML) {
|
||||||
var html = '';
|
let html = '';
|
||||||
|
|
||||||
for (i = 0, length = sections.length; i < length; i++) {
|
for (let i = 0, length = sections.length; i < length; i++) {
|
||||||
html += '<div class="verticalSection section' + sections[i].id + '"></div>';
|
html += '<div class="verticalSection section' + sections[i].id + '"></div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
elem.innerHTML = html;
|
elem.innerHTML = html;
|
||||||
}
|
}
|
||||||
|
|
||||||
var promises = [];
|
const promises = [];
|
||||||
|
|
||||||
for (i = 0, length = sections.length; i < length; i++) {
|
for (let i = 0, length = sections.length; i < length; i++) {
|
||||||
var section = sections[i];
|
const section = sections[i];
|
||||||
elem = page.querySelector('.section' + section.id);
|
elem = page.querySelector('.section' + section.id);
|
||||||
promises.push(loadSection(elem, userId, topParentId, section, sections.length === 1));
|
promises.push(loadSection(elem, userId, topParentId, section, sections.length === 1));
|
||||||
}
|
}
|
||||||
|
@ -223,7 +230,8 @@ define(['loading', 'libraryBrowser', 'cardBuilder', 'dom', 'apphost', 'imageLoad
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
export default {
|
||||||
render: loadSections
|
render: loadSections
|
||||||
};
|
};
|
||||||
});
|
|
||||||
|
/* eslint-enable indent */
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
define(['require', 'dom', 'focusManager', 'dialogHelper', 'loading', 'apphost', 'inputManager', 'layoutManager', 'connectionManager', 'appRouter', 'globalize', 'userSettings', 'emby-checkbox', 'emby-input', 'paper-icon-button-light', 'emby-select', 'material-icons', 'css!./../formdialog', 'emby-button', 'flexStyles'], function (require, dom, focusManager, dialogHelper, loading, appHost, inputManager, layoutManager, connectionManager, appRouter, globalize, userSettings) {
|
define(['require', 'dom', 'focusManager', 'dialogHelper', 'loading', 'apphost', 'inputManager', 'layoutManager', 'connectionManager', 'appRouter', 'globalize', 'userSettings', 'emby-checkbox', 'emby-input', 'paper-icon-button-light', 'emby-select', 'material-icons', 'css!./../formdialog', 'emby-button', 'flexStyles'], function (require, dom, focusManager, dialogHelper, loading, appHost, inputManager, layoutManager, connectionManager, appRouter, globalize, userSettings) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
focusManager = focusManager.default || focusManager;
|
||||||
|
|
||||||
|
layoutManager = layoutManager.default || layoutManager;
|
||||||
|
|
||||||
function onSubmit(e) {
|
function onSubmit(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
@ -150,6 +153,7 @@ define(['require', 'dom', 'focusManager', 'dialogHelper', 'loading', 'apphost',
|
||||||
|
|
||||||
function centerFocus(elem, horiz, on) {
|
function centerFocus(elem, horiz, on) {
|
||||||
require(['scrollHelper'], function (scrollHelper) {
|
require(['scrollHelper'], function (scrollHelper) {
|
||||||
|
scrollHelper = scrollHelper.default || scrollHelper;
|
||||||
var fn = on ? 'on' : 'off';
|
var fn = on ? 'on' : 'off';
|
||||||
scrollHelper.centerFocus[fn](elem, horiz);
|
scrollHelper.centerFocus[fn](elem, horiz);
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
define(['dom', 'scrollManager'], function (dom, scrollManager) {
|
/* eslint-disable indent */
|
||||||
'use strict';
|
|
||||||
|
import dom from 'dom';
|
||||||
|
import scrollManager from 'scrollManager';
|
||||||
|
|
||||||
var scopes = [];
|
var scopes = [];
|
||||||
function pushScope(elem) {
|
function pushScope(elem) {
|
||||||
|
@ -472,37 +474,38 @@ define(['dom', 'scrollManager'], function (dom, scrollManager) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
/* eslint-enable indent */
|
||||||
autoFocus: autoFocus,
|
|
||||||
focus: focus,
|
export default {
|
||||||
focusableParent: focusableParent,
|
autoFocus: autoFocus,
|
||||||
getFocusableElements: getFocusableElements,
|
focus: focus,
|
||||||
moveLeft: function (sourceElement, options) {
|
focusableParent: focusableParent,
|
||||||
var container = options ? options.container : null;
|
getFocusableElements: getFocusableElements,
|
||||||
var focusableElements = options ? options.focusableElements : null;
|
moveLeft: function (sourceElement, options) {
|
||||||
nav(sourceElement, 0, container, focusableElements);
|
var container = options ? options.container : null;
|
||||||
},
|
var focusableElements = options ? options.focusableElements : null;
|
||||||
moveRight: function (sourceElement, options) {
|
nav(sourceElement, 0, container, focusableElements);
|
||||||
var container = options ? options.container : null;
|
},
|
||||||
var focusableElements = options ? options.focusableElements : null;
|
moveRight: function (sourceElement, options) {
|
||||||
nav(sourceElement, 1, container, focusableElements);
|
var container = options ? options.container : null;
|
||||||
},
|
var focusableElements = options ? options.focusableElements : null;
|
||||||
moveUp: function (sourceElement, options) {
|
nav(sourceElement, 1, container, focusableElements);
|
||||||
var container = options ? options.container : null;
|
},
|
||||||
var focusableElements = options ? options.focusableElements : null;
|
moveUp: function (sourceElement, options) {
|
||||||
nav(sourceElement, 2, container, focusableElements);
|
var container = options ? options.container : null;
|
||||||
},
|
var focusableElements = options ? options.focusableElements : null;
|
||||||
moveDown: function (sourceElement, options) {
|
nav(sourceElement, 2, container, focusableElements);
|
||||||
var container = options ? options.container : null;
|
},
|
||||||
var focusableElements = options ? options.focusableElements : null;
|
moveDown: function (sourceElement, options) {
|
||||||
nav(sourceElement, 3, container, focusableElements);
|
var container = options ? options.container : null;
|
||||||
},
|
var focusableElements = options ? options.focusableElements : null;
|
||||||
sendText: sendText,
|
nav(sourceElement, 3, container, focusableElements);
|
||||||
isCurrentlyFocusable: isCurrentlyFocusable,
|
},
|
||||||
pushScope: pushScope,
|
sendText: sendText,
|
||||||
popScope: popScope,
|
isCurrentlyFocusable: isCurrentlyFocusable,
|
||||||
focusFirst: focusFirst,
|
pushScope: pushScope,
|
||||||
focusLast: focusLast,
|
popScope: popScope,
|
||||||
moveFocus: moveFocus
|
focusFirst: focusFirst,
|
||||||
};
|
focusLast: focusLast,
|
||||||
});
|
moveFocus: moveFocus
|
||||||
|
};
|
||||||
|
|
|
@ -1,147 +1,149 @@
|
||||||
define(['dialogHelper', 'globalize', 'userSettings', 'layoutManager', 'connectionManager', 'require', 'loading', 'scrollHelper', 'emby-checkbox', 'emby-radio', 'css!./../formdialog', 'material-icons'], function (dialogHelper, globalize, userSettings, layoutManager, connectionManager, require, loading, scrollHelper) {
|
import dialogHelper from 'dialogHelper';
|
||||||
'use strict';
|
import globalize from 'globalize';
|
||||||
|
import * as userSettings from 'userSettings';
|
||||||
|
import layoutManager from 'layoutManager';
|
||||||
|
import scrollHelper from 'scrollHelper';
|
||||||
|
import 'emby-checkbox';
|
||||||
|
import 'emby-radio';
|
||||||
|
import 'css!./../formdialog';
|
||||||
|
import 'material-icons';
|
||||||
|
|
||||||
function saveCategories(context, options) {
|
function saveCategories(context, options) {
|
||||||
var categories = [];
|
const categories = [];
|
||||||
|
|
||||||
var chkCategorys = context.querySelectorAll('.chkCategory');
|
const chkCategorys = context.querySelectorAll('.chkCategory');
|
||||||
for (var i = 0, length = chkCategorys.length; i < length; i++) {
|
for (const chkCategory of chkCategorys) {
|
||||||
var type = chkCategorys[i].getAttribute('data-type');
|
const type = chkCategory.getAttribute('data-type');
|
||||||
|
|
||||||
if (chkCategorys[i].checked) {
|
if (chkCategory.checked) {
|
||||||
categories.push(type);
|
categories.push(type);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (categories.length >= 4) {
|
|
||||||
categories.push('series');
|
|
||||||
}
|
|
||||||
|
|
||||||
// differentiate between none and all
|
|
||||||
categories.push('all');
|
|
||||||
options.categories = categories;
|
|
||||||
}
|
|
||||||
|
|
||||||
function loadCategories(context, options) {
|
|
||||||
var selectedCategories = options.categories || [];
|
|
||||||
|
|
||||||
var chkCategorys = context.querySelectorAll('.chkCategory');
|
|
||||||
for (var i = 0, length = chkCategorys.length; i < length; i++) {
|
|
||||||
var type = chkCategorys[i].getAttribute('data-type');
|
|
||||||
|
|
||||||
chkCategorys[i].checked = !selectedCategories.length || selectedCategories.indexOf(type) !== -1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function save(context) {
|
if (categories.length >= 4) {
|
||||||
var i;
|
categories.push('series');
|
||||||
var length;
|
}
|
||||||
|
|
||||||
var chkIndicators = context.querySelectorAll('.chkIndicator');
|
// differentiate between none and all
|
||||||
for (i = 0, length = chkIndicators.length; i < length; i++) {
|
categories.push('all');
|
||||||
var type = chkIndicators[i].getAttribute('data-type');
|
options.categories = categories;
|
||||||
userSettings.set('guide-indicator-' + type, chkIndicators[i].checked);
|
}
|
||||||
|
|
||||||
|
function loadCategories(context, options) {
|
||||||
|
const selectedCategories = options.categories || [];
|
||||||
|
|
||||||
|
const chkCategorys = context.querySelectorAll('.chkCategory');
|
||||||
|
for (const chkCategory of chkCategorys) {
|
||||||
|
const type = chkCategory.getAttribute('data-type');
|
||||||
|
|
||||||
|
chkCategory.checked = !selectedCategories.length || selectedCategories.indexOf(type) !== -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function save(context) {
|
||||||
|
const chkIndicators = context.querySelectorAll('.chkIndicator');
|
||||||
|
|
||||||
|
for (const chkIndicator of chkIndicators) {
|
||||||
|
const type = chkIndicator.getAttribute('data-type');
|
||||||
|
userSettings.set('guide-indicator-' + type, chkIndicator.checked);
|
||||||
|
}
|
||||||
|
|
||||||
|
userSettings.set('guide-colorcodedbackgrounds', context.querySelector('.chkColorCodedBackgrounds').checked);
|
||||||
|
userSettings.set('livetv-favoritechannelsattop', context.querySelector('.chkFavoriteChannelsAtTop').checked);
|
||||||
|
|
||||||
|
const sortBys = context.querySelectorAll('.chkSortOrder');
|
||||||
|
for (const sortBy of sortBys) {
|
||||||
|
if (sortBy.checked) {
|
||||||
|
userSettings.set('livetv-channelorder', sortBy.value);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
userSettings.set('guide-colorcodedbackgrounds', context.querySelector('.chkColorCodedBackgrounds').checked);
|
function load(context) {
|
||||||
userSettings.set('livetv-favoritechannelsattop', context.querySelector('.chkFavoriteChannelsAtTop').checked);
|
const chkIndicators = context.querySelectorAll('.chkIndicator');
|
||||||
|
|
||||||
var sortBys = context.querySelectorAll('.chkSortOrder');
|
for (const chkIndicator of chkIndicators) {
|
||||||
for (i = 0, length = sortBys.length; i < length; i++) {
|
const type = chkIndicator.getAttribute('data-type');
|
||||||
if (sortBys[i].checked) {
|
|
||||||
userSettings.set('livetv-channelorder', sortBys[i].value);
|
if (chkIndicator.getAttribute('data-default') === 'true') {
|
||||||
break;
|
chkIndicator.checked = userSettings.get('guide-indicator-' + type) !== 'false';
|
||||||
}
|
} else {
|
||||||
|
chkIndicator.checked = userSettings.get('guide-indicator-' + type) === 'true';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function load(context) {
|
context.querySelector('.chkColorCodedBackgrounds').checked = userSettings.get('guide-colorcodedbackgrounds') === 'true';
|
||||||
var i;
|
context.querySelector('.chkFavoriteChannelsAtTop').checked = userSettings.get('livetv-favoritechannelsattop') !== 'false';
|
||||||
var length;
|
|
||||||
|
|
||||||
var chkIndicators = context.querySelectorAll('.chkIndicator');
|
const sortByValue = userSettings.get('livetv-channelorder') || 'Number';
|
||||||
for (i = 0, length = chkIndicators.length; i < length; i++) {
|
|
||||||
var type = chkIndicators[i].getAttribute('data-type');
|
|
||||||
|
|
||||||
if (chkIndicators[i].getAttribute('data-default') === 'true') {
|
const sortBys = context.querySelectorAll('.chkSortOrder');
|
||||||
chkIndicators[i].checked = userSettings.get('guide-indicator-' + type) !== 'false';
|
for (const sortBy of sortBys) {
|
||||||
|
sortBy.checked = sortBy.value === sortByValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function showEditor(options) {
|
||||||
|
return new Promise(function (resolve, reject) {
|
||||||
|
let settingsChanged = false;
|
||||||
|
|
||||||
|
import('text!./guide-settings.template.html').then(({ default: template }) => {
|
||||||
|
const dialogOptions = {
|
||||||
|
removeOnClose: true,
|
||||||
|
scrollY: false
|
||||||
|
};
|
||||||
|
|
||||||
|
if (layoutManager.tv) {
|
||||||
|
dialogOptions.size = 'fullscreen';
|
||||||
} else {
|
} else {
|
||||||
chkIndicators[i].checked = userSettings.get('guide-indicator-' + type) === 'true';
|
dialogOptions.size = 'small';
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
context.querySelector('.chkColorCodedBackgrounds').checked = userSettings.get('guide-colorcodedbackgrounds') === 'true';
|
const dlg = dialogHelper.createDialog(dialogOptions);
|
||||||
context.querySelector('.chkFavoriteChannelsAtTop').checked = userSettings.get('livetv-favoritechannelsattop') !== 'false';
|
|
||||||
|
|
||||||
var sortByValue = userSettings.get('livetv-channelorder') || 'Number';
|
dlg.classList.add('formDialog');
|
||||||
|
|
||||||
var sortBys = context.querySelectorAll('.chkSortOrder');
|
let html = '';
|
||||||
for (i = 0, length = sortBys.length; i < length; i++) {
|
|
||||||
sortBys[i].checked = sortBys[i].value === sortByValue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function showEditor(options) {
|
html += globalize.translateHtml(template, 'core');
|
||||||
return new Promise(function (resolve, reject) {
|
|
||||||
var settingsChanged = false;
|
|
||||||
|
|
||||||
require(['text!./guide-settings.template.html'], function (template) {
|
dlg.innerHTML = html;
|
||||||
var dialogOptions = {
|
|
||||||
removeOnClose: true,
|
|
||||||
scrollY: false
|
|
||||||
};
|
|
||||||
|
|
||||||
if (layoutManager.tv) {
|
dlg.addEventListener('change', function () {
|
||||||
dialogOptions.size = 'fullscreen';
|
settingsChanged = true;
|
||||||
} else {
|
|
||||||
dialogOptions.size = 'small';
|
|
||||||
}
|
|
||||||
|
|
||||||
var dlg = dialogHelper.createDialog(dialogOptions);
|
|
||||||
|
|
||||||
dlg.classList.add('formDialog');
|
|
||||||
|
|
||||||
var html = '';
|
|
||||||
|
|
||||||
html += globalize.translateHtml(template, 'core');
|
|
||||||
|
|
||||||
dlg.innerHTML = html;
|
|
||||||
|
|
||||||
dlg.addEventListener('change', function () {
|
|
||||||
settingsChanged = true;
|
|
||||||
});
|
|
||||||
|
|
||||||
dlg.addEventListener('close', function () {
|
|
||||||
if (layoutManager.tv) {
|
|
||||||
scrollHelper.centerFocus.off(dlg.querySelector('.formDialogContent'), false);
|
|
||||||
}
|
|
||||||
|
|
||||||
save(dlg);
|
|
||||||
saveCategories(dlg, options);
|
|
||||||
|
|
||||||
if (settingsChanged) {
|
|
||||||
resolve();
|
|
||||||
} else {
|
|
||||||
reject();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
dlg.querySelector('.btnCancel').addEventListener('click', function () {
|
|
||||||
dialogHelper.close(dlg);
|
|
||||||
});
|
|
||||||
|
|
||||||
if (layoutManager.tv) {
|
|
||||||
scrollHelper.centerFocus.on(dlg.querySelector('.formDialogContent'), false);
|
|
||||||
}
|
|
||||||
|
|
||||||
load(dlg);
|
|
||||||
loadCategories(dlg, options);
|
|
||||||
dialogHelper.open(dlg);
|
|
||||||
});
|
});
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
dlg.addEventListener('close', function () {
|
||||||
show: showEditor
|
if (layoutManager.tv) {
|
||||||
};
|
scrollHelper.centerFocus.off(dlg.querySelector('.formDialogContent'), false);
|
||||||
});
|
}
|
||||||
|
|
||||||
|
save(dlg);
|
||||||
|
saveCategories(dlg, options);
|
||||||
|
|
||||||
|
if (settingsChanged) {
|
||||||
|
resolve();
|
||||||
|
} else {
|
||||||
|
reject();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
dlg.querySelector('.btnCancel').addEventListener('click', function () {
|
||||||
|
dialogHelper.close(dlg);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (layoutManager.tv) {
|
||||||
|
scrollHelper.centerFocus.on(dlg.querySelector('.formDialogContent'), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
load(dlg);
|
||||||
|
loadCategories(dlg, options);
|
||||||
|
dialogHelper.open(dlg);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export default {
|
||||||
|
show: showEditor
|
||||||
|
};
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -8,7 +8,6 @@ import browser from 'browser';
|
||||||
import layoutManager from 'layoutManager';
|
import layoutManager from 'layoutManager';
|
||||||
import scrollHelper from 'scrollHelper';
|
import scrollHelper from 'scrollHelper';
|
||||||
import globalize from 'globalize';
|
import globalize from 'globalize';
|
||||||
import require from 'require';
|
|
||||||
import 'emby-checkbox';
|
import 'emby-checkbox';
|
||||||
import 'paper-icon-button-light';
|
import 'paper-icon-button-light';
|
||||||
import 'emby-button';
|
import 'emby-button';
|
||||||
|
@ -317,7 +316,7 @@ import 'cardStyle';
|
||||||
function showEditor(itemId, serverId, itemType) {
|
function showEditor(itemId, serverId, itemType) {
|
||||||
loading.show();
|
loading.show();
|
||||||
|
|
||||||
require(['text!./imageDownloader.template.html'], function (template) {
|
import('text!./imageDownloader.template.html').then(({default: template}) => {
|
||||||
const apiClient = connectionManager.getApiClient(serverId);
|
const apiClient = connectionManager.getApiClient(serverId);
|
||||||
|
|
||||||
currentItemId = itemId;
|
currentItemId = itemId;
|
||||||
|
|
|
@ -59,8 +59,8 @@ import 'css!./imageeditor';
|
||||||
currentItem = item;
|
currentItem = item;
|
||||||
|
|
||||||
apiClient.getRemoteImageProviders(getBaseRemoteOptions()).then(function (providers) {
|
apiClient.getRemoteImageProviders(getBaseRemoteOptions()).then(function (providers) {
|
||||||
const btnBrowseAllImages = page.querySelectorAll('.btnBrowseAllImages');
|
var btnBrowseAllImages = page.querySelectorAll('.btnBrowseAllImages');
|
||||||
for (let i = 0, length = btnBrowseAllImages.length; i < length; i++) {
|
for (var i = 0, length = btnBrowseAllImages.length; i < length; i++) {
|
||||||
if (providers.length) {
|
if (providers.length) {
|
||||||
btnBrowseAllImages[i].classList.remove('hide');
|
btnBrowseAllImages[i].classList.remove('hide');
|
||||||
} else {
|
} else {
|
||||||
|
@ -217,7 +217,7 @@ import 'css!./imageeditor';
|
||||||
reload(context, null, focusContext);
|
reload(context, null, focusContext);
|
||||||
}, function () {
|
}, function () {
|
||||||
import('alert').then(({default: alert}) => {
|
import('alert').then(({default: alert}) => {
|
||||||
alert(globalize.translate('DefaultErrorMessage'));
|
alert(globalize.translate('ErrorDefault'));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -205,7 +205,7 @@ import 'css!./style';
|
||||||
|
|
||||||
/* eslint-enable indent */
|
/* eslint-enable indent */
|
||||||
export default {
|
export default {
|
||||||
serLazyImage: setLazyImage,
|
setLazyImage: setLazyImage,
|
||||||
fillImages: fillImages,
|
fillImages: fillImages,
|
||||||
fillImage: fillImage,
|
fillImage: fillImage,
|
||||||
lazyImage: lazyImage,
|
lazyImage: lazyImage,
|
||||||
|
|
|
@ -1,128 +1,130 @@
|
||||||
define(['playbackManager', 'serverNotifications', 'events'], function (playbackManager, serverNotifications, events) {
|
import playbackManager from 'playbackManager';
|
||||||
'use strict';
|
import serverNotifications from 'serverNotifications';
|
||||||
|
import events from 'events';
|
||||||
|
|
||||||
function onUserDataChanged(e, apiClient, userData) {
|
function onUserDataChanged(e, apiClient, userData) {
|
||||||
var instance = this;
|
const instance = this;
|
||||||
|
|
||||||
var eventsToMonitor = getEventsToMonitor(instance);
|
const eventsToMonitor = getEventsToMonitor(instance);
|
||||||
|
|
||||||
// TODO: Check user data change reason?
|
|
||||||
if (eventsToMonitor.indexOf('markfavorite') !== -1) {
|
|
||||||
instance.notifyRefreshNeeded();
|
|
||||||
} else if (eventsToMonitor.indexOf('markplayed') !== -1) {
|
|
||||||
instance.notifyRefreshNeeded();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function getEventsToMonitor(instance) {
|
|
||||||
var options = instance.options;
|
|
||||||
var monitor = options ? options.monitorEvents : null;
|
|
||||||
if (monitor) {
|
|
||||||
return monitor.split(',');
|
|
||||||
}
|
|
||||||
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
function onTimerCreated(e, apiClient, data) {
|
|
||||||
var instance = this;
|
|
||||||
|
|
||||||
if (getEventsToMonitor(instance).indexOf('timers') !== -1) {
|
|
||||||
instance.notifyRefreshNeeded();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function onSeriesTimerCreated(e, apiClient, data) {
|
|
||||||
var instance = this;
|
|
||||||
if (getEventsToMonitor(instance).indexOf('seriestimers') !== -1) {
|
|
||||||
instance.notifyRefreshNeeded();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function onTimerCancelled(e, apiClient, data) {
|
|
||||||
var instance = this;
|
|
||||||
|
|
||||||
if (getEventsToMonitor(instance).indexOf('timers') !== -1) {
|
|
||||||
instance.notifyRefreshNeeded();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function onSeriesTimerCancelled(e, apiClient, data) {
|
|
||||||
var instance = this;
|
|
||||||
if (getEventsToMonitor(instance).indexOf('seriestimers') !== -1) {
|
|
||||||
instance.notifyRefreshNeeded();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function onLibraryChanged(e, apiClient, data) {
|
|
||||||
var instance = this;
|
|
||||||
var eventsToMonitor = getEventsToMonitor(instance);
|
|
||||||
if (eventsToMonitor.indexOf('seriestimers') !== -1 || eventsToMonitor.indexOf('timers') !== -1) {
|
|
||||||
// yes this is an assumption
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var itemsAdded = data.ItemsAdded || [];
|
|
||||||
var itemsRemoved = data.ItemsRemoved || [];
|
|
||||||
if (!itemsAdded.length && !itemsRemoved.length) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var options = instance.options || {};
|
|
||||||
var parentId = options.parentId;
|
|
||||||
if (parentId) {
|
|
||||||
var foldersAddedTo = data.FoldersAddedTo || [];
|
|
||||||
var foldersRemovedFrom = data.FoldersRemovedFrom || [];
|
|
||||||
var collectionFolders = data.CollectionFolders || [];
|
|
||||||
|
|
||||||
if (foldersAddedTo.indexOf(parentId) === -1 && foldersRemovedFrom.indexOf(parentId) === -1 && collectionFolders.indexOf(parentId) === -1) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// TODO: Check user data change reason?
|
||||||
|
if (eventsToMonitor.indexOf('markfavorite') !== -1) {
|
||||||
|
instance.notifyRefreshNeeded();
|
||||||
|
} else if (eventsToMonitor.indexOf('markplayed') !== -1) {
|
||||||
instance.notifyRefreshNeeded();
|
instance.notifyRefreshNeeded();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function onPlaybackStopped(e, stopInfo) {
|
function getEventsToMonitor(instance) {
|
||||||
var instance = this;
|
const options = instance.options;
|
||||||
|
const monitor = options ? options.monitorEvents : null;
|
||||||
|
if (monitor) {
|
||||||
|
return monitor.split(',');
|
||||||
|
}
|
||||||
|
|
||||||
var state = stopInfo.state;
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
var eventsToMonitor = getEventsToMonitor(instance);
|
function onTimerCreated(e, apiClient, data) {
|
||||||
if (state.NowPlayingItem && state.NowPlayingItem.MediaType === 'Video') {
|
const instance = this;
|
||||||
if (eventsToMonitor.indexOf('videoplayback') !== -1) {
|
|
||||||
instance.notifyRefreshNeeded(true);
|
if (getEventsToMonitor(instance).indexOf('timers') !== -1) {
|
||||||
return;
|
instance.notifyRefreshNeeded();
|
||||||
}
|
return;
|
||||||
} else if (state.NowPlayingItem && state.NowPlayingItem.MediaType === 'Audio') {
|
}
|
||||||
if (eventsToMonitor.indexOf('audioplayback') !== -1) {
|
}
|
||||||
instance.notifyRefreshNeeded(true);
|
|
||||||
return;
|
function onSeriesTimerCreated(e, apiClient, data) {
|
||||||
}
|
const instance = this;
|
||||||
|
if (getEventsToMonitor(instance).indexOf('seriestimers') !== -1) {
|
||||||
|
instance.notifyRefreshNeeded();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function onTimerCancelled(e, apiClient, data) {
|
||||||
|
const instance = this;
|
||||||
|
|
||||||
|
if (getEventsToMonitor(instance).indexOf('timers') !== -1) {
|
||||||
|
instance.notifyRefreshNeeded();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function onSeriesTimerCancelled(e, apiClient, data) {
|
||||||
|
const instance = this;
|
||||||
|
if (getEventsToMonitor(instance).indexOf('seriestimers') !== -1) {
|
||||||
|
instance.notifyRefreshNeeded();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function onLibraryChanged(e, apiClient, data) {
|
||||||
|
const instance = this;
|
||||||
|
const eventsToMonitor = getEventsToMonitor(instance);
|
||||||
|
if (eventsToMonitor.indexOf('seriestimers') !== -1 || eventsToMonitor.indexOf('timers') !== -1) {
|
||||||
|
// yes this is an assumption
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const itemsAdded = data.ItemsAdded || [];
|
||||||
|
const itemsRemoved = data.ItemsRemoved || [];
|
||||||
|
if (!itemsAdded.length && !itemsRemoved.length) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const options = instance.options || {};
|
||||||
|
const parentId = options.parentId;
|
||||||
|
if (parentId) {
|
||||||
|
const foldersAddedTo = data.FoldersAddedTo || [];
|
||||||
|
const foldersRemovedFrom = data.FoldersRemovedFrom || [];
|
||||||
|
const collectionFolders = data.CollectionFolders || [];
|
||||||
|
|
||||||
|
if (foldersAddedTo.indexOf(parentId) === -1 && foldersRemovedFrom.indexOf(parentId) === -1 && collectionFolders.indexOf(parentId) === -1) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function addNotificationEvent(instance, name, handler, owner) {
|
instance.notifyRefreshNeeded();
|
||||||
var localHandler = handler.bind(instance);
|
}
|
||||||
|
|
||||||
|
function onPlaybackStopped(e, stopInfo) {
|
||||||
|
const instance = this;
|
||||||
|
|
||||||
|
const state = stopInfo.state;
|
||||||
|
|
||||||
|
const eventsToMonitor = getEventsToMonitor(instance);
|
||||||
|
if (state.NowPlayingItem && state.NowPlayingItem.MediaType === 'Video') {
|
||||||
|
if (eventsToMonitor.indexOf('videoplayback') !== -1) {
|
||||||
|
instance.notifyRefreshNeeded(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else if (state.NowPlayingItem && state.NowPlayingItem.MediaType === 'Audio') {
|
||||||
|
if (eventsToMonitor.indexOf('audioplayback') !== -1) {
|
||||||
|
instance.notifyRefreshNeeded(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function addNotificationEvent(instance, name, handler, owner) {
|
||||||
|
const localHandler = handler.bind(instance);
|
||||||
|
owner = owner || serverNotifications;
|
||||||
|
events.on(owner, name, localHandler);
|
||||||
|
instance['event_' + name] = localHandler;
|
||||||
|
}
|
||||||
|
|
||||||
|
function removeNotificationEvent(instance, name, owner) {
|
||||||
|
const handler = instance['event_' + name];
|
||||||
|
if (handler) {
|
||||||
owner = owner || serverNotifications;
|
owner = owner || serverNotifications;
|
||||||
events.on(owner, name, localHandler);
|
events.off(owner, name, handler);
|
||||||
instance['event_' + name] = localHandler;
|
instance['event_' + name] = null;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function removeNotificationEvent(instance, name, owner) {
|
class ItemsRefresher {
|
||||||
var handler = instance['event_' + name];
|
constructor(options) {
|
||||||
if (handler) {
|
|
||||||
owner = owner || serverNotifications;
|
|
||||||
events.off(owner, name, handler);
|
|
||||||
instance['event_' + name] = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function ItemsRefresher(options) {
|
|
||||||
this.options = options || {};
|
this.options = options || {};
|
||||||
|
|
||||||
addNotificationEvent(this, 'UserDataChanged', onUserDataChanged);
|
addNotificationEvent(this, 'UserDataChanged', onUserDataChanged);
|
||||||
|
@ -134,18 +136,18 @@ define(['playbackManager', 'serverNotifications', 'events'], function (playbackM
|
||||||
addNotificationEvent(this, 'playbackstop', onPlaybackStopped, playbackManager);
|
addNotificationEvent(this, 'playbackstop', onPlaybackStopped, playbackManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemsRefresher.prototype.pause = function () {
|
pause() {
|
||||||
clearRefreshInterval(this, true);
|
clearRefreshInterval(this, true);
|
||||||
|
|
||||||
this.paused = true;
|
this.paused = true;
|
||||||
};
|
}
|
||||||
|
|
||||||
ItemsRefresher.prototype.resume = function (options) {
|
resume(options) {
|
||||||
this.paused = false;
|
this.paused = false;
|
||||||
|
|
||||||
var refreshIntervalEndTime = this.refreshIntervalEndTime;
|
const refreshIntervalEndTime = this.refreshIntervalEndTime;
|
||||||
if (refreshIntervalEndTime) {
|
if (refreshIntervalEndTime) {
|
||||||
var remainingMs = refreshIntervalEndTime - new Date().getTime();
|
const remainingMs = refreshIntervalEndTime - new Date().getTime();
|
||||||
if (remainingMs > 0 && !this.needsRefresh) {
|
if (remainingMs > 0 && !this.needsRefresh) {
|
||||||
resetRefreshInterval(this, remainingMs);
|
resetRefreshInterval(this, remainingMs);
|
||||||
} else {
|
} else {
|
||||||
|
@ -159,9 +161,9 @@ define(['playbackManager', 'serverNotifications', 'events'], function (playbackM
|
||||||
}
|
}
|
||||||
|
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
};
|
}
|
||||||
|
|
||||||
ItemsRefresher.prototype.refreshItems = function () {
|
refreshItems() {
|
||||||
if (!this.fetchData) {
|
if (!this.fetchData) {
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
@ -174,15 +176,15 @@ define(['playbackManager', 'serverNotifications', 'events'], function (playbackM
|
||||||
this.needsRefresh = false;
|
this.needsRefresh = false;
|
||||||
|
|
||||||
return this.fetchData().then(onDataFetched.bind(this));
|
return this.fetchData().then(onDataFetched.bind(this));
|
||||||
};
|
}
|
||||||
|
|
||||||
ItemsRefresher.prototype.notifyRefreshNeeded = function (isInForeground) {
|
notifyRefreshNeeded(isInForeground) {
|
||||||
if (this.paused) {
|
if (this.paused) {
|
||||||
this.needsRefresh = true;
|
this.needsRefresh = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var timeout = this.refreshTimeout;
|
const timeout = this.refreshTimeout;
|
||||||
if (timeout) {
|
if (timeout) {
|
||||||
clearTimeout(timeout);
|
clearTimeout(timeout);
|
||||||
}
|
}
|
||||||
|
@ -192,44 +194,9 @@ define(['playbackManager', 'serverNotifications', 'events'], function (playbackM
|
||||||
} else {
|
} else {
|
||||||
this.refreshTimeout = setTimeout(this.refreshItems.bind(this), 10000);
|
this.refreshTimeout = setTimeout(this.refreshItems.bind(this), 10000);
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
function clearRefreshInterval(instance, isPausing) {
|
|
||||||
if (instance.refreshInterval) {
|
|
||||||
clearInterval(instance.refreshInterval);
|
|
||||||
instance.refreshInterval = null;
|
|
||||||
|
|
||||||
if (!isPausing) {
|
|
||||||
instance.refreshIntervalEndTime = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function resetRefreshInterval(instance, intervalMs) {
|
destroy() {
|
||||||
clearRefreshInterval(instance);
|
|
||||||
|
|
||||||
if (!intervalMs) {
|
|
||||||
var options = instance.options;
|
|
||||||
if (options) {
|
|
||||||
intervalMs = options.refreshIntervalMs;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (intervalMs) {
|
|
||||||
instance.refreshInterval = setInterval(instance.notifyRefreshNeeded.bind(instance), intervalMs);
|
|
||||||
instance.refreshIntervalEndTime = new Date().getTime() + intervalMs;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function onDataFetched(result) {
|
|
||||||
resetRefreshInterval(this);
|
|
||||||
|
|
||||||
if (this.afterRefresh) {
|
|
||||||
this.afterRefresh(result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ItemsRefresher.prototype.destroy = function () {
|
|
||||||
clearRefreshInterval(this);
|
clearRefreshInterval(this);
|
||||||
|
|
||||||
removeNotificationEvent(this, 'UserDataChanged');
|
removeNotificationEvent(this, 'UserDataChanged');
|
||||||
|
@ -242,7 +209,42 @@ define(['playbackManager', 'serverNotifications', 'events'], function (playbackM
|
||||||
|
|
||||||
this.fetchData = null;
|
this.fetchData = null;
|
||||||
this.options = null;
|
this.options = null;
|
||||||
};
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return ItemsRefresher;
|
function clearRefreshInterval(instance, isPausing) {
|
||||||
});
|
if (instance.refreshInterval) {
|
||||||
|
clearInterval(instance.refreshInterval);
|
||||||
|
instance.refreshInterval = null;
|
||||||
|
|
||||||
|
if (!isPausing) {
|
||||||
|
instance.refreshIntervalEndTime = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function resetRefreshInterval(instance, intervalMs) {
|
||||||
|
clearRefreshInterval(instance);
|
||||||
|
|
||||||
|
if (!intervalMs) {
|
||||||
|
const options = instance.options;
|
||||||
|
if (options) {
|
||||||
|
intervalMs = options.refreshIntervalMs;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (intervalMs) {
|
||||||
|
instance.refreshInterval = setInterval(instance.notifyRefreshNeeded.bind(instance), intervalMs);
|
||||||
|
instance.refreshIntervalEndTime = new Date().getTime() + intervalMs;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function onDataFetched(result) {
|
||||||
|
resetRefreshInterval(this);
|
||||||
|
|
||||||
|
if (this.afterRefresh) {
|
||||||
|
this.afterRefresh(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default ItemsRefresher;
|
||||||
|
|
|
@ -1,21 +1,19 @@
|
||||||
define(['browser', 'appSettings', 'events'], function (browser, appSettings, events) {
|
import browser from 'browser';
|
||||||
'use strict';
|
import appSettings from 'appSettings';
|
||||||
|
import events from 'events';
|
||||||
|
|
||||||
function setLayout(instance, layout, selectedLayout) {
|
function setLayout(instance, layout, selectedLayout) {
|
||||||
if (layout === selectedLayout) {
|
if (layout === selectedLayout) {
|
||||||
instance[layout] = true;
|
instance[layout] = true;
|
||||||
document.documentElement.classList.add('layout-' + layout);
|
document.documentElement.classList.add('layout-' + layout);
|
||||||
} else {
|
} else {
|
||||||
instance[layout] = false;
|
instance[layout] = false;
|
||||||
document.documentElement.classList.remove('layout-' + layout);
|
document.documentElement.classList.remove('layout-' + layout);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function LayoutManager() {
|
class LayoutManager {
|
||||||
|
setLayout(layout, save) {
|
||||||
}
|
|
||||||
|
|
||||||
LayoutManager.prototype.setLayout = function (layout, save) {
|
|
||||||
if (!layout || layout === 'auto') {
|
if (!layout || layout === 'auto') {
|
||||||
this.autoLayout();
|
this.autoLayout();
|
||||||
|
|
||||||
|
@ -33,13 +31,13 @@ define(['browser', 'appSettings', 'events'], function (browser, appSettings, eve
|
||||||
}
|
}
|
||||||
|
|
||||||
events.trigger(this, 'modechange');
|
events.trigger(this, 'modechange');
|
||||||
};
|
}
|
||||||
|
|
||||||
LayoutManager.prototype.getSavedLayout = function (layout) {
|
getSavedLayout(layout) {
|
||||||
return appSettings.get('layout');
|
return appSettings.get('layout');
|
||||||
};
|
}
|
||||||
|
|
||||||
LayoutManager.prototype.autoLayout = function () {
|
autoLayout() {
|
||||||
// Take a guess at initial layout. The consuming app can override
|
// Take a guess at initial layout. The consuming app can override
|
||||||
if (browser.mobile) {
|
if (browser.mobile) {
|
||||||
this.setLayout('mobile', false);
|
this.setLayout('mobile', false);
|
||||||
|
@ -48,16 +46,16 @@ define(['browser', 'appSettings', 'events'], function (browser, appSettings, eve
|
||||||
} else {
|
} else {
|
||||||
this.setLayout(this.defaultLayout || 'tv', false);
|
this.setLayout(this.defaultLayout || 'tv', false);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
LayoutManager.prototype.init = function () {
|
init() {
|
||||||
var saved = this.getSavedLayout();
|
const saved = this.getSavedLayout();
|
||||||
if (saved) {
|
if (saved) {
|
||||||
this.setLayout(saved, false);
|
this.setLayout(saved, false);
|
||||||
} else {
|
} else {
|
||||||
this.autoLayout();
|
this.autoLayout();
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return new LayoutManager();
|
export default new LayoutManager();
|
||||||
});
|
|
||||||
|
|
|
@ -1,78 +1,74 @@
|
||||||
define(['css!./loading'], function () {
|
import 'css!./loading';
|
||||||
'use strict';
|
|
||||||
|
|
||||||
var loadingElem;
|
let loadingElem;
|
||||||
var layer1;
|
let layer1;
|
||||||
var layer2;
|
let layer2;
|
||||||
var layer3;
|
let layer3;
|
||||||
var layer4;
|
let layer4;
|
||||||
var circleLefts;
|
let circleLefts;
|
||||||
var circleRights;
|
let circleRights;
|
||||||
|
|
||||||
return {
|
export function show() {
|
||||||
show: function () {
|
let elem = loadingElem;
|
||||||
var elem = loadingElem;
|
|
||||||
|
|
||||||
if (!elem) {
|
if (!elem) {
|
||||||
elem = document.createElement('div');
|
elem = document.createElement('div');
|
||||||
loadingElem = elem;
|
loadingElem = elem;
|
||||||
|
|
||||||
elem.classList.add('docspinner');
|
elem.classList.add('docspinner');
|
||||||
elem.classList.add('mdl-spinner');
|
elem.classList.add('mdl-spinner');
|
||||||
|
|
||||||
elem.innerHTML = '<div class="mdl-spinner__layer mdl-spinner__layer-1"><div class="mdl-spinner__circle-clipper mdl-spinner__left"><div class="mdl-spinner__circle mdl-spinner__circleLeft"></div></div><div class="mdl-spinner__circle-clipper mdl-spinner__right"><div class="mdl-spinner__circle mdl-spinner__circleRight"></div></div></div><div class="mdl-spinner__layer mdl-spinner__layer-2"><div class="mdl-spinner__circle-clipper mdl-spinner__left"><div class="mdl-spinner__circle mdl-spinner__circleLeft"></div></div><div class="mdl-spinner__circle-clipper mdl-spinner__right"><div class="mdl-spinner__circle mdl-spinner__circleRight"></div></div></div><div class="mdl-spinner__layer mdl-spinner__layer-3"><div class="mdl-spinner__circle-clipper mdl-spinner__left"><div class="mdl-spinner__circle mdl-spinner__circleLeft"></div></div><div class="mdl-spinner__circle-clipper mdl-spinner__right"><div class="mdl-spinner__circle mdl-spinner__circleRight"></div></div></div><div class="mdl-spinner__layer mdl-spinner__layer-4"><div class="mdl-spinner__circle-clipper mdl-spinner__left"><div class="mdl-spinner__circle mdl-spinner__circleLeft"></div></div><div class="mdl-spinner__circle-clipper mdl-spinner__right"><div class="mdl-spinner__circle mdl-spinner__circleRight"></div></div></div>';
|
elem.innerHTML = '<div class="mdl-spinner__layer mdl-spinner__layer-1"><div class="mdl-spinner__circle-clipper mdl-spinner__left"><div class="mdl-spinner__circle mdl-spinner__circleLeft"></div></div><div class="mdl-spinner__circle-clipper mdl-spinner__right"><div class="mdl-spinner__circle mdl-spinner__circleRight"></div></div></div><div class="mdl-spinner__layer mdl-spinner__layer-2"><div class="mdl-spinner__circle-clipper mdl-spinner__left"><div class="mdl-spinner__circle mdl-spinner__circleLeft"></div></div><div class="mdl-spinner__circle-clipper mdl-spinner__right"><div class="mdl-spinner__circle mdl-spinner__circleRight"></div></div></div><div class="mdl-spinner__layer mdl-spinner__layer-3"><div class="mdl-spinner__circle-clipper mdl-spinner__left"><div class="mdl-spinner__circle mdl-spinner__circleLeft"></div></div><div class="mdl-spinner__circle-clipper mdl-spinner__right"><div class="mdl-spinner__circle mdl-spinner__circleRight"></div></div></div><div class="mdl-spinner__layer mdl-spinner__layer-4"><div class="mdl-spinner__circle-clipper mdl-spinner__left"><div class="mdl-spinner__circle mdl-spinner__circleLeft"></div></div><div class="mdl-spinner__circle-clipper mdl-spinner__right"><div class="mdl-spinner__circle mdl-spinner__circleRight"></div></div></div>';
|
||||||
|
|
||||||
document.body.appendChild(elem);
|
document.body.appendChild(elem);
|
||||||
|
|
||||||
layer1 = elem.querySelector('.mdl-spinner__layer-1');
|
layer1 = elem.querySelector('.mdl-spinner__layer-1');
|
||||||
layer2 = elem.querySelector('.mdl-spinner__layer-2');
|
layer2 = elem.querySelector('.mdl-spinner__layer-2');
|
||||||
layer3 = elem.querySelector('.mdl-spinner__layer-3');
|
layer3 = elem.querySelector('.mdl-spinner__layer-3');
|
||||||
layer4 = elem.querySelector('.mdl-spinner__layer-4');
|
layer4 = elem.querySelector('.mdl-spinner__layer-4');
|
||||||
|
|
||||||
circleLefts = elem.querySelectorAll('.mdl-spinner__circleLeft');
|
circleLefts = elem.querySelectorAll('.mdl-spinner__circleLeft');
|
||||||
circleRights = elem.querySelectorAll('.mdl-spinner__circleRight');
|
circleRights = elem.querySelectorAll('.mdl-spinner__circleRight');
|
||||||
}
|
}
|
||||||
|
|
||||||
elem.classList.add('mdlSpinnerActive');
|
elem.classList.add('mdlSpinnerActive');
|
||||||
|
|
||||||
layer1.classList.add('mdl-spinner__layer-1-active');
|
layer1.classList.add('mdl-spinner__layer-1-active');
|
||||||
layer2.classList.add('mdl-spinner__layer-2-active');
|
layer2.classList.add('mdl-spinner__layer-2-active');
|
||||||
layer3.classList.add('mdl-spinner__layer-3-active');
|
layer3.classList.add('mdl-spinner__layer-3-active');
|
||||||
layer4.classList.add('mdl-spinner__layer-4-active');
|
layer4.classList.add('mdl-spinner__layer-4-active');
|
||||||
|
|
||||||
var i;
|
for (let i = 0, length = circleLefts.length; i < length; i++) {
|
||||||
var length;
|
circleLefts[i].classList.add('mdl-spinner__circleLeft-active');
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0, length = circleLefts.length; i < length; i++) {
|
for (let i = 0, length = circleRights.length; i < length; i++) {
|
||||||
circleLefts[i].classList.add('mdl-spinner__circleLeft-active');
|
circleRights[i].classList.add('mdl-spinner__circleRight-active');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0, length = circleRights.length; i < length; i++) {
|
export function hide() {
|
||||||
circleRights[i].classList.add('mdl-spinner__circleRight-active');
|
const elem = loadingElem;
|
||||||
}
|
|
||||||
},
|
|
||||||
hide: function () {
|
|
||||||
var elem = loadingElem;
|
|
||||||
|
|
||||||
if (elem) {
|
if (elem) {
|
||||||
elem.classList.remove('mdlSpinnerActive');
|
elem.classList.remove('mdlSpinnerActive');
|
||||||
|
|
||||||
elem.classList.remove('mdl-spinner__layer-1-active');
|
elem.classList.remove('mdl-spinner__layer-1-active');
|
||||||
elem.classList.remove('mdl-spinner__layer-2-active');
|
elem.classList.remove('mdl-spinner__layer-2-active');
|
||||||
elem.classList.remove('mdl-spinner__layer-3-active');
|
elem.classList.remove('mdl-spinner__layer-3-active');
|
||||||
elem.classList.remove('mdl-spinner__layer-4-active');
|
elem.classList.remove('mdl-spinner__layer-4-active');
|
||||||
|
|
||||||
var i;
|
for (let i = 0, length = circleLefts.length; i < length; i++) {
|
||||||
var length;
|
circleLefts[i].classList.remove('mdl-spinner__circleLeft-active');
|
||||||
|
|
||||||
for (i = 0, length = circleLefts.length; i < length; i++) {
|
|
||||||
circleLefts[i].classList.remove('mdl-spinner__circleLeft-active');
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0, length = circleRights.length; i < length; i++) {
|
|
||||||
circleRights[i].classList.remove('mdl-spinner__circleRight-active');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
|
||||||
});
|
for (let i = 0, length = circleRights.length; i < length; i++) {
|
||||||
|
circleRights[i].classList.remove('mdl-spinner__circleRight-active');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default {
|
||||||
|
show: show,
|
||||||
|
hide: hide
|
||||||
|
};
|
||||||
|
|
|
@ -85,7 +85,7 @@ import 'flexStyles';
|
||||||
refreshLibraryFromServer(dom.parentWithClass(button, 'dlg-libraryeditor'));
|
refreshLibraryFromServer(dom.parentWithClass(button, 'dlg-libraryeditor'));
|
||||||
}, () => {
|
}, () => {
|
||||||
import('toast').then(({default: toast}) => {
|
import('toast').then(({default: toast}) => {
|
||||||
toast(globalize.translate('DefaultErrorMessage'));
|
toast(globalize.translate('ErrorDefault'));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -6,7 +6,6 @@ import loading from 'loading';
|
||||||
import focusManager from 'focusManager';
|
import focusManager from 'focusManager';
|
||||||
import connectionManager from 'connectionManager';
|
import connectionManager from 'connectionManager';
|
||||||
import globalize from 'globalize';
|
import globalize from 'globalize';
|
||||||
import require from 'require';
|
|
||||||
import shell from 'shell';
|
import shell from 'shell';
|
||||||
import 'emby-checkbox';
|
import 'emby-checkbox';
|
||||||
import 'emby-input';
|
import 'emby-input';
|
||||||
|
@ -37,7 +36,7 @@ import 'flexStyles';
|
||||||
|
|
||||||
function submitUpdatedItem(form, item) {
|
function submitUpdatedItem(form, item) {
|
||||||
function afterContentTypeUpdated() {
|
function afterContentTypeUpdated() {
|
||||||
require(['toast'], function (toast) {
|
import('toast').then(({default: toast}) => {
|
||||||
toast(globalize.translate('MessageItemSaved'));
|
toast(globalize.translate('MessageItemSaved'));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -227,7 +226,7 @@ import 'flexStyles';
|
||||||
}
|
}
|
||||||
|
|
||||||
function editPerson(context, person, index) {
|
function editPerson(context, person, index) {
|
||||||
require(['personEditor'], function (personEditor) {
|
import('personEditor').then(({default: personEditor}) => {
|
||||||
personEditor.show(person).then(function (updatedPerson) {
|
personEditor.show(person).then(function (updatedPerson) {
|
||||||
const isNew = index === -1;
|
const isNew = index === -1;
|
||||||
|
|
||||||
|
@ -246,14 +245,14 @@ import 'flexStyles';
|
||||||
if (parentId) {
|
if (parentId) {
|
||||||
reload(context, parentId, item.ServerId);
|
reload(context, parentId, item.ServerId);
|
||||||
} else {
|
} else {
|
||||||
require(['appRouter'], function (appRouter) {
|
import('appRouter').then(({default: appRouter}) => {
|
||||||
appRouter.goHome();
|
appRouter.goHome();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function showMoreMenu(context, button, user) {
|
function showMoreMenu(context, button, user) {
|
||||||
require(['itemContextMenu'], function (itemContextMenu) {
|
import('itemContextMenu').then(({default: itemContextMenu}) => {
|
||||||
var item = currentItem;
|
var item = currentItem;
|
||||||
|
|
||||||
itemContextMenu.show({
|
itemContextMenu.show({
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
define(['serverNotifications', 'playbackManager', 'events', 'globalize', 'require'], function (serverNotifications, playbackManager, events, globalize, require) {
|
define(['serverNotifications', 'playbackManager', 'events', 'globalize', 'require'], function (serverNotifications, playbackManager, events, globalize, require) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
playbackManager = playbackManager.default || playbackManager;
|
||||||
|
serverNotifications = serverNotifications.default || serverNotifications;
|
||||||
|
|
||||||
function onOneDocumentClick() {
|
function onOneDocumentClick() {
|
||||||
document.removeEventListener('click', onOneDocumentClick);
|
document.removeEventListener('click', onOneDocumentClick);
|
||||||
document.removeEventListener('keydown', onOneDocumentClick);
|
document.removeEventListener('keydown', onOneDocumentClick);
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -210,7 +210,7 @@ import 'emby-button';
|
||||||
}
|
}
|
||||||
|
|
||||||
function centerFocus(elem, horiz, on) {
|
function centerFocus(elem, horiz, on) {
|
||||||
import('scrollHelper').then(scrollHelper => {
|
import('scrollHelper').then((scrollHelper) => {
|
||||||
const fn = on ? 'on' : 'off';
|
const fn = on ? 'on' : 'off';
|
||||||
scrollHelper.centerFocus[fn](elem, horiz);
|
scrollHelper.centerFocus[fn](elem, horiz);
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,35 +1,40 @@
|
||||||
define(['globalize', 'connectionManager', 'require', 'loading', 'apphost', 'dom', 'recordingHelper', 'events', 'paper-icon-button-light', 'emby-button', 'css!./recordingfields'], function (globalize, connectionManager, require, loading, appHost, dom, recordingHelper, events) {
|
import connectionManager from 'connectionManager';
|
||||||
'use strict';
|
import dom from 'dom';
|
||||||
|
import recordingHelper from 'recordingHelper';
|
||||||
|
import 'paper-icon-button-light';
|
||||||
|
import 'emby-button';
|
||||||
|
import 'css!./recordingfields';
|
||||||
|
|
||||||
function onRecordingButtonClick(e) {
|
function onRecordingButtonClick(e) {
|
||||||
var item = this.item;
|
const item = this.item;
|
||||||
|
|
||||||
if (item) {
|
if (item) {
|
||||||
var serverId = item.ServerId;
|
const serverId = item.ServerId;
|
||||||
var programId = item.Id;
|
const programId = item.Id;
|
||||||
var timerId = item.TimerId;
|
const timerId = item.TimerId;
|
||||||
var timerStatus = item.Status;
|
const timerStatus = item.Status;
|
||||||
var seriesTimerId = item.SeriesTimerId;
|
const seriesTimerId = item.SeriesTimerId;
|
||||||
|
|
||||||
var instance = this;
|
const instance = this;
|
||||||
|
|
||||||
recordingHelper.toggleRecording(serverId, programId, timerId, timerStatus, seriesTimerId).then(function () {
|
recordingHelper.toggleRecording(serverId, programId, timerId, timerStatus, seriesTimerId).then(function () {
|
||||||
instance.refresh(serverId, programId);
|
instance.refresh(serverId, programId);
|
||||||
});
|
});
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function setButtonIcon(button, icon) {
|
function setButtonIcon(button, icon) {
|
||||||
var inner = button.querySelector('.material-icons');
|
const inner = button.querySelector('.material-icons');
|
||||||
inner.classList.remove('fiber_smart_record');
|
inner.classList.remove('fiber_smart_record');
|
||||||
inner.classList.remove('fiber_manual_record');
|
inner.classList.remove('fiber_manual_record');
|
||||||
inner.classList.add(icon);
|
inner.classList.add(icon);
|
||||||
}
|
}
|
||||||
|
|
||||||
function RecordingButton(options) {
|
class RecordingButton {
|
||||||
|
constructor(options) {
|
||||||
this.options = options;
|
this.options = options;
|
||||||
|
|
||||||
var button = options.button;
|
const button = options.button;
|
||||||
|
|
||||||
setButtonIcon(button, 'fiber_manual_record');
|
setButtonIcon(button, 'fiber_manual_record');
|
||||||
|
|
||||||
|
@ -39,7 +44,7 @@ define(['globalize', 'connectionManager', 'require', 'loading', 'apphost', 'dom'
|
||||||
this.refresh(options.itemId, options.serverId);
|
this.refresh(options.itemId, options.serverId);
|
||||||
}
|
}
|
||||||
|
|
||||||
var clickFn = onRecordingButtonClick.bind(this);
|
const clickFn = onRecordingButtonClick.bind(this);
|
||||||
this.clickFn = clickFn;
|
this.clickFn = clickFn;
|
||||||
|
|
||||||
dom.addEventListener(button, 'click', clickFn, {
|
dom.addEventListener(button, 'click', clickFn, {
|
||||||
|
@ -47,39 +52,17 @@ define(['globalize', 'connectionManager', 'require', 'loading', 'apphost', 'dom'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function getIndicatorIcon(item) {
|
refresh(serverId, itemId) {
|
||||||
var status;
|
const apiClient = connectionManager.getApiClient(serverId);
|
||||||
|
const self = this;
|
||||||
if (item.Type === 'SeriesTimer') {
|
|
||||||
return 'fiber_smart_record';
|
|
||||||
} else if (item.TimerId || item.SeriesTimerId) {
|
|
||||||
status = item.Status || 'Cancelled';
|
|
||||||
} else if (item.Type === 'Timer') {
|
|
||||||
status = item.Status;
|
|
||||||
} else {
|
|
||||||
return 'fiber_manual_record';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (item.SeriesTimerId) {
|
|
||||||
if (status !== 'Cancelled') {
|
|
||||||
return 'fiber_smart_record';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 'fiber_manual_record';
|
|
||||||
}
|
|
||||||
|
|
||||||
RecordingButton.prototype.refresh = function (serverId, itemId) {
|
|
||||||
var apiClient = connectionManager.getApiClient(serverId);
|
|
||||||
var self = this;
|
|
||||||
apiClient.getItem(apiClient.getCurrentUserId(), itemId).then(function (item) {
|
apiClient.getItem(apiClient.getCurrentUserId(), itemId).then(function (item) {
|
||||||
self.refreshItem(item);
|
self.refreshItem(item);
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
RecordingButton.prototype.refreshItem = function (item) {
|
refreshItem(item) {
|
||||||
var options = this.options;
|
const options = this.options;
|
||||||
var button = options.button;
|
const button = options.button;
|
||||||
this.item = item;
|
this.item = item;
|
||||||
setButtonIcon(button, getIndicatorIcon(item));
|
setButtonIcon(button, getIndicatorIcon(item));
|
||||||
|
|
||||||
|
@ -88,15 +71,15 @@ define(['globalize', 'connectionManager', 'require', 'loading', 'apphost', 'dom'
|
||||||
} else {
|
} else {
|
||||||
button.classList.remove('recordingIcon-active');
|
button.classList.remove('recordingIcon-active');
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
RecordingButton.prototype.destroy = function () {
|
destroy() {
|
||||||
var options = this.options;
|
const options = this.options;
|
||||||
|
|
||||||
if (options) {
|
if (options) {
|
||||||
var button = options.button;
|
const button = options.button;
|
||||||
|
|
||||||
var clickFn = this.clickFn;
|
const clickFn = this.clickFn;
|
||||||
|
|
||||||
if (clickFn) {
|
if (clickFn) {
|
||||||
dom.removeEventListener(button, 'click', clickFn, {
|
dom.removeEventListener(button, 'click', clickFn, {
|
||||||
|
@ -107,7 +90,29 @@ define(['globalize', 'connectionManager', 'require', 'loading', 'apphost', 'dom'
|
||||||
|
|
||||||
this.options = null;
|
this.options = null;
|
||||||
this.item = null;
|
this.item = null;
|
||||||
};
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return RecordingButton;
|
function getIndicatorIcon(item) {
|
||||||
});
|
let status;
|
||||||
|
|
||||||
|
if (item.Type === 'SeriesTimer') {
|
||||||
|
return 'fiber_smart_record';
|
||||||
|
} else if (item.TimerId || item.SeriesTimerId) {
|
||||||
|
status = item.Status || 'Cancelled';
|
||||||
|
} else if (item.Type === 'Timer') {
|
||||||
|
status = item.Status;
|
||||||
|
} else {
|
||||||
|
return 'fiber_manual_record';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item.SeriesTimerId) {
|
||||||
|
if (status !== 'Cancelled') {
|
||||||
|
return 'fiber_smart_record';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 'fiber_manual_record';
|
||||||
|
}
|
||||||
|
|
||||||
|
export default RecordingButton;
|
||||||
|
|
|
@ -1,187 +1,204 @@
|
||||||
define(['dialogHelper', 'globalize', 'layoutManager', 'mediaInfo', 'apphost', 'connectionManager', 'require', 'loading', 'scrollHelper', 'datetime', 'imageLoader', 'recordingFields', 'events', 'emby-checkbox', 'emby-button', 'emby-collapse', 'emby-input', 'paper-icon-button-light', 'css!./../formdialog', 'css!./recordingcreator', 'material-icons'], function (dialogHelper, globalize, layoutManager, mediaInfo, appHost, connectionManager, require, loading, scrollHelper, datetime, imageLoader, recordingFields, events) {
|
import dialogHelper from 'dialogHelper';
|
||||||
'use strict';
|
import globalize from 'globalize';
|
||||||
|
import layoutManager from 'layoutManager';
|
||||||
|
import mediaInfo from 'mediaInfo';
|
||||||
|
import connectionManager from 'connectionManager';
|
||||||
|
import require from 'require';
|
||||||
|
import loading from 'loading';
|
||||||
|
import scrollHelper from 'scrollHelper';
|
||||||
|
import datetime from 'datetime';
|
||||||
|
import imageLoader from 'imageLoader';
|
||||||
|
import recordingFields from 'recordingFields';
|
||||||
|
import events from 'events';
|
||||||
|
import 'emby-checkbox';
|
||||||
|
import 'emby-button';
|
||||||
|
import 'emby-collapse';
|
||||||
|
import 'emby-input';
|
||||||
|
import 'paper-icon-button-light';
|
||||||
|
import 'css!./../formdialog';
|
||||||
|
import 'css!./recordingcreator';
|
||||||
|
import 'material-icons';
|
||||||
|
|
||||||
var currentDialog;
|
let currentDialog;
|
||||||
var closeAction;
|
let closeAction;
|
||||||
var currentRecordingFields;
|
let currentRecordingFields;
|
||||||
|
|
||||||
function closeDialog() {
|
function closeDialog() {
|
||||||
dialogHelper.close(currentDialog);
|
dialogHelper.close(currentDialog);
|
||||||
|
}
|
||||||
|
|
||||||
|
function init(context) {
|
||||||
|
context.querySelector('.btnPlay').addEventListener('click', function () {
|
||||||
|
closeAction = 'play';
|
||||||
|
closeDialog();
|
||||||
|
});
|
||||||
|
|
||||||
|
context.querySelector('.btnCancel').addEventListener('click', function () {
|
||||||
|
closeAction = null;
|
||||||
|
closeDialog();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function getImageUrl(item, apiClient, imageHeight) {
|
||||||
|
const imageTags = item.ImageTags || {};
|
||||||
|
|
||||||
|
if (item.PrimaryImageTag) {
|
||||||
|
imageTags.Primary = item.PrimaryImageTag;
|
||||||
}
|
}
|
||||||
|
|
||||||
function init(context) {
|
if (imageTags.Primary) {
|
||||||
context.querySelector('.btnPlay').addEventListener('click', function () {
|
return apiClient.getScaledImageUrl(item.Id, {
|
||||||
closeAction = 'play';
|
type: 'Primary',
|
||||||
closeDialog();
|
maxHeight: imageHeight,
|
||||||
|
tag: item.ImageTags.Primary
|
||||||
});
|
});
|
||||||
|
} else if (imageTags.Thumb) {
|
||||||
context.querySelector('.btnCancel').addEventListener('click', function () {
|
return apiClient.getScaledImageUrl(item.Id, {
|
||||||
closeAction = null;
|
type: 'Thumb',
|
||||||
closeDialog();
|
maxHeight: imageHeight,
|
||||||
|
tag: item.ImageTags.Thumb
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function getImageUrl(item, apiClient, imageHeight) {
|
return null;
|
||||||
var imageTags = item.ImageTags || {};
|
}
|
||||||
|
|
||||||
if (item.PrimaryImageTag) {
|
function renderRecording(context, defaultTimer, program, apiClient, refreshRecordingStateOnly) {
|
||||||
imageTags.Primary = item.PrimaryImageTag;
|
if (!refreshRecordingStateOnly) {
|
||||||
|
const imgUrl = getImageUrl(program, apiClient, 200);
|
||||||
|
const imageContainer = context.querySelector('.recordingDialog-imageContainer');
|
||||||
|
|
||||||
|
if (imgUrl) {
|
||||||
|
imageContainer.innerHTML = '<img src="' + require.toUrl('.').split('?')[0] + '/empty.png" data-src="' + imgUrl + '" class="recordingDialog-img lazy" />';
|
||||||
|
imageContainer.classList.remove('hide');
|
||||||
|
|
||||||
|
imageLoader.lazyChildren(imageContainer);
|
||||||
|
} else {
|
||||||
|
imageContainer.innerHTML = '';
|
||||||
|
imageContainer.classList.add('hide');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (imageTags.Primary) {
|
context.querySelector('.recordingDialog-itemName').innerHTML = program.Name;
|
||||||
return apiClient.getScaledImageUrl(item.Id, {
|
context.querySelector('.formDialogHeaderTitle').innerHTML = program.Name;
|
||||||
type: 'Primary',
|
context.querySelector('.itemGenres').innerHTML = (program.Genres || []).join(' / ');
|
||||||
maxHeight: imageHeight,
|
context.querySelector('.itemOverview').innerHTML = program.Overview || '';
|
||||||
tag: item.ImageTags.Primary
|
|
||||||
});
|
const formDialogFooter = context.querySelector('.formDialogFooter');
|
||||||
} else if (imageTags.Thumb) {
|
const now = new Date();
|
||||||
return apiClient.getScaledImageUrl(item.Id, {
|
if (now >= datetime.parseISO8601Date(program.StartDate, true) && now < datetime.parseISO8601Date(program.EndDate, true)) {
|
||||||
type: 'Thumb',
|
formDialogFooter.classList.remove('hide');
|
||||||
maxHeight: imageHeight,
|
} else {
|
||||||
tag: item.ImageTags.Thumb
|
formDialogFooter.classList.add('hide');
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
context.querySelector('.itemMiscInfoPrimary').innerHTML = mediaInfo.getPrimaryMediaInfoHtml(program);
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderRecording(context, defaultTimer, program, apiClient, refreshRecordingStateOnly) {
|
context.querySelector('.itemMiscInfoSecondary').innerHTML = mediaInfo.getSecondaryMediaInfoHtml(program, {
|
||||||
if (!refreshRecordingStateOnly) {
|
});
|
||||||
var imgUrl = getImageUrl(program, apiClient, 200);
|
|
||||||
var imageContainer = context.querySelector('.recordingDialog-imageContainer');
|
|
||||||
|
|
||||||
if (imgUrl) {
|
loading.hide();
|
||||||
imageContainer.innerHTML = '<img src="' + require.toUrl('.').split('?')[0] + '/empty.png" data-src="' + imgUrl + '" class="recordingDialog-img lazy" />';
|
}
|
||||||
imageContainer.classList.remove('hide');
|
|
||||||
|
|
||||||
imageLoader.lazyChildren(imageContainer);
|
function reload(context, programId, serverId, refreshRecordingStateOnly) {
|
||||||
} else {
|
loading.show();
|
||||||
imageContainer.innerHTML = '';
|
|
||||||
imageContainer.classList.add('hide');
|
|
||||||
}
|
|
||||||
|
|
||||||
context.querySelector('.recordingDialog-itemName').innerHTML = program.Name;
|
const apiClient = connectionManager.getApiClient(serverId);
|
||||||
context.querySelector('.formDialogHeaderTitle').innerHTML = program.Name;
|
|
||||||
context.querySelector('.itemGenres').innerHTML = (program.Genres || []).join(' / ');
|
|
||||||
context.querySelector('.itemOverview').innerHTML = program.Overview || '';
|
|
||||||
|
|
||||||
var formDialogFooter = context.querySelector('.formDialogFooter');
|
const promise1 = apiClient.getNewLiveTvTimerDefaults({ programId: programId });
|
||||||
var now = new Date();
|
const promise2 = apiClient.getLiveTvProgram(programId, apiClient.getCurrentUserId());
|
||||||
if (now >= datetime.parseISO8601Date(program.StartDate, true) && now < datetime.parseISO8601Date(program.EndDate, true)) {
|
|
||||||
formDialogFooter.classList.remove('hide');
|
|
||||||
} else {
|
|
||||||
formDialogFooter.classList.add('hide');
|
|
||||||
}
|
|
||||||
|
|
||||||
context.querySelector('.itemMiscInfoPrimary').innerHTML = mediaInfo.getPrimaryMediaInfoHtml(program);
|
Promise.all([promise1, promise2]).then(function (responses) {
|
||||||
}
|
const defaults = responses[0];
|
||||||
|
const program = responses[1];
|
||||||
|
|
||||||
context.querySelector('.itemMiscInfoSecondary').innerHTML = mediaInfo.getSecondaryMediaInfoHtml(program, {
|
renderRecording(context, defaults, program, apiClient, refreshRecordingStateOnly);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
loading.hide();
|
function executeCloseAction(action, programId, serverId) {
|
||||||
}
|
if (action === 'play') {
|
||||||
|
import('playbackManager').then(({default: playbackManager}) => {
|
||||||
|
const apiClient = connectionManager.getApiClient(serverId);
|
||||||
|
|
||||||
function reload(context, programId, serverId, refreshRecordingStateOnly) {
|
apiClient.getLiveTvProgram(programId, apiClient.getCurrentUserId()).then(function (item) {
|
||||||
loading.show();
|
playbackManager.play({
|
||||||
|
ids: [item.ChannelId],
|
||||||
var apiClient = connectionManager.getApiClient(serverId);
|
|
||||||
|
|
||||||
var promise1 = apiClient.getNewLiveTvTimerDefaults({ programId: programId });
|
|
||||||
var promise2 = apiClient.getLiveTvProgram(programId, apiClient.getCurrentUserId());
|
|
||||||
|
|
||||||
Promise.all([promise1, promise2]).then(function (responses) {
|
|
||||||
var defaults = responses[0];
|
|
||||||
var program = responses[1];
|
|
||||||
|
|
||||||
renderRecording(context, defaults, program, apiClient, refreshRecordingStateOnly);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function executeCloseAction(action, programId, serverId) {
|
|
||||||
if (action === 'play') {
|
|
||||||
require(['playbackManager'], function (playbackManager) {
|
|
||||||
var apiClient = connectionManager.getApiClient(serverId);
|
|
||||||
|
|
||||||
apiClient.getLiveTvProgram(programId, apiClient.getCurrentUserId()).then(function (item) {
|
|
||||||
playbackManager.play({
|
|
||||||
ids: [item.ChannelId],
|
|
||||||
serverId: serverId
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function showEditor(itemId, serverId) {
|
|
||||||
return new Promise(function (resolve, reject) {
|
|
||||||
closeAction = null;
|
|
||||||
|
|
||||||
loading.show();
|
|
||||||
|
|
||||||
require(['text!./recordingcreator.template.html'], function (template) {
|
|
||||||
var dialogOptions = {
|
|
||||||
removeOnClose: true,
|
|
||||||
scrollY: false
|
|
||||||
};
|
|
||||||
|
|
||||||
if (layoutManager.tv) {
|
|
||||||
dialogOptions.size = 'fullscreen';
|
|
||||||
} else {
|
|
||||||
dialogOptions.size = 'small';
|
|
||||||
}
|
|
||||||
|
|
||||||
var dlg = dialogHelper.createDialog(dialogOptions);
|
|
||||||
|
|
||||||
dlg.classList.add('formDialog');
|
|
||||||
dlg.classList.add('recordingDialog');
|
|
||||||
|
|
||||||
var html = '';
|
|
||||||
|
|
||||||
html += globalize.translateHtml(template, 'core');
|
|
||||||
|
|
||||||
dlg.innerHTML = html;
|
|
||||||
|
|
||||||
currentDialog = dlg;
|
|
||||||
|
|
||||||
function onRecordingChanged() {
|
|
||||||
reload(dlg, itemId, serverId, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
dlg.addEventListener('close', function () {
|
|
||||||
events.off(currentRecordingFields, 'recordingchanged', onRecordingChanged);
|
|
||||||
executeCloseAction(closeAction, itemId, serverId);
|
|
||||||
|
|
||||||
if (currentRecordingFields && currentRecordingFields.hasChanged()) {
|
|
||||||
resolve();
|
|
||||||
} else {
|
|
||||||
reject();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (layoutManager.tv) {
|
|
||||||
scrollHelper.centerFocus.on(dlg.querySelector('.formDialogContent'), false);
|
|
||||||
}
|
|
||||||
|
|
||||||
init(dlg);
|
|
||||||
|
|
||||||
reload(dlg, itemId, serverId);
|
|
||||||
|
|
||||||
currentRecordingFields = new recordingFields({
|
|
||||||
parent: dlg.querySelector('.recordingFields'),
|
|
||||||
programId: itemId,
|
|
||||||
serverId: serverId
|
serverId: serverId
|
||||||
});
|
});
|
||||||
|
|
||||||
events.on(currentRecordingFields, 'recordingchanged', onRecordingChanged);
|
|
||||||
|
|
||||||
dialogHelper.open(dlg);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
function showEditor(itemId, serverId) {
|
||||||
show: showEditor
|
return new Promise(function (resolve, reject) {
|
||||||
};
|
closeAction = null;
|
||||||
});
|
|
||||||
|
loading.show();
|
||||||
|
|
||||||
|
import('text!./recordingcreator.template.html').then(({default: template}) => {
|
||||||
|
const dialogOptions = {
|
||||||
|
removeOnClose: true,
|
||||||
|
scrollY: false
|
||||||
|
};
|
||||||
|
|
||||||
|
if (layoutManager.tv) {
|
||||||
|
dialogOptions.size = 'fullscreen';
|
||||||
|
} else {
|
||||||
|
dialogOptions.size = 'small';
|
||||||
|
}
|
||||||
|
|
||||||
|
const dlg = dialogHelper.createDialog(dialogOptions);
|
||||||
|
|
||||||
|
dlg.classList.add('formDialog');
|
||||||
|
dlg.classList.add('recordingDialog');
|
||||||
|
|
||||||
|
let html = '';
|
||||||
|
|
||||||
|
html += globalize.translateHtml(template, 'core');
|
||||||
|
|
||||||
|
dlg.innerHTML = html;
|
||||||
|
|
||||||
|
currentDialog = dlg;
|
||||||
|
|
||||||
|
function onRecordingChanged() {
|
||||||
|
reload(dlg, itemId, serverId, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
dlg.addEventListener('close', function () {
|
||||||
|
events.off(currentRecordingFields, 'recordingchanged', onRecordingChanged);
|
||||||
|
executeCloseAction(closeAction, itemId, serverId);
|
||||||
|
|
||||||
|
if (currentRecordingFields && currentRecordingFields.hasChanged()) {
|
||||||
|
resolve();
|
||||||
|
} else {
|
||||||
|
reject();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (layoutManager.tv) {
|
||||||
|
scrollHelper.centerFocus.on(dlg.querySelector('.formDialogContent'), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
init(dlg);
|
||||||
|
|
||||||
|
reload(dlg, itemId, serverId);
|
||||||
|
|
||||||
|
currentRecordingFields = new recordingFields({
|
||||||
|
parent: dlg.querySelector('.recordingFields'),
|
||||||
|
programId: itemId,
|
||||||
|
serverId: serverId
|
||||||
|
});
|
||||||
|
|
||||||
|
events.on(currentRecordingFields, 'recordingchanged', onRecordingChanged);
|
||||||
|
|
||||||
|
dialogHelper.open(dlg);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export default {
|
||||||
|
show: showEditor
|
||||||
|
};
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
define(['dialogHelper', 'globalize', 'layoutManager', 'mediaInfo', 'apphost', 'connectionManager', 'require', 'loading', 'scrollHelper', 'imageLoader', 'scrollStyles', 'emby-button', 'emby-collapse', 'emby-input', 'paper-icon-button-light', 'css!./../formdialog', 'css!./recordingcreator', 'material-icons', 'flexStyles'], function (dialogHelper, globalize, layoutManager, mediaInfo, appHost, connectionManager, require, loading, scrollHelper, imageLoader) {
|
define(['dialogHelper', 'globalize', 'layoutManager', 'mediaInfo', 'apphost', 'connectionManager', 'require', 'loading', 'scrollHelper', 'imageLoader', 'scrollStyles', 'emby-button', 'emby-collapse', 'emby-input', 'paper-icon-button-light', 'css!./../formdialog', 'css!./recordingcreator', 'material-icons', 'flexStyles'], function (dialogHelper, globalize, layoutManager, mediaInfo, appHost, connectionManager, require, loading, scrollHelper, imageLoader) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
scrollHelper = scrollHelper.default || scrollHelper;
|
||||||
|
loading = loading.default || loading;
|
||||||
|
layoutManager = layoutManager.default || layoutManager;
|
||||||
|
|
||||||
var currentDialog;
|
var currentDialog;
|
||||||
var recordingDeleted = false;
|
var recordingDeleted = false;
|
||||||
var currentItemId;
|
var currentItemId;
|
||||||
|
@ -10,6 +14,8 @@ define(['dialogHelper', 'globalize', 'layoutManager', 'mediaInfo', 'apphost', 'c
|
||||||
function deleteTimer(apiClient, timerId) {
|
function deleteTimer(apiClient, timerId) {
|
||||||
return new Promise(function (resolve, reject) {
|
return new Promise(function (resolve, reject) {
|
||||||
require(['recordingHelper'], function (recordingHelper) {
|
require(['recordingHelper'], function (recordingHelper) {
|
||||||
|
recordingHelper = recordingHelper.default || recordingHelper;
|
||||||
|
|
||||||
recordingHelper.cancelTimerWithConfirmation(timerId, apiClient.serverId()).then(resolve, reject);
|
recordingHelper.cancelTimerWithConfirmation(timerId, apiClient.serverId()).then(resolve, reject);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
define(['globalize', 'connectionManager', 'serverNotifications', 'require', 'loading', 'apphost', 'dom', 'recordingHelper', 'events', 'paper-icon-button-light', 'emby-button', 'css!./recordingfields', 'flexStyles'], function (globalize, connectionManager, serverNotifications, require, loading, appHost, dom, recordingHelper, events) {
|
define(['globalize', 'connectionManager', 'serverNotifications', 'require', 'loading', 'apphost', 'dom', 'recordingHelper', 'events', 'paper-icon-button-light', 'emby-button', 'css!./recordingfields', 'flexStyles'], function (globalize, connectionManager, serverNotifications, require, loading, appHost, dom, recordingHelper, events) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
serverNotifications = serverNotifications.default || serverNotifications;
|
||||||
|
recordingHelper = recordingHelper.default || recordingHelper;
|
||||||
|
loading = loading.default || loading;
|
||||||
|
|
||||||
function loadData(parent, program, apiClient) {
|
function loadData(parent, program, apiClient) {
|
||||||
if (program.IsSeries) {
|
if (program.IsSeries) {
|
||||||
parent.querySelector('.recordSeriesContainer').classList.remove('hide');
|
parent.querySelector('.recordSeriesContainer').classList.remove('hide');
|
||||||
|
|
|
@ -1,192 +1,195 @@
|
||||||
define(['globalize', 'loading', 'connectionManager'], function (globalize, loading, connectionManager) {
|
import globalize from 'globalize';
|
||||||
'use strict';
|
import loading from 'loading';
|
||||||
|
import connectionManager from 'connectionManager';
|
||||||
|
|
||||||
function changeRecordingToSeries(apiClient, timerId, programId, confirmTimerCancellation) {
|
/*eslint prefer-const: "error"*/
|
||||||
loading.show();
|
|
||||||
|
|
||||||
return apiClient.getItem(apiClient.getCurrentUserId(), programId).then(function (item) {
|
function changeRecordingToSeries(apiClient, timerId, programId, confirmTimerCancellation) {
|
||||||
if (item.IsSeries) {
|
loading.show();
|
||||||
// create series
|
|
||||||
return apiClient.getNewLiveTvTimerDefaults({ programId: programId }).then(function (timerDefaults) {
|
return apiClient.getItem(apiClient.getCurrentUserId(), programId).then(function (item) {
|
||||||
return apiClient.createLiveTvSeriesTimer(timerDefaults).then(function () {
|
if (item.IsSeries) {
|
||||||
loading.hide();
|
// create series
|
||||||
sendToast(globalize.translate('SeriesRecordingScheduled'));
|
return apiClient.getNewLiveTvTimerDefaults({ programId: programId }).then(function (timerDefaults) {
|
||||||
|
return apiClient.createLiveTvSeriesTimer(timerDefaults).then(function () {
|
||||||
|
loading.hide();
|
||||||
|
sendToast(globalize.translate('SeriesRecordingScheduled'));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// cancel
|
||||||
|
if (confirmTimerCancellation) {
|
||||||
|
return cancelTimerWithConfirmation(timerId, apiClient.serverId());
|
||||||
|
}
|
||||||
|
|
||||||
|
return cancelTimer(apiClient.serverId(), timerId, true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function cancelTimerWithConfirmation(timerId, serverId) {
|
||||||
|
return new Promise(function (resolve, reject) {
|
||||||
|
import('confirm').then(({ default: confirm }) => {
|
||||||
|
confirm.default({
|
||||||
|
|
||||||
|
text: globalize.translate('MessageConfirmRecordingCancellation'),
|
||||||
|
primary: 'delete',
|
||||||
|
confirmText: globalize.translate('HeaderCancelRecording'),
|
||||||
|
cancelText: globalize.translate('HeaderKeepRecording')
|
||||||
|
|
||||||
|
}).then(function () {
|
||||||
|
loading.show();
|
||||||
|
|
||||||
|
const apiClient = connectionManager.getApiClient(serverId);
|
||||||
|
cancelTimer(apiClient, timerId, true).then(resolve, reject);
|
||||||
|
}, reject);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function cancelSeriesTimerWithConfirmation(timerId, serverId) {
|
||||||
|
return new Promise(function (resolve, reject) {
|
||||||
|
import('confirm').then(({ default: confirm }) => {
|
||||||
|
confirm.default({
|
||||||
|
|
||||||
|
text: globalize.translate('MessageConfirmRecordingCancellation'),
|
||||||
|
primary: 'delete',
|
||||||
|
confirmText: globalize.translate('HeaderCancelSeries'),
|
||||||
|
cancelText: globalize.translate('HeaderKeepSeries')
|
||||||
|
|
||||||
|
}).then(function () {
|
||||||
|
loading.show();
|
||||||
|
|
||||||
|
const apiClient = connectionManager.getApiClient(serverId);
|
||||||
|
apiClient.cancelLiveTvSeriesTimer(timerId).then(function () {
|
||||||
|
import('toast').then(({default: toast}) => {
|
||||||
|
toast(globalize.translate('SeriesCancelled'));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
loading.hide();
|
||||||
|
resolve();
|
||||||
|
}, reject);
|
||||||
|
}, reject);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function cancelTimer(apiClient, timerId, hideLoading) {
|
||||||
|
loading.show();
|
||||||
|
return apiClient.cancelLiveTvTimer(timerId).then(function () {
|
||||||
|
if (hideLoading !== false) {
|
||||||
|
loading.hide();
|
||||||
|
sendToast(globalize.translate('RecordingCancelled'));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function createRecording(apiClient, programId, isSeries) {
|
||||||
|
loading.show();
|
||||||
|
return apiClient.getNewLiveTvTimerDefaults({ programId: programId }).then(function (item) {
|
||||||
|
const promise = isSeries ?
|
||||||
|
apiClient.createLiveTvSeriesTimer(item) :
|
||||||
|
apiClient.createLiveTvTimer(item);
|
||||||
|
|
||||||
|
return promise.then(function () {
|
||||||
|
loading.hide();
|
||||||
|
sendToast(globalize.translate('RecordingScheduled'));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function sendToast(msg) {
|
||||||
|
import('toast').then(({ default: toast }) => {
|
||||||
|
toast(msg);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function showMultiCancellationPrompt(serverId, programId, timerId, timerStatus, seriesTimerId) {
|
||||||
|
return new Promise(function (resolve, reject) {
|
||||||
|
import('dialog').then(({ default: dialog }) => {
|
||||||
|
const items = [];
|
||||||
|
|
||||||
|
items.push({
|
||||||
|
name: globalize.translate('HeaderKeepRecording'),
|
||||||
|
id: 'cancel',
|
||||||
|
type: 'submit'
|
||||||
|
});
|
||||||
|
|
||||||
|
if (timerStatus === 'InProgress') {
|
||||||
|
items.push({
|
||||||
|
name: globalize.translate('HeaderStopRecording'),
|
||||||
|
id: 'canceltimer',
|
||||||
|
type: 'cancel'
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// cancel
|
items.push({
|
||||||
if (confirmTimerCancellation) {
|
name: globalize.translate('HeaderCancelRecording'),
|
||||||
return cancelTimerWithConfirmation(timerId, apiClient.serverId());
|
id: 'canceltimer',
|
||||||
}
|
type: 'cancel'
|
||||||
|
});
|
||||||
return cancelTimer(apiClient.serverId(), timerId, true);
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function cancelTimerWithConfirmation(timerId, serverId) {
|
items.push({
|
||||||
return new Promise(function (resolve, reject) {
|
name: globalize.translate('HeaderCancelSeries'),
|
||||||
require(['confirm'], function (confirm) {
|
id: 'cancelseriestimer',
|
||||||
confirm.default({
|
type: 'cancel'
|
||||||
|
|
||||||
text: globalize.translate('MessageConfirmRecordingCancellation'),
|
|
||||||
primary: 'delete',
|
|
||||||
confirmText: globalize.translate('HeaderCancelRecording'),
|
|
||||||
cancelText: globalize.translate('HeaderKeepRecording')
|
|
||||||
|
|
||||||
}).then(function () {
|
|
||||||
loading.show();
|
|
||||||
|
|
||||||
var apiClient = connectionManager.getApiClient(serverId);
|
|
||||||
cancelTimer(apiClient, timerId, true).then(resolve, reject);
|
|
||||||
}, reject);
|
|
||||||
});
|
});
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function cancelSeriesTimerWithConfirmation(timerId, serverId) {
|
dialog({
|
||||||
return new Promise(function (resolve, reject) {
|
|
||||||
require(['confirm'], function (confirm) {
|
|
||||||
confirm.default({
|
|
||||||
|
|
||||||
text: globalize.translate('MessageConfirmRecordingCancellation'),
|
text: globalize.translate('MessageConfirmRecordingCancellation'),
|
||||||
primary: 'delete',
|
buttons: items
|
||||||
confirmText: globalize.translate('HeaderCancelSeries'),
|
|
||||||
cancelText: globalize.translate('HeaderKeepSeries')
|
|
||||||
|
|
||||||
}).then(function () {
|
}).then(function (result) {
|
||||||
|
const apiClient = connectionManager.getApiClient(serverId);
|
||||||
|
|
||||||
|
if (result === 'canceltimer') {
|
||||||
loading.show();
|
loading.show();
|
||||||
|
|
||||||
var apiClient = connectionManager.getApiClient(serverId);
|
cancelTimer(apiClient, timerId, true).then(resolve, reject);
|
||||||
apiClient.cancelLiveTvSeriesTimer(timerId).then(function () {
|
} else if (result === 'cancelseriestimer') {
|
||||||
require(['toast'], function (toast) {
|
loading.show();
|
||||||
|
|
||||||
|
apiClient.cancelLiveTvSeriesTimer(seriesTimerId).then(function () {
|
||||||
|
import('toast').then(({ default: toast }) => {
|
||||||
toast(globalize.translate('SeriesCancelled'));
|
toast(globalize.translate('SeriesCancelled'));
|
||||||
});
|
});
|
||||||
|
|
||||||
loading.hide();
|
loading.hide();
|
||||||
resolve();
|
resolve();
|
||||||
}, reject);
|
}, reject);
|
||||||
}, reject);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function cancelTimer(apiClient, timerId, hideLoading) {
|
|
||||||
loading.show();
|
|
||||||
return apiClient.cancelLiveTvTimer(timerId).then(function () {
|
|
||||||
if (hideLoading !== false) {
|
|
||||||
loading.hide();
|
|
||||||
sendToast(globalize.translate('RecordingCancelled'));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function createRecording(apiClient, programId, isSeries) {
|
|
||||||
loading.show();
|
|
||||||
return apiClient.getNewLiveTvTimerDefaults({ programId: programId }).then(function (item) {
|
|
||||||
var promise = isSeries ?
|
|
||||||
apiClient.createLiveTvSeriesTimer(item) :
|
|
||||||
apiClient.createLiveTvTimer(item);
|
|
||||||
|
|
||||||
return promise.then(function () {
|
|
||||||
loading.hide();
|
|
||||||
sendToast(globalize.translate('RecordingScheduled'));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function sendToast(msg) {
|
|
||||||
require(['toast'], function (toast) {
|
|
||||||
toast(msg);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function showMultiCancellationPrompt(serverId, programId, timerId, timerStatus, seriesTimerId) {
|
|
||||||
return new Promise(function (resolve, reject) {
|
|
||||||
require(['dialog'], function (dialog) {
|
|
||||||
var items = [];
|
|
||||||
|
|
||||||
items.push({
|
|
||||||
name: globalize.translate('HeaderKeepRecording'),
|
|
||||||
id: 'cancel',
|
|
||||||
type: 'submit'
|
|
||||||
});
|
|
||||||
|
|
||||||
if (timerStatus === 'InProgress') {
|
|
||||||
items.push({
|
|
||||||
name: globalize.translate('HeaderStopRecording'),
|
|
||||||
id: 'canceltimer',
|
|
||||||
type: 'cancel'
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
items.push({
|
resolve();
|
||||||
name: globalize.translate('HeaderCancelRecording'),
|
|
||||||
id: 'canceltimer',
|
|
||||||
type: 'cancel'
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
}, reject);
|
||||||
items.push({
|
|
||||||
name: globalize.translate('HeaderCancelSeries'),
|
|
||||||
id: 'cancelseriestimer',
|
|
||||||
type: 'cancel'
|
|
||||||
});
|
|
||||||
|
|
||||||
dialog({
|
|
||||||
|
|
||||||
text: globalize.translate('MessageConfirmRecordingCancellation'),
|
|
||||||
buttons: items
|
|
||||||
|
|
||||||
}).then(function (result) {
|
|
||||||
var apiClient = connectionManager.getApiClient(serverId);
|
|
||||||
|
|
||||||
if (result === 'canceltimer') {
|
|
||||||
loading.show();
|
|
||||||
|
|
||||||
cancelTimer(apiClient, timerId, true).then(resolve, reject);
|
|
||||||
} else if (result === 'cancelseriestimer') {
|
|
||||||
loading.show();
|
|
||||||
|
|
||||||
apiClient.cancelLiveTvSeriesTimer(seriesTimerId).then(function () {
|
|
||||||
require(['toast'], function (toast) {
|
|
||||||
toast(globalize.translate('SeriesCancelled'));
|
|
||||||
});
|
|
||||||
|
|
||||||
loading.hide();
|
|
||||||
resolve();
|
|
||||||
}, reject);
|
|
||||||
} else {
|
|
||||||
resolve();
|
|
||||||
}
|
|
||||||
}, reject);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function toggleRecording(serverId, programId, timerId, timerStatus, seriesTimerId) {
|
function toggleRecording(serverId, programId, timerId, timerStatus, seriesTimerId) {
|
||||||
var apiClient = connectionManager.getApiClient(serverId);
|
const apiClient = connectionManager.getApiClient(serverId);
|
||||||
var hasTimer = timerId && timerStatus !== 'Cancelled';
|
const hasTimer = timerId && timerStatus !== 'Cancelled';
|
||||||
if (seriesTimerId && hasTimer) {
|
if (seriesTimerId && hasTimer) {
|
||||||
// cancel
|
// cancel
|
||||||
return showMultiCancellationPrompt(serverId, programId, timerId, timerStatus, seriesTimerId);
|
return showMultiCancellationPrompt(serverId, programId, timerId, timerStatus, seriesTimerId);
|
||||||
} else if (hasTimer && programId) {
|
} else if (hasTimer && programId) {
|
||||||
// change to series recording, if possible
|
// change to series recording, if possible
|
||||||
// otherwise cancel individual recording
|
// otherwise cancel individual recording
|
||||||
return changeRecordingToSeries(apiClient, timerId, programId, true);
|
return changeRecordingToSeries(apiClient, timerId, programId, true);
|
||||||
} else if (programId) {
|
} else if (programId) {
|
||||||
// schedule recording
|
// schedule recording
|
||||||
return createRecording(apiClient, programId);
|
return createRecording(apiClient, programId);
|
||||||
} else {
|
} else {
|
||||||
return Promise.reject();
|
return Promise.reject();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default {
|
||||||
|
cancelTimer: cancelTimer,
|
||||||
|
createRecording: createRecording,
|
||||||
|
changeRecordingToSeries: changeRecordingToSeries,
|
||||||
|
toggleRecording: toggleRecording,
|
||||||
|
cancelTimerWithConfirmation: cancelTimerWithConfirmation,
|
||||||
|
cancelSeriesTimerWithConfirmation: cancelSeriesTimerWithConfirmation
|
||||||
|
};
|
||||||
|
|
||||||
return {
|
|
||||||
cancelTimer: cancelTimer,
|
|
||||||
createRecording: createRecording,
|
|
||||||
changeRecordingToSeries: changeRecordingToSeries,
|
|
||||||
toggleRecording: toggleRecording,
|
|
||||||
cancelTimerWithConfirmation: cancelTimerWithConfirmation,
|
|
||||||
cancelSeriesTimerWithConfirmation: cancelSeriesTimerWithConfirmation
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
|
@ -1,141 +1,200 @@
|
||||||
define(['dialogHelper', 'globalize', 'layoutManager', 'mediaInfo', 'apphost', 'connectionManager', 'require', 'loading', 'scrollHelper', 'imageLoader', 'datetime', 'scrollStyles', 'emby-button', 'emby-checkbox', 'emby-input', 'emby-select', 'paper-icon-button-light', 'css!./../formdialog', 'css!./recordingcreator', 'material-icons', 'flexStyles'], function (dialogHelper, globalize, layoutManager, mediaInfo, appHost, connectionManager, require, loading, scrollHelper, imageLoader, datetime) {
|
import dialogHelper from 'dialogHelper';
|
||||||
'use strict';
|
import globalize from 'globalize';
|
||||||
|
import layoutManager from 'layoutManager';
|
||||||
|
import connectionManager from 'connectionManager';
|
||||||
|
import loading from 'loading';
|
||||||
|
import scrollHelper from 'scrollHelper';
|
||||||
|
import datetime from 'datetime';
|
||||||
|
import 'scrollStyles';
|
||||||
|
import 'emby-button';
|
||||||
|
import 'emby-checkbox';
|
||||||
|
import 'emby-input';
|
||||||
|
import 'emby-select';
|
||||||
|
import 'paper-icon-button-light';
|
||||||
|
import 'css!./../formdialog';
|
||||||
|
import 'css!./recordingcreator';
|
||||||
|
import 'material-icons';
|
||||||
|
import 'flexStyles';
|
||||||
|
|
||||||
var currentDialog;
|
/*eslint prefer-const: "error"*/
|
||||||
var recordingUpdated = false;
|
|
||||||
var recordingDeleted = false;
|
|
||||||
var currentItemId;
|
|
||||||
var currentServerId;
|
|
||||||
|
|
||||||
function deleteTimer(apiClient, timerId) {
|
let currentDialog;
|
||||||
return new Promise(function (resolve, reject) {
|
let recordingUpdated = false;
|
||||||
require(['recordingHelper'], function (recordingHelper) {
|
let recordingDeleted = false;
|
||||||
recordingHelper.cancelSeriesTimerWithConfirmation(timerId, apiClient.serverId()).then(resolve, reject);
|
let currentItemId;
|
||||||
});
|
let currentServerId;
|
||||||
|
|
||||||
|
function deleteTimer(apiClient, timerId) {
|
||||||
|
return new Promise(function (resolve, reject) {
|
||||||
|
import('recordingHelper').then(({ default: recordingHelper }) => {
|
||||||
|
recordingHelper.cancelSeriesTimerWithConfirmation(timerId, apiClient.serverId()).then(resolve, reject);
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderTimer(context, item) {
|
||||||
|
context.querySelector('#txtPrePaddingMinutes').value = item.PrePaddingSeconds / 60;
|
||||||
|
context.querySelector('#txtPostPaddingMinutes').value = item.PostPaddingSeconds / 60;
|
||||||
|
|
||||||
|
context.querySelector('.selectChannels').value = item.RecordAnyChannel ? 'all' : 'one';
|
||||||
|
context.querySelector('.selectAirTime').value = item.RecordAnyTime ? 'any' : 'original';
|
||||||
|
|
||||||
|
context.querySelector('.selectShowType').value = item.RecordNewOnly ? 'new' : 'all';
|
||||||
|
context.querySelector('.chkSkipEpisodesInLibrary').checked = item.SkipEpisodesInLibrary;
|
||||||
|
context.querySelector('.selectKeepUpTo').value = item.KeepUpTo || 0;
|
||||||
|
|
||||||
|
if (item.ChannelName || item.ChannelNumber) {
|
||||||
|
context.querySelector('.optionChannelOnly').innerHTML = globalize.translate('ChannelNameOnly', item.ChannelName || item.ChannelNumber);
|
||||||
|
} else {
|
||||||
|
context.querySelector('.optionChannelOnly').innerHTML = globalize.translate('OneChannel');
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderTimer(context, item, apiClient) {
|
context.querySelector('.optionAroundTime').innerHTML = globalize.translate('AroundTime', datetime.getDisplayTime(datetime.parseISO8601Date(item.StartDate)));
|
||||||
context.querySelector('#txtPrePaddingMinutes').value = item.PrePaddingSeconds / 60;
|
|
||||||
context.querySelector('#txtPostPaddingMinutes').value = item.PostPaddingSeconds / 60;
|
|
||||||
|
|
||||||
context.querySelector('.selectChannels').value = item.RecordAnyChannel ? 'all' : 'one';
|
loading.hide();
|
||||||
context.querySelector('.selectAirTime').value = item.RecordAnyTime ? 'any' : 'original';
|
}
|
||||||
|
|
||||||
context.querySelector('.selectShowType').value = item.RecordNewOnly ? 'new' : 'all';
|
function closeDialog(isDeleted) {
|
||||||
context.querySelector('.chkSkipEpisodesInLibrary').checked = item.SkipEpisodesInLibrary;
|
recordingUpdated = true;
|
||||||
context.querySelector('.selectKeepUpTo').value = item.KeepUpTo || 0;
|
recordingDeleted = isDeleted;
|
||||||
|
|
||||||
if (item.ChannelName || item.ChannelNumber) {
|
dialogHelper.close(currentDialog);
|
||||||
context.querySelector('.optionChannelOnly').innerHTML = globalize.translate('ChannelNameOnly', item.ChannelName || item.ChannelNumber);
|
}
|
||||||
} else {
|
|
||||||
context.querySelector('.optionChannelOnly').innerHTML = globalize.translate('OneChannel');
|
|
||||||
}
|
|
||||||
|
|
||||||
context.querySelector('.optionAroundTime').innerHTML = globalize.translate('AroundTime', datetime.getDisplayTime(datetime.parseISO8601Date(item.StartDate)));
|
function onSubmit(e) {
|
||||||
|
const form = this;
|
||||||
|
|
||||||
|
const apiClient = connectionManager.getApiClient(currentServerId);
|
||||||
|
|
||||||
|
apiClient.getLiveTvSeriesTimer(currentItemId).then(function (item) {
|
||||||
|
item.PrePaddingSeconds = form.querySelector('#txtPrePaddingMinutes').value * 60;
|
||||||
|
item.PostPaddingSeconds = form.querySelector('#txtPostPaddingMinutes').value * 60;
|
||||||
|
item.RecordAnyChannel = form.querySelector('.selectChannels').value === 'all';
|
||||||
|
item.RecordAnyTime = form.querySelector('.selectAirTime').value === 'any';
|
||||||
|
item.RecordNewOnly = form.querySelector('.selectShowType').value === 'new';
|
||||||
|
item.SkipEpisodesInLibrary = form.querySelector('.chkSkipEpisodesInLibrary').checked;
|
||||||
|
item.KeepUpTo = form.querySelector('.selectKeepUpTo').value;
|
||||||
|
|
||||||
|
apiClient.updateLiveTvSeriesTimer(item);
|
||||||
|
});
|
||||||
|
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
// Disable default form submission
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function init(context) {
|
||||||
|
fillKeepUpTo(context);
|
||||||
|
|
||||||
|
context.querySelector('.btnCancel').addEventListener('click', function () {
|
||||||
|
closeDialog(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
context.querySelector('.btnCancelRecording').addEventListener('click', function () {
|
||||||
|
const apiClient = connectionManager.getApiClient(currentServerId);
|
||||||
|
deleteTimer(apiClient, currentItemId).then(function () {
|
||||||
|
closeDialog(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
context.querySelector('form').addEventListener('submit', onSubmit);
|
||||||
|
}
|
||||||
|
|
||||||
|
function reload(context, id) {
|
||||||
|
const apiClient = connectionManager.getApiClient(currentServerId);
|
||||||
|
|
||||||
|
loading.show();
|
||||||
|
if (typeof id === 'string') {
|
||||||
|
currentItemId = id;
|
||||||
|
|
||||||
|
apiClient.getLiveTvSeriesTimer(id).then(function (result) {
|
||||||
|
renderTimer(context, result);
|
||||||
|
loading.hide();
|
||||||
|
});
|
||||||
|
} else if (id) {
|
||||||
|
currentItemId = id.Id;
|
||||||
|
|
||||||
|
renderTimer(context, id);
|
||||||
loading.hide();
|
loading.hide();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function closeDialog(isDeleted) {
|
function fillKeepUpTo(context) {
|
||||||
recordingUpdated = true;
|
let html = '';
|
||||||
recordingDeleted = isDeleted;
|
|
||||||
|
|
||||||
dialogHelper.close(currentDialog);
|
for (let i = 0; i <= 50; i++) {
|
||||||
}
|
let text;
|
||||||
|
|
||||||
function onSubmit(e) {
|
if (i === 0) {
|
||||||
var form = this;
|
text = globalize.translate('AsManyAsPossible');
|
||||||
|
} else if (i === 1) {
|
||||||
var apiClient = connectionManager.getApiClient(currentServerId);
|
text = globalize.translate('ValueOneEpisode');
|
||||||
|
} else {
|
||||||
apiClient.getLiveTvSeriesTimer(currentItemId).then(function (item) {
|
text = globalize.translate('ValueEpisodeCount', i);
|
||||||
item.PrePaddingSeconds = form.querySelector('#txtPrePaddingMinutes').value * 60;
|
|
||||||
item.PostPaddingSeconds = form.querySelector('#txtPostPaddingMinutes').value * 60;
|
|
||||||
item.RecordAnyChannel = form.querySelector('.selectChannels').value === 'all';
|
|
||||||
item.RecordAnyTime = form.querySelector('.selectAirTime').value === 'any';
|
|
||||||
item.RecordNewOnly = form.querySelector('.selectShowType').value === 'new';
|
|
||||||
item.SkipEpisodesInLibrary = form.querySelector('.chkSkipEpisodesInLibrary').checked;
|
|
||||||
item.KeepUpTo = form.querySelector('.selectKeepUpTo').value;
|
|
||||||
|
|
||||||
apiClient.updateLiveTvSeriesTimer(item);
|
|
||||||
});
|
|
||||||
|
|
||||||
e.preventDefault();
|
|
||||||
|
|
||||||
// Disable default form submission
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
function init(context) {
|
|
||||||
fillKeepUpTo(context);
|
|
||||||
|
|
||||||
context.querySelector('.btnCancel').addEventListener('click', function () {
|
|
||||||
closeDialog(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
context.querySelector('.btnCancelRecording').addEventListener('click', function () {
|
|
||||||
var apiClient = connectionManager.getApiClient(currentServerId);
|
|
||||||
deleteTimer(apiClient, currentItemId).then(function () {
|
|
||||||
closeDialog(true);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
context.querySelector('form').addEventListener('submit', onSubmit);
|
|
||||||
}
|
|
||||||
|
|
||||||
function reload(context, id) {
|
|
||||||
var apiClient = connectionManager.getApiClient(currentServerId);
|
|
||||||
|
|
||||||
loading.show();
|
|
||||||
if (typeof id === 'string') {
|
|
||||||
currentItemId = id;
|
|
||||||
|
|
||||||
apiClient.getLiveTvSeriesTimer(id).then(function (result) {
|
|
||||||
renderTimer(context, result, apiClient);
|
|
||||||
loading.hide();
|
|
||||||
});
|
|
||||||
} else if (id) {
|
|
||||||
currentItemId = id.Id;
|
|
||||||
|
|
||||||
renderTimer(context, id, apiClient);
|
|
||||||
loading.hide();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function fillKeepUpTo(context) {
|
|
||||||
var html = '';
|
|
||||||
|
|
||||||
for (var i = 0; i <= 50; i++) {
|
|
||||||
var text;
|
|
||||||
|
|
||||||
if (i === 0) {
|
|
||||||
text = globalize.translate('AsManyAsPossible');
|
|
||||||
} else if (i === 1) {
|
|
||||||
text = globalize.translate('ValueOneEpisode');
|
|
||||||
} else {
|
|
||||||
text = globalize.translate('ValueEpisodeCount', i);
|
|
||||||
}
|
|
||||||
|
|
||||||
html += '<option value="' + i + '">' + text + '</option>';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
context.querySelector('.selectKeepUpTo').innerHTML = html;
|
html += '<option value="' + i + '">' + text + '</option>';
|
||||||
}
|
}
|
||||||
|
|
||||||
function onFieldChange(e) {
|
context.querySelector('.selectKeepUpTo').innerHTML = html;
|
||||||
this.querySelector('.btnSubmit').click();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
function embed(itemId, serverId, options) {
|
function onFieldChange() {
|
||||||
|
this.querySelector('.btnSubmit').click();
|
||||||
|
}
|
||||||
|
|
||||||
|
function embed(itemId, serverId, options) {
|
||||||
|
recordingUpdated = false;
|
||||||
|
recordingDeleted = false;
|
||||||
|
currentServerId = serverId;
|
||||||
|
loading.show();
|
||||||
|
options = options || {};
|
||||||
|
|
||||||
|
import('text!./seriesrecordingeditor.template.html').then(({ default: template }) => {
|
||||||
|
const dialogOptions = {
|
||||||
|
removeOnClose: true,
|
||||||
|
scrollY: false
|
||||||
|
};
|
||||||
|
|
||||||
|
if (layoutManager.tv) {
|
||||||
|
dialogOptions.size = 'fullscreen';
|
||||||
|
} else {
|
||||||
|
dialogOptions.size = 'small';
|
||||||
|
}
|
||||||
|
|
||||||
|
const dlg = options.context;
|
||||||
|
|
||||||
|
dlg.classList.add('hide');
|
||||||
|
dlg.innerHTML = globalize.translateHtml(template, 'core');
|
||||||
|
|
||||||
|
dlg.querySelector('.formDialogHeader').classList.add('hide');
|
||||||
|
dlg.querySelector('.formDialogFooter').classList.add('hide');
|
||||||
|
dlg.querySelector('.formDialogContent').className = '';
|
||||||
|
dlg.querySelector('.dialogContentInner').className = '';
|
||||||
|
dlg.classList.remove('hide');
|
||||||
|
|
||||||
|
dlg.removeEventListener('change', onFieldChange);
|
||||||
|
dlg.addEventListener('change', onFieldChange);
|
||||||
|
|
||||||
|
currentDialog = dlg;
|
||||||
|
|
||||||
|
init(dlg);
|
||||||
|
|
||||||
|
reload(dlg, itemId);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function showEditor(itemId, serverId, options) {
|
||||||
|
return new Promise(function (resolve, reject) {
|
||||||
recordingUpdated = false;
|
recordingUpdated = false;
|
||||||
recordingDeleted = false;
|
recordingDeleted = false;
|
||||||
currentServerId = serverId;
|
currentServerId = serverId;
|
||||||
loading.show();
|
loading.show();
|
||||||
options = options || {};
|
options = options || {};
|
||||||
|
|
||||||
require(['text!./seriesrecordingeditor.template.html'], function (template) {
|
import('text!./seriesrecordingeditor.template.html').then(({ default: template }) => {
|
||||||
var dialogOptions = {
|
const dialogOptions = {
|
||||||
removeOnClose: true,
|
removeOnClose: true,
|
||||||
scrollY: false
|
scrollY: false
|
||||||
};
|
};
|
||||||
|
@ -146,101 +205,58 @@ define(['dialogHelper', 'globalize', 'layoutManager', 'mediaInfo', 'apphost', 'c
|
||||||
dialogOptions.size = 'small';
|
dialogOptions.size = 'small';
|
||||||
}
|
}
|
||||||
|
|
||||||
var dlg = options.context;
|
const dlg = dialogHelper.createDialog(dialogOptions);
|
||||||
|
|
||||||
dlg.classList.add('hide');
|
dlg.classList.add('formDialog');
|
||||||
dlg.innerHTML = globalize.translateHtml(template, 'core');
|
dlg.classList.add('recordingDialog');
|
||||||
|
|
||||||
dlg.querySelector('.formDialogHeader').classList.add('hide');
|
if (!layoutManager.tv) {
|
||||||
dlg.querySelector('.formDialogFooter').classList.add('hide');
|
dlg.style['min-width'] = '20%';
|
||||||
dlg.querySelector('.formDialogContent').className = '';
|
}
|
||||||
dlg.querySelector('.dialogContentInner').className = '';
|
|
||||||
dlg.classList.remove('hide');
|
|
||||||
|
|
||||||
dlg.removeEventListener('change', onFieldChange);
|
let html = '';
|
||||||
dlg.addEventListener('change', onFieldChange);
|
|
||||||
|
html += globalize.translateHtml(template, 'core');
|
||||||
|
|
||||||
|
dlg.innerHTML = html;
|
||||||
|
|
||||||
|
if (options.enableCancel === false) {
|
||||||
|
dlg.querySelector('.formDialogFooter').classList.add('hide');
|
||||||
|
}
|
||||||
|
|
||||||
currentDialog = dlg;
|
currentDialog = dlg;
|
||||||
|
|
||||||
|
dlg.addEventListener('closing', function () {
|
||||||
|
if (!recordingDeleted) {
|
||||||
|
this.querySelector('.btnSubmit').click();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
dlg.addEventListener('close', function () {
|
||||||
|
if (recordingUpdated) {
|
||||||
|
resolve({
|
||||||
|
updated: true,
|
||||||
|
deleted: recordingDeleted
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
reject();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (layoutManager.tv) {
|
||||||
|
scrollHelper.centerFocus.on(dlg.querySelector('.formDialogContent'), false);
|
||||||
|
}
|
||||||
|
|
||||||
init(dlg);
|
init(dlg);
|
||||||
|
|
||||||
reload(dlg, itemId);
|
reload(dlg, itemId);
|
||||||
|
|
||||||
|
dialogHelper.open(dlg);
|
||||||
});
|
});
|
||||||
}
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function showEditor(itemId, serverId, options) {
|
export default {
|
||||||
return new Promise(function (resolve, reject) {
|
show: showEditor,
|
||||||
recordingUpdated = false;
|
embed: embed
|
||||||
recordingDeleted = false;
|
};
|
||||||
currentServerId = serverId;
|
|
||||||
loading.show();
|
|
||||||
options = options || {};
|
|
||||||
|
|
||||||
require(['text!./seriesrecordingeditor.template.html'], function (template) {
|
|
||||||
var dialogOptions = {
|
|
||||||
removeOnClose: true,
|
|
||||||
scrollY: false
|
|
||||||
};
|
|
||||||
|
|
||||||
if (layoutManager.tv) {
|
|
||||||
dialogOptions.size = 'fullscreen';
|
|
||||||
} else {
|
|
||||||
dialogOptions.size = 'small';
|
|
||||||
}
|
|
||||||
|
|
||||||
var dlg = dialogHelper.createDialog(dialogOptions);
|
|
||||||
|
|
||||||
dlg.classList.add('formDialog');
|
|
||||||
dlg.classList.add('recordingDialog');
|
|
||||||
|
|
||||||
if (!layoutManager.tv) {
|
|
||||||
dlg.style['min-width'] = '20%';
|
|
||||||
}
|
|
||||||
|
|
||||||
var html = '';
|
|
||||||
|
|
||||||
html += globalize.translateHtml(template, 'core');
|
|
||||||
|
|
||||||
dlg.innerHTML = html;
|
|
||||||
|
|
||||||
if (options.enableCancel === false) {
|
|
||||||
dlg.querySelector('.formDialogFooter').classList.add('hide');
|
|
||||||
}
|
|
||||||
|
|
||||||
currentDialog = dlg;
|
|
||||||
|
|
||||||
dlg.addEventListener('closing', function () {
|
|
||||||
if (!recordingDeleted) {
|
|
||||||
this.querySelector('.btnSubmit').click();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
dlg.addEventListener('close', function () {
|
|
||||||
if (recordingUpdated) {
|
|
||||||
resolve({
|
|
||||||
updated: true,
|
|
||||||
deleted: recordingDeleted
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
reject();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (layoutManager.tv) {
|
|
||||||
scrollHelper.centerFocus.on(dlg.querySelector('.formDialogContent'), false);
|
|
||||||
}
|
|
||||||
|
|
||||||
init(dlg);
|
|
||||||
|
|
||||||
reload(dlg, itemId);
|
|
||||||
|
|
||||||
dialogHelper.open(dlg);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
show: showEditor,
|
|
||||||
embed: embed
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,184 +0,0 @@
|
||||||
define(['apphost', 'userSettings', 'browser', 'events', 'backdrop', 'globalize', 'require', 'appSettings'], function (appHost, userSettings, browser, events, backdrop, globalize, require, appSettings) {
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
var themeStyleElement;
|
|
||||||
var currentThemeId;
|
|
||||||
|
|
||||||
function unloadTheme() {
|
|
||||||
var elem = themeStyleElement;
|
|
||||||
if (elem) {
|
|
||||||
elem.parentNode.removeChild(elem);
|
|
||||||
themeStyleElement = null;
|
|
||||||
currentThemeId = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function loadUserSkin(options) {
|
|
||||||
options = options || {};
|
|
||||||
if (options.start) {
|
|
||||||
Emby.Page.invokeShortcut(options.start);
|
|
||||||
} else {
|
|
||||||
Emby.Page.goHome();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function getThemes() {
|
|
||||||
return [{
|
|
||||||
name: 'Apple TV',
|
|
||||||
id: 'appletv'
|
|
||||||
}, {
|
|
||||||
name: 'Blue Radiance',
|
|
||||||
id: 'blueradiance'
|
|
||||||
}, {
|
|
||||||
name: 'Dark',
|
|
||||||
id: 'dark',
|
|
||||||
isDefault: true,
|
|
||||||
isDefaultServerDashboard: true
|
|
||||||
}, {
|
|
||||||
name: 'Light',
|
|
||||||
id: 'light'
|
|
||||||
}, {
|
|
||||||
name: 'Purple Haze',
|
|
||||||
id: 'purplehaze'
|
|
||||||
}, {
|
|
||||||
name: 'Windows Media Center',
|
|
||||||
id: 'wmc'
|
|
||||||
}];
|
|
||||||
}
|
|
||||||
|
|
||||||
var skinManager = {
|
|
||||||
getThemes: getThemes,
|
|
||||||
loadUserSkin: loadUserSkin
|
|
||||||
};
|
|
||||||
|
|
||||||
function getThemeStylesheetInfo(id, isDefaultProperty) {
|
|
||||||
var themes = skinManager.getThemes();
|
|
||||||
var defaultTheme;
|
|
||||||
var selectedTheme;
|
|
||||||
|
|
||||||
for (var i = 0, length = themes.length; i < length; i++) {
|
|
||||||
var theme = themes[i];
|
|
||||||
if (theme[isDefaultProperty]) {
|
|
||||||
defaultTheme = theme;
|
|
||||||
}
|
|
||||||
if (id === theme.id) {
|
|
||||||
selectedTheme = theme;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
selectedTheme = selectedTheme || defaultTheme;
|
|
||||||
return {
|
|
||||||
stylesheetPath: require.toUrl('themes/' + selectedTheme.id + '/theme.css'),
|
|
||||||
themeId: selectedTheme.id
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
var themeResources = {};
|
|
||||||
var lastSound = 0;
|
|
||||||
var currentSound;
|
|
||||||
|
|
||||||
function loadThemeResources(id) {
|
|
||||||
lastSound = 0;
|
|
||||||
if (currentSound) {
|
|
||||||
currentSound.stop();
|
|
||||||
currentSound = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
backdrop.clearBackdrop();
|
|
||||||
}
|
|
||||||
|
|
||||||
function onThemeLoaded() {
|
|
||||||
document.documentElement.classList.remove('preload');
|
|
||||||
try {
|
|
||||||
var color = getComputedStyle(document.querySelector('.skinHeader')).getPropertyValue('background-color');
|
|
||||||
if (color) {
|
|
||||||
appHost.setThemeColor(color);
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
console.error('error setting theme color: ' + err);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
skinManager.setTheme = function (id, context) {
|
|
||||||
return new Promise(function (resolve, reject) {
|
|
||||||
if (currentThemeId && currentThemeId === id) {
|
|
||||||
resolve();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var isDefaultProperty = context === 'serverdashboard' ? 'isDefaultServerDashboard' : 'isDefault';
|
|
||||||
var info = getThemeStylesheetInfo(id, isDefaultProperty);
|
|
||||||
if (currentThemeId && currentThemeId === info.themeId) {
|
|
||||||
resolve();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var linkUrl = info.stylesheetPath;
|
|
||||||
unloadTheme();
|
|
||||||
|
|
||||||
var link = document.createElement('link');
|
|
||||||
link.setAttribute('rel', 'stylesheet');
|
|
||||||
link.setAttribute('type', 'text/css');
|
|
||||||
link.onload = function () {
|
|
||||||
onThemeLoaded();
|
|
||||||
resolve();
|
|
||||||
};
|
|
||||||
|
|
||||||
link.setAttribute('href', linkUrl);
|
|
||||||
document.head.appendChild(link);
|
|
||||||
themeStyleElement = link;
|
|
||||||
currentThemeId = info.themeId;
|
|
||||||
loadThemeResources(info.themeId);
|
|
||||||
|
|
||||||
onViewBeforeShow({});
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
function onViewBeforeShow(e) {
|
|
||||||
if (e.detail && e.detail.type === 'video-osd') {
|
|
||||||
// This removes the space that the scrollbar takes while playing a video
|
|
||||||
document.body.classList.remove('force-scroll');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (themeResources.backdrop) {
|
|
||||||
backdrop.setBackdrop(themeResources.backdrop);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!browser.mobile && userSettings.enableThemeSongs()) {
|
|
||||||
if (lastSound === 0) {
|
|
||||||
if (themeResources.themeSong) {
|
|
||||||
playSound(themeResources.themeSong);
|
|
||||||
}
|
|
||||||
} else if ((new Date().getTime() - lastSound) > 30000) {
|
|
||||||
if (themeResources.effect) {
|
|
||||||
playSound(themeResources.effect);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// This keeps the scrollbar always present in all pages, so we avoid clipping while switching between pages
|
|
||||||
// that need the scrollbar and pages that don't.
|
|
||||||
document.body.classList.add('force-scroll');
|
|
||||||
}
|
|
||||||
|
|
||||||
document.addEventListener('viewshow', onViewBeforeShow);
|
|
||||||
|
|
||||||
function playSound(path, volume) {
|
|
||||||
lastSound = new Date().getTime();
|
|
||||||
require(['howler'], function (howler) {
|
|
||||||
/* globals Howl */
|
|
||||||
try {
|
|
||||||
var sound = new Howl({
|
|
||||||
src: [path],
|
|
||||||
volume: volume || 0.1
|
|
||||||
});
|
|
||||||
sound.play();
|
|
||||||
currentSound = sound;
|
|
||||||
} catch (err) {
|
|
||||||
console.error('error playing sound: ' + err);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return skinManager;
|
|
||||||
});
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,46 +1,51 @@
|
||||||
define(['require', 'dom', 'focusManager', 'dialogHelper', 'loading', 'layoutManager', 'connectionManager', 'globalize', 'userSettings', 'emby-select', 'paper-icon-button-light', 'material-icons', 'css!./../formdialog', 'emby-button', 'flexStyles'], function (require, dom, focusManager, dialogHelper, loading, layoutManager, connectionManager, globalize, userSettings) {
|
import dialogHelper from 'dialogHelper';
|
||||||
'use strict';
|
import layoutManager from 'layoutManager';
|
||||||
|
import globalize from 'globalize';
|
||||||
|
import * as userSettings from 'userSettings';
|
||||||
|
import 'emby-select';
|
||||||
|
import 'paper-icon-button-light';
|
||||||
|
import 'material-icons';
|
||||||
|
import 'css!./../formdialog';
|
||||||
|
import 'emby-button';
|
||||||
|
import 'flexStyles';
|
||||||
|
|
||||||
function onSubmit(e) {
|
function onSubmit(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function initEditor(context, settings) {
|
function initEditor(context, settings) {
|
||||||
context.querySelector('form').addEventListener('submit', onSubmit);
|
context.querySelector('form').addEventListener('submit', onSubmit);
|
||||||
|
|
||||||
context.querySelector('.selectSortOrder').value = settings.sortOrder;
|
context.querySelector('.selectSortOrder').value = settings.sortOrder;
|
||||||
context.querySelector('.selectSortBy').value = settings.sortBy;
|
context.querySelector('.selectSortBy').value = settings.sortBy;
|
||||||
}
|
}
|
||||||
|
|
||||||
function centerFocus(elem, horiz, on) {
|
function centerFocus(elem, horiz, on) {
|
||||||
require(['scrollHelper'], function (scrollHelper) {
|
import('scrollHelper').then(({default: scrollHelper}) => {
|
||||||
var fn = on ? 'on' : 'off';
|
const fn = on ? 'on' : 'off';
|
||||||
scrollHelper.centerFocus[fn](elem, horiz);
|
scrollHelper.centerFocus[fn](elem, horiz);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function fillSortBy(context, options) {
|
function fillSortBy(context, options) {
|
||||||
var selectSortBy = context.querySelector('.selectSortBy');
|
const selectSortBy = context.querySelector('.selectSortBy');
|
||||||
|
|
||||||
selectSortBy.innerHTML = options.map(function (o) {
|
selectSortBy.innerHTML = options.map(function (o) {
|
||||||
return '<option value="' + o.value + '">' + o.name + '</option>';
|
return '<option value="' + o.value + '">' + o.name + '</option>';
|
||||||
}).join('');
|
}).join('');
|
||||||
}
|
}
|
||||||
|
|
||||||
function saveValues(context, settings, settingsKey) {
|
function saveValues(context, settingsKey) {
|
||||||
userSettings.setFilter(settingsKey + '-sortorder', context.querySelector('.selectSortOrder').value);
|
userSettings.setFilter(settingsKey + '-sortorder', context.querySelector('.selectSortOrder').value);
|
||||||
userSettings.setFilter(settingsKey + '-sortby', context.querySelector('.selectSortBy').value);
|
userSettings.setFilter(settingsKey + '-sortby', context.querySelector('.selectSortBy').value);
|
||||||
}
|
}
|
||||||
|
|
||||||
function SortMenu() {
|
class SortMenu {
|
||||||
|
show(options) {
|
||||||
}
|
|
||||||
|
|
||||||
SortMenu.prototype.show = function (options) {
|
|
||||||
return new Promise(function (resolve, reject) {
|
return new Promise(function (resolve, reject) {
|
||||||
require(['text!./sortmenu.template.html'], function (template) {
|
import('text!./sortmenu.template.html').then(({default: template}) => {
|
||||||
var dialogOptions = {
|
const dialogOptions = {
|
||||||
removeOnClose: true,
|
removeOnClose: true,
|
||||||
scrollY: false
|
scrollY: false
|
||||||
};
|
};
|
||||||
|
@ -51,11 +56,11 @@ define(['require', 'dom', 'focusManager', 'dialogHelper', 'loading', 'layoutMana
|
||||||
dialogOptions.size = 'small';
|
dialogOptions.size = 'small';
|
||||||
}
|
}
|
||||||
|
|
||||||
var dlg = dialogHelper.createDialog(dialogOptions);
|
const dlg = dialogHelper.createDialog(dialogOptions);
|
||||||
|
|
||||||
dlg.classList.add('formDialog');
|
dlg.classList.add('formDialog');
|
||||||
|
|
||||||
var html = '';
|
let html = '';
|
||||||
|
|
||||||
html += '<div class="formDialogHeader">';
|
html += '<div class="formDialogHeader">';
|
||||||
html += '<button is="paper-icon-button-light" class="btnCancel hide-mouse-idle-tv" tabindex="-1"><span class="material-icons arrow_back"></span></button>';
|
html += '<button is="paper-icon-button-light" class="btnCancel hide-mouse-idle-tv" tabindex="-1"><span class="material-icons arrow_back"></span></button>';
|
||||||
|
@ -78,7 +83,7 @@ define(['require', 'dom', 'focusManager', 'dialogHelper', 'loading', 'layoutMana
|
||||||
centerFocus(dlg.querySelector('.formDialogContent'), false, true);
|
centerFocus(dlg.querySelector('.formDialogContent'), false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
var submitted;
|
let submitted;
|
||||||
|
|
||||||
dlg.querySelector('form').addEventListener('change', function () {
|
dlg.querySelector('form').addEventListener('change', function () {
|
||||||
submitted = true;
|
submitted = true;
|
||||||
|
@ -90,7 +95,7 @@ define(['require', 'dom', 'focusManager', 'dialogHelper', 'loading', 'layoutMana
|
||||||
}
|
}
|
||||||
|
|
||||||
if (submitted) {
|
if (submitted) {
|
||||||
saveValues(dlg, options.settings, options.settingsKey);
|
saveValues(dlg, options.settingsKey);
|
||||||
resolve();
|
resolve();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -99,7 +104,7 @@ define(['require', 'dom', 'focusManager', 'dialogHelper', 'loading', 'layoutMana
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return SortMenu;
|
export default SortMenu;
|
||||||
});
|
|
||||||
|
|
|
@ -1,424 +1,437 @@
|
||||||
define(['dialogHelper', 'require', 'layoutManager', 'globalize', 'userSettings', 'connectionManager', 'loading', 'focusManager', 'dom', 'apphost', 'emby-select', 'listViewStyle', 'paper-icon-button-light', 'css!./../formdialog', 'material-icons', 'css!./subtitleeditor', 'emby-button', 'flexStyles'], function (dialogHelper, require, layoutManager, globalize, userSettings, connectionManager, loading, focusManager, dom, appHost) {
|
import dialogHelper from 'dialogHelper';
|
||||||
'use strict';
|
import layoutManager from 'layoutManager';
|
||||||
|
import globalize from 'globalize';
|
||||||
|
import * as userSettings from 'userSettings';
|
||||||
|
import connectionManager from 'connectionManager';
|
||||||
|
import loading from 'loading';
|
||||||
|
import focusManager from 'focusManager';
|
||||||
|
import dom from 'dom';
|
||||||
|
import 'emby-select';
|
||||||
|
import 'listViewStyle';
|
||||||
|
import 'paper-icon-button-light';
|
||||||
|
import 'css!./../formdialog';
|
||||||
|
import 'material-icons';
|
||||||
|
import 'css!./subtitleeditor';
|
||||||
|
import 'emby-button';
|
||||||
|
import 'flexStyles';
|
||||||
|
|
||||||
var currentItem;
|
let currentItem;
|
||||||
var hasChanges;
|
let hasChanges;
|
||||||
|
|
||||||
function downloadRemoteSubtitles(context, id) {
|
function downloadRemoteSubtitles(context, id) {
|
||||||
var url = 'Items/' + currentItem.Id + '/RemoteSearch/Subtitles/' + id;
|
let url = 'Items/' + currentItem.Id + '/RemoteSearch/Subtitles/' + id;
|
||||||
|
|
||||||
var apiClient = connectionManager.getApiClient(currentItem.ServerId);
|
let apiClient = connectionManager.getApiClient(currentItem.ServerId);
|
||||||
apiClient.ajax({
|
apiClient.ajax({
|
||||||
|
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
url: apiClient.getUrl(url)
|
url: apiClient.getUrl(url)
|
||||||
|
|
||||||
|
}).then(function () {
|
||||||
|
hasChanges = true;
|
||||||
|
|
||||||
|
import('toast').then(({default: toast}) => {
|
||||||
|
toast(globalize.translate('MessageDownloadQueued'));
|
||||||
|
});
|
||||||
|
|
||||||
|
focusManager.autoFocus(context);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function deleteLocalSubtitle(context, index) {
|
||||||
|
let msg = globalize.translate('MessageAreYouSureDeleteSubtitles');
|
||||||
|
|
||||||
|
import('confirm').then(({default: confirm}) => {
|
||||||
|
confirm({
|
||||||
|
|
||||||
|
title: globalize.translate('ConfirmDeletion'),
|
||||||
|
text: msg,
|
||||||
|
confirmText: globalize.translate('Delete'),
|
||||||
|
primary: 'delete'
|
||||||
|
|
||||||
}).then(function () {
|
}).then(function () {
|
||||||
hasChanges = true;
|
loading.show();
|
||||||
|
|
||||||
require(['toast'], function (toast) {
|
let itemId = currentItem.Id;
|
||||||
toast(globalize.translate('MessageDownloadQueued'));
|
let url = 'Videos/' + itemId + '/Subtitles/' + index;
|
||||||
});
|
|
||||||
|
|
||||||
focusManager.autoFocus(context);
|
let apiClient = connectionManager.getApiClient(currentItem.ServerId);
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function deleteLocalSubtitle(context, index) {
|
apiClient.ajax({
|
||||||
var msg = globalize.translate('MessageAreYouSureDeleteSubtitles');
|
|
||||||
|
|
||||||
require(['confirm'], function (confirm) {
|
type: 'DELETE',
|
||||||
confirm.default({
|
url: apiClient.getUrl(url)
|
||||||
|
|
||||||
title: globalize.translate('ConfirmDeletion'),
|
|
||||||
text: msg,
|
|
||||||
confirmText: globalize.translate('Delete'),
|
|
||||||
primary: 'delete'
|
|
||||||
|
|
||||||
}).then(function () {
|
}).then(function () {
|
||||||
loading.show();
|
hasChanges = true;
|
||||||
|
reload(context, apiClient, itemId);
|
||||||
var itemId = currentItem.Id;
|
|
||||||
var url = 'Videos/' + itemId + '/Subtitles/' + index;
|
|
||||||
|
|
||||||
var apiClient = connectionManager.getApiClient(currentItem.ServerId);
|
|
||||||
|
|
||||||
apiClient.ajax({
|
|
||||||
|
|
||||||
type: 'DELETE',
|
|
||||||
url: apiClient.getUrl(url)
|
|
||||||
|
|
||||||
}).then(function () {
|
|
||||||
hasChanges = true;
|
|
||||||
reload(context, apiClient, itemId);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function fillSubtitleList(context, item) {
|
function fillSubtitleList(context, item) {
|
||||||
var streams = item.MediaStreams || [];
|
let streams = item.MediaStreams || [];
|
||||||
|
|
||||||
var subs = streams.filter(function (s) {
|
let subs = streams.filter(function (s) {
|
||||||
return s.Type === 'Subtitle';
|
return s.Type === 'Subtitle';
|
||||||
});
|
});
|
||||||
|
|
||||||
var html = '';
|
let html = '';
|
||||||
|
|
||||||
if (subs.length) {
|
if (subs.length) {
|
||||||
html += '<h2>' + globalize.translate('MySubtitles') + '</h2>';
|
html += '<h2>' + globalize.translate('MySubtitles') + '</h2>';
|
||||||
|
|
||||||
html += '<div>';
|
html += '<div>';
|
||||||
|
|
||||||
html += subs.map(function (s) {
|
html += subs.map(function (s) {
|
||||||
var itemHtml = '';
|
let itemHtml = '';
|
||||||
|
|
||||||
var tagName = layoutManager.tv ? 'button' : 'div';
|
let tagName = layoutManager.tv ? 'button' : 'div';
|
||||||
var className = layoutManager.tv && s.Path ? 'listItem listItem-border btnDelete' : 'listItem listItem-border';
|
let className = layoutManager.tv && s.Path ? 'listItem listItem-border btnDelete' : 'listItem listItem-border';
|
||||||
|
|
||||||
if (layoutManager.tv) {
|
|
||||||
className += ' listItem-focusscale listItem-button';
|
|
||||||
}
|
|
||||||
|
|
||||||
className += ' listItem-noborder';
|
|
||||||
|
|
||||||
itemHtml += '<' + tagName + ' class="' + className + '" data-index="' + s.Index + '">';
|
|
||||||
|
|
||||||
itemHtml += '<span class="listItemIcon material-icons closed_caption"></span>';
|
|
||||||
|
|
||||||
itemHtml += '<div class="listItemBody two-line">';
|
|
||||||
|
|
||||||
itemHtml += '<div>';
|
|
||||||
itemHtml += s.DisplayTitle || '';
|
|
||||||
itemHtml += '</div>';
|
|
||||||
|
|
||||||
if (s.Path) {
|
|
||||||
itemHtml += '<div class="secondary listItemBodyText">' + (s.Path) + '</div>';
|
|
||||||
}
|
|
||||||
|
|
||||||
itemHtml += '</a>';
|
|
||||||
itemHtml += '</div>';
|
|
||||||
|
|
||||||
if (!layoutManager.tv) {
|
|
||||||
if (s.Path) {
|
|
||||||
itemHtml += '<button is="paper-icon-button-light" data-index="' + s.Index + '" title="' + globalize.translate('Delete') + '" class="btnDelete listItemButton"><span class="material-icons delete"></span></button>';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
itemHtml += '</' + tagName + '>';
|
|
||||||
|
|
||||||
return itemHtml;
|
|
||||||
}).join('');
|
|
||||||
|
|
||||||
html += '</div>';
|
|
||||||
}
|
|
||||||
|
|
||||||
var elem = context.querySelector('.subtitleList');
|
|
||||||
|
|
||||||
if (subs.length) {
|
|
||||||
elem.classList.remove('hide');
|
|
||||||
} else {
|
|
||||||
elem.classList.add('hide');
|
|
||||||
}
|
|
||||||
elem.innerHTML = html;
|
|
||||||
}
|
|
||||||
|
|
||||||
function fillLanguages(context, apiClient, languages) {
|
|
||||||
var selectLanguage = context.querySelector('#selectLanguage');
|
|
||||||
|
|
||||||
selectLanguage.innerHTML = languages.map(function (l) {
|
|
||||||
return '<option value="' + l.ThreeLetterISOLanguageName + '">' + l.DisplayName + '</option>';
|
|
||||||
});
|
|
||||||
|
|
||||||
var lastLanguage = userSettings.get('subtitleeditor-language');
|
|
||||||
if (lastLanguage) {
|
|
||||||
selectLanguage.value = lastLanguage;
|
|
||||||
} else {
|
|
||||||
apiClient.getCurrentUser().then(function (user) {
|
|
||||||
var lang = user.Configuration.SubtitleLanguagePreference;
|
|
||||||
|
|
||||||
if (lang) {
|
|
||||||
selectLanguage.value = lang;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function renderSearchResults(context, results) {
|
|
||||||
var lastProvider = '';
|
|
||||||
var html = '';
|
|
||||||
|
|
||||||
if (!results.length) {
|
|
||||||
context.querySelector('.noSearchResults').classList.remove('hide');
|
|
||||||
context.querySelector('.subtitleResults').innerHTML = '';
|
|
||||||
loading.hide();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
context.querySelector('.noSearchResults').classList.add('hide');
|
|
||||||
|
|
||||||
for (var i = 0, length = results.length; i < length; i++) {
|
|
||||||
var result = results[i];
|
|
||||||
|
|
||||||
var provider = result.ProviderName;
|
|
||||||
|
|
||||||
if (provider !== lastProvider) {
|
|
||||||
if (i > 0) {
|
|
||||||
html += '</div>';
|
|
||||||
}
|
|
||||||
html += '<h2>' + provider + '</h2>';
|
|
||||||
html += '<div>';
|
|
||||||
lastProvider = provider;
|
|
||||||
}
|
|
||||||
|
|
||||||
var tagName = layoutManager.tv ? 'button' : 'div';
|
|
||||||
var className = layoutManager.tv ? 'listItem listItem-border btnOptions' : 'listItem listItem-border';
|
|
||||||
if (layoutManager.tv) {
|
if (layoutManager.tv) {
|
||||||
className += ' listItem-focusscale listItem-button';
|
className += ' listItem-focusscale listItem-button';
|
||||||
}
|
}
|
||||||
|
|
||||||
html += '<' + tagName + ' class="' + className + '" data-subid="' + result.Id + '">';
|
className += ' listItem-noborder';
|
||||||
|
|
||||||
html += '<span class="listItemIcon material-icons closed_caption"></span>';
|
itemHtml += '<' + tagName + ' class="' + className + '" data-index="' + s.Index + '">';
|
||||||
|
|
||||||
var bodyClass = result.Comment || result.IsHashMatch ? 'three-line' : 'two-line';
|
itemHtml += '<span class="listItemIcon material-icons closed_caption"></span>';
|
||||||
|
|
||||||
html += '<div class="listItemBody ' + bodyClass + '">';
|
itemHtml += '<div class="listItemBody two-line">';
|
||||||
|
|
||||||
html += '<div>' + (result.Name) + '</div>';
|
itemHtml += '<div>';
|
||||||
html += '<div class="secondary listItemBodyText">';
|
itemHtml += s.DisplayTitle || '';
|
||||||
|
itemHtml += '</div>';
|
||||||
|
|
||||||
if (result.Format) {
|
if (s.Path) {
|
||||||
html += '<span style="margin-right:1em;">' + globalize.translate('FormatValue', result.Format) + '</span>';
|
itemHtml += '<div class="secondary listItemBodyText">' + (s.Path) + '</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result.DownloadCount != null) {
|
itemHtml += '</a>';
|
||||||
html += '<span>' + globalize.translate('DownloadsValue', result.DownloadCount) + '</span>';
|
itemHtml += '</div>';
|
||||||
}
|
|
||||||
html += '</div>';
|
|
||||||
|
|
||||||
if (result.Comment) {
|
|
||||||
html += '<div class="secondary listItemBodyText">' + (result.Comment) + '</div>';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (result.IsHashMatch) {
|
|
||||||
html += '<div class="secondary listItemBodyText"><div class="inline-flex align-items-center justify-content-center" style="background:#3388cc;color:#fff;padding: .3em 1em;border-radius:1000em;">' + globalize.translate('PerfectMatch') + '</div></div>';
|
|
||||||
}
|
|
||||||
|
|
||||||
html += '</div>';
|
|
||||||
|
|
||||||
if (!layoutManager.tv) {
|
if (!layoutManager.tv) {
|
||||||
html += '<button type="button" is="paper-icon-button-light" data-subid="' + result.Id + '" class="btnDownload listItemButton"><span class="material-icons file_download"></span></button>';
|
if (s.Path) {
|
||||||
|
itemHtml += '<button is="paper-icon-button-light" data-index="' + s.Index + '" title="' + globalize.translate('Delete') + '" class="btnDelete listItemButton"><span class="material-icons delete"></span></button>';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
html += '</' + tagName + '>';
|
itemHtml += '</' + tagName + '>';
|
||||||
|
|
||||||
|
return itemHtml;
|
||||||
|
}).join('');
|
||||||
|
|
||||||
|
html += '</div>';
|
||||||
|
}
|
||||||
|
|
||||||
|
let elem = context.querySelector('.subtitleList');
|
||||||
|
|
||||||
|
if (subs.length) {
|
||||||
|
elem.classList.remove('hide');
|
||||||
|
} else {
|
||||||
|
elem.classList.add('hide');
|
||||||
|
}
|
||||||
|
elem.innerHTML = html;
|
||||||
|
}
|
||||||
|
|
||||||
|
function fillLanguages(context, apiClient, languages) {
|
||||||
|
let selectLanguage = context.querySelector('#selectLanguage');
|
||||||
|
|
||||||
|
selectLanguage.innerHTML = languages.map(function (l) {
|
||||||
|
return '<option value="' + l.ThreeLetterISOLanguageName + '">' + l.DisplayName + '</option>';
|
||||||
|
});
|
||||||
|
|
||||||
|
let lastLanguage = userSettings.get('subtitleeditor-language');
|
||||||
|
if (lastLanguage) {
|
||||||
|
selectLanguage.value = lastLanguage;
|
||||||
|
} else {
|
||||||
|
apiClient.getCurrentUser().then(function (user) {
|
||||||
|
let lang = user.Configuration.SubtitleLanguagePreference;
|
||||||
|
|
||||||
|
if (lang) {
|
||||||
|
selectLanguage.value = lang;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderSearchResults(context, results) {
|
||||||
|
let lastProvider = '';
|
||||||
|
let html = '';
|
||||||
|
|
||||||
|
if (!results.length) {
|
||||||
|
context.querySelector('.noSearchResults').classList.remove('hide');
|
||||||
|
context.querySelector('.subtitleResults').innerHTML = '';
|
||||||
|
loading.hide();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
context.querySelector('.noSearchResults').classList.add('hide');
|
||||||
|
|
||||||
|
for (let i = 0, length = results.length; i < length; i++) {
|
||||||
|
let result = results[i];
|
||||||
|
|
||||||
|
let provider = result.ProviderName;
|
||||||
|
|
||||||
|
if (provider !== lastProvider) {
|
||||||
|
if (i > 0) {
|
||||||
|
html += '</div>';
|
||||||
|
}
|
||||||
|
html += '<h2>' + provider + '</h2>';
|
||||||
|
html += '<div>';
|
||||||
|
lastProvider = provider;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (results.length) {
|
let tagName = layoutManager.tv ? 'button' : 'div';
|
||||||
html += '</div>';
|
let className = layoutManager.tv ? 'listItem listItem-border btnOptions' : 'listItem listItem-border';
|
||||||
|
if (layoutManager.tv) {
|
||||||
|
className += ' listItem-focusscale listItem-button';
|
||||||
}
|
}
|
||||||
|
|
||||||
var elem = context.querySelector('.subtitleResults');
|
html += '<' + tagName + ' class="' + className + '" data-subid="' + result.Id + '">';
|
||||||
elem.innerHTML = html;
|
|
||||||
|
html += '<span class="listItemIcon material-icons closed_caption"></span>';
|
||||||
|
|
||||||
|
let bodyClass = result.Comment || result.IsHashMatch ? 'three-line' : 'two-line';
|
||||||
|
|
||||||
|
html += '<div class="listItemBody ' + bodyClass + '">';
|
||||||
|
|
||||||
|
html += '<div>' + (result.Name) + '</div>';
|
||||||
|
html += '<div class="secondary listItemBodyText">';
|
||||||
|
|
||||||
|
if (result.Format) {
|
||||||
|
html += '<span style="margin-right:1em;">' + globalize.translate('FormatValue', result.Format) + '</span>';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result.DownloadCount != null) {
|
||||||
|
html += '<span>' + globalize.translate('DownloadsValue', result.DownloadCount) + '</span>';
|
||||||
|
}
|
||||||
|
html += '</div>';
|
||||||
|
|
||||||
|
if (result.Comment) {
|
||||||
|
html += '<div class="secondary listItemBodyText">' + (result.Comment) + '</div>';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result.IsHashMatch) {
|
||||||
|
html += '<div class="secondary listItemBodyText"><div class="inline-flex align-items-center justify-content-center" style="background:#3388cc;color:#fff;padding: .3em 1em;border-radius:1000em;">' + globalize.translate('PerfectMatch') + '</div></div>';
|
||||||
|
}
|
||||||
|
|
||||||
|
html += '</div>';
|
||||||
|
|
||||||
|
if (!layoutManager.tv) {
|
||||||
|
html += '<button type="button" is="paper-icon-button-light" data-subid="' + result.Id + '" class="btnDownload listItemButton"><span class="material-icons file_download"></span></button>';
|
||||||
|
}
|
||||||
|
|
||||||
|
html += '</' + tagName + '>';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (results.length) {
|
||||||
|
html += '</div>';
|
||||||
|
}
|
||||||
|
|
||||||
|
let elem = context.querySelector('.subtitleResults');
|
||||||
|
elem.innerHTML = html;
|
||||||
|
|
||||||
|
loading.hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
function searchForSubtitles(context, language) {
|
||||||
|
userSettings.set('subtitleeditor-language', language);
|
||||||
|
|
||||||
|
loading.show();
|
||||||
|
|
||||||
|
let apiClient = connectionManager.getApiClient(currentItem.ServerId);
|
||||||
|
let url = apiClient.getUrl('Items/' + currentItem.Id + '/RemoteSearch/Subtitles/' + language);
|
||||||
|
|
||||||
|
apiClient.getJSON(url).then(function (results) {
|
||||||
|
renderSearchResults(context, results);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function reload(context, apiClient, itemId) {
|
||||||
|
context.querySelector('.noSearchResults').classList.add('hide');
|
||||||
|
|
||||||
|
function onGetItem(item) {
|
||||||
|
currentItem = item;
|
||||||
|
|
||||||
|
fillSubtitleList(context, item);
|
||||||
|
let file = item.Path || '';
|
||||||
|
let index = Math.max(file.lastIndexOf('/'), file.lastIndexOf('\\'));
|
||||||
|
if (index > -1) {
|
||||||
|
file = file.substring(index + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (file) {
|
||||||
|
context.querySelector('.pathValue').innerHTML = file;
|
||||||
|
context.querySelector('.originalFile').classList.remove('hide');
|
||||||
|
} else {
|
||||||
|
context.querySelector('.pathValue').innerHTML = '';
|
||||||
|
context.querySelector('.originalFile').classList.add('hide');
|
||||||
|
}
|
||||||
|
|
||||||
loading.hide();
|
loading.hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
function searchForSubtitles(context, language) {
|
if (typeof itemId === 'string') {
|
||||||
userSettings.set('subtitleeditor-language', language);
|
apiClient.getItem(apiClient.getCurrentUserId(), itemId).then(onGetItem);
|
||||||
|
} else {
|
||||||
|
onGetItem(itemId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
loading.show();
|
function onSearchSubmit(e) {
|
||||||
|
let form = this;
|
||||||
|
|
||||||
var apiClient = connectionManager.getApiClient(currentItem.ServerId);
|
let lang = form.querySelector('#selectLanguage', form).value;
|
||||||
var url = apiClient.getUrl('Items/' + currentItem.Id + '/RemoteSearch/Subtitles/' + language);
|
|
||||||
|
|
||||||
apiClient.getJSON(url).then(function (results) {
|
searchForSubtitles(dom.parentWithClass(form, 'formDialogContent'), lang);
|
||||||
renderSearchResults(context, results);
|
|
||||||
});
|
e.preventDefault();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function onSubtitleListClick(e) {
|
||||||
|
let btnDelete = dom.parentWithClass(e.target, 'btnDelete');
|
||||||
|
if (btnDelete) {
|
||||||
|
let index = btnDelete.getAttribute('data-index');
|
||||||
|
let context = dom.parentWithClass(btnDelete, 'subtitleEditorDialog');
|
||||||
|
deleteLocalSubtitle(context, index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function onSubtitleResultsClick(e) {
|
||||||
|
let subtitleId;
|
||||||
|
let context;
|
||||||
|
|
||||||
|
let btnOptions = dom.parentWithClass(e.target, 'btnOptions');
|
||||||
|
if (btnOptions) {
|
||||||
|
subtitleId = btnOptions.getAttribute('data-subid');
|
||||||
|
context = dom.parentWithClass(btnOptions, 'subtitleEditorDialog');
|
||||||
|
showDownloadOptions(btnOptions, context, subtitleId);
|
||||||
}
|
}
|
||||||
|
|
||||||
function reload(context, apiClient, itemId) {
|
let btnDownload = dom.parentWithClass(e.target, 'btnDownload');
|
||||||
context.querySelector('.noSearchResults').classList.add('hide');
|
if (btnDownload) {
|
||||||
|
subtitleId = btnDownload.getAttribute('data-subid');
|
||||||
|
context = dom.parentWithClass(btnDownload, 'subtitleEditorDialog');
|
||||||
|
downloadRemoteSubtitles(context, subtitleId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function onGetItem(item) {
|
function showDownloadOptions(button, context, subtitleId) {
|
||||||
currentItem = item;
|
let items = [];
|
||||||
|
|
||||||
fillSubtitleList(context, item);
|
items.push({
|
||||||
var file = item.Path || '';
|
name: globalize.translate('Download'),
|
||||||
var index = Math.max(file.lastIndexOf('/'), file.lastIndexOf('\\'));
|
id: 'download'
|
||||||
if (index > -1) {
|
});
|
||||||
file = file.substring(index + 1);
|
|
||||||
|
import('actionsheet').then(({default: actionsheet}) => {
|
||||||
|
actionsheet.show({
|
||||||
|
items: items,
|
||||||
|
positionTo: button
|
||||||
|
|
||||||
|
}).then(function (id) {
|
||||||
|
switch (id) {
|
||||||
|
case 'download':
|
||||||
|
downloadRemoteSubtitles(context, subtitleId);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (file) {
|
function centerFocus(elem, horiz, on) {
|
||||||
context.querySelector('.pathValue').innerHTML = file;
|
import('scrollHelper').then(({default: scrollHelper}) => {
|
||||||
context.querySelector('.originalFile').classList.remove('hide');
|
let fn = on ? 'on' : 'off';
|
||||||
} else {
|
scrollHelper.centerFocus[fn](elem, horiz);
|
||||||
context.querySelector('.pathValue').innerHTML = '';
|
});
|
||||||
context.querySelector('.originalFile').classList.add('hide');
|
}
|
||||||
}
|
|
||||||
|
|
||||||
loading.hide();
|
function showEditorInternal(itemId, serverId, template) {
|
||||||
}
|
hasChanges = false;
|
||||||
|
|
||||||
if (typeof itemId === 'string') {
|
let apiClient = connectionManager.getApiClient(serverId);
|
||||||
apiClient.getItem(apiClient.getCurrentUserId(), itemId).then(onGetItem);
|
return apiClient.getItem(apiClient.getCurrentUserId(), itemId).then(function (item) {
|
||||||
|
let dialogOptions = {
|
||||||
|
removeOnClose: true,
|
||||||
|
scrollY: false
|
||||||
|
};
|
||||||
|
|
||||||
|
if (layoutManager.tv) {
|
||||||
|
dialogOptions.size = 'fullscreen';
|
||||||
} else {
|
} else {
|
||||||
onGetItem(itemId);
|
dialogOptions.size = 'small';
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function onSearchSubmit(e) {
|
|
||||||
var form = this;
|
|
||||||
|
|
||||||
var lang = form.querySelector('#selectLanguage', form).value;
|
|
||||||
|
|
||||||
searchForSubtitles(dom.parentWithClass(form, 'formDialogContent'), lang);
|
|
||||||
|
|
||||||
e.preventDefault();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
function onSubtitleListClick(e) {
|
|
||||||
var btnDelete = dom.parentWithClass(e.target, 'btnDelete');
|
|
||||||
if (btnDelete) {
|
|
||||||
var index = btnDelete.getAttribute('data-index');
|
|
||||||
var context = dom.parentWithClass(btnDelete, 'subtitleEditorDialog');
|
|
||||||
deleteLocalSubtitle(context, index);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function onSubtitleResultsClick(e) {
|
|
||||||
var subtitleId;
|
|
||||||
var context;
|
|
||||||
|
|
||||||
var btnOptions = dom.parentWithClass(e.target, 'btnOptions');
|
|
||||||
if (btnOptions) {
|
|
||||||
subtitleId = btnOptions.getAttribute('data-subid');
|
|
||||||
context = dom.parentWithClass(btnOptions, 'subtitleEditorDialog');
|
|
||||||
showDownloadOptions(btnOptions, context, subtitleId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var btnDownload = dom.parentWithClass(e.target, 'btnDownload');
|
let dlg = dialogHelper.createDialog(dialogOptions);
|
||||||
if (btnDownload) {
|
|
||||||
subtitleId = btnDownload.getAttribute('data-subid');
|
dlg.classList.add('formDialog');
|
||||||
context = dom.parentWithClass(btnDownload, 'subtitleEditorDialog');
|
dlg.classList.add('subtitleEditorDialog');
|
||||||
downloadRemoteSubtitles(context, subtitleId);
|
|
||||||
|
dlg.innerHTML = globalize.translateHtml(template, 'core');
|
||||||
|
|
||||||
|
dlg.querySelector('.originalSubtitleFileLabel').innerHTML = globalize.translate('File');
|
||||||
|
|
||||||
|
dlg.querySelector('.subtitleSearchForm').addEventListener('submit', onSearchSubmit);
|
||||||
|
|
||||||
|
let btnSubmit = dlg.querySelector('.btnSubmit');
|
||||||
|
|
||||||
|
if (layoutManager.tv) {
|
||||||
|
centerFocus(dlg.querySelector('.formDialogContent'), false, true);
|
||||||
|
dlg.querySelector('.btnSearchSubtitles').classList.add('hide');
|
||||||
|
} else {
|
||||||
|
btnSubmit.classList.add('hide');
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
function showDownloadOptions(button, context, subtitleId) {
|
let editorContent = dlg.querySelector('.formDialogContent');
|
||||||
var items = [];
|
|
||||||
|
|
||||||
items.push({
|
dlg.querySelector('.subtitleList').addEventListener('click', onSubtitleListClick);
|
||||||
name: globalize.translate('Download'),
|
dlg.querySelector('.subtitleResults').addEventListener('click', onSubtitleResultsClick);
|
||||||
id: 'download'
|
|
||||||
|
apiClient.getCultures().then(function (languages) {
|
||||||
|
fillLanguages(editorContent, apiClient, languages);
|
||||||
});
|
});
|
||||||
|
|
||||||
require(['actionsheet'], function (actionsheet) {
|
dlg.querySelector('.btnCancel').addEventListener('click', function () {
|
||||||
actionsheet.show({
|
dialogHelper.close(dlg);
|
||||||
items: items,
|
|
||||||
positionTo: button
|
|
||||||
|
|
||||||
}).then(function (id) {
|
|
||||||
switch (id) {
|
|
||||||
case 'download':
|
|
||||||
downloadRemoteSubtitles(context, subtitleId);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
function centerFocus(elem, horiz, on) {
|
|
||||||
require(['scrollHelper'], function (scrollHelper) {
|
|
||||||
var fn = on ? 'on' : 'off';
|
|
||||||
scrollHelper.centerFocus[fn](elem, horiz);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function showEditorInternal(itemId, serverId, template) {
|
|
||||||
hasChanges = false;
|
|
||||||
|
|
||||||
var apiClient = connectionManager.getApiClient(serverId);
|
|
||||||
return apiClient.getItem(apiClient.getCurrentUserId(), itemId).then(function (item) {
|
|
||||||
var dialogOptions = {
|
|
||||||
removeOnClose: true,
|
|
||||||
scrollY: false
|
|
||||||
};
|
|
||||||
|
|
||||||
if (layoutManager.tv) {
|
|
||||||
dialogOptions.size = 'fullscreen';
|
|
||||||
} else {
|
|
||||||
dialogOptions.size = 'small';
|
|
||||||
}
|
|
||||||
|
|
||||||
var dlg = dialogHelper.createDialog(dialogOptions);
|
|
||||||
|
|
||||||
dlg.classList.add('formDialog');
|
|
||||||
dlg.classList.add('subtitleEditorDialog');
|
|
||||||
|
|
||||||
dlg.innerHTML = globalize.translateHtml(template, 'core');
|
|
||||||
|
|
||||||
dlg.querySelector('.originalSubtitleFileLabel').innerHTML = globalize.translate('File');
|
|
||||||
|
|
||||||
dlg.querySelector('.subtitleSearchForm').addEventListener('submit', onSearchSubmit);
|
|
||||||
|
|
||||||
var btnSubmit = dlg.querySelector('.btnSubmit');
|
|
||||||
|
|
||||||
if (layoutManager.tv) {
|
|
||||||
centerFocus(dlg.querySelector('.formDialogContent'), false, true);
|
|
||||||
dlg.querySelector('.btnSearchSubtitles').classList.add('hide');
|
|
||||||
} else {
|
|
||||||
btnSubmit.classList.add('hide');
|
|
||||||
}
|
|
||||||
|
|
||||||
var editorContent = dlg.querySelector('.formDialogContent');
|
|
||||||
|
|
||||||
dlg.querySelector('.subtitleList').addEventListener('click', onSubtitleListClick);
|
|
||||||
dlg.querySelector('.subtitleResults').addEventListener('click', onSubtitleResultsClick);
|
|
||||||
|
|
||||||
apiClient.getCultures().then(function (languages) {
|
|
||||||
fillLanguages(editorContent, apiClient, languages);
|
|
||||||
});
|
|
||||||
|
|
||||||
dlg.querySelector('.btnCancel').addEventListener('click', function () {
|
|
||||||
dialogHelper.close(dlg);
|
|
||||||
});
|
|
||||||
|
|
||||||
return new Promise(function (resolve, reject) {
|
|
||||||
dlg.addEventListener('close', function () {
|
|
||||||
if (layoutManager.tv) {
|
|
||||||
centerFocus(dlg.querySelector('.formDialogContent'), false, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hasChanges) {
|
|
||||||
resolve();
|
|
||||||
} else {
|
|
||||||
reject();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
dialogHelper.open(dlg);
|
|
||||||
|
|
||||||
reload(editorContent, apiClient, item);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function showEditor(itemId, serverId) {
|
|
||||||
loading.show();
|
|
||||||
|
|
||||||
return new Promise(function (resolve, reject) {
|
return new Promise(function (resolve, reject) {
|
||||||
require(['text!./subtitleeditor.template.html'], function (template) {
|
dlg.addEventListener('close', function () {
|
||||||
showEditorInternal(itemId, serverId, template).then(resolve, reject);
|
if (layoutManager.tv) {
|
||||||
});
|
centerFocus(dlg.querySelector('.formDialogContent'), false, false);
|
||||||
});
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
if (hasChanges) {
|
||||||
show: showEditor
|
resolve();
|
||||||
};
|
} else {
|
||||||
});
|
reject();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
dialogHelper.open(dlg);
|
||||||
|
|
||||||
|
reload(editorContent, apiClient, item);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function showEditor(itemId, serverId) {
|
||||||
|
loading.show();
|
||||||
|
|
||||||
|
return new Promise(function (resolve, reject) {
|
||||||
|
import('text!./subtitleeditor.template.html').then(({default: template}) => {
|
||||||
|
showEditorInternal(itemId, serverId, template).then(resolve, reject);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export default {
|
||||||
|
show: showEditor
|
||||||
|
};
|
||||||
|
|
|
@ -3,52 +3,29 @@
|
||||||
* @module components/subtitleSettings/subtitleAppearanceHelper
|
* @module components/subtitleSettings/subtitleAppearanceHelper
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function getTextStyles(settings, isCue) {
|
function getTextStyles(settings, preview) {
|
||||||
let list = [];
|
let list = [];
|
||||||
|
|
||||||
if (isCue) {
|
switch (settings.textSize || '') {
|
||||||
switch (settings.textSize || '') {
|
case 'smaller':
|
||||||
case 'smaller':
|
list.push({ name: 'font-size', value: '.8em' });
|
||||||
list.push({ name: 'font-size', value: '.5em' });
|
break;
|
||||||
break;
|
case 'small':
|
||||||
case 'small':
|
list.push({ name: 'font-size', value: 'inherit' });
|
||||||
list.push({ name: 'font-size', value: '.7em' });
|
break;
|
||||||
break;
|
case 'larger':
|
||||||
case 'large':
|
list.push({ name: 'font-size', value: '2em' });
|
||||||
list.push({ name: 'font-size', value: '1.3em' });
|
break;
|
||||||
break;
|
case 'extralarge':
|
||||||
case 'larger':
|
list.push({ name: 'font-size', value: '2.2em' });
|
||||||
list.push({ name: 'font-size', value: '1.72em' });
|
break;
|
||||||
break;
|
case 'large':
|
||||||
case 'extralarge':
|
list.push({ name: 'font-size', value: '1.72em' });
|
||||||
list.push({ name: 'font-size', value: '2em' });
|
break;
|
||||||
break;
|
default:
|
||||||
default:
|
case 'medium':
|
||||||
case 'medium':
|
list.push({ name: 'font-size', value: '1.36em' });
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
} else {
|
|
||||||
switch (settings.textSize || '') {
|
|
||||||
case 'smaller':
|
|
||||||
list.push({ name: 'font-size', value: '.8em' });
|
|
||||||
break;
|
|
||||||
case 'small':
|
|
||||||
list.push({ name: 'font-size', value: 'inherit' });
|
|
||||||
break;
|
|
||||||
case 'larger':
|
|
||||||
list.push({ name: 'font-size', value: '2em' });
|
|
||||||
break;
|
|
||||||
case 'extralarge':
|
|
||||||
list.push({ name: 'font-size', value: '2.2em' });
|
|
||||||
break;
|
|
||||||
case 'large':
|
|
||||||
list.push({ name: 'font-size', value: '1.72em' });
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
case 'medium':
|
|
||||||
list.push({ name: 'font-size', value: '1.36em' });
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (settings.dropShadow || '') {
|
switch (settings.dropShadow || '') {
|
||||||
|
@ -111,13 +88,43 @@ function getTextStyles(settings, isCue) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!preview) {
|
||||||
|
const pos = parseInt(settings.verticalPosition, 10);
|
||||||
|
const lineHeight = 1.35; // FIXME: It is better to read this value from element
|
||||||
|
const line = Math.abs(pos * lineHeight);
|
||||||
|
if (pos < 0) {
|
||||||
|
list.push({ name: 'min-height', value: `${line}em` });
|
||||||
|
list.push({ name: 'margin-top', value: '' });
|
||||||
|
} else {
|
||||||
|
list.push({ name: 'min-height', value: '' });
|
||||||
|
list.push({ name: 'margin-top', value: `${line}em` });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getStyles(settings, isCue) {
|
function getWindowStyles(settings, preview) {
|
||||||
|
const list = [];
|
||||||
|
|
||||||
|
if (!preview) {
|
||||||
|
const pos = parseInt(settings.verticalPosition, 10);
|
||||||
|
if (pos < 0) {
|
||||||
|
list.push({ name: 'top', value: '' });
|
||||||
|
list.push({ name: 'bottom', value: '0' });
|
||||||
|
} else {
|
||||||
|
list.push({ name: 'top', value: '0' });
|
||||||
|
list.push({ name: 'bottom', value: '' });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getStyles(settings, preview) {
|
||||||
return {
|
return {
|
||||||
text: getTextStyles(settings, isCue),
|
text: getTextStyles(settings, preview),
|
||||||
window: []
|
window: getWindowStyles(settings, preview)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,7 +137,7 @@ function applyStyleList(styles, elem) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function applyStyles(elements, appearanceSettings) {
|
export function applyStyles(elements, appearanceSettings) {
|
||||||
let styles = getStyles(appearanceSettings);
|
let styles = getStyles(appearanceSettings, !!elements.preview);
|
||||||
|
|
||||||
if (elements.text) {
|
if (elements.text) {
|
||||||
applyStyleList(styles.text, elements.text);
|
applyStyleList(styles.text, elements.text);
|
||||||
|
|
26
src/components/subtitlesettings/subtitlesettings.css
Normal file
26
src/components/subtitlesettings/subtitlesettings.css
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
.subtitleappearance-fullpreview {
|
||||||
|
position: fixed;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
z-index: 1000;
|
||||||
|
pointer-events: none;
|
||||||
|
transition: 0.2s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.subtitleappearance-fullpreview-hide {
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.subtitleappearance-fullpreview-window {
|
||||||
|
position: absolute;
|
||||||
|
width: 100%;
|
||||||
|
font-size: 170%;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.subtitleappearance-fullpreview-text {
|
||||||
|
display: inline-block;
|
||||||
|
max-width: 70%;
|
||||||
|
}
|
|
@ -2,6 +2,7 @@ import globalize from 'globalize';
|
||||||
import appHost from 'apphost';
|
import appHost from 'apphost';
|
||||||
import appSettings from 'appSettings';
|
import appSettings from 'appSettings';
|
||||||
import focusManager from 'focusManager';
|
import focusManager from 'focusManager';
|
||||||
|
import layoutManager from 'layoutManager';
|
||||||
import loading from 'loading';
|
import loading from 'loading';
|
||||||
import connectionManager from 'connectionManager';
|
import connectionManager from 'connectionManager';
|
||||||
import subtitleAppearanceHelper from 'subtitleAppearanceHelper';
|
import subtitleAppearanceHelper from 'subtitleAppearanceHelper';
|
||||||
|
@ -10,9 +11,11 @@ import dom from 'dom';
|
||||||
import events from 'events';
|
import events from 'events';
|
||||||
import 'listViewStyle';
|
import 'listViewStyle';
|
||||||
import 'emby-select';
|
import 'emby-select';
|
||||||
|
import 'emby-slider';
|
||||||
import 'emby-input';
|
import 'emby-input';
|
||||||
import 'emby-checkbox';
|
import 'emby-checkbox';
|
||||||
import 'flexStyles';
|
import 'flexStyles';
|
||||||
|
import 'css!./subtitlesettings';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Subtitle settings.
|
* Subtitle settings.
|
||||||
|
@ -27,6 +30,7 @@ function getSubtitleAppearanceObject(context) {
|
||||||
appearanceSettings.font = context.querySelector('#selectFont').value;
|
appearanceSettings.font = context.querySelector('#selectFont').value;
|
||||||
appearanceSettings.textBackground = context.querySelector('#inputTextBackground').value;
|
appearanceSettings.textBackground = context.querySelector('#inputTextBackground').value;
|
||||||
appearanceSettings.textColor = context.querySelector('#inputTextColor').value;
|
appearanceSettings.textColor = context.querySelector('#inputTextColor').value;
|
||||||
|
appearanceSettings.verticalPosition = context.querySelector('#sliderVerticalPosition').value;
|
||||||
|
|
||||||
return appearanceSettings;
|
return appearanceSettings;
|
||||||
}
|
}
|
||||||
|
@ -51,6 +55,7 @@ function loadForm(context, user, userSettings, appearanceSettings, apiClient) {
|
||||||
context.querySelector('#inputTextBackground').value = appearanceSettings.textBackground || 'transparent';
|
context.querySelector('#inputTextBackground').value = appearanceSettings.textBackground || 'transparent';
|
||||||
context.querySelector('#inputTextColor').value = appearanceSettings.textColor || '#ffffff';
|
context.querySelector('#inputTextColor').value = appearanceSettings.textColor || '#ffffff';
|
||||||
context.querySelector('#selectFont').value = appearanceSettings.font || '';
|
context.querySelector('#selectFont').value = appearanceSettings.font || '';
|
||||||
|
context.querySelector('#sliderVerticalPosition').value = appearanceSettings.verticalPosition;
|
||||||
|
|
||||||
context.querySelector('#selectSubtitleBurnIn').value = appSettings.get('subtitleburnin') || '';
|
context.querySelector('#selectSubtitleBurnIn').value = appSettings.get('subtitleburnin') || '';
|
||||||
|
|
||||||
|
@ -112,10 +117,45 @@ function onAppearanceFieldChange(e) {
|
||||||
|
|
||||||
let elements = {
|
let elements = {
|
||||||
window: view.querySelector('.subtitleappearance-preview-window'),
|
window: view.querySelector('.subtitleappearance-preview-window'),
|
||||||
text: view.querySelector('.subtitleappearance-preview-text')
|
text: view.querySelector('.subtitleappearance-preview-text'),
|
||||||
|
preview: true
|
||||||
};
|
};
|
||||||
|
|
||||||
subtitleAppearanceHelper.applyStyles(elements, appearanceSettings);
|
subtitleAppearanceHelper.applyStyles(elements, appearanceSettings);
|
||||||
|
|
||||||
|
subtitleAppearanceHelper.applyStyles({
|
||||||
|
window: view.querySelector('.subtitleappearance-fullpreview-window'),
|
||||||
|
text: view.querySelector('.subtitleappearance-fullpreview-text')
|
||||||
|
}, appearanceSettings);
|
||||||
|
}
|
||||||
|
|
||||||
|
const subtitlePreviewDelay = 1000;
|
||||||
|
let subtitlePreviewTimer;
|
||||||
|
|
||||||
|
function showSubtitlePreview(persistent) {
|
||||||
|
clearTimeout(subtitlePreviewTimer);
|
||||||
|
|
||||||
|
this._fullPreview.classList.remove('subtitleappearance-fullpreview-hide');
|
||||||
|
|
||||||
|
if (persistent) {
|
||||||
|
this._refFullPreview++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this._refFullPreview === 0) {
|
||||||
|
subtitlePreviewTimer = setTimeout(hideSubtitlePreview.bind(this), subtitlePreviewDelay);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function hideSubtitlePreview(persistent) {
|
||||||
|
clearTimeout(subtitlePreviewTimer);
|
||||||
|
|
||||||
|
if (persistent) {
|
||||||
|
this._refFullPreview--;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this._refFullPreview === 0) {
|
||||||
|
this._fullPreview.classList.add('subtitleappearance-fullpreview-hide');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function embed(options, self) {
|
function embed(options, self) {
|
||||||
|
@ -138,6 +178,36 @@ function embed(options, self) {
|
||||||
|
|
||||||
if (appHost.supports('subtitleappearancesettings')) {
|
if (appHost.supports('subtitleappearancesettings')) {
|
||||||
options.element.querySelector('.subtitleAppearanceSection').classList.remove('hide');
|
options.element.querySelector('.subtitleAppearanceSection').classList.remove('hide');
|
||||||
|
|
||||||
|
self._fullPreview = options.element.querySelector('.subtitleappearance-fullpreview');
|
||||||
|
self._refFullPreview = 0;
|
||||||
|
|
||||||
|
const sliderVerticalPosition = options.element.querySelector('#sliderVerticalPosition');
|
||||||
|
sliderVerticalPosition.addEventListener('input', onAppearanceFieldChange);
|
||||||
|
sliderVerticalPosition.addEventListener('input', () => showSubtitlePreview.call(self));
|
||||||
|
|
||||||
|
const eventPrefix = window.PointerEvent ? 'pointer' : 'mouse';
|
||||||
|
sliderVerticalPosition.addEventListener(`${eventPrefix}enter`, () => showSubtitlePreview.call(self, true));
|
||||||
|
sliderVerticalPosition.addEventListener(`${eventPrefix}leave`, () => hideSubtitlePreview.call(self, true));
|
||||||
|
|
||||||
|
if (layoutManager.tv) {
|
||||||
|
sliderVerticalPosition.addEventListener('focus', () => showSubtitlePreview.call(self, true));
|
||||||
|
sliderVerticalPosition.addEventListener('blur', () => hideSubtitlePreview.call(self, true));
|
||||||
|
|
||||||
|
// Give CustomElements time to attach
|
||||||
|
setTimeout(() => {
|
||||||
|
sliderVerticalPosition.classList.add('focusable');
|
||||||
|
sliderVerticalPosition.enableKeyboardDragging();
|
||||||
|
}, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
options.element.querySelector('.chkPreview').addEventListener('change', (e) => {
|
||||||
|
if (e.target.checked) {
|
||||||
|
showSubtitlePreview.call(self, true);
|
||||||
|
} else {
|
||||||
|
hideSubtitlePreview.call(self, true);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
self.loadData();
|
self.loadData();
|
||||||
|
|
|
@ -38,6 +38,16 @@
|
||||||
${HeaderSubtitleAppearance}
|
${HeaderSubtitleAppearance}
|
||||||
</h2>
|
</h2>
|
||||||
|
|
||||||
|
<div class="subtitleappearance-fullpreview subtitleappearance-fullpreview-hide">
|
||||||
|
<div class="subtitleappearance-fullpreview-window">
|
||||||
|
<div class="subtitleappearance-fullpreview-text">
|
||||||
|
${HeaderSubtitleAppearance}
|
||||||
|
<br>
|
||||||
|
${TheseSettingsAffectSubtitlesOnThisDevice}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div style="margin: 2em 0 2em;">
|
<div style="margin: 2em 0 2em;">
|
||||||
<div class="subtitleappearance-preview flex align-items-center justify-content-center" style="margin:2em 0;padding:1.6em;color:black;background:linear-gradient(140deg,#aa5cc3,#00a4dc);">
|
<div class="subtitleappearance-preview flex align-items-center justify-content-center" style="margin:2em 0;padding:1.6em;color:black;background:linear-gradient(140deg,#aa5cc3,#00a4dc);">
|
||||||
<div class="subtitleappearance-preview-window flex align-items-center justify-content-center" style="width: 90%; padding: .25em;">
|
<div class="subtitleappearance-preview-window flex align-items-center justify-content-center" style="width: 90%; padding: .25em;">
|
||||||
|
@ -89,6 +99,20 @@
|
||||||
<option value="">${DropShadow}</option>
|
<option value="">${DropShadow}</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="sliderContainer-settings">
|
||||||
|
<div class="sliderContainer">
|
||||||
|
<input is="emby-slider" id="sliderVerticalPosition" label="${LabelSubtitleVerticalPosition}" type="range" min="-16" max="16" />
|
||||||
|
</div>
|
||||||
|
<div class="fieldDescription">${SubtitleVerticalPositionHelp}</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="checkboxContainer">
|
||||||
|
<label>
|
||||||
|
<input is="emby-checkbox" type="checkbox" class="chkPreview" />
|
||||||
|
<span>${Preview}</span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button is="emby-button" type="submit" class="raised button-submit block btnSave hide">
|
<button is="emby-button" type="submit" class="raised button-submit block btnSave hide">
|
||||||
|
|
|
@ -1,145 +1,148 @@
|
||||||
define(['playbackManager', 'layoutManager', 'text!./subtitlesync.template.html', 'css!./subtitlesync'], function (playbackManager, layoutManager, template, css) {
|
import playbackManager from 'playbackManager';
|
||||||
'use strict';
|
import layoutManager from 'layoutManager';
|
||||||
|
import template from 'text!./subtitlesync.template.html';
|
||||||
|
import 'css!./subtitlesync';
|
||||||
|
|
||||||
var player;
|
let player;
|
||||||
var subtitleSyncSlider;
|
let subtitleSyncSlider;
|
||||||
var subtitleSyncTextField;
|
let subtitleSyncTextField;
|
||||||
var subtitleSyncCloseButton;
|
let subtitleSyncCloseButton;
|
||||||
var subtitleSyncContainer;
|
let subtitleSyncContainer;
|
||||||
|
|
||||||
function init(instance) {
|
function init(instance) {
|
||||||
var parent = document.createElement('div');
|
const parent = document.createElement('div');
|
||||||
document.body.appendChild(parent);
|
document.body.appendChild(parent);
|
||||||
parent.innerHTML = template;
|
parent.innerHTML = template;
|
||||||
|
|
||||||
subtitleSyncSlider = parent.querySelector('.subtitleSyncSlider');
|
subtitleSyncSlider = parent.querySelector('.subtitleSyncSlider');
|
||||||
subtitleSyncTextField = parent.querySelector('.subtitleSyncTextField');
|
subtitleSyncTextField = parent.querySelector('.subtitleSyncTextField');
|
||||||
subtitleSyncCloseButton = parent.querySelector('.subtitleSync-closeButton');
|
subtitleSyncCloseButton = parent.querySelector('.subtitleSync-closeButton');
|
||||||
subtitleSyncContainer = parent.querySelector('.subtitleSyncContainer');
|
subtitleSyncContainer = parent.querySelector('.subtitleSyncContainer');
|
||||||
|
|
||||||
if (layoutManager.tv) {
|
if (layoutManager.tv) {
|
||||||
subtitleSyncSlider.classList.add('focusable');
|
subtitleSyncSlider.classList.add('focusable');
|
||||||
// HACK: Delay to give time for registered element attach (Firefox)
|
// HACK: Delay to give time for registered element attach (Firefox)
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
subtitleSyncSlider.enableKeyboardDragging();
|
subtitleSyncSlider.enableKeyboardDragging();
|
||||||
}, 0);
|
}, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
subtitleSyncContainer.classList.add('hide');
|
subtitleSyncContainer.classList.add('hide');
|
||||||
|
|
||||||
subtitleSyncTextField.updateOffset = function(offset) {
|
subtitleSyncTextField.updateOffset = function (offset) {
|
||||||
this.textContent = offset + 's';
|
this.textContent = offset + 's';
|
||||||
};
|
};
|
||||||
|
|
||||||
subtitleSyncTextField.addEventListener('click', function () {
|
subtitleSyncTextField.addEventListener('click', function () {
|
||||||
|
// keep focus to prevent fade with osd
|
||||||
|
this.hasFocus = true;
|
||||||
|
});
|
||||||
|
|
||||||
|
subtitleSyncTextField.addEventListener('keydown', function (event) {
|
||||||
|
if (event.key === 'Enter') {
|
||||||
|
// if input key is enter search for float pattern
|
||||||
|
let inputOffset = /[-+]?\d+\.?\d*/g.exec(this.textContent);
|
||||||
|
if (inputOffset) {
|
||||||
|
inputOffset = inputOffset[0];
|
||||||
|
|
||||||
|
// replace current text by considered offset
|
||||||
|
this.textContent = inputOffset + 's';
|
||||||
|
|
||||||
|
inputOffset = parseFloat(inputOffset);
|
||||||
|
// set new offset
|
||||||
|
playbackManager.setSubtitleOffset(inputOffset, player);
|
||||||
|
// synchronize with slider value
|
||||||
|
subtitleSyncSlider.updateOffset(
|
||||||
|
getPercentageFromOffset(inputOffset));
|
||||||
|
} else {
|
||||||
|
this.textContent = (playbackManager.getPlayerSubtitleOffset(player) || 0) + 's';
|
||||||
|
}
|
||||||
|
this.hasFocus = false;
|
||||||
|
event.preventDefault();
|
||||||
|
} else {
|
||||||
// keep focus to prevent fade with osd
|
// keep focus to prevent fade with osd
|
||||||
this.hasFocus = true;
|
this.hasFocus = true;
|
||||||
});
|
if (event.key.match(/[+-\d.s]/) === null) {
|
||||||
|
|
||||||
subtitleSyncTextField.addEventListener('keydown', function(event) {
|
|
||||||
if (event.key === 'Enter') {
|
|
||||||
// if input key is enter search for float pattern
|
|
||||||
var inputOffset = /[-+]?\d+\.?\d*/g.exec(this.textContent);
|
|
||||||
if (inputOffset) {
|
|
||||||
inputOffset = inputOffset[0];
|
|
||||||
|
|
||||||
// replace current text by considered offset
|
|
||||||
this.textContent = inputOffset + 's';
|
|
||||||
|
|
||||||
inputOffset = parseFloat(inputOffset);
|
|
||||||
// set new offset
|
|
||||||
playbackManager.setSubtitleOffset(inputOffset, player);
|
|
||||||
// synchronize with slider value
|
|
||||||
subtitleSyncSlider.updateOffset(
|
|
||||||
getPercentageFromOffset(inputOffset));
|
|
||||||
} else {
|
|
||||||
this.textContent = (playbackManager.getPlayerSubtitleOffset(player) || 0) + 's';
|
|
||||||
}
|
|
||||||
this.hasFocus = false;
|
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
} else {
|
|
||||||
// keep focus to prevent fade with osd
|
|
||||||
this.hasFocus = true;
|
|
||||||
if (event.key.match(/[+-\d.s]/) === null) {
|
|
||||||
event.preventDefault();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// FIXME: TV layout will require special handling for navigation keys. But now field is not focusable
|
// FIXME: TV layout will require special handling for navigation keys. But now field is not focusable
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
});
|
});
|
||||||
|
|
||||||
subtitleSyncTextField.blur = function() {
|
subtitleSyncTextField.blur = function () {
|
||||||
// prevent textfield to blur while element has focus
|
// prevent textfield to blur while element has focus
|
||||||
if (!this.hasFocus && this.prototype) {
|
if (!this.hasFocus && this.prototype) {
|
||||||
this.prototype.blur();
|
this.prototype.blur();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
subtitleSyncSlider.updateOffset = function(percent) {
|
subtitleSyncSlider.updateOffset = function (percent) {
|
||||||
// default value is 0s = 50%
|
// default value is 0s = 50%
|
||||||
this.value = percent === undefined ? 50 : percent;
|
this.value = percent === undefined ? 50 : percent;
|
||||||
};
|
};
|
||||||
|
|
||||||
subtitleSyncSlider.addEventListener('change', function () {
|
subtitleSyncSlider.addEventListener('change', function () {
|
||||||
// set new offset
|
// set new offset
|
||||||
playbackManager.setSubtitleOffset(getOffsetFromPercentage(this.value), player);
|
playbackManager.setSubtitleOffset(getOffsetFromPercentage(this.value), player);
|
||||||
// synchronize with textField value
|
// synchronize with textField value
|
||||||
subtitleSyncTextField.updateOffset(
|
subtitleSyncTextField.updateOffset(
|
||||||
getOffsetFromPercentage(this.value));
|
getOffsetFromPercentage(this.value));
|
||||||
});
|
});
|
||||||
|
|
||||||
subtitleSyncSlider.getBubbleHtml = function (value) {
|
subtitleSyncSlider.getBubbleHtml = function (value) {
|
||||||
var newOffset = getOffsetFromPercentage(value);
|
const newOffset = getOffsetFromPercentage(value);
|
||||||
return '<h1 class="sliderBubbleText">' +
|
return '<h1 class="sliderBubbleText">' +
|
||||||
(newOffset > 0 ? '+' : '') + parseFloat(newOffset) + 's' +
|
(newOffset > 0 ? '+' : '') + parseFloat(newOffset) + 's' +
|
||||||
'</h1>';
|
'</h1>';
|
||||||
};
|
};
|
||||||
|
|
||||||
subtitleSyncCloseButton.addEventListener('click', function() {
|
subtitleSyncCloseButton.addEventListener('click', function () {
|
||||||
playbackManager.disableShowingSubtitleOffset(player);
|
playbackManager.disableShowingSubtitleOffset(player);
|
||||||
SubtitleSync.prototype.toggle('forceToHide');
|
SubtitleSync.prototype.toggle('forceToHide');
|
||||||
});
|
});
|
||||||
|
|
||||||
instance.element = parent;
|
instance.element = parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getOffsetFromPercentage(value) {
|
function getOffsetFromPercentage(value) {
|
||||||
// convert percent to fraction
|
// convert percent to fraction
|
||||||
var offset = (value - 50) / 50;
|
let offset = (value - 50) / 50;
|
||||||
// multiply by offset min/max range value (-x to +x) :
|
// multiply by offset min/max range value (-x to +x) :
|
||||||
offset *= 30;
|
offset *= 30;
|
||||||
return offset.toFixed(1);
|
return offset.toFixed(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getPercentageFromOffset(value) {
|
function getPercentageFromOffset(value) {
|
||||||
// divide by offset min/max range value (-x to +x) :
|
// divide by offset min/max range value (-x to +x) :
|
||||||
var percentValue = value / 30;
|
let percentValue = value / 30;
|
||||||
// convert fraction to percent
|
// convert fraction to percent
|
||||||
percentValue *= 50;
|
percentValue *= 50;
|
||||||
percentValue += 50;
|
percentValue += 50;
|
||||||
return Math.min(100, Math.max(0, percentValue.toFixed()));
|
return Math.min(100, Math.max(0, percentValue.toFixed()));
|
||||||
}
|
}
|
||||||
|
|
||||||
function SubtitleSync(currentPlayer) {
|
class SubtitleSync {
|
||||||
|
constructor(currentPlayer) {
|
||||||
player = currentPlayer;
|
player = currentPlayer;
|
||||||
init(this);
|
init(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
SubtitleSync.prototype.destroy = function() {
|
destroy() {
|
||||||
SubtitleSync.prototype.toggle('forceToHide');
|
SubtitleSync.prototype.toggle('forceToHide');
|
||||||
if (player) {
|
if (player) {
|
||||||
playbackManager.disableShowingSubtitleOffset(player);
|
playbackManager.disableShowingSubtitleOffset(player);
|
||||||
playbackManager.setSubtitleOffset(0, player);
|
playbackManager.setSubtitleOffset(0, player);
|
||||||
}
|
}
|
||||||
var elem = this.element;
|
const elem = this.element;
|
||||||
if (elem) {
|
if (elem) {
|
||||||
elem.parentNode.removeChild(elem);
|
elem.parentNode.removeChild(elem);
|
||||||
this.element = null;
|
this.element = null;
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
SubtitleSync.prototype.toggle = function(action) {
|
toggle(action) {
|
||||||
if (player && playbackManager.supportSubtitleOffset(player)) {
|
if (player && playbackManager.supportSubtitleOffset(player)) {
|
||||||
/* eslint-disable no-fallthrough */
|
/* eslint-disable no-fallthrough */
|
||||||
switch (action) {
|
switch (action) {
|
||||||
|
@ -168,7 +171,7 @@ define(['playbackManager', 'layoutManager', 'text!./subtitlesync.template.html',
|
||||||
}
|
}
|
||||||
/* eslint-enable no-fallthrough */
|
/* eslint-enable no-fallthrough */
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return SubtitleSync;
|
export default SubtitleSync;
|
||||||
});
|
|
||||||
|
|
|
@ -1,30 +1,33 @@
|
||||||
define(['backdrop', 'mainTabsManager', 'layoutManager', 'emby-tabs'], function (backdrop, mainTabsManager, layoutManager) {
|
import backdrop from 'backdrop';
|
||||||
'use strict';
|
import * as mainTabsManager from 'mainTabsManager';
|
||||||
|
import layoutManager from 'layoutManager';
|
||||||
|
import 'emby-tabs';
|
||||||
|
|
||||||
function onViewDestroy(e) {
|
function onViewDestroy(e) {
|
||||||
var tabControllers = this.tabControllers;
|
var tabControllers = this.tabControllers;
|
||||||
|
|
||||||
if (tabControllers) {
|
if (tabControllers) {
|
||||||
tabControllers.forEach(function (t) {
|
tabControllers.forEach(function (t) {
|
||||||
if (t.destroy) {
|
if (t.destroy) {
|
||||||
t.destroy();
|
t.destroy();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.tabControllers = null;
|
this.tabControllers = null;
|
||||||
}
|
|
||||||
|
|
||||||
this.view = null;
|
|
||||||
this.params = null;
|
|
||||||
this.currentTabController = null;
|
|
||||||
this.initialTabIndex = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function onBeforeTabChange() {
|
this.view = null;
|
||||||
|
this.params = null;
|
||||||
|
this.currentTabController = null;
|
||||||
|
this.initialTabIndex = null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
function onBeforeTabChange() {
|
||||||
|
|
||||||
function TabbedView(view, params) {
|
}
|
||||||
|
|
||||||
|
class TabbedView {
|
||||||
|
constructor(view, params) {
|
||||||
this.tabControllers = [];
|
this.tabControllers = [];
|
||||||
this.view = view;
|
this.view = view;
|
||||||
this.params = params;
|
this.params = params;
|
||||||
|
@ -85,7 +88,7 @@ define(['backdrop', 'mainTabsManager', 'layoutManager', 'emby-tabs'], function (
|
||||||
view.addEventListener('viewdestroy', onViewDestroy.bind(this));
|
view.addEventListener('viewdestroy', onViewDestroy.bind(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
TabbedView.prototype.onResume = function (options) {
|
onResume(options) {
|
||||||
this.setTitle();
|
this.setTitle();
|
||||||
backdrop.clearBackdrop();
|
backdrop.clearBackdrop();
|
||||||
|
|
||||||
|
@ -96,19 +99,18 @@ define(['backdrop', 'mainTabsManager', 'layoutManager', 'emby-tabs'], function (
|
||||||
} else if (currentTabController && currentTabController.onResume) {
|
} else if (currentTabController && currentTabController.onResume) {
|
||||||
currentTabController.onResume({});
|
currentTabController.onResume({});
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
TabbedView.prototype.onPause = function () {
|
onPause() {
|
||||||
var currentTabController = this.currentTabController;
|
var currentTabController = this.currentTabController;
|
||||||
|
|
||||||
if (currentTabController && currentTabController.onPause) {
|
if (currentTabController && currentTabController.onPause) {
|
||||||
currentTabController.onPause();
|
currentTabController.onPause();
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
setTitle() {
|
||||||
TabbedView.prototype.setTitle = function () {
|
|
||||||
Emby.Page.setTitle('');
|
Emby.Page.setTitle('');
|
||||||
};
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return TabbedView;
|
export default TabbedView;
|
||||||
});
|
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
define(['playbackManager', 'userSettings', 'connectionManager'], function (playbackManager, userSettings, connectionManager) {
|
define(['playbackManager', 'userSettings', 'connectionManager'], function (playbackManager, userSettings, connectionManager) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
playbackManager = playbackManager.default || playbackManager;
|
||||||
|
|
||||||
var currentOwnerId;
|
var currentOwnerId;
|
||||||
var currentThemeIds = [];
|
var currentThemeIds = [];
|
||||||
|
|
||||||
|
|
|
@ -1,36 +1,34 @@
|
||||||
define(['css!./toast'], function () {
|
import 'css!./toast';
|
||||||
'use strict';
|
|
||||||
|
|
||||||
function remove(elem) {
|
function remove(elem) {
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
elem.parentNode.removeChild(elem);
|
elem.parentNode.removeChild(elem);
|
||||||
}, 300);
|
}, 300);
|
||||||
|
}
|
||||||
|
|
||||||
|
function animateRemove(elem) {
|
||||||
|
setTimeout(function () {
|
||||||
|
elem.classList.remove('toastVisible');
|
||||||
|
remove(elem);
|
||||||
|
}, 3300);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function (options) {
|
||||||
|
if (typeof options === 'string') {
|
||||||
|
options = {
|
||||||
|
text: options
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function animateRemove(elem) {
|
const elem = document.createElement('div');
|
||||||
setTimeout(function () {
|
elem.classList.add('toast');
|
||||||
elem.classList.remove('toastVisible');
|
elem.innerHTML = options.text;
|
||||||
remove(elem);
|
|
||||||
}, 3300);
|
|
||||||
}
|
|
||||||
|
|
||||||
return function (options) {
|
document.body.appendChild(elem);
|
||||||
if (typeof options === 'string') {
|
|
||||||
options = {
|
|
||||||
text: options
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
var elem = document.createElement('div');
|
setTimeout(function () {
|
||||||
elem.classList.add('toast');
|
elem.classList.add('toastVisible');
|
||||||
elem.innerHTML = options.text;
|
|
||||||
|
|
||||||
document.body.appendChild(elem);
|
animateRemove(elem);
|
||||||
|
}, 300);
|
||||||
setTimeout(function () {
|
}
|
||||||
elem.classList.add('toastVisible');
|
|
||||||
|
|
||||||
animateRemove(elem);
|
|
||||||
}, 300);
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
|
@ -1,6 +1,12 @@
|
||||||
define(['dialogHelper', 'dom', 'layoutManager', 'connectionManager', 'globalize', 'loading', 'browser', 'focusManager', 'scrollHelper', 'material-icons', 'formDialogStyle', 'emby-button', 'emby-itemscontainer', 'cardStyle'], function (dialogHelper, dom, layoutManager, connectionManager, globalize, loading, browser, focusManager, scrollHelper) {
|
define(['dialogHelper', 'dom', 'layoutManager', 'connectionManager', 'globalize', 'loading', 'browser', 'focusManager', 'scrollHelper', 'material-icons', 'formDialogStyle', 'emby-button', 'emby-itemscontainer', 'cardStyle'], function (dialogHelper, dom, layoutManager, connectionManager, globalize, loading, browser, focusManager, scrollHelper) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
browser = browser.default || browser;
|
||||||
|
loading = loading.default || loading;
|
||||||
|
layoutManager = layoutManager.default || layoutManager;
|
||||||
|
focusManager = focusManager.default || focusManager;
|
||||||
|
scrollHelper = scrollHelper.default || scrollHelper;
|
||||||
|
|
||||||
var enableFocusTransform = !browser.slow && !browser.edge;
|
var enableFocusTransform = !browser.slow && !browser.edge;
|
||||||
|
|
||||||
function getEditorHtml() {
|
function getEditorHtml() {
|
||||||
|
|
|
@ -1,297 +1,304 @@
|
||||||
define(['jQuery', 'loading', 'globalize', 'emby-checkbox', 'listViewStyle', 'emby-input', 'emby-select', 'emby-button', 'flexStyles'], function ($, loading, globalize) {
|
import $ from 'jQuery';
|
||||||
'use strict';
|
import loading from 'loading';
|
||||||
|
import globalize from 'globalize';
|
||||||
|
import 'emby-checkbox';
|
||||||
|
import 'emby-input';
|
||||||
|
import 'listViewStyle';
|
||||||
|
import 'paper-icon-button-light';
|
||||||
|
import 'emby-select';
|
||||||
|
import 'emby-button';
|
||||||
|
import 'flexStyles';
|
||||||
|
|
||||||
return function (page, providerId, options) {
|
export default function (page, providerId, options) {
|
||||||
function reload() {
|
function reload() {
|
||||||
loading.show();
|
loading.show();
|
||||||
ApiClient.getNamedConfiguration('livetv').then(function (config) {
|
ApiClient.getNamedConfiguration('livetv').then(function (config) {
|
||||||
var info = config.ListingProviders.filter(function (i) {
|
const info = config.ListingProviders.filter(function (i) {
|
||||||
return i.Id === providerId;
|
return i.Id === providerId;
|
||||||
})[0] || {};
|
})[0] || {};
|
||||||
listingsId = info.ListingsId;
|
listingsId = info.ListingsId;
|
||||||
$('#selectListing', page).val(info.ListingsId || '');
|
$('#selectListing', page).val(info.ListingsId || '');
|
||||||
page.querySelector('.txtUser').value = info.Username || '';
|
page.querySelector('.txtUser').value = info.Username || '';
|
||||||
page.querySelector('.txtPass').value = '';
|
page.querySelector('.txtPass').value = '';
|
||||||
page.querySelector('.txtZipCode').value = info.ZipCode || '';
|
page.querySelector('.txtZipCode').value = info.ZipCode || '';
|
||||||
|
|
||||||
if (info.Username && info.Password) {
|
if (info.Username && info.Password) {
|
||||||
page.querySelector('.listingsSection').classList.remove('hide');
|
page.querySelector('.listingsSection').classList.remove('hide');
|
||||||
} else {
|
} else {
|
||||||
page.querySelector('.listingsSection').classList.add('hide');
|
page.querySelector('.listingsSection').classList.add('hide');
|
||||||
}
|
|
||||||
|
|
||||||
page.querySelector('.chkAllTuners').checked = info.EnableAllTuners;
|
|
||||||
|
|
||||||
if (info.EnableAllTuners) {
|
|
||||||
page.querySelector('.selectTunersSection').classList.add('hide');
|
|
||||||
} else {
|
|
||||||
page.querySelector('.selectTunersSection').classList.remove('hide');
|
|
||||||
}
|
|
||||||
|
|
||||||
setCountry(info);
|
|
||||||
refreshTunerDevices(page, info, config.TunerHosts);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function setCountry(info) {
|
|
||||||
ApiClient.getJSON(ApiClient.getUrl('LiveTv/ListingProviders/SchedulesDirect/Countries')).then(function (result) {
|
|
||||||
var i;
|
|
||||||
var length;
|
|
||||||
var countryList = [];
|
|
||||||
|
|
||||||
for (var region in result) {
|
|
||||||
var countries = result[region];
|
|
||||||
|
|
||||||
if (countries.length && region !== 'ZZZ') {
|
|
||||||
for (i = 0, length = countries.length; i < length; i++) {
|
|
||||||
countryList.push({
|
|
||||||
name: countries[i].fullName,
|
|
||||||
value: countries[i].shortName
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
countryList.sort(function (a, b) {
|
|
||||||
if (a.name > b.name) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (a.name < b.name) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
});
|
|
||||||
$('#selectCountry', page).html(countryList.map(function (c) {
|
|
||||||
return '<option value="' + c.value + '">' + c.name + '</option>';
|
|
||||||
}).join('')).val(info.Country || '');
|
|
||||||
$(page.querySelector('.txtZipCode')).trigger('change');
|
|
||||||
}, function () { // ApiClient.getJSON() error handler
|
|
||||||
Dashboard.alert({
|
|
||||||
message: globalize.translate('ErrorGettingTvLineups')
|
|
||||||
});
|
|
||||||
});
|
|
||||||
loading.hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
function sha256(str) {
|
|
||||||
if (!self.TextEncoder) {
|
|
||||||
return Promise.resolve('');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var buffer = new TextEncoder('utf-8').encode(str);
|
page.querySelector('.chkAllTuners').checked = info.EnableAllTuners;
|
||||||
return crypto.subtle.digest('SHA-256', buffer).then(function (hash) {
|
|
||||||
return hex(hash);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function hex(buffer) {
|
if (info.EnableAllTuners) {
|
||||||
var hexCodes = [];
|
page.querySelector('.selectTunersSection').classList.add('hide');
|
||||||
var view = new DataView(buffer);
|
} else {
|
||||||
|
page.querySelector('.selectTunersSection').classList.remove('hide');
|
||||||
for (var i = 0; i < view.byteLength; i += 4) {
|
|
||||||
var value = view.getUint32(i);
|
|
||||||
var stringValue = value.toString(16);
|
|
||||||
var paddedValue = ('00000000' + stringValue).slice(-'00000000'.length);
|
|
||||||
hexCodes.push(paddedValue);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return hexCodes.join('');
|
setCountry(info);
|
||||||
}
|
refreshTunerDevices(page, info, config.TunerHosts);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function submitLoginForm() {
|
function setCountry(info) {
|
||||||
loading.show();
|
ApiClient.getJSON(ApiClient.getUrl('LiveTv/ListingProviders/SchedulesDirect/Countries')).then(function (result) {
|
||||||
sha256(page.querySelector('.txtPass').value).then(function (passwordHash) {
|
let i;
|
||||||
var info = {
|
let length;
|
||||||
Type: 'SchedulesDirect',
|
const countryList = [];
|
||||||
Username: page.querySelector('.txtUser').value,
|
|
||||||
EnableAllTuners: true,
|
|
||||||
Password: passwordHash,
|
|
||||||
Pw: page.querySelector('.txtPass').value
|
|
||||||
};
|
|
||||||
var id = providerId;
|
|
||||||
|
|
||||||
if (id) {
|
for (const region in result) {
|
||||||
info.Id = id;
|
const countries = result[region];
|
||||||
|
|
||||||
|
if (countries.length && region !== 'ZZZ') {
|
||||||
|
for (i = 0, length = countries.length; i < length; i++) {
|
||||||
|
countryList.push({
|
||||||
|
name: countries[i].fullName,
|
||||||
|
value: countries[i].shortName
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
countryList.sort(function (a, b) {
|
||||||
|
if (a.name > b.name) {
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ApiClient.ajax({
|
if (a.name < b.name) {
|
||||||
type: 'POST',
|
return -1;
|
||||||
url: ApiClient.getUrl('LiveTv/ListingProviders', {
|
}
|
||||||
ValidateLogin: true
|
|
||||||
}),
|
return 0;
|
||||||
data: JSON.stringify(info),
|
|
||||||
contentType: 'application/json',
|
|
||||||
dataType: 'json'
|
|
||||||
}).then(function (result) {
|
|
||||||
Dashboard.processServerConfigurationUpdateResult();
|
|
||||||
providerId = result.Id;
|
|
||||||
reload();
|
|
||||||
}, function () {
|
|
||||||
Dashboard.alert({ // ApiClient.ajax() error handler
|
|
||||||
message: globalize.translate('ErrorSavingTvProvider')
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
$('#selectCountry', page).html(countryList.map(function (c) {
|
||||||
|
return '<option value="' + c.value + '">' + c.name + '</option>';
|
||||||
|
}).join('')).val(info.Country || '');
|
||||||
|
$(page.querySelector('.txtZipCode')).trigger('change');
|
||||||
|
}, function () { // ApiClient.getJSON() error handler
|
||||||
|
Dashboard.alert({
|
||||||
|
message: globalize.translate('ErrorGettingTvLineups')
|
||||||
|
});
|
||||||
|
});
|
||||||
|
loading.hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
function sha256(str) {
|
||||||
|
if (!self.TextEncoder) {
|
||||||
|
return Promise.resolve('');
|
||||||
}
|
}
|
||||||
|
|
||||||
function submitListingsForm() {
|
const buffer = new TextEncoder('utf-8').encode(str);
|
||||||
var selectedListingsId = $('#selectListing', page).val();
|
return crypto.subtle.digest('SHA-256', buffer).then(function (hash) {
|
||||||
|
return hex(hash);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (!selectedListingsId) {
|
function hex(buffer) {
|
||||||
return void Dashboard.alert({
|
const hexCodes = [];
|
||||||
message: globalize.translate('ErrorPleaseSelectLineup')
|
const view = new DataView(buffer);
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
loading.show();
|
for (let i = 0; i < view.byteLength; i += 4) {
|
||||||
var id = providerId;
|
const value = view.getUint32(i);
|
||||||
ApiClient.getNamedConfiguration('livetv').then(function (config) {
|
const stringValue = value.toString(16);
|
||||||
var info = config.ListingProviders.filter(function (i) {
|
const paddedValue = ('00000000' + stringValue).slice(-'00000000'.length);
|
||||||
return i.Id === id;
|
hexCodes.push(paddedValue);
|
||||||
})[0];
|
|
||||||
info.ZipCode = page.querySelector('.txtZipCode').value;
|
|
||||||
info.Country = $('#selectCountry', page).val();
|
|
||||||
info.ListingsId = selectedListingsId;
|
|
||||||
info.EnableAllTuners = page.querySelector('.chkAllTuners').checked;
|
|
||||||
info.EnabledTuners = info.EnableAllTuners ? [] : $('.chkTuner', page).get().filter(function (i) {
|
|
||||||
return i.checked;
|
|
||||||
}).map(function (i) {
|
|
||||||
return i.getAttribute('data-id');
|
|
||||||
});
|
|
||||||
ApiClient.ajax({
|
|
||||||
type: 'POST',
|
|
||||||
url: ApiClient.getUrl('LiveTv/ListingProviders', {
|
|
||||||
ValidateListings: true
|
|
||||||
}),
|
|
||||||
data: JSON.stringify(info),
|
|
||||||
contentType: 'application/json'
|
|
||||||
}).then(function (result) {
|
|
||||||
loading.hide();
|
|
||||||
|
|
||||||
if (options.showConfirmation) {
|
|
||||||
Dashboard.processServerConfigurationUpdateResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
Events.trigger(self, 'submitted');
|
|
||||||
}, function () {
|
|
||||||
loading.hide();
|
|
||||||
Dashboard.alert({
|
|
||||||
message: globalize.translate('ErrorAddingListingsToSchedulesDirect')
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function refreshListings(value) {
|
return hexCodes.join('');
|
||||||
if (!value) {
|
}
|
||||||
return void $('#selectListing', page).html('');
|
|
||||||
|
function submitLoginForm() {
|
||||||
|
loading.show();
|
||||||
|
sha256(page.querySelector('.txtPass').value).then(function (passwordHash) {
|
||||||
|
const info = {
|
||||||
|
Type: 'SchedulesDirect',
|
||||||
|
Username: page.querySelector('.txtUser').value,
|
||||||
|
EnableAllTuners: true,
|
||||||
|
Password: passwordHash,
|
||||||
|
Pw: page.querySelector('.txtPass').value
|
||||||
|
};
|
||||||
|
const id = providerId;
|
||||||
|
|
||||||
|
if (id) {
|
||||||
|
info.Id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
loading.show();
|
|
||||||
ApiClient.ajax({
|
ApiClient.ajax({
|
||||||
type: 'GET',
|
type: 'POST',
|
||||||
url: ApiClient.getUrl('LiveTv/ListingProviders/Lineups', {
|
url: ApiClient.getUrl('LiveTv/ListingProviders', {
|
||||||
Id: providerId,
|
ValidateLogin: true
|
||||||
Location: value,
|
|
||||||
Country: $('#selectCountry', page).val()
|
|
||||||
}),
|
}),
|
||||||
|
data: JSON.stringify(info),
|
||||||
|
contentType: 'application/json',
|
||||||
dataType: 'json'
|
dataType: 'json'
|
||||||
}).then(function (result) {
|
}).then(function (result) {
|
||||||
$('#selectListing', page).html(result.map(function (o) {
|
Dashboard.processServerConfigurationUpdateResult();
|
||||||
return '<option value="' + o.Id + '">' + o.Name + '</option>';
|
providerId = result.Id;
|
||||||
}));
|
reload();
|
||||||
|
}, function () {
|
||||||
if (listingsId) {
|
Dashboard.alert({ // ApiClient.ajax() error handler
|
||||||
$('#selectListing', page).val(listingsId);
|
message: globalize.translate('ErrorSavingTvProvider')
|
||||||
}
|
|
||||||
|
|
||||||
loading.hide();
|
|
||||||
}, function (result) {
|
|
||||||
Dashboard.alert({
|
|
||||||
message: globalize.translate('ErrorGettingTvLineups')
|
|
||||||
});
|
});
|
||||||
refreshListings('');
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function submitListingsForm() {
|
||||||
|
const selectedListingsId = $('#selectListing', page).val();
|
||||||
|
|
||||||
|
if (!selectedListingsId) {
|
||||||
|
return void Dashboard.alert({
|
||||||
|
message: globalize.translate('ErrorPleaseSelectLineup')
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
loading.show();
|
||||||
|
const id = providerId;
|
||||||
|
ApiClient.getNamedConfiguration('livetv').then(function (config) {
|
||||||
|
const info = config.ListingProviders.filter(function (i) {
|
||||||
|
return i.Id === id;
|
||||||
|
})[0];
|
||||||
|
info.ZipCode = page.querySelector('.txtZipCode').value;
|
||||||
|
info.Country = $('#selectCountry', page).val();
|
||||||
|
info.ListingsId = selectedListingsId;
|
||||||
|
info.EnableAllTuners = page.querySelector('.chkAllTuners').checked;
|
||||||
|
info.EnabledTuners = info.EnableAllTuners ? [] : $('.chkTuner', page).get().filter(function (i) {
|
||||||
|
return i.checked;
|
||||||
|
}).map(function (i) {
|
||||||
|
return i.getAttribute('data-id');
|
||||||
|
});
|
||||||
|
ApiClient.ajax({
|
||||||
|
type: 'POST',
|
||||||
|
url: ApiClient.getUrl('LiveTv/ListingProviders', {
|
||||||
|
ValidateListings: true
|
||||||
|
}),
|
||||||
|
data: JSON.stringify(info),
|
||||||
|
contentType: 'application/json'
|
||||||
|
}).then(function (result) {
|
||||||
loading.hide();
|
loading.hide();
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function getTunerName(providerId) {
|
if (options.showConfirmation) {
|
||||||
switch (providerId = providerId.toLowerCase()) {
|
Dashboard.processServerConfigurationUpdateResult();
|
||||||
case 'm3u':
|
|
||||||
return 'M3U Playlist';
|
|
||||||
case 'hdhomerun':
|
|
||||||
return 'HDHomerun';
|
|
||||||
case 'satip':
|
|
||||||
return 'DVB';
|
|
||||||
default:
|
|
||||||
return 'Unknown';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function refreshTunerDevices(page, providerInfo, devices) {
|
|
||||||
var html = '';
|
|
||||||
|
|
||||||
for (var i = 0, length = devices.length; i < length; i++) {
|
|
||||||
var device = devices[i];
|
|
||||||
html += '<div class="listItem">';
|
|
||||||
var enabledTuners = providerInfo.EnabledTuners || [];
|
|
||||||
var isChecked = providerInfo.EnableAllTuners || enabledTuners.indexOf(device.Id) !== -1;
|
|
||||||
var checkedAttribute = isChecked ? ' checked' : '';
|
|
||||||
html += '<label class="checkboxContainer listItemCheckboxContainer"><input type="checkbox" is="emby-checkbox" data-id="' + device.Id + '" class="chkTuner" ' + checkedAttribute + '/><span></span></label>';
|
|
||||||
html += '<div class="listItemBody two-line">';
|
|
||||||
html += '<div class="listItemBodyText">';
|
|
||||||
html += device.FriendlyName || getTunerName(device.Type);
|
|
||||||
html += '</div>';
|
|
||||||
html += '<div class="listItemBodyText secondary">';
|
|
||||||
html += device.Url;
|
|
||||||
html += '</div>';
|
|
||||||
html += '</div>';
|
|
||||||
html += '</div>';
|
|
||||||
}
|
|
||||||
|
|
||||||
page.querySelector('.tunerList').innerHTML = html;
|
|
||||||
}
|
|
||||||
|
|
||||||
var listingsId;
|
|
||||||
var self = this;
|
|
||||||
|
|
||||||
self.submit = function () {
|
|
||||||
page.querySelector('.btnSubmitListingsContainer').click();
|
|
||||||
};
|
|
||||||
|
|
||||||
self.init = function () {
|
|
||||||
options = options || {};
|
|
||||||
|
|
||||||
// Only hide the buttons if explicitly set to false; default to showing if undefined or null
|
|
||||||
// FIXME: rename this option to clarify logic
|
|
||||||
var hideCancelButton = options.showCancelButton === false;
|
|
||||||
page.querySelector('.btnCancel').classList.toggle('hide', hideCancelButton);
|
|
||||||
|
|
||||||
var hideSubmitButton = options.showSubmitButton === false;
|
|
||||||
page.querySelector('.btnSubmitListings').classList.toggle('hide', hideSubmitButton);
|
|
||||||
|
|
||||||
$('.formLogin', page).on('submit', function () {
|
|
||||||
submitLoginForm();
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
$('.formListings', page).on('submit', function () {
|
|
||||||
submitListingsForm();
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
$('.txtZipCode', page).on('change', function () {
|
|
||||||
refreshListings(this.value);
|
|
||||||
});
|
|
||||||
page.querySelector('.chkAllTuners').addEventListener('change', function (e) {
|
|
||||||
if (e.target.checked) {
|
|
||||||
page.querySelector('.selectTunersSection').classList.add('hide');
|
|
||||||
} else {
|
|
||||||
page.querySelector('.selectTunersSection').classList.remove('hide');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Events.trigger(self, 'submitted');
|
||||||
|
}, function () {
|
||||||
|
loading.hide();
|
||||||
|
Dashboard.alert({
|
||||||
|
message: globalize.translate('ErrorAddingListingsToSchedulesDirect')
|
||||||
|
});
|
||||||
});
|
});
|
||||||
$('.createAccountHelp', page).html(globalize.translate('MessageCreateAccountAt', '<a is="emby-linkbutton" class="button-link" href="http://www.schedulesdirect.org" target="_blank">http://www.schedulesdirect.org</a>'));
|
});
|
||||||
reload();
|
}
|
||||||
};
|
|
||||||
|
function refreshListings(value) {
|
||||||
|
if (!value) {
|
||||||
|
return void $('#selectListing', page).html('');
|
||||||
|
}
|
||||||
|
|
||||||
|
loading.show();
|
||||||
|
ApiClient.ajax({
|
||||||
|
type: 'GET',
|
||||||
|
url: ApiClient.getUrl('LiveTv/ListingProviders/Lineups', {
|
||||||
|
Id: providerId,
|
||||||
|
Location: value,
|
||||||
|
Country: $('#selectCountry', page).val()
|
||||||
|
}),
|
||||||
|
dataType: 'json'
|
||||||
|
}).then(function (result) {
|
||||||
|
$('#selectListing', page).html(result.map(function (o) {
|
||||||
|
return '<option value="' + o.Id + '">' + o.Name + '</option>';
|
||||||
|
}));
|
||||||
|
|
||||||
|
if (listingsId) {
|
||||||
|
$('#selectListing', page).val(listingsId);
|
||||||
|
}
|
||||||
|
|
||||||
|
loading.hide();
|
||||||
|
}, function (result) {
|
||||||
|
Dashboard.alert({
|
||||||
|
message: globalize.translate('ErrorGettingTvLineups')
|
||||||
|
});
|
||||||
|
refreshListings('');
|
||||||
|
loading.hide();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function getTunerName(providerId) {
|
||||||
|
switch (providerId = providerId.toLowerCase()) {
|
||||||
|
case 'm3u':
|
||||||
|
return 'M3U Playlist';
|
||||||
|
case 'hdhomerun':
|
||||||
|
return 'HDHomerun';
|
||||||
|
case 'satip':
|
||||||
|
return 'DVB';
|
||||||
|
default:
|
||||||
|
return 'Unknown';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function refreshTunerDevices(page, providerInfo, devices) {
|
||||||
|
let html = '';
|
||||||
|
|
||||||
|
for (let i = 0, length = devices.length; i < length; i++) {
|
||||||
|
const device = devices[i];
|
||||||
|
html += '<div class="listItem">';
|
||||||
|
const enabledTuners = providerInfo.EnabledTuners || [];
|
||||||
|
const isChecked = providerInfo.EnableAllTuners || enabledTuners.indexOf(device.Id) !== -1;
|
||||||
|
const checkedAttribute = isChecked ? ' checked' : '';
|
||||||
|
html += '<label class="checkboxContainer listItemCheckboxContainer"><input type="checkbox" is="emby-checkbox" data-id="' + device.Id + '" class="chkTuner" ' + checkedAttribute + '/><span></span></label>';
|
||||||
|
html += '<div class="listItemBody two-line">';
|
||||||
|
html += '<div class="listItemBodyText">';
|
||||||
|
html += device.FriendlyName || getTunerName(device.Type);
|
||||||
|
html += '</div>';
|
||||||
|
html += '<div class="listItemBodyText secondary">';
|
||||||
|
html += device.Url;
|
||||||
|
html += '</div>';
|
||||||
|
html += '</div>';
|
||||||
|
html += '</div>';
|
||||||
|
}
|
||||||
|
|
||||||
|
page.querySelector('.tunerList').innerHTML = html;
|
||||||
|
}
|
||||||
|
|
||||||
|
let listingsId;
|
||||||
|
const self = this;
|
||||||
|
|
||||||
|
self.submit = function () {
|
||||||
|
page.querySelector('.btnSubmitListingsContainer').click();
|
||||||
};
|
};
|
||||||
});
|
|
||||||
|
self.init = function () {
|
||||||
|
options = options || {};
|
||||||
|
|
||||||
|
// Only hide the buttons if explicitly set to false; default to showing if undefined or null
|
||||||
|
// FIXME: rename this option to clarify logic
|
||||||
|
const hideCancelButton = options.showCancelButton === false;
|
||||||
|
page.querySelector('.btnCancel').classList.toggle('hide', hideCancelButton);
|
||||||
|
|
||||||
|
const hideSubmitButton = options.showSubmitButton === false;
|
||||||
|
page.querySelector('.btnSubmitListings').classList.toggle('hide', hideSubmitButton);
|
||||||
|
|
||||||
|
$('.formLogin', page).on('submit', function () {
|
||||||
|
submitLoginForm();
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
$('.formListings', page).on('submit', function () {
|
||||||
|
submitListingsForm();
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
$('.txtZipCode', page).on('change', function () {
|
||||||
|
refreshListings(this.value);
|
||||||
|
});
|
||||||
|
page.querySelector('.chkAllTuners').addEventListener('change', function (e) {
|
||||||
|
if (e.target.checked) {
|
||||||
|
page.querySelector('.selectTunersSection').classList.add('hide');
|
||||||
|
} else {
|
||||||
|
page.querySelector('.selectTunersSection').classList.remove('hide');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$('.createAccountHelp', page).html(globalize.translate('MessageCreateAccountAt', '<a is="emby-linkbutton" class="button-link" href="http://www.schedulesdirect.org" target="_blank">http://www.schedulesdirect.org</a>'));
|
||||||
|
reload();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
|
@ -1,189 +1,193 @@
|
||||||
define(['jQuery', 'loading', 'globalize', 'emby-checkbox', 'emby-input', 'listViewStyle', 'paper-icon-button-light'], function ($, loading, globalize) {
|
import $ from 'jQuery';
|
||||||
'use strict';
|
import loading from 'loading';
|
||||||
|
import globalize from 'globalize';
|
||||||
|
import 'emby-checkbox';
|
||||||
|
import 'emby-input';
|
||||||
|
import 'listViewStyle';
|
||||||
|
import 'paper-icon-button-light';
|
||||||
|
|
||||||
return function (page, providerId, options) {
|
export default function (page, providerId, options) {
|
||||||
function getListingProvider(config, id) {
|
function getListingProvider(config, id) {
|
||||||
if (config && id) {
|
if (config && id) {
|
||||||
var result = config.ListingProviders.filter(function (provider) {
|
const result = config.ListingProviders.filter(function (provider) {
|
||||||
return provider.Id === id;
|
return provider.Id === id;
|
||||||
})[0];
|
})[0];
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
return Promise.resolve(result);
|
return Promise.resolve(result);
|
||||||
}
|
|
||||||
|
|
||||||
return getListingProvider();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ApiClient.getJSON(ApiClient.getUrl('LiveTv/ListingProviders/Default'));
|
return getListingProvider();
|
||||||
}
|
}
|
||||||
|
|
||||||
function reload() {
|
return ApiClient.getJSON(ApiClient.getUrl('LiveTv/ListingProviders/Default'));
|
||||||
loading.show();
|
}
|
||||||
ApiClient.getNamedConfiguration('livetv').then(function (config) {
|
|
||||||
getListingProvider(config, providerId).then(function (info) {
|
|
||||||
page.querySelector('.txtPath').value = info.Path || '';
|
|
||||||
page.querySelector('.txtKids').value = (info.KidsCategories || []).join('|');
|
|
||||||
page.querySelector('.txtNews').value = (info.NewsCategories || []).join('|');
|
|
||||||
page.querySelector('.txtSports').value = (info.SportsCategories || []).join('|');
|
|
||||||
page.querySelector('.txtMovies').value = (info.MovieCategories || []).join('|');
|
|
||||||
page.querySelector('.txtMoviePrefix').value = info.MoviePrefix || '';
|
|
||||||
page.querySelector('.txtUserAgent').value = info.UserAgent || '';
|
|
||||||
page.querySelector('.chkAllTuners').checked = info.EnableAllTuners;
|
|
||||||
|
|
||||||
if (page.querySelector('.chkAllTuners').checked) {
|
function reload() {
|
||||||
page.querySelector('.selectTunersSection').classList.add('hide');
|
loading.show();
|
||||||
} else {
|
ApiClient.getNamedConfiguration('livetv').then(function (config) {
|
||||||
page.querySelector('.selectTunersSection').classList.remove('hide');
|
getListingProvider(config, providerId).then(function (info) {
|
||||||
}
|
page.querySelector('.txtPath').value = info.Path || '';
|
||||||
|
page.querySelector('.txtKids').value = (info.KidsCategories || []).join('|');
|
||||||
|
page.querySelector('.txtNews').value = (info.NewsCategories || []).join('|');
|
||||||
|
page.querySelector('.txtSports').value = (info.SportsCategories || []).join('|');
|
||||||
|
page.querySelector('.txtMovies').value = (info.MovieCategories || []).join('|');
|
||||||
|
page.querySelector('.txtMoviePrefix').value = info.MoviePrefix || '';
|
||||||
|
page.querySelector('.txtUserAgent').value = info.UserAgent || '';
|
||||||
|
page.querySelector('.chkAllTuners').checked = info.EnableAllTuners;
|
||||||
|
|
||||||
refreshTunerDevices(page, info, config.TunerHosts);
|
if (page.querySelector('.chkAllTuners').checked) {
|
||||||
loading.hide();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function getCategories(txtInput) {
|
|
||||||
var value = txtInput.value;
|
|
||||||
|
|
||||||
if (value) {
|
|
||||||
return value.split('|');
|
|
||||||
}
|
|
||||||
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
function submitListingsForm() {
|
|
||||||
loading.show();
|
|
||||||
var id = providerId;
|
|
||||||
ApiClient.getNamedConfiguration('livetv').then(function (config) {
|
|
||||||
var info = config.ListingProviders.filter(function (provider) {
|
|
||||||
return provider.Id === id;
|
|
||||||
})[0] || {};
|
|
||||||
info.Type = 'xmltv';
|
|
||||||
info.Path = page.querySelector('.txtPath').value;
|
|
||||||
info.MoviePrefix = page.querySelector('.txtMoviePrefix').value || null;
|
|
||||||
info.UserAgent = page.querySelector('.txtUserAgent').value || null;
|
|
||||||
info.MovieCategories = getCategories(page.querySelector('.txtMovies'));
|
|
||||||
info.KidsCategories = getCategories(page.querySelector('.txtKids'));
|
|
||||||
info.NewsCategories = getCategories(page.querySelector('.txtNews'));
|
|
||||||
info.SportsCategories = getCategories(page.querySelector('.txtSports'));
|
|
||||||
info.EnableAllTuners = page.querySelector('.chkAllTuners').checked;
|
|
||||||
info.EnabledTuners = info.EnableAllTuners ? [] : $('.chkTuner', page).get().filter(function (tuner) {
|
|
||||||
return tuner.checked;
|
|
||||||
}).map(function (tuner) {
|
|
||||||
return tuner.getAttribute('data-id');
|
|
||||||
});
|
|
||||||
ApiClient.ajax({
|
|
||||||
type: 'POST',
|
|
||||||
url: ApiClient.getUrl('LiveTv/ListingProviders', {
|
|
||||||
ValidateListings: true
|
|
||||||
}),
|
|
||||||
data: JSON.stringify(info),
|
|
||||||
contentType: 'application/json'
|
|
||||||
}).then(function (result) {
|
|
||||||
loading.hide();
|
|
||||||
|
|
||||||
if (options.showConfirmation !== false) {
|
|
||||||
Dashboard.processServerConfigurationUpdateResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
Events.trigger(self, 'submitted');
|
|
||||||
}, function () {
|
|
||||||
loading.hide();
|
|
||||||
Dashboard.alert({
|
|
||||||
message: globalize.translate('ErrorAddingXmlTvFile')
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function getTunerName(providerId) {
|
|
||||||
switch (providerId = providerId.toLowerCase()) {
|
|
||||||
case 'm3u':
|
|
||||||
return 'M3U Playlist';
|
|
||||||
case 'hdhomerun':
|
|
||||||
return 'HDHomerun';
|
|
||||||
case 'satip':
|
|
||||||
return 'DVB';
|
|
||||||
default:
|
|
||||||
return 'Unknown';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function refreshTunerDevices(page, providerInfo, devices) {
|
|
||||||
var html = '';
|
|
||||||
|
|
||||||
for (var i = 0, length = devices.length; i < length; i++) {
|
|
||||||
var device = devices[i];
|
|
||||||
html += '<div class="listItem">';
|
|
||||||
var enabledTuners = providerInfo.EnabledTuners || [];
|
|
||||||
var isChecked = providerInfo.EnableAllTuners || enabledTuners.indexOf(device.Id) !== -1;
|
|
||||||
var checkedAttribute = isChecked ? ' checked' : '';
|
|
||||||
html += '<label class="listItemCheckboxContainer"><input type="checkbox" is="emby-checkbox" class="chkTuner" data-id="' + device.Id + '" ' + checkedAttribute + '><span></span></label>';
|
|
||||||
html += '<div class="listItemBody two-line">';
|
|
||||||
html += '<div class="listItemBodyText">';
|
|
||||||
html += device.FriendlyName || getTunerName(device.Type);
|
|
||||||
html += '</div>';
|
|
||||||
html += '<div class="listItemBodyText secondary">';
|
|
||||||
html += device.Url;
|
|
||||||
html += '</div>';
|
|
||||||
html += '</div>';
|
|
||||||
html += '</div>';
|
|
||||||
}
|
|
||||||
|
|
||||||
page.querySelector('.tunerList').innerHTML = html;
|
|
||||||
}
|
|
||||||
|
|
||||||
function onSelectPathClick(e) {
|
|
||||||
var page = $(e.target).parents('.xmltvForm')[0];
|
|
||||||
|
|
||||||
require(['directorybrowser'], function (directoryBrowser) {
|
|
||||||
var picker = new directoryBrowser.default();
|
|
||||||
picker.show({
|
|
||||||
includeFiles: true,
|
|
||||||
callback: function (path) {
|
|
||||||
if (path) {
|
|
||||||
var txtPath = page.querySelector('.txtPath');
|
|
||||||
txtPath.value = path;
|
|
||||||
txtPath.focus();
|
|
||||||
}
|
|
||||||
picker.close();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
var self = this;
|
|
||||||
|
|
||||||
self.submit = function () {
|
|
||||||
page.querySelector('.btnSubmitListings').click();
|
|
||||||
};
|
|
||||||
|
|
||||||
self.init = function () {
|
|
||||||
options = options || {};
|
|
||||||
|
|
||||||
// Only hide the buttons if explicitly set to false; default to showing if undefined or null
|
|
||||||
// FIXME: rename this option to clarify logic
|
|
||||||
var hideCancelButton = options.showCancelButton === false;
|
|
||||||
page.querySelector('.btnCancel').classList.toggle('hide', hideCancelButton);
|
|
||||||
|
|
||||||
var hideSubmitButton = options.showSubmitButton === false;
|
|
||||||
page.querySelector('.btnSubmitListings').classList.toggle('hide', hideSubmitButton);
|
|
||||||
|
|
||||||
$('form', page).on('submit', function () {
|
|
||||||
submitListingsForm();
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
page.querySelector('#btnSelectPath').addEventListener('click', onSelectPathClick);
|
|
||||||
page.querySelector('.chkAllTuners').addEventListener('change', function (evt) {
|
|
||||||
if (evt.target.checked) {
|
|
||||||
page.querySelector('.selectTunersSection').classList.add('hide');
|
page.querySelector('.selectTunersSection').classList.add('hide');
|
||||||
} else {
|
} else {
|
||||||
page.querySelector('.selectTunersSection').classList.remove('hide');
|
page.querySelector('.selectTunersSection').classList.remove('hide');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
refreshTunerDevices(page, info, config.TunerHosts);
|
||||||
|
loading.hide();
|
||||||
});
|
});
|
||||||
reload();
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
|
function getCategories(txtInput) {
|
||||||
|
const value = txtInput.value;
|
||||||
|
|
||||||
|
if (value) {
|
||||||
|
return value.split('|');
|
||||||
|
}
|
||||||
|
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
function submitListingsForm() {
|
||||||
|
loading.show();
|
||||||
|
const id = providerId;
|
||||||
|
ApiClient.getNamedConfiguration('livetv').then(function (config) {
|
||||||
|
const info = config.ListingProviders.filter(function (provider) {
|
||||||
|
return provider.Id === id;
|
||||||
|
})[0] || {};
|
||||||
|
info.Type = 'xmltv';
|
||||||
|
info.Path = page.querySelector('.txtPath').value;
|
||||||
|
info.MoviePrefix = page.querySelector('.txtMoviePrefix').value || null;
|
||||||
|
info.UserAgent = page.querySelector('.txtUserAgent').value || null;
|
||||||
|
info.MovieCategories = getCategories(page.querySelector('.txtMovies'));
|
||||||
|
info.KidsCategories = getCategories(page.querySelector('.txtKids'));
|
||||||
|
info.NewsCategories = getCategories(page.querySelector('.txtNews'));
|
||||||
|
info.SportsCategories = getCategories(page.querySelector('.txtSports'));
|
||||||
|
info.EnableAllTuners = page.querySelector('.chkAllTuners').checked;
|
||||||
|
info.EnabledTuners = info.EnableAllTuners ? [] : $('.chkTuner', page).get().filter(function (tuner) {
|
||||||
|
return tuner.checked;
|
||||||
|
}).map(function (tuner) {
|
||||||
|
return tuner.getAttribute('data-id');
|
||||||
|
});
|
||||||
|
ApiClient.ajax({
|
||||||
|
type: 'POST',
|
||||||
|
url: ApiClient.getUrl('LiveTv/ListingProviders', {
|
||||||
|
ValidateListings: true
|
||||||
|
}),
|
||||||
|
data: JSON.stringify(info),
|
||||||
|
contentType: 'application/json'
|
||||||
|
}).then(function (result) {
|
||||||
|
loading.hide();
|
||||||
|
|
||||||
|
if (options.showConfirmation !== false) {
|
||||||
|
Dashboard.processServerConfigurationUpdateResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
Events.trigger(self, 'submitted');
|
||||||
|
}, function () {
|
||||||
|
loading.hide();
|
||||||
|
Dashboard.alert({
|
||||||
|
message: globalize.translate('ErrorAddingXmlTvFile')
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function getTunerName(providerId) {
|
||||||
|
switch (providerId = providerId.toLowerCase()) {
|
||||||
|
case 'm3u':
|
||||||
|
return 'M3U Playlist';
|
||||||
|
case 'hdhomerun':
|
||||||
|
return 'HDHomerun';
|
||||||
|
case 'satip':
|
||||||
|
return 'DVB';
|
||||||
|
default:
|
||||||
|
return 'Unknown';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function refreshTunerDevices(page, providerInfo, devices) {
|
||||||
|
let html = '';
|
||||||
|
|
||||||
|
for (let i = 0, length = devices.length; i < length; i++) {
|
||||||
|
const device = devices[i];
|
||||||
|
html += '<div class="listItem">';
|
||||||
|
const enabledTuners = providerInfo.EnabledTuners || [];
|
||||||
|
const isChecked = providerInfo.EnableAllTuners || enabledTuners.indexOf(device.Id) !== -1;
|
||||||
|
const checkedAttribute = isChecked ? ' checked' : '';
|
||||||
|
html += '<label class="listItemCheckboxContainer"><input type="checkbox" is="emby-checkbox" class="chkTuner" data-id="' + device.Id + '" ' + checkedAttribute + '><span></span></label>';
|
||||||
|
html += '<div class="listItemBody two-line">';
|
||||||
|
html += '<div class="listItemBodyText">';
|
||||||
|
html += device.FriendlyName || getTunerName(device.Type);
|
||||||
|
html += '</div>';
|
||||||
|
html += '<div class="listItemBodyText secondary">';
|
||||||
|
html += device.Url;
|
||||||
|
html += '</div>';
|
||||||
|
html += '</div>';
|
||||||
|
html += '</div>';
|
||||||
|
}
|
||||||
|
|
||||||
|
page.querySelector('.tunerList').innerHTML = html;
|
||||||
|
}
|
||||||
|
|
||||||
|
function onSelectPathClick(e) {
|
||||||
|
const page = $(e.target).parents('.xmltvForm')[0];
|
||||||
|
|
||||||
|
import('directorybrowser').then(({default: directoryBrowser}) => {
|
||||||
|
const picker = new directoryBrowser();
|
||||||
|
picker.show({
|
||||||
|
includeFiles: true,
|
||||||
|
callback: function (path) {
|
||||||
|
if (path) {
|
||||||
|
const txtPath = page.querySelector('.txtPath');
|
||||||
|
txtPath.value = path;
|
||||||
|
txtPath.focus();
|
||||||
|
}
|
||||||
|
picker.close();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const self = this;
|
||||||
|
|
||||||
|
self.submit = function () {
|
||||||
|
page.querySelector('.btnSubmitListings').click();
|
||||||
};
|
};
|
||||||
});
|
|
||||||
|
self.init = function () {
|
||||||
|
options = options || {};
|
||||||
|
|
||||||
|
// Only hide the buttons if explicitly set to false; default to showing if undefined or null
|
||||||
|
// FIXME: rename this option to clarify logic
|
||||||
|
const hideCancelButton = options.showCancelButton === false;
|
||||||
|
page.querySelector('.btnCancel').classList.toggle('hide', hideCancelButton);
|
||||||
|
|
||||||
|
const hideSubmitButton = options.showSubmitButton === false;
|
||||||
|
page.querySelector('.btnSubmitListings').classList.toggle('hide', hideSubmitButton);
|
||||||
|
|
||||||
|
$('form', page).on('submit', function () {
|
||||||
|
submitListingsForm();
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
page.querySelector('#btnSelectPath').addEventListener('click', onSelectPathClick);
|
||||||
|
page.querySelector('.chkAllTuners').addEventListener('change', function (evt) {
|
||||||
|
if (evt.target.checked) {
|
||||||
|
page.querySelector('.selectTunersSection').classList.add('hide');
|
||||||
|
} else {
|
||||||
|
page.querySelector('.selectTunersSection').classList.remove('hide');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
reload();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
|
@ -1,7 +1,19 @@
|
||||||
define(['dom', 'playbackManager', 'connectionManager', 'events', 'mediaInfo', 'layoutManager', 'focusManager', 'globalize', 'itemHelper', 'css!./upnextdialog', 'emby-button', 'flexStyles'], function (dom, playbackManager, connectionManager, events, mediaInfo, layoutManager, focusManager, globalize, itemHelper) {
|
import dom from 'dom';
|
||||||
'use strict';
|
import playbackManager from 'playbackManager';
|
||||||
|
import connectionManager from 'connectionManager';
|
||||||
|
import events from 'events';
|
||||||
|
import mediaInfo from 'mediaInfo';
|
||||||
|
import layoutManager from 'layoutManager';
|
||||||
|
import focusManager from 'focusManager';
|
||||||
|
import globalize from 'globalize';
|
||||||
|
import itemHelper from 'itemHelper';
|
||||||
|
import 'css!./upnextdialog';
|
||||||
|
import 'emby-button';
|
||||||
|
import 'flexStyles';
|
||||||
|
|
||||||
var transitionEndEventName = dom.whichTransitionEvent();
|
/* eslint-disable indent */
|
||||||
|
|
||||||
|
const transitionEndEventName = dom.whichTransitionEvent();
|
||||||
|
|
||||||
function seriesImageUrl(item, options) {
|
function seriesImageUrl(item, options) {
|
||||||
if (item.Type !== 'Episode') {
|
if (item.Type !== 'Episode') {
|
||||||
|
@ -56,7 +68,7 @@ define(['dom', 'playbackManager', 'connectionManager', 'events', 'mediaInfo', 'l
|
||||||
|
|
||||||
function setPoster(osdPoster, item, secondaryItem) {
|
function setPoster(osdPoster, item, secondaryItem) {
|
||||||
if (item) {
|
if (item) {
|
||||||
var imgUrl = seriesImageUrl(item, { type: 'Primary' }) ||
|
let imgUrl = seriesImageUrl(item, { type: 'Primary' }) ||
|
||||||
seriesImageUrl(item, { type: 'Thumb' }) ||
|
seriesImageUrl(item, { type: 'Thumb' }) ||
|
||||||
imageUrl(item, { type: 'Primary' });
|
imageUrl(item, { type: 'Primary' });
|
||||||
|
|
||||||
|
@ -76,7 +88,7 @@ define(['dom', 'playbackManager', 'connectionManager', 'events', 'mediaInfo', 'l
|
||||||
}
|
}
|
||||||
|
|
||||||
function getHtml() {
|
function getHtml() {
|
||||||
var html = '';
|
let html = '';
|
||||||
|
|
||||||
html += '<div class="upNextDialog-poster">';
|
html += '<div class="upNextDialog-poster">';
|
||||||
html += '</div>';
|
html += '</div>';
|
||||||
|
@ -112,17 +124,17 @@ define(['dom', 'playbackManager', 'connectionManager', 'events', 'mediaInfo', 'l
|
||||||
}
|
}
|
||||||
|
|
||||||
function setNextVideoText() {
|
function setNextVideoText() {
|
||||||
var instance = this;
|
const instance = this;
|
||||||
|
|
||||||
var elem = instance.options.parent;
|
const elem = instance.options.parent;
|
||||||
|
|
||||||
var secondsRemaining = Math.max(Math.round(getTimeRemainingMs(instance) / 1000), 0);
|
const secondsRemaining = Math.max(Math.round(getTimeRemainingMs(instance) / 1000), 0);
|
||||||
|
|
||||||
console.debug('up next seconds remaining: ' + secondsRemaining);
|
console.debug('up next seconds remaining: ' + secondsRemaining);
|
||||||
|
|
||||||
var timeText = '<span class="upNextDialog-countdownText">' + globalize.translate('HeaderSecondsValue', secondsRemaining) + '</span>';
|
const timeText = '<span class="upNextDialog-countdownText">' + globalize.translate('HeaderSecondsValue', secondsRemaining) + '</span>';
|
||||||
|
|
||||||
var nextVideoText = instance.itemType === 'Episode' ?
|
const nextVideoText = instance.itemType === 'Episode' ?
|
||||||
globalize.translate('HeaderNextEpisodePlayingInValue', timeText) :
|
globalize.translate('HeaderNextEpisodePlayingInValue', timeText) :
|
||||||
globalize.translate('HeaderNextVideoPlayingInValue', timeText);
|
globalize.translate('HeaderNextVideoPlayingInValue', timeText);
|
||||||
|
|
||||||
|
@ -130,9 +142,9 @@ define(['dom', 'playbackManager', 'connectionManager', 'events', 'mediaInfo', 'l
|
||||||
}
|
}
|
||||||
|
|
||||||
function fillItem(item) {
|
function fillItem(item) {
|
||||||
var instance = this;
|
const instance = this;
|
||||||
|
|
||||||
var elem = instance.options.parent;
|
const elem = instance.options.parent;
|
||||||
|
|
||||||
setPoster(elem.querySelector('.upNextDialog-poster'), item);
|
setPoster(elem.querySelector('.upNextDialog-poster'), item);
|
||||||
|
|
||||||
|
@ -141,7 +153,7 @@ define(['dom', 'playbackManager', 'connectionManager', 'events', 'mediaInfo', 'l
|
||||||
elem.querySelector('.upNextDialog-mediainfo').innerHTML = mediaInfo.getPrimaryMediaInfoHtml(item, {
|
elem.querySelector('.upNextDialog-mediainfo').innerHTML = mediaInfo.getPrimaryMediaInfoHtml(item, {
|
||||||
});
|
});
|
||||||
|
|
||||||
var title = itemHelper.getDisplayName(item);
|
let title = itemHelper.getDisplayName(item);
|
||||||
if (item.SeriesName) {
|
if (item.SeriesName) {
|
||||||
title = item.SeriesName + ' - ' + title;
|
title = item.SeriesName + ' - ' + title;
|
||||||
}
|
}
|
||||||
|
@ -161,10 +173,10 @@ define(['dom', 'playbackManager', 'connectionManager', 'events', 'mediaInfo', 'l
|
||||||
}
|
}
|
||||||
|
|
||||||
function onStartNowClick() {
|
function onStartNowClick() {
|
||||||
var options = this.options;
|
const options = this.options;
|
||||||
|
|
||||||
if (options) {
|
if (options) {
|
||||||
var player = options.player;
|
const player = options.player;
|
||||||
|
|
||||||
this.hide();
|
this.hide();
|
||||||
|
|
||||||
|
@ -186,7 +198,7 @@ define(['dom', 'playbackManager', 'connectionManager', 'events', 'mediaInfo', 'l
|
||||||
}
|
}
|
||||||
|
|
||||||
function clearHideAnimationEventListeners(instance, elem) {
|
function clearHideAnimationEventListeners(instance, elem) {
|
||||||
var fn = instance._onHideAnimationComplete;
|
const fn = instance._onHideAnimationComplete;
|
||||||
|
|
||||||
if (fn) {
|
if (fn) {
|
||||||
dom.removeEventListener(elem, transitionEndEventName, fn, {
|
dom.removeEventListener(elem, transitionEndEventName, fn, {
|
||||||
|
@ -196,8 +208,8 @@ define(['dom', 'playbackManager', 'connectionManager', 'events', 'mediaInfo', 'l
|
||||||
}
|
}
|
||||||
|
|
||||||
function onHideAnimationComplete(e) {
|
function onHideAnimationComplete(e) {
|
||||||
var instance = this;
|
const instance = this;
|
||||||
var elem = e.target;
|
const elem = e.target;
|
||||||
|
|
||||||
elem.classList.add('hide');
|
elem.classList.add('hide');
|
||||||
|
|
||||||
|
@ -206,14 +218,14 @@ define(['dom', 'playbackManager', 'connectionManager', 'events', 'mediaInfo', 'l
|
||||||
}
|
}
|
||||||
|
|
||||||
function hideComingUpNext() {
|
function hideComingUpNext() {
|
||||||
var instance = this;
|
const instance = this;
|
||||||
clearCountdownTextTimeout(this);
|
clearCountdownTextTimeout(this);
|
||||||
|
|
||||||
if (!instance.options) {
|
if (!instance.options) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var elem = instance.options.parent;
|
const elem = instance.options.parent;
|
||||||
|
|
||||||
if (!elem) {
|
if (!elem) {
|
||||||
return;
|
return;
|
||||||
|
@ -230,7 +242,7 @@ define(['dom', 'playbackManager', 'connectionManager', 'events', 'mediaInfo', 'l
|
||||||
|
|
||||||
elem.classList.add('upNextDialog-hidden');
|
elem.classList.add('upNextDialog-hidden');
|
||||||
|
|
||||||
var fn = onHideAnimationComplete.bind(instance);
|
const fn = onHideAnimationComplete.bind(instance);
|
||||||
instance._onHideAnimationComplete = fn;
|
instance._onHideAnimationComplete = fn;
|
||||||
|
|
||||||
dom.addEventListener(elem, transitionEndEventName, fn, {
|
dom.addEventListener(elem, transitionEndEventName, fn, {
|
||||||
|
@ -239,12 +251,12 @@ define(['dom', 'playbackManager', 'connectionManager', 'events', 'mediaInfo', 'l
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTimeRemainingMs(instance) {
|
function getTimeRemainingMs(instance) {
|
||||||
var options = instance.options;
|
const options = instance.options;
|
||||||
if (options) {
|
if (options) {
|
||||||
var runtimeTicks = playbackManager.duration(options.player);
|
const runtimeTicks = playbackManager.duration(options.player);
|
||||||
|
|
||||||
if (runtimeTicks) {
|
if (runtimeTicks) {
|
||||||
var timeRemainingTicks = runtimeTicks - playbackManager.currentTime(options.player);
|
const timeRemainingTicks = runtimeTicks - playbackManager.currentTime(options.player);
|
||||||
|
|
||||||
return Math.round(timeRemainingTicks / 10000);
|
return Math.round(timeRemainingTicks / 10000);
|
||||||
}
|
}
|
||||||
|
@ -254,7 +266,7 @@ define(['dom', 'playbackManager', 'connectionManager', 'events', 'mediaInfo', 'l
|
||||||
}
|
}
|
||||||
|
|
||||||
function startComingUpNextHideTimer(instance) {
|
function startComingUpNextHideTimer(instance) {
|
||||||
var timeRemainingMs = getTimeRemainingMs(instance);
|
const timeRemainingMs = getTimeRemainingMs(instance);
|
||||||
|
|
||||||
if (timeRemainingMs <= 0) {
|
if (timeRemainingMs <= 0) {
|
||||||
return;
|
return;
|
||||||
|
@ -266,14 +278,14 @@ define(['dom', 'playbackManager', 'connectionManager', 'events', 'mediaInfo', 'l
|
||||||
instance._countdownTextTimeout = setInterval(setNextVideoText.bind(instance), 400);
|
instance._countdownTextTimeout = setInterval(setNextVideoText.bind(instance), 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
function UpNextDialog(options) {
|
class UpNextDialog {
|
||||||
|
constructor(options) {
|
||||||
this.options = options;
|
this.options = options;
|
||||||
|
|
||||||
init(this, options);
|
init(this, options);
|
||||||
}
|
}
|
||||||
|
show() {
|
||||||
UpNextDialog.prototype.show = function () {
|
const elem = this.options.parent;
|
||||||
var elem = this.options.parent;
|
|
||||||
|
|
||||||
clearHideAnimationEventListeners(this, elem);
|
clearHideAnimationEventListeners(this, elem);
|
||||||
|
|
||||||
|
@ -291,18 +303,18 @@ define(['dom', 'playbackManager', 'connectionManager', 'events', 'mediaInfo', 'l
|
||||||
}
|
}
|
||||||
|
|
||||||
startComingUpNextHideTimer(this);
|
startComingUpNextHideTimer(this);
|
||||||
};
|
}
|
||||||
|
hide() {
|
||||||
UpNextDialog.prototype.hide = function () {
|
|
||||||
hideComingUpNext.call(this);
|
hideComingUpNext.call(this);
|
||||||
};
|
}
|
||||||
|
destroy() {
|
||||||
UpNextDialog.prototype.destroy = function () {
|
|
||||||
hideComingUpNext.call(this);
|
hideComingUpNext.call(this);
|
||||||
|
|
||||||
this.options = null;
|
this.options = null;
|
||||||
this.itemType = null;
|
this.itemType = null;
|
||||||
};
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return UpNextDialog;
|
export default UpNextDialog;
|
||||||
});
|
|
||||||
|
/* eslint-enable indent */
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
define(['browser', 'dom', 'layoutManager', 'css!components/viewManager/viewContainer'], function (browser, dom, layoutManager) {
|
import 'css!components/viewManager/viewContainer';
|
||||||
'use strict';
|
/* eslint-disable indent */
|
||||||
|
|
||||||
function setControllerClass(view, options) {
|
function setControllerClass(view, options) {
|
||||||
if (options.controllerFactory) {
|
if (options.controllerFactory) {
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
var controllerUrl = view.getAttribute('data-controller');
|
let controllerUrl = view.getAttribute('data-controller');
|
||||||
|
|
||||||
if (controllerUrl) {
|
if (controllerUrl) {
|
||||||
if (controllerUrl.indexOf('__plugin/') === 0) {
|
if (controllerUrl.indexOf('__plugin/') === 0) {
|
||||||
|
@ -14,7 +14,7 @@ define(['browser', 'dom', 'layoutManager', 'css!components/viewManager/viewConta
|
||||||
}
|
}
|
||||||
|
|
||||||
controllerUrl = Dashboard.getConfigurationResourceUrl(controllerUrl);
|
controllerUrl = Dashboard.getConfigurationResourceUrl(controllerUrl);
|
||||||
return getRequirePromise([controllerUrl]).then(function (ControllerFactory) {
|
return import(controllerUrl).then((ControllerFactory) => {
|
||||||
options.controllerFactory = ControllerFactory;
|
options.controllerFactory = ControllerFactory;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -22,94 +22,85 @@ define(['browser', 'dom', 'layoutManager', 'css!components/viewManager/viewConta
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
function getRequirePromise(deps) {
|
export function loadView(options) {
|
||||||
return new Promise(function (resolve, reject) {
|
|
||||||
require(deps, resolve);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function loadView(options) {
|
|
||||||
if (!options.cancel) {
|
if (!options.cancel) {
|
||||||
var selected = selectedPageIndex;
|
const selected = selectedPageIndex;
|
||||||
var previousAnimatable = selected === -1 ? null : allPages[selected];
|
const previousAnimatable = selected === -1 ? null : allPages[selected];
|
||||||
var pageIndex = selected + 1;
|
let pageIndex = selected + 1;
|
||||||
|
|
||||||
if (pageIndex >= pageContainerCount) {
|
if (pageIndex >= pageContainerCount) {
|
||||||
pageIndex = 0;
|
pageIndex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
var isPluginpage = options.url.toLowerCase().indexOf('/configurationpage') !== -1;
|
const isPluginpage = options.url.toLowerCase().indexOf('/configurationpage') !== -1;
|
||||||
var newViewInfo = normalizeNewView(options, isPluginpage);
|
const newViewInfo = normalizeNewView(options, isPluginpage);
|
||||||
var newView = newViewInfo.elem;
|
const newView = newViewInfo.elem;
|
||||||
var modulesToLoad = [];
|
|
||||||
|
|
||||||
return new Promise(function (resolve) {
|
return new Promise((resolve) => {
|
||||||
require(modulesToLoad, function () {
|
const currentPage = allPages[pageIndex];
|
||||||
var currentPage = allPages[pageIndex];
|
|
||||||
|
|
||||||
if (currentPage) {
|
if (currentPage) {
|
||||||
triggerDestroy(currentPage);
|
triggerDestroy(currentPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
var view = newView;
|
let view = newView;
|
||||||
|
|
||||||
if (typeof view == 'string') {
|
if (typeof view == 'string') {
|
||||||
view = document.createElement('div');
|
view = document.createElement('div');
|
||||||
view.innerHTML = newView;
|
view.innerHTML = newView;
|
||||||
}
|
}
|
||||||
|
|
||||||
view.classList.add('mainAnimatedPage');
|
view.classList.add('mainAnimatedPage');
|
||||||
|
|
||||||
if (currentPage) {
|
if (currentPage) {
|
||||||
if (newViewInfo.hasScript && window.$) {
|
if (newViewInfo.hasScript && window.$) {
|
||||||
view = $(view).appendTo(mainAnimatedPages)[0];
|
mainAnimatedPages.removeChild(currentPage);
|
||||||
mainAnimatedPages.removeChild(currentPage);
|
view = $(view).appendTo(mainAnimatedPages)[0];
|
||||||
} else {
|
|
||||||
mainAnimatedPages.replaceChild(view, currentPage);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (newViewInfo.hasScript && window.$) {
|
mainAnimatedPages.replaceChild(view, currentPage);
|
||||||
view = $(view).appendTo(mainAnimatedPages)[0];
|
}
|
||||||
} else {
|
} else {
|
||||||
mainAnimatedPages.appendChild(view);
|
if (newViewInfo.hasScript && window.$) {
|
||||||
}
|
view = $(view).appendTo(mainAnimatedPages)[0];
|
||||||
|
} else {
|
||||||
|
mainAnimatedPages.appendChild(view);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (options.type) {
|
||||||
|
view.setAttribute('data-type', options.type);
|
||||||
|
}
|
||||||
|
|
||||||
|
const properties = [];
|
||||||
|
|
||||||
|
if (options.fullscreen) {
|
||||||
|
properties.push('fullscreen');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (properties.length) {
|
||||||
|
view.setAttribute('data-properties', properties.join(','));
|
||||||
|
}
|
||||||
|
|
||||||
|
allPages[pageIndex] = view;
|
||||||
|
setControllerClass(view, options).then(() => {
|
||||||
|
if (onBeforeChange) {
|
||||||
|
onBeforeChange(view, false, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.type) {
|
beforeAnimate(allPages, pageIndex, selected);
|
||||||
view.setAttribute('data-type', options.type);
|
selectedPageIndex = pageIndex;
|
||||||
|
currentUrls[pageIndex] = options.url;
|
||||||
|
|
||||||
|
if (!options.cancel && previousAnimatable) {
|
||||||
|
afterAnimate(allPages, pageIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
var properties = [];
|
if (window.$) {
|
||||||
|
$.mobile = $.mobile || {};
|
||||||
if (options.fullscreen) {
|
$.mobile.activePage = view;
|
||||||
properties.push('fullscreen');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (properties.length) {
|
resolve(view);
|
||||||
view.setAttribute('data-properties', properties.join(','));
|
|
||||||
}
|
|
||||||
|
|
||||||
allPages[pageIndex] = view;
|
|
||||||
setControllerClass(view, options).then(function () {
|
|
||||||
if (onBeforeChange) {
|
|
||||||
onBeforeChange(view, false, options);
|
|
||||||
}
|
|
||||||
|
|
||||||
beforeAnimate(allPages, pageIndex, selected);
|
|
||||||
selectedPageIndex = pageIndex;
|
|
||||||
currentUrls[pageIndex] = options.url;
|
|
||||||
|
|
||||||
if (!options.cancel && previousAnimatable) {
|
|
||||||
afterAnimate(allPages, pageIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (window.$) {
|
|
||||||
$.mobile = $.mobile || {};
|
|
||||||
$.mobile.activePage = view;
|
|
||||||
}
|
|
||||||
|
|
||||||
resolve(view);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -125,28 +116,28 @@ define(['browser', 'dom', 'layoutManager', 'css!components/viewManager/viewConta
|
||||||
html = replaceAll(html, '<\/script>--\x3e', '<\/script>');
|
html = replaceAll(html, '<\/script>--\x3e', '<\/script>');
|
||||||
}
|
}
|
||||||
|
|
||||||
var wrapper = document.createElement('div');
|
const wrapper = document.createElement('div');
|
||||||
wrapper.innerHTML = html;
|
wrapper.innerHTML = html;
|
||||||
return wrapper.querySelector('div[data-role="page"]');
|
return wrapper.querySelector('div[data-role="page"]');
|
||||||
}
|
}
|
||||||
|
|
||||||
function normalizeNewView(options, isPluginpage) {
|
function normalizeNewView(options, isPluginpage) {
|
||||||
var viewHtml = options.view;
|
const viewHtml = options.view;
|
||||||
|
|
||||||
if (viewHtml.indexOf('data-role="page"') === -1) {
|
if (viewHtml.indexOf('data-role="page"') === -1) {
|
||||||
return viewHtml;
|
return viewHtml;
|
||||||
}
|
}
|
||||||
|
|
||||||
var hasScript = viewHtml.indexOf('<script') !== -1;
|
let hasScript = viewHtml.indexOf('<script') !== -1;
|
||||||
var elem = parseHtml(viewHtml, hasScript);
|
const elem = parseHtml(viewHtml, hasScript);
|
||||||
|
|
||||||
if (hasScript) {
|
if (hasScript) {
|
||||||
hasScript = elem.querySelector('script') != null;
|
hasScript = elem.querySelector('script') != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
var hasjQuery = false;
|
let hasjQuery = false;
|
||||||
var hasjQuerySelect = false;
|
let hasjQuerySelect = false;
|
||||||
var hasjQueryChecked = false;
|
let hasjQueryChecked = false;
|
||||||
|
|
||||||
if (isPluginpage) {
|
if (isPluginpage) {
|
||||||
hasjQuery = viewHtml.indexOf('jQuery') != -1 || viewHtml.indexOf('$(') != -1 || viewHtml.indexOf('$.') != -1;
|
hasjQuery = viewHtml.indexOf('jQuery') != -1 || viewHtml.indexOf('$(') != -1 || viewHtml.indexOf('$.') != -1;
|
||||||
|
@ -164,7 +155,7 @@ define(['browser', 'dom', 'layoutManager', 'css!components/viewManager/viewConta
|
||||||
}
|
}
|
||||||
|
|
||||||
function beforeAnimate(allPages, newPageIndex, oldPageIndex) {
|
function beforeAnimate(allPages, newPageIndex, oldPageIndex) {
|
||||||
for (var index = 0, length = allPages.length; index < length; index++) {
|
for (let index = 0, length = allPages.length; index < length; index++) {
|
||||||
if (newPageIndex !== index && oldPageIndex !== index) {
|
if (newPageIndex !== index && oldPageIndex !== index) {
|
||||||
allPages[index].classList.add('hide');
|
allPages[index].classList.add('hide');
|
||||||
}
|
}
|
||||||
|
@ -172,33 +163,33 @@ define(['browser', 'dom', 'layoutManager', 'css!components/viewManager/viewConta
|
||||||
}
|
}
|
||||||
|
|
||||||
function afterAnimate(allPages, newPageIndex) {
|
function afterAnimate(allPages, newPageIndex) {
|
||||||
for (var index = 0, length = allPages.length; index < length; index++) {
|
for (let index = 0, length = allPages.length; index < length; index++) {
|
||||||
if (newPageIndex !== index) {
|
if (newPageIndex !== index) {
|
||||||
allPages[index].classList.add('hide');
|
allPages[index].classList.add('hide');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function setOnBeforeChange(fn) {
|
export function setOnBeforeChange(fn) {
|
||||||
onBeforeChange = fn;
|
onBeforeChange = fn;
|
||||||
}
|
}
|
||||||
|
|
||||||
function tryRestoreView(options) {
|
export function tryRestoreView(options) {
|
||||||
var url = options.url;
|
const url = options.url;
|
||||||
var index = currentUrls.indexOf(url);
|
const index = currentUrls.indexOf(url);
|
||||||
|
|
||||||
if (index !== -1) {
|
if (index !== -1) {
|
||||||
var animatable = allPages[index];
|
const animatable = allPages[index];
|
||||||
var view = animatable;
|
const view = animatable;
|
||||||
|
|
||||||
if (view) {
|
if (view) {
|
||||||
if (options.cancel) {
|
if (options.cancel) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var selected = selectedPageIndex;
|
const selected = selectedPageIndex;
|
||||||
var previousAnimatable = selected === -1 ? null : allPages[selected];
|
const previousAnimatable = selected === -1 ? null : allPages[selected];
|
||||||
return setControllerClass(view, options).then(function () {
|
return setControllerClass(view, options).then(() => {
|
||||||
if (onBeforeChange) {
|
if (onBeforeChange) {
|
||||||
onBeforeChange(view, true, options);
|
onBeforeChange(view, true, options);
|
||||||
}
|
}
|
||||||
|
@ -228,25 +219,28 @@ define(['browser', 'dom', 'layoutManager', 'css!components/viewManager/viewConta
|
||||||
view.dispatchEvent(new CustomEvent('viewdestroy', {}));
|
view.dispatchEvent(new CustomEvent('viewdestroy', {}));
|
||||||
}
|
}
|
||||||
|
|
||||||
function reset() {
|
export function reset() {
|
||||||
allPages = [];
|
allPages = [];
|
||||||
currentUrls = [];
|
currentUrls = [];
|
||||||
mainAnimatedPages.innerHTML = '';
|
mainAnimatedPages.innerHTML = '';
|
||||||
selectedPageIndex = -1;
|
selectedPageIndex = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
var onBeforeChange;
|
let onBeforeChange;
|
||||||
var mainAnimatedPages = document.querySelector('.mainAnimatedPages');
|
const mainAnimatedPages = document.querySelector('.mainAnimatedPages');
|
||||||
var allPages = [];
|
let allPages = [];
|
||||||
var currentUrls = [];
|
let currentUrls = [];
|
||||||
var pageContainerCount = 3;
|
const pageContainerCount = 3;
|
||||||
var selectedPageIndex = -1;
|
let selectedPageIndex = -1;
|
||||||
reset();
|
reset();
|
||||||
mainAnimatedPages.classList.remove('hide');
|
mainAnimatedPages.classList.remove('hide');
|
||||||
return {
|
|
||||||
loadView: loadView,
|
/* eslint-enable indent */
|
||||||
tryRestoreView: tryRestoreView,
|
|
||||||
reset: reset,
|
export default {
|
||||||
setOnBeforeChange: setOnBeforeChange
|
loadView: loadView,
|
||||||
};
|
tryRestoreView: tryRestoreView,
|
||||||
});
|
reset: reset,
|
||||||
|
setOnBeforeChange: setOnBeforeChange
|
||||||
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,134 +1,134 @@
|
||||||
define(['viewContainer', 'focusManager', 'queryString', 'layoutManager'], function (viewContainer, focusManager, queryString, layoutManager) {
|
import viewContainer from 'viewContainer';
|
||||||
'use strict';
|
import focusManager from 'focusManager';
|
||||||
|
import queryString from 'queryString';
|
||||||
|
import layoutManager from 'layoutManager';
|
||||||
|
|
||||||
var currentView;
|
let currentView;
|
||||||
var dispatchPageEvents;
|
let dispatchPageEvents;
|
||||||
|
|
||||||
viewContainer.setOnBeforeChange(function (newView, isRestored, options) {
|
viewContainer.setOnBeforeChange(function (newView, isRestored, options) {
|
||||||
var lastView = currentView;
|
const lastView = currentView;
|
||||||
if (lastView) {
|
if (lastView) {
|
||||||
var beforeHideResult = dispatchViewEvent(lastView, null, 'viewbeforehide', true);
|
const beforeHideResult = dispatchViewEvent(lastView, null, 'viewbeforehide', true);
|
||||||
|
|
||||||
if (!beforeHideResult) {
|
if (!beforeHideResult) {
|
||||||
// todo: cancel
|
// todo: cancel
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var eventDetail = getViewEventDetail(newView, options, isRestored);
|
|
||||||
|
|
||||||
if (!newView.initComplete) {
|
|
||||||
newView.initComplete = true;
|
|
||||||
|
|
||||||
if (typeof options.controllerFactory === 'function') {
|
|
||||||
new options.controllerFactory(newView, eventDetail.detail.params);
|
|
||||||
} else if (options.controllerFactory && typeof options.controllerFactory.default === 'function') {
|
|
||||||
new options.controllerFactory.default(newView, eventDetail.detail.params);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!options.controllerFactory || dispatchPageEvents) {
|
|
||||||
dispatchViewEvent(newView, eventDetail, 'viewinit');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
dispatchViewEvent(newView, eventDetail, 'viewbeforeshow');
|
|
||||||
});
|
|
||||||
|
|
||||||
function onViewChange(view, options, isRestore) {
|
|
||||||
var lastView = currentView;
|
|
||||||
if (lastView) {
|
|
||||||
dispatchViewEvent(lastView, null, 'viewhide');
|
|
||||||
}
|
|
||||||
|
|
||||||
currentView = view;
|
|
||||||
|
|
||||||
var eventDetail = getViewEventDetail(view, options, isRestore);
|
|
||||||
|
|
||||||
if (!isRestore) {
|
|
||||||
if (options.autoFocus !== false) {
|
|
||||||
focusManager.autoFocus(view);
|
|
||||||
}
|
|
||||||
} else if (!layoutManager.mobile) {
|
|
||||||
if (view.activeElement && document.body.contains(view.activeElement) && focusManager.isCurrentlyFocusable(view.activeElement)) {
|
|
||||||
focusManager.focus(view.activeElement);
|
|
||||||
} else {
|
|
||||||
focusManager.autoFocus(view);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
view.dispatchEvent(new CustomEvent('viewshow', eventDetail));
|
|
||||||
|
|
||||||
if (dispatchPageEvents) {
|
|
||||||
view.dispatchEvent(new CustomEvent('pageshow', eventDetail));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getProperties(view) {
|
const eventDetail = getViewEventDetail(newView, options, isRestored);
|
||||||
var props = view.getAttribute('data-properties');
|
|
||||||
|
|
||||||
if (props) {
|
if (!newView.initComplete) {
|
||||||
return props.split(',');
|
newView.initComplete = true;
|
||||||
|
|
||||||
|
if (typeof options.controllerFactory === 'function') {
|
||||||
|
new options.controllerFactory(newView, eventDetail.detail.params);
|
||||||
|
} else if (options.controllerFactory && typeof options.controllerFactory.default === 'function') {
|
||||||
|
new options.controllerFactory.default(newView, eventDetail.detail.params);
|
||||||
}
|
}
|
||||||
|
|
||||||
return [];
|
if (!options.controllerFactory || dispatchPageEvents) {
|
||||||
|
dispatchViewEvent(newView, eventDetail, 'viewinit');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function dispatchViewEvent(view, eventInfo, eventName, isCancellable) {
|
dispatchViewEvent(newView, eventDetail, 'viewbeforeshow');
|
||||||
if (!eventInfo) {
|
});
|
||||||
eventInfo = {
|
|
||||||
detail: {
|
|
||||||
type: view.getAttribute('data-type'),
|
|
||||||
properties: getProperties(view)
|
|
||||||
},
|
|
||||||
bubbles: true,
|
|
||||||
cancelable: isCancellable
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
eventInfo.cancelable = isCancellable || false;
|
function onViewChange(view, options, isRestore) {
|
||||||
|
const lastView = currentView;
|
||||||
var eventResult = view.dispatchEvent(new CustomEvent(eventName, eventInfo));
|
if (lastView) {
|
||||||
|
dispatchViewEvent(lastView, null, 'viewhide');
|
||||||
if (dispatchPageEvents) {
|
|
||||||
eventInfo.cancelable = false;
|
|
||||||
view.dispatchEvent(new CustomEvent(eventName.replace('view', 'page'), eventInfo));
|
|
||||||
}
|
|
||||||
|
|
||||||
return eventResult;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getViewEventDetail(view, options, isRestore) {
|
currentView = view;
|
||||||
var url = options.url;
|
|
||||||
var index = url.indexOf('?');
|
|
||||||
var params = index === -1 ? {} : queryString.parse(url.substring(index + 1));
|
|
||||||
|
|
||||||
return {
|
const eventDetail = getViewEventDetail(view, options, isRestore);
|
||||||
|
|
||||||
|
if (!isRestore) {
|
||||||
|
if (options.autoFocus !== false) {
|
||||||
|
focusManager.autoFocus(view);
|
||||||
|
}
|
||||||
|
} else if (!layoutManager.mobile) {
|
||||||
|
if (view.activeElement && document.body.contains(view.activeElement) && focusManager.isCurrentlyFocusable(view.activeElement)) {
|
||||||
|
focusManager.focus(view.activeElement);
|
||||||
|
} else {
|
||||||
|
focusManager.autoFocus(view);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
view.dispatchEvent(new CustomEvent('viewshow', eventDetail));
|
||||||
|
|
||||||
|
if (dispatchPageEvents) {
|
||||||
|
view.dispatchEvent(new CustomEvent('pageshow', eventDetail));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getProperties(view) {
|
||||||
|
const props = view.getAttribute('data-properties');
|
||||||
|
|
||||||
|
if (props) {
|
||||||
|
return props.split(',');
|
||||||
|
}
|
||||||
|
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
function dispatchViewEvent(view, eventInfo, eventName, isCancellable) {
|
||||||
|
if (!eventInfo) {
|
||||||
|
eventInfo = {
|
||||||
detail: {
|
detail: {
|
||||||
type: view.getAttribute('data-type'),
|
type: view.getAttribute('data-type'),
|
||||||
properties: getProperties(view),
|
properties: getProperties(view)
|
||||||
params: params,
|
|
||||||
isRestored: isRestore,
|
|
||||||
state: options.state,
|
|
||||||
|
|
||||||
// The route options
|
|
||||||
options: options.options || {}
|
|
||||||
},
|
},
|
||||||
bubbles: true,
|
bubbles: true,
|
||||||
cancelable: false
|
cancelable: isCancellable
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function resetCachedViews() {
|
eventInfo.cancelable = isCancellable || false;
|
||||||
// Reset all cached views whenever the skin changes
|
|
||||||
viewContainer.reset();
|
const eventResult = view.dispatchEvent(new CustomEvent(eventName, eventInfo));
|
||||||
|
|
||||||
|
if (dispatchPageEvents) {
|
||||||
|
eventInfo.cancelable = false;
|
||||||
|
view.dispatchEvent(new CustomEvent(eventName.replace('view', 'page'), eventInfo));
|
||||||
}
|
}
|
||||||
|
|
||||||
document.addEventListener('skinunload', resetCachedViews);
|
return eventResult;
|
||||||
|
}
|
||||||
|
|
||||||
function ViewManager() {
|
function getViewEventDetail(view, options, isRestore) {
|
||||||
}
|
const url = options.url;
|
||||||
|
const index = url.indexOf('?');
|
||||||
|
const params = index === -1 ? {} : queryString.parse(url.substring(index + 1));
|
||||||
|
|
||||||
ViewManager.prototype.loadView = function (options) {
|
return {
|
||||||
var lastView = currentView;
|
detail: {
|
||||||
|
type: view.getAttribute('data-type'),
|
||||||
|
properties: getProperties(view),
|
||||||
|
params: params,
|
||||||
|
isRestored: isRestore,
|
||||||
|
state: options.state,
|
||||||
|
|
||||||
|
// The route options
|
||||||
|
options: options.options || {}
|
||||||
|
},
|
||||||
|
bubbles: true,
|
||||||
|
cancelable: false
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function resetCachedViews() {
|
||||||
|
// Reset all cached views whenever the skin changes
|
||||||
|
viewContainer.reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
document.addEventListener('skinunload', resetCachedViews);
|
||||||
|
|
||||||
|
class ViewManager {
|
||||||
|
loadView(options) {
|
||||||
|
const lastView = currentView;
|
||||||
|
|
||||||
// Record the element that has focus
|
// Record the element that has focus
|
||||||
if (lastView) {
|
if (lastView) {
|
||||||
|
@ -142,9 +142,9 @@ define(['viewContainer', 'focusManager', 'queryString', 'layoutManager'], functi
|
||||||
viewContainer.loadView(options).then(function (view) {
|
viewContainer.loadView(options).then(function (view) {
|
||||||
onViewChange(view, options);
|
onViewChange(view, options);
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
ViewManager.prototype.tryRestoreView = function (options, onViewChanging) {
|
tryRestoreView(options, onViewChanging) {
|
||||||
if (options.cancel) {
|
if (options.cancel) {
|
||||||
return Promise.reject({ cancelled: true });
|
return Promise.reject({ cancelled: true });
|
||||||
}
|
}
|
||||||
|
@ -158,15 +158,15 @@ define(['viewContainer', 'focusManager', 'queryString', 'layoutManager'], functi
|
||||||
onViewChanging();
|
onViewChanging();
|
||||||
onViewChange(view, options, true);
|
onViewChange(view, options, true);
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
ViewManager.prototype.currentView = function () {
|
currentView() {
|
||||||
return currentView;
|
return currentView;
|
||||||
};
|
}
|
||||||
|
|
||||||
ViewManager.prototype.dispatchPageEvents = function (value) {
|
dispatchPageEvents(value) {
|
||||||
dispatchPageEvents = value;
|
dispatchPageEvents = value;
|
||||||
};
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return new ViewManager();
|
export default new ViewManager();
|
||||||
});
|
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
define(['require', 'dialogHelper', 'loading', 'apphost', 'layoutManager', 'connectionManager', 'appRouter', 'globalize', 'userSettings', 'emby-checkbox', 'emby-input', 'paper-icon-button-light', 'emby-select', 'material-icons', 'css!./../formdialog', 'emby-button', 'flexStyles'], function (require, dialogHelper, loading, appHost, layoutManager, connectionManager, appRouter, globalize, userSettings) {
|
define(['require', 'dialogHelper', 'loading', 'apphost', 'layoutManager', 'connectionManager', 'appRouter', 'globalize', 'userSettings', 'emby-checkbox', 'emby-input', 'paper-icon-button-light', 'emby-select', 'material-icons', 'css!./../formdialog', 'emby-button', 'flexStyles'], function (require, dialogHelper, loading, appHost, layoutManager, connectionManager, appRouter, globalize, userSettings) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
layoutManager = layoutManager.default || layoutManager;
|
||||||
|
|
||||||
function onSubmit(e) {
|
function onSubmit(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
return false;
|
return false;
|
||||||
|
@ -29,6 +31,7 @@ define(['require', 'dialogHelper', 'loading', 'apphost', 'layoutManager', 'conne
|
||||||
|
|
||||||
function centerFocus(elem, horiz, on) {
|
function centerFocus(elem, horiz, on) {
|
||||||
require(['scrollHelper'], function (scrollHelper) {
|
require(['scrollHelper'], function (scrollHelper) {
|
||||||
|
scrollHelper = scrollHelper.default || scrollHelper;
|
||||||
var fn = on ? 'on' : 'off';
|
var fn = on ? 'on' : 'off';
|
||||||
scrollHelper.centerFocus[fn](elem, horiz);
|
scrollHelper.centerFocus[fn](elem, horiz);
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,3 +1,38 @@
|
||||||
{
|
{
|
||||||
"multiserver": false
|
"multiserver": false,
|
||||||
|
"themes": [
|
||||||
|
{
|
||||||
|
"name": "Apple TV",
|
||||||
|
"id": "appletv"
|
||||||
|
}, {
|
||||||
|
"name": "Blue Radiance",
|
||||||
|
"id": "blueradiance"
|
||||||
|
}, {
|
||||||
|
"name": "Dark",
|
||||||
|
"id": "dark",
|
||||||
|
"default": true
|
||||||
|
}, {
|
||||||
|
"name": "Light",
|
||||||
|
"id": "light"
|
||||||
|
}, {
|
||||||
|
"name": "Purple Haze",
|
||||||
|
"id": "purplehaze"
|
||||||
|
}, {
|
||||||
|
"name": "WMC",
|
||||||
|
"id": "wmc"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"plugins": [
|
||||||
|
"plugins/playAccessValidation/plugin",
|
||||||
|
"plugins/experimentalWarnings/plugin",
|
||||||
|
"plugins/htmlAudioPlayer/plugin",
|
||||||
|
"plugins/htmlVideoPlayer/plugin",
|
||||||
|
"plugins/photoPlayer/plugin",
|
||||||
|
"plugins/bookPlayer/plugin",
|
||||||
|
"plugins/youtubePlayer/plugin",
|
||||||
|
"plugins/backdropScreensaver/plugin",
|
||||||
|
"plugins/logoScreensaver/plugin",
|
||||||
|
"plugins/sessionPlayer/plugin",
|
||||||
|
"plugins/chromecastPlayer/plugin"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,7 +83,7 @@ import libraryMenu from 'libraryMenu';
|
||||||
updateEncoder(form);
|
updateEncoder(form);
|
||||||
}, function () {
|
}, function () {
|
||||||
import('alert').then(({default: alert}) => {
|
import('alert').then(({default: alert}) => {
|
||||||
alert(globalize.translate('DefaultErrorMessage'));
|
alert(globalize.translate('ErrorDefault'));
|
||||||
});
|
});
|
||||||
|
|
||||||
Dashboard.processServerConfigurationUpdateResult();
|
Dashboard.processServerConfigurationUpdateResult();
|
||||||
|
|
|
@ -52,7 +52,7 @@ import 'emby-button';
|
||||||
});
|
});
|
||||||
}, function () {
|
}, function () {
|
||||||
import('alert').then(({default: alert}) => {
|
import('alert').then(({default: alert}) => {
|
||||||
alert(globalize.translate('DefaultErrorMessage'));
|
alert(globalize.translate('ErrorDefault'));
|
||||||
});
|
});
|
||||||
|
|
||||||
Dashboard.processServerConfigurationUpdateResult();
|
Dashboard.processServerConfigurationUpdateResult();
|
||||||
|
|
|
@ -1,119 +1,118 @@
|
||||||
define(['jQuery', 'emby-checkbox'], function ($) {
|
import $ from 'jQuery';
|
||||||
'use strict';
|
import 'emby-checkbox';
|
||||||
|
|
||||||
function fillItems(elem, items, cssClass, idPrefix, currentList, isEnabledList) {
|
function fillItems(elem, items, cssClass, idPrefix, currentList, isEnabledList) {
|
||||||
var html = '<div class="checkboxList paperList" style="padding: .5em 1em;">';
|
let html = '<div class="checkboxList paperList" style="padding: .5em 1em;">';
|
||||||
html += items.map(function (u) {
|
html += items.map(function (u) {
|
||||||
var isChecked = isEnabledList ? currentList.indexOf(u.Id) != -1 : currentList.indexOf(u.Id) == -1;
|
const isChecked = isEnabledList ? currentList.indexOf(u.Id) != -1 : currentList.indexOf(u.Id) == -1;
|
||||||
var checkedHtml = isChecked ? ' checked="checked"' : '';
|
const checkedHtml = isChecked ? ' checked="checked"' : '';
|
||||||
return '<label><input is="emby-checkbox" class="' + cssClass + '" type="checkbox" data-itemid="' + u.Id + '"' + checkedHtml + '/><span>' + u.Name + '</span></label>';
|
return '<label><input is="emby-checkbox" class="' + cssClass + '" type="checkbox" data-itemid="' + u.Id + '"' + checkedHtml + '/><span>' + u.Name + '</span></label>';
|
||||||
}).join('');
|
}).join('');
|
||||||
html += '</div>';
|
html += '</div>';
|
||||||
elem.html(html).trigger('create');
|
elem.html(html).trigger('create');
|
||||||
}
|
}
|
||||||
|
|
||||||
function reload(page) {
|
function reload(page) {
|
||||||
var type = getParameterByName('type');
|
const type = getParameterByName('type');
|
||||||
var promise1 = ApiClient.getUsers();
|
const promise1 = ApiClient.getUsers();
|
||||||
var promise2 = ApiClient.getNamedConfiguration(notificationsConfigurationKey);
|
const promise2 = ApiClient.getNamedConfiguration(notificationsConfigurationKey);
|
||||||
var promise3 = ApiClient.getJSON(ApiClient.getUrl('Notifications/Types'));
|
const promise3 = ApiClient.getJSON(ApiClient.getUrl('Notifications/Types'));
|
||||||
var promise4 = ApiClient.getJSON(ApiClient.getUrl('Notifications/Services'));
|
const promise4 = ApiClient.getJSON(ApiClient.getUrl('Notifications/Services'));
|
||||||
Promise.all([promise1, promise2, promise3, promise4]).then(function (responses) {
|
Promise.all([promise1, promise2, promise3, promise4]).then(function (responses) {
|
||||||
var users = responses[0];
|
const users = responses[0];
|
||||||
var notificationOptions = responses[1];
|
const notificationOptions = responses[1];
|
||||||
var types = responses[2];
|
const types = responses[2];
|
||||||
var services = responses[3];
|
const services = responses[3];
|
||||||
var notificationConfig = notificationOptions.Options.filter(function (n) {
|
let notificationConfig = notificationOptions.Options.filter(function (n) {
|
||||||
return n.Type == type;
|
return n.Type == type;
|
||||||
})[0];
|
})[0];
|
||||||
var typeInfo = types.filter(function (n) {
|
const typeInfo = types.filter(function (n) {
|
||||||
return n.Type == type;
|
return n.Type == type;
|
||||||
})[0] || {};
|
})[0] || {};
|
||||||
|
|
||||||
if (typeInfo.IsBasedOnUserEvent) {
|
if (typeInfo.IsBasedOnUserEvent) {
|
||||||
$('.monitorUsers', page).show();
|
$('.monitorUsers', page).show();
|
||||||
} else {
|
} else {
|
||||||
$('.monitorUsers', page).hide();
|
$('.monitorUsers', page).hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
$('.notificationType', page).html(typeInfo.Name || 'Unknown Notification');
|
$('.notificationType', page).html(typeInfo.Name || 'Unknown Notification');
|
||||||
|
|
||||||
if (!notificationConfig) {
|
if (!notificationConfig) {
|
||||||
notificationConfig = {
|
notificationConfig = {
|
||||||
DisabledMonitorUsers: [],
|
DisabledMonitorUsers: [],
|
||||||
SendToUsers: [],
|
SendToUsers: [],
|
||||||
DisabledServices: [],
|
DisabledServices: [],
|
||||||
SendToUserMode: 'Admins'
|
SendToUserMode: 'Admins'
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
fillItems($('.monitorUsersList', page), users, 'chkMonitor', 'chkMonitor', notificationConfig.DisabledMonitorUsers);
|
fillItems($('.monitorUsersList', page), users, 'chkMonitor', 'chkMonitor', notificationConfig.DisabledMonitorUsers);
|
||||||
fillItems($('.sendToUsersList', page), users, 'chkSendTo', 'chkSendTo', notificationConfig.SendToUsers, true);
|
fillItems($('.sendToUsersList', page), users, 'chkSendTo', 'chkSendTo', notificationConfig.SendToUsers, true);
|
||||||
fillItems($('.servicesList', page), services, 'chkService', 'chkService', notificationConfig.DisabledServices);
|
fillItems($('.servicesList', page), services, 'chkService', 'chkService', notificationConfig.DisabledServices);
|
||||||
$('#chkEnabled', page).prop('checked', notificationConfig.Enabled || false);
|
$('#chkEnabled', page).prop('checked', notificationConfig.Enabled || false);
|
||||||
$('#selectUsers', page).val(notificationConfig.SendToUserMode).trigger('change');
|
$('#selectUsers', page).val(notificationConfig.SendToUserMode).trigger('change');
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function save(page) {
|
|
||||||
var type = getParameterByName('type');
|
|
||||||
var promise1 = ApiClient.getNamedConfiguration(notificationsConfigurationKey);
|
|
||||||
// TODO: Check if this promise is really needed, as it's unused.
|
|
||||||
var promise2 = ApiClient.getJSON(ApiClient.getUrl('Notifications/Types'));
|
|
||||||
Promise.all([promise1, promise2]).then(function (responses) {
|
|
||||||
var notificationOptions = responses[0];
|
|
||||||
var notificationConfig = notificationOptions.Options.filter(function (n) {
|
|
||||||
return n.Type == type;
|
|
||||||
})[0];
|
|
||||||
|
|
||||||
if (!notificationConfig) {
|
|
||||||
notificationConfig = {
|
|
||||||
Type: type
|
|
||||||
};
|
|
||||||
notificationOptions.Options.push(notificationConfig);
|
|
||||||
}
|
|
||||||
|
|
||||||
notificationConfig.Enabled = $('#chkEnabled', page).is(':checked');
|
|
||||||
notificationConfig.SendToUserMode = $('#selectUsers', page).val();
|
|
||||||
notificationConfig.DisabledMonitorUsers = $('.chkMonitor', page).get().filter(function (c) {
|
|
||||||
return !c.checked;
|
|
||||||
}).map(function (c) {
|
|
||||||
return c.getAttribute('data-itemid');
|
|
||||||
});
|
|
||||||
notificationConfig.SendToUsers = $('.chkSendTo', page).get().filter(function (c) {
|
|
||||||
return c.checked;
|
|
||||||
}).map(function (c) {
|
|
||||||
return c.getAttribute('data-itemid');
|
|
||||||
});
|
|
||||||
notificationConfig.DisabledServices = $('.chkService', page).get().filter(function (c) {
|
|
||||||
return !c.checked;
|
|
||||||
}).map(function (c) {
|
|
||||||
return c.getAttribute('data-itemid');
|
|
||||||
});
|
|
||||||
ApiClient.updateNamedConfiguration(notificationsConfigurationKey, notificationOptions).then(function (r) {
|
|
||||||
Dashboard.processServerConfigurationUpdateResult();
|
|
||||||
Dashboard.navigate('notificationsettings.html');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function onSubmit() {
|
|
||||||
save($(this).parents('.page'));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
var notificationsConfigurationKey = 'notifications';
|
|
||||||
$(document).on('pageinit', '#notificationSettingPage', function () {
|
|
||||||
var page = this;
|
|
||||||
$('#selectUsers', page).on('change', function () {
|
|
||||||
if (this.value == 'Custom') {
|
|
||||||
$('.selectCustomUsers', page).show();
|
|
||||||
} else {
|
|
||||||
$('.selectCustomUsers', page).hide();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
$('.notificationSettingForm').off('submit', onSubmit).on('submit', onSubmit);
|
|
||||||
}).on('pageshow', '#notificationSettingPage', function () {
|
|
||||||
reload(this);
|
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function save(page) {
|
||||||
|
const type = getParameterByName('type');
|
||||||
|
const promise1 = ApiClient.getNamedConfiguration(notificationsConfigurationKey);
|
||||||
|
// TODO: Check if this promise is really needed, as it's unused.
|
||||||
|
const promise2 = ApiClient.getJSON(ApiClient.getUrl('Notifications/Types'));
|
||||||
|
Promise.all([promise1, promise2]).then(function (responses) {
|
||||||
|
const notificationOptions = responses[0];
|
||||||
|
let notificationConfig = notificationOptions.Options.filter(function (n) {
|
||||||
|
return n.Type == type;
|
||||||
|
})[0];
|
||||||
|
|
||||||
|
if (!notificationConfig) {
|
||||||
|
notificationConfig = {
|
||||||
|
Type: type
|
||||||
|
};
|
||||||
|
notificationOptions.Options.push(notificationConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
notificationConfig.Enabled = $('#chkEnabled', page).is(':checked');
|
||||||
|
notificationConfig.SendToUserMode = $('#selectUsers', page).val();
|
||||||
|
notificationConfig.DisabledMonitorUsers = $('.chkMonitor', page).get().filter(function (c) {
|
||||||
|
return !c.checked;
|
||||||
|
}).map(function (c) {
|
||||||
|
return c.getAttribute('data-itemid');
|
||||||
|
});
|
||||||
|
notificationConfig.SendToUsers = $('.chkSendTo', page).get().filter(function (c) {
|
||||||
|
return c.checked;
|
||||||
|
}).map(function (c) {
|
||||||
|
return c.getAttribute('data-itemid');
|
||||||
|
});
|
||||||
|
notificationConfig.DisabledServices = $('.chkService', page).get().filter(function (c) {
|
||||||
|
return !c.checked;
|
||||||
|
}).map(function (c) {
|
||||||
|
return c.getAttribute('data-itemid');
|
||||||
|
});
|
||||||
|
ApiClient.updateNamedConfiguration(notificationsConfigurationKey, notificationOptions).then(function (r) {
|
||||||
|
Dashboard.processServerConfigurationUpdateResult();
|
||||||
|
Dashboard.navigate('notificationsettings.html');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function onSubmit() {
|
||||||
|
save($(this).parents('.page'));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const notificationsConfigurationKey = 'notifications';
|
||||||
|
$(document).on('pageinit', '#notificationSettingPage', function () {
|
||||||
|
const page = this;
|
||||||
|
$('#selectUsers', page).on('change', function () {
|
||||||
|
if (this.value == 'Custom') {
|
||||||
|
$('.selectCustomUsers', page).show();
|
||||||
|
} else {
|
||||||
|
$('.selectCustomUsers', page).hide();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$('.notificationSettingForm').off('submit', onSubmit).on('submit', onSubmit);
|
||||||
|
}).on('pageshow', '#notificationSettingPage', function () {
|
||||||
|
reload(this);
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,60 +1,61 @@
|
||||||
define(['loading', 'libraryMenu', 'globalize', 'listViewStyle', 'emby-button'], function(loading, libraryMenu, globalize) {
|
import loading from 'loading';
|
||||||
'use strict';
|
import globalize from 'globalize';
|
||||||
|
import 'listViewStyle';
|
||||||
|
import 'emby-button';
|
||||||
|
|
||||||
function reload(page) {
|
function reload(page) {
|
||||||
loading.show();
|
loading.show();
|
||||||
ApiClient.getJSON(ApiClient.getUrl('Notifications/Types')).then(function(list) {
|
ApiClient.getJSON(ApiClient.getUrl('Notifications/Types')).then(function (list) {
|
||||||
var html = '';
|
let html = '';
|
||||||
var lastCategory = '';
|
let lastCategory = '';
|
||||||
var showHelp = true;
|
let showHelp = true;
|
||||||
html += list.map(function(notification) {
|
html += list.map(function (notification) {
|
||||||
var itemHtml = '';
|
let itemHtml = '';
|
||||||
if (notification.Category !== lastCategory) {
|
if (notification.Category !== lastCategory) {
|
||||||
lastCategory = notification.Category;
|
lastCategory = notification.Category;
|
||||||
if (lastCategory) {
|
if (lastCategory) {
|
||||||
itemHtml += '</div>';
|
itemHtml += '</div>';
|
||||||
itemHtml += '</div>';
|
|
||||||
}
|
|
||||||
itemHtml += '<div class="verticalSection verticalSection-extrabottompadding">';
|
|
||||||
itemHtml += '<div class="sectionTitleContainer" style="margin-bottom:1em;">';
|
|
||||||
itemHtml += '<h2 class="sectionTitle">';
|
|
||||||
itemHtml += notification.Category;
|
|
||||||
itemHtml += '</h2>';
|
|
||||||
if (showHelp) {
|
|
||||||
showHelp = false;
|
|
||||||
itemHtml += '<a is="emby-linkbutton" class="raised button-alt headerHelpButton" target="_blank" href="https://docs.jellyfin.org/general/server/notifications.html">';
|
|
||||||
itemHtml += globalize.translate('Help');
|
|
||||||
itemHtml += '</a>';
|
|
||||||
}
|
|
||||||
itemHtml += '</div>';
|
itemHtml += '</div>';
|
||||||
itemHtml += '<div class="paperList">';
|
|
||||||
}
|
}
|
||||||
itemHtml += '<a class="listItem listItem-border" is="emby-linkbutton" data-ripple="false" href="notificationsetting.html?type=' + notification.Type + '">';
|
itemHtml += '<div class="verticalSection verticalSection-extrabottompadding">';
|
||||||
if (notification.Enabled) {
|
itemHtml += '<div class="sectionTitleContainer" style="margin-bottom:1em;">';
|
||||||
itemHtml += '<span class="listItemIcon material-icons notifications_active"></span>';
|
itemHtml += '<h2 class="sectionTitle">';
|
||||||
} else {
|
itemHtml += notification.Category;
|
||||||
itemHtml += '<span class="listItemIcon material-icons notifications_off" style="background-color:#999;"></span>';
|
itemHtml += '</h2>';
|
||||||
|
if (showHelp) {
|
||||||
|
showHelp = false;
|
||||||
|
itemHtml += '<a is="emby-linkbutton" class="raised button-alt headerHelpButton" target="_blank" href="https://docs.jellyfin.org/general/server/notifications.html">';
|
||||||
|
itemHtml += globalize.translate('Help');
|
||||||
|
itemHtml += '</a>';
|
||||||
}
|
}
|
||||||
itemHtml += '<div class="listItemBody">';
|
|
||||||
itemHtml += '<div class="listItemBodyText">' + notification.Name + '</div>';
|
|
||||||
itemHtml += '</div>';
|
itemHtml += '</div>';
|
||||||
itemHtml += '<button type="button" is="paper-icon-button-light"><span class="material-icons mode_edit"></span></button>';
|
itemHtml += '<div class="paperList">';
|
||||||
itemHtml += '</a>';
|
|
||||||
return itemHtml;
|
|
||||||
}).join('');
|
|
||||||
|
|
||||||
if (list.length) {
|
|
||||||
html += '</div>';
|
|
||||||
html += '</div>';
|
|
||||||
}
|
}
|
||||||
page.querySelector('.notificationList').innerHTML = html;
|
itemHtml += '<a class="listItem listItem-border" is="emby-linkbutton" data-ripple="false" href="notificationsetting.html?type=' + notification.Type + '">';
|
||||||
loading.hide();
|
if (notification.Enabled) {
|
||||||
});
|
itemHtml += '<span class="listItemIcon material-icons notifications_active"></span>';
|
||||||
}
|
} else {
|
||||||
|
itemHtml += '<span class="listItemIcon material-icons notifications_off" style="background-color:#999;"></span>';
|
||||||
|
}
|
||||||
|
itemHtml += '<div class="listItemBody">';
|
||||||
|
itemHtml += '<div class="listItemBodyText">' + notification.Name + '</div>';
|
||||||
|
itemHtml += '</div>';
|
||||||
|
itemHtml += '<button type="button" is="paper-icon-button-light"><span class="material-icons mode_edit"></span></button>';
|
||||||
|
itemHtml += '</a>';
|
||||||
|
return itemHtml;
|
||||||
|
}).join('');
|
||||||
|
|
||||||
return function(view, params) {
|
if (list.length) {
|
||||||
view.addEventListener('viewshow', function() {
|
html += '</div>';
|
||||||
reload(view);
|
html += '</div>';
|
||||||
});
|
}
|
||||||
};
|
page.querySelector('.notificationList').innerHTML = html;
|
||||||
});
|
loading.hide();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function (view, params) {
|
||||||
|
view.addEventListener('viewshow', function () {
|
||||||
|
reload(view);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
|
@ -1,141 +1,146 @@
|
||||||
define(['jQuery', 'loading', 'libraryMenu', 'globalize', 'connectionManager', 'emby-button'], function ($, loading, libraryMenu, globalize, connectionManager) {
|
import $ from 'jQuery';
|
||||||
'use strict';
|
import loading from 'loading';
|
||||||
|
import globalize from 'globalize';
|
||||||
|
import 'emby-button';
|
||||||
|
|
||||||
function populateHistory(packageInfo, page) {
|
function populateHistory(packageInfo, page) {
|
||||||
var html = '';
|
let html = '';
|
||||||
var length = Math.min(packageInfo.versions.length, 10);
|
const length = Math.min(packageInfo.versions.length, 10);
|
||||||
|
|
||||||
for (var i = 0; i < length; i++) {
|
for (let i = 0; i < length; i++) {
|
||||||
var version = packageInfo.versions[i];
|
let version = packageInfo.versions[i];
|
||||||
html += '<h2 style="margin:.5em 0;">' + version.version + '</h2>';
|
html += '<h2 style="margin:.5em 0;">' + version.version + '</h2>';
|
||||||
html += '<div style="margin-bottom:1.5em;">' + version.changelog + '</div>';
|
html += '<div style="margin-bottom:1.5em;">' + version.changelog + '</div>';
|
||||||
}
|
|
||||||
|
|
||||||
$('#revisionHistory', page).html(html);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function populateVersions(packageInfo, page, installedPlugin) {
|
$('#revisionHistory', page).html(html);
|
||||||
var html = '';
|
}
|
||||||
|
|
||||||
for (var i = 0; i < packageInfo.versions.length; i++) {
|
function populateVersions(packageInfo, page, installedPlugin) {
|
||||||
var version = packageInfo.versions[i];
|
let html = '';
|
||||||
html += '<option value="' + version.version + '">' + version.version + '</option>';
|
|
||||||
}
|
|
||||||
|
|
||||||
var selectmenu = $('#selectVersion', page).html(html);
|
for (let i = 0; i < packageInfo.versions.length; i++) {
|
||||||
|
const version = packageInfo.versions[i];
|
||||||
if (!installedPlugin) {
|
html += '<option value="' + version.version + '">' + version.version + '</option>';
|
||||||
$('#pCurrentVersion', page).hide().html('');
|
|
||||||
}
|
|
||||||
|
|
||||||
var packageVersion = packageInfo.versions[0];
|
|
||||||
if (packageVersion) {
|
|
||||||
selectmenu.val(packageVersion.version);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderPackage(pkg, installedPlugins, page) {
|
const selectmenu = $('#selectVersion', page).html(html);
|
||||||
var installedPlugin = installedPlugins.filter(function (ip) {
|
|
||||||
return ip.Name == pkg.name;
|
|
||||||
})[0];
|
|
||||||
|
|
||||||
populateVersions(pkg, page, installedPlugin);
|
if (!installedPlugin) {
|
||||||
populateHistory(pkg, page);
|
$('#pCurrentVersion', page).hide().html('');
|
||||||
|
|
||||||
$('.pluginName', page).html(pkg.name);
|
|
||||||
$('#btnInstallDiv', page).removeClass('hide');
|
|
||||||
$('#pSelectVersion', page).removeClass('hide');
|
|
||||||
|
|
||||||
if (pkg.overview) {
|
|
||||||
$('#overview', page).show().html(pkg.overview);
|
|
||||||
} else {
|
|
||||||
$('#overview', page).hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
$('#description', page).html(pkg.description);
|
|
||||||
$('#developer', page).html(pkg.owner);
|
|
||||||
|
|
||||||
if (installedPlugin) {
|
|
||||||
var currentVersionText = globalize.translate('MessageYouHaveVersionInstalled', '<strong>' + installedPlugin.Version + '</strong>');
|
|
||||||
$('#pCurrentVersion', page).show().html(currentVersionText);
|
|
||||||
} else {
|
|
||||||
$('#pCurrentVersion', page).hide().html('');
|
|
||||||
}
|
|
||||||
|
|
||||||
loading.hide();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function alertText(options) {
|
const packageVersion = packageInfo.versions[0];
|
||||||
require(['alert'], function ({default: alert}) {
|
if (packageVersion) {
|
||||||
alert(options);
|
selectmenu.val(packageVersion.version);
|
||||||
});
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderPackage(pkg, installedPlugins, page) {
|
||||||
|
const installedPlugin = installedPlugins.filter(function (ip) {
|
||||||
|
return ip.Name == pkg.name;
|
||||||
|
})[0];
|
||||||
|
|
||||||
|
populateVersions(pkg, page, installedPlugin);
|
||||||
|
populateHistory(pkg, page);
|
||||||
|
|
||||||
|
$('.pluginName', page).html(pkg.name);
|
||||||
|
$('#btnInstallDiv', page).removeClass('hide');
|
||||||
|
$('#pSelectVersion', page).removeClass('hide');
|
||||||
|
|
||||||
|
if (pkg.overview) {
|
||||||
|
$('#overview', page).show().html(pkg.overview);
|
||||||
|
} else {
|
||||||
|
$('#overview', page).hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
function performInstallation(page, name, guid, version) {
|
$('#description', page).html(pkg.description);
|
||||||
var developer = $('#developer', page).html().toLowerCase();
|
$('#developer', page).html(pkg.owner);
|
||||||
|
|
||||||
var alertCallback = function () {
|
if (installedPlugin) {
|
||||||
loading.show();
|
const currentVersionText = globalize.translate('MessageYouHaveVersionInstalled', '<strong>' + installedPlugin.Version + '</strong>');
|
||||||
page.querySelector('#btnInstall').disabled = true;
|
$('#pCurrentVersion', page).show().html(currentVersionText);
|
||||||
ApiClient.installPlugin(name, guid, version).then(function () {
|
} else {
|
||||||
loading.hide();
|
$('#pCurrentVersion', page).hide().html('');
|
||||||
alertText(globalize.translate('PluginInstalledMessage'));
|
}
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
if (developer !== 'jellyfin') {
|
loading.hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
function alertText(options) {
|
||||||
|
import('alert').then(({default: alert}) => {
|
||||||
|
alert(options);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function performInstallation(page, name, guid, version) {
|
||||||
|
const developer = $('#developer', page).html().toLowerCase();
|
||||||
|
|
||||||
|
const alertCallback = function () {
|
||||||
|
loading.show();
|
||||||
|
page.querySelector('#btnInstall').disabled = true;
|
||||||
|
ApiClient.installPlugin(name, guid, version).then(() => {
|
||||||
loading.hide();
|
loading.hide();
|
||||||
var msg = globalize.translate('MessagePluginInstallDisclaimer');
|
alertText(globalize.translate('MessagePluginInstalled'));
|
||||||
msg += '<br/>';
|
}).catch(() => {
|
||||||
msg += '<br/>';
|
alertText(globalize.translate('MessagePluginInstallError'));
|
||||||
msg += globalize.translate('PleaseConfirmPluginInstallation');
|
|
||||||
|
|
||||||
require(['confirm'], function (confirm) {
|
|
||||||
confirm.default(msg, globalize.translate('HeaderConfirmPluginInstallation')).then(function () {
|
|
||||||
alertCallback();
|
|
||||||
}, function () {
|
|
||||||
console.debug('plugin not installed');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
alertCallback();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return function (view, params) {
|
|
||||||
$('.addPluginForm', view).on('submit', function () {
|
|
||||||
loading.show();
|
|
||||||
var page = $(this).parents('#addPluginPage')[0];
|
|
||||||
var name = params.name;
|
|
||||||
var guid = params.guid;
|
|
||||||
ApiClient.getInstalledPlugins().then(function (plugins) {
|
|
||||||
var installedPlugin = plugins.filter(function (plugin) {
|
|
||||||
return plugin.Name == name;
|
|
||||||
})[0];
|
|
||||||
|
|
||||||
var version = $('#selectVersion', page).val();
|
|
||||||
if (installedPlugin && installedPlugin.Version === version) {
|
|
||||||
loading.hide();
|
|
||||||
Dashboard.alert({
|
|
||||||
message: globalize.translate('MessageAlreadyInstalled'),
|
|
||||||
title: globalize.translate('HeaderPluginInstallation')
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
performInstallation(page, name, guid, version);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
view.addEventListener('viewshow', function () {
|
|
||||||
var page = this;
|
|
||||||
loading.show();
|
|
||||||
var name = params.name;
|
|
||||||
var guid = params.guid;
|
|
||||||
var promise1 = ApiClient.getPackageInfo(name, guid);
|
|
||||||
var promise2 = ApiClient.getInstalledPlugins();
|
|
||||||
Promise.all([promise1, promise2]).then(function (responses) {
|
|
||||||
renderPackage(responses[0], responses[1], page);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
});
|
|
||||||
|
if (developer !== 'jellyfin') {
|
||||||
|
loading.hide();
|
||||||
|
let msg = globalize.translate('MessagePluginInstallDisclaimer');
|
||||||
|
msg += '<br/>';
|
||||||
|
msg += '<br/>';
|
||||||
|
msg += globalize.translate('PleaseConfirmPluginInstallation');
|
||||||
|
|
||||||
|
import('confirm').then(({default: confirm}) => {
|
||||||
|
confirm(msg, globalize.translate('HeaderConfirmPluginInstallation')).then(function () {
|
||||||
|
alertCallback();
|
||||||
|
}).catch(() => {
|
||||||
|
console.debug('plugin not installed');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
alertCallback();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function(view, params) {
|
||||||
|
$('.addPluginForm', view).on('submit', function () {
|
||||||
|
loading.show();
|
||||||
|
const page = $(this).parents('#addPluginPage')[0];
|
||||||
|
const name = params.name;
|
||||||
|
const guid = params.guid;
|
||||||
|
ApiClient.getInstalledPlugins().then(function (plugins) {
|
||||||
|
const installedPlugin = plugins.filter(function (plugin) {
|
||||||
|
return plugin.Name == name;
|
||||||
|
})[0];
|
||||||
|
|
||||||
|
const version = $('#selectVersion', page).val();
|
||||||
|
if (installedPlugin && installedPlugin.Version === version) {
|
||||||
|
loading.hide();
|
||||||
|
Dashboard.alert({
|
||||||
|
message: globalize.translate('MessageAlreadyInstalled'),
|
||||||
|
title: globalize.translate('HeaderPluginInstallation')
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
performInstallation(page, name, guid, version);
|
||||||
|
}
|
||||||
|
}).catch(() => {
|
||||||
|
alertText(globalize.translate('MessageGetInstalledPluginsError'));
|
||||||
|
});
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
view.addEventListener('viewshow', function () {
|
||||||
|
const page = this;
|
||||||
|
loading.show();
|
||||||
|
const name = params.name;
|
||||||
|
const guid = params.guid;
|
||||||
|
const promise1 = ApiClient.getPackageInfo(name, guid);
|
||||||
|
const promise2 = ApiClient.getInstalledPlugins();
|
||||||
|
Promise.all([promise1, promise2]).then(function (responses) {
|
||||||
|
renderPackage(responses[0], responses[1], page);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
|
@ -1,141 +1,142 @@
|
||||||
define(['loading', 'libraryMenu', 'globalize', 'cardStyle', 'emby-button', 'emby-checkbox', 'emby-select'], function (loading, libraryMenu, globalize) {
|
import loading from 'loading';
|
||||||
'use strict';
|
import libraryMenu from 'libraryMenu';
|
||||||
|
import globalize from 'globalize';
|
||||||
|
import 'cardStyle';
|
||||||
|
import 'emby-button';
|
||||||
|
import 'emby-checkbox';
|
||||||
|
import 'emby-select';
|
||||||
|
|
||||||
function reloadList(page) {
|
function reloadList(page) {
|
||||||
loading.show();
|
loading.show();
|
||||||
var promise1 = ApiClient.getAvailablePlugins();
|
const promise1 = ApiClient.getAvailablePlugins();
|
||||||
var promise2 = ApiClient.getInstalledPlugins();
|
const promise2 = ApiClient.getInstalledPlugins();
|
||||||
Promise.all([promise1, promise2]).then(function (responses) {
|
Promise.all([promise1, promise2]).then(function (responses) {
|
||||||
populateList({
|
populateList({
|
||||||
catalogElement: page.querySelector('#pluginTiles'),
|
catalogElement: page.querySelector('#pluginTiles'),
|
||||||
noItemsElement: page.querySelector('#noPlugins'),
|
noItemsElement: page.querySelector('#noPlugins'),
|
||||||
availablePlugins: responses[0],
|
availablePlugins: responses[0],
|
||||||
installedPlugins: responses[1]
|
installedPlugins: responses[1]
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function getHeaderText(category) {
|
||||||
|
category = category.replace(' ', '');
|
||||||
|
// TODO: Replace with switch
|
||||||
|
if (category === 'Channel') {
|
||||||
|
category = 'Channels';
|
||||||
|
} else if (category === 'Theme') {
|
||||||
|
category = 'Themes';
|
||||||
|
} else if (category === 'LiveTV') {
|
||||||
|
category = 'HeaderLiveTV';
|
||||||
|
} else if (category === 'ScreenSaver') {
|
||||||
|
category = 'HeaderScreenSavers';
|
||||||
}
|
}
|
||||||
|
|
||||||
function getHeaderText(category) {
|
return globalize.translate(category);
|
||||||
category = category.replace(' ', '');
|
}
|
||||||
if (category === 'Channel') {
|
|
||||||
category = 'Channels';
|
function populateList(options) {
|
||||||
} else if (category === 'Theme') {
|
const availablePlugins = options.availablePlugins;
|
||||||
category = 'Themes';
|
const installedPlugins = options.installedPlugins;
|
||||||
} else if (category === 'LiveTV') {
|
|
||||||
category = 'HeaderLiveTV';
|
availablePlugins.forEach(function (plugin, index, array) {
|
||||||
} else if (category === 'ScreenSaver') {
|
plugin.category = plugin.category || 'General';
|
||||||
category = 'HeaderScreenSavers';
|
plugin.categoryDisplayName = getHeaderText(plugin.category);
|
||||||
|
array[index] = plugin;
|
||||||
|
});
|
||||||
|
|
||||||
|
availablePlugins.sort(function (a, b) {
|
||||||
|
if (a.category > b.category) {
|
||||||
|
return 1;
|
||||||
|
} else if (b.category > a.category) {
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
if (a.name > b.name) {
|
||||||
|
return 1;
|
||||||
|
} else if (b.name > a.name) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
});
|
||||||
|
|
||||||
return globalize.translate(category);
|
let currentCategory = null;
|
||||||
}
|
let html = '';
|
||||||
|
|
||||||
function populateList(options) {
|
for (let i = 0; i < availablePlugins.length; i++) {
|
||||||
var availablePlugins = options.availablePlugins;
|
const plugin = availablePlugins[i];
|
||||||
var installedPlugins = options.installedPlugins;
|
const category = plugin.categoryDisplayName;
|
||||||
|
if (category != currentCategory) {
|
||||||
availablePlugins.forEach(function (plugin, index, array) {
|
if (currentCategory) {
|
||||||
plugin.category = plugin.category || 'General';
|
html += '</div>';
|
||||||
plugin.categoryDisplayName = getHeaderText(plugin.category);
|
html += '</div>';
|
||||||
array[index] = plugin;
|
|
||||||
});
|
|
||||||
|
|
||||||
availablePlugins.sort(function (a, b) {
|
|
||||||
if (a.category > b.category) {
|
|
||||||
return 1;
|
|
||||||
} else if (b.category > a.category) {
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
if (a.name > b.name) {
|
html += '<div class="verticalSection">';
|
||||||
return 1;
|
html += '<h2 class="sectionTitle sectionTitle-cards">' + category + '</h2>';
|
||||||
} else if (b.name > a.name) {
|
html += '<div class="itemsContainer vertical-wrap">';
|
||||||
return -1;
|
currentCategory = category;
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
});
|
|
||||||
|
|
||||||
var currentCategory = null;
|
|
||||||
var html = '';
|
|
||||||
|
|
||||||
for (var i = 0; i < availablePlugins.length; i++) {
|
|
||||||
var plugin = availablePlugins[i];
|
|
||||||
var category = plugin.categoryDisplayName;
|
|
||||||
if (category != currentCategory) {
|
|
||||||
if (currentCategory) {
|
|
||||||
html += '</div>';
|
|
||||||
html += '</div>';
|
|
||||||
}
|
|
||||||
html += '<div class="verticalSection">';
|
|
||||||
html += '<h2 class="sectionTitle sectionTitle-cards">' + category + '</h2>';
|
|
||||||
html += '<div class="itemsContainer vertical-wrap">';
|
|
||||||
currentCategory = category;
|
|
||||||
}
|
|
||||||
html += getPluginHtml(plugin, options, installedPlugins);
|
|
||||||
}
|
}
|
||||||
html += '</div>';
|
html += getPluginHtml(plugin, options, installedPlugins);
|
||||||
html += '</div>';
|
}
|
||||||
|
html += '</div>';
|
||||||
|
html += '</div>';
|
||||||
|
|
||||||
if (!availablePlugins.length && options.noItemsElement) {
|
if (!availablePlugins.length && options.noItemsElement) {
|
||||||
options.noItemsElement.classList.remove('hide');
|
options.noItemsElement.classList.remove('hide');
|
||||||
}
|
|
||||||
|
|
||||||
options.catalogElement.innerHTML = html;
|
|
||||||
loading.hide();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getPluginHtml(plugin, options, installedPlugins) {
|
options.catalogElement.innerHTML = html;
|
||||||
var html = '';
|
loading.hide();
|
||||||
var href = plugin.externalUrl ? plugin.externalUrl : 'addplugin.html?name=' + encodeURIComponent(plugin.name) + '&guid=' + plugin.guid;
|
}
|
||||||
|
|
||||||
if (options.context) {
|
function getPluginHtml(plugin, options, installedPlugins) {
|
||||||
href += '&context=' + options.context;
|
let html = '';
|
||||||
}
|
let href = plugin.externalUrl ? plugin.externalUrl : 'addplugin.html?name=' + encodeURIComponent(plugin.name) + '&guid=' + plugin.guid;
|
||||||
|
|
||||||
var target = plugin.externalUrl ? ' target="_blank"' : '';
|
if (options.context) {
|
||||||
html += "<div class='card backdropCard'>";
|
href += '&context=' + options.context;
|
||||||
html += '<div class="cardBox visualCardBox">';
|
|
||||||
html += '<div class="cardScalable visualCardBox-cardScalable">';
|
|
||||||
html += '<div class="cardPadder cardPadder-backdrop"></div>';
|
|
||||||
html += '<a class="cardContent cardImageContainer" is="emby-linkbutton" href="' + href + '"' + target + '>';
|
|
||||||
html += '<span class="cardImageIcon material-icons folder"></span>';
|
|
||||||
html += '</a>';
|
|
||||||
html += '</div>';
|
|
||||||
html += '<div class="cardFooter">';
|
|
||||||
html += "<div class='cardText'>";
|
|
||||||
html += plugin.name;
|
|
||||||
html += '</div>';
|
|
||||||
var installedPlugin = installedPlugins.filter(function (ip) {
|
|
||||||
return ip.Id == plugin.guid;
|
|
||||||
})[0];
|
|
||||||
html += "<div class='cardText cardText-secondary'>";
|
|
||||||
html += installedPlugin ? globalize.translate('LabelVersionInstalled', installedPlugin.Version) : ' ';
|
|
||||||
html += '</div>';
|
|
||||||
html += '</div>';
|
|
||||||
html += '</div>';
|
|
||||||
return html += '</div>';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTabs() {
|
const target = plugin.externalUrl ? ' target="_blank"' : '';
|
||||||
return [{
|
html += "<div class='card backdropCard'>";
|
||||||
href: 'installedplugins.html',
|
html += '<div class="cardBox visualCardBox">';
|
||||||
name: globalize.translate('TabMyPlugins')
|
html += '<div class="cardScalable visualCardBox-cardScalable">';
|
||||||
}, {
|
html += '<div class="cardPadder cardPadder-backdrop"></div>';
|
||||||
href: 'availableplugins.html',
|
html += '<a class="cardContent cardImageContainer" is="emby-linkbutton" href="' + href + '"' + target + '>';
|
||||||
name: globalize.translate('TabCatalog')
|
html += '<span class="cardImageIcon material-icons folder"></span>';
|
||||||
}, {
|
html += '</a>';
|
||||||
href: 'repositories.html',
|
html += '</div>';
|
||||||
name: globalize.translate('TabRepositories')
|
html += '<div class="cardFooter">';
|
||||||
}];
|
html += "<div class='cardText'>";
|
||||||
}
|
html += plugin.name;
|
||||||
|
html += '</div>';
|
||||||
|
const installedPlugin = installedPlugins.filter(function (ip) {
|
||||||
|
return ip.Id == plugin.guid;
|
||||||
|
})[0];
|
||||||
|
html += "<div class='cardText cardText-secondary'>";
|
||||||
|
html += installedPlugin ? globalize.translate('LabelVersionInstalled', installedPlugin.Version) : ' ';
|
||||||
|
html += '</div>';
|
||||||
|
html += '</div>';
|
||||||
|
html += '</div>';
|
||||||
|
return html += '</div>';
|
||||||
|
}
|
||||||
|
|
||||||
window.PluginCatalog = {
|
function getTabs() {
|
||||||
renderCatalog: populateList
|
return [{
|
||||||
};
|
href: 'installedplugins.html',
|
||||||
|
name: globalize.translate('TabMyPlugins')
|
||||||
|
}, {
|
||||||
|
href: 'availableplugins.html',
|
||||||
|
name: globalize.translate('TabCatalog')
|
||||||
|
}, {
|
||||||
|
href: 'repositories.html',
|
||||||
|
name: globalize.translate('TabRepositories')
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
|
||||||
return function (view, params) {
|
export default function (view) {
|
||||||
view.addEventListener('viewshow', function () {
|
view.addEventListener('viewshow', function () {
|
||||||
libraryMenu.setTabs('plugins', 1, getTabs);
|
libraryMenu.setTabs('plugins', 1, getTabs);
|
||||||
reloadList(this);
|
reloadList(this);
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
});
|
|
||||||
|
|
|
@ -1,190 +1,193 @@
|
||||||
define(['loading', 'libraryMenu', 'dom', 'globalize', 'cardStyle', 'emby-button'], function (loading, libraryMenu, dom, globalize) {
|
import loading from 'loading';
|
||||||
'use strict';
|
import libraryMenu from 'libraryMenu';
|
||||||
|
import dom from 'dom';
|
||||||
|
import globalize from 'globalize';
|
||||||
|
import 'cardStyle';
|
||||||
|
import 'emby-button';
|
||||||
|
|
||||||
function deletePlugin(page, uniqueid, name) {
|
function deletePlugin(page, uniqueid, name) {
|
||||||
var msg = globalize.translate('UninstallPluginConfirmation', name);
|
const msg = globalize.translate('UninstallPluginConfirmation', name);
|
||||||
|
|
||||||
require(['confirm'], function (confirm) {
|
import('confirm').then(({default: confirm}) => {
|
||||||
confirm.default({
|
confirm.default({
|
||||||
title: globalize.translate('UninstallPluginHeader'),
|
title: globalize.translate('HeaderUninstallPlugin'),
|
||||||
text: msg,
|
text: msg,
|
||||||
primary: 'delete',
|
primary: 'delete',
|
||||||
confirmText: globalize.translate('UninstallPluginHeader')
|
confirmText: globalize.translate('HeaderUninstallPlugin')
|
||||||
}).then(function () {
|
}).then(function () {
|
||||||
loading.show();
|
loading.show();
|
||||||
ApiClient.uninstallPlugin(uniqueid).then(function () {
|
ApiClient.uninstallPlugin(uniqueid).then(function () {
|
||||||
reloadList(page);
|
reloadList(page);
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function showNoConfigurationMessage() {
|
function showNoConfigurationMessage() {
|
||||||
Dashboard.alert({
|
Dashboard.alert({
|
||||||
message: globalize.translate('NoPluginConfigurationMessage')
|
message: globalize.translate('MessageNoPluginConfiguration')
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function showConnectMessage() {
|
function showConnectMessage() {
|
||||||
Dashboard.alert({
|
Dashboard.alert({
|
||||||
message: globalize.translate('MessagePluginConfigurationRequiresLocalAccess')
|
message: globalize.translate('MessagePluginConfigurationRequiresLocalAccess')
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function getPluginCardHtml(plugin, pluginConfigurationPages) {
|
function getPluginCardHtml(plugin, pluginConfigurationPages) {
|
||||||
var configPage = pluginConfigurationPages.filter(function (pluginConfigurationPage) {
|
const configPage = pluginConfigurationPages.filter(function (pluginConfigurationPage) {
|
||||||
return pluginConfigurationPage.PluginId == plugin.Id;
|
return pluginConfigurationPage.PluginId == plugin.Id;
|
||||||
})[0];
|
})[0];
|
||||||
var configPageUrl = configPage ? Dashboard.getConfigurationPageUrl(configPage.Name) : null;
|
const configPageUrl = configPage ? Dashboard.getConfigurationPageUrl(configPage.Name) : null;
|
||||||
var html = '';
|
let html = '';
|
||||||
html += "<div data-id='" + plugin.Id + "' data-name='" + plugin.Name + "' data-removable='" + plugin.CanUninstall + "' class='card backdropCard'>";
|
html += "<div data-id='" + plugin.Id + "' data-name='" + plugin.Name + "' data-removable='" + plugin.CanUninstall + "' class='card backdropCard'>";
|
||||||
html += '<div class="cardBox visualCardBox">';
|
html += '<div class="cardBox visualCardBox">';
|
||||||
html += '<div class="cardScalable">';
|
html += '<div class="cardScalable">';
|
||||||
html += '<div class="cardPadder cardPadder-backdrop"></div>';
|
html += '<div class="cardPadder cardPadder-backdrop"></div>';
|
||||||
html += configPageUrl ? '<a class="cardContent cardImageContainer" is="emby-linkbutton" href="' + configPageUrl + '">' : '<div class="cardContent noConfigPluginCard noHoverEffect cardImageContainer emby-button">';
|
html += configPageUrl ? '<a class="cardContent cardImageContainer" is="emby-linkbutton" href="' + configPageUrl + '">' : '<div class="cardContent noConfigPluginCard noHoverEffect cardImageContainer emby-button">';
|
||||||
html += '<span class="cardImageIcon material-icons folder"></span>';
|
html += '<span class="cardImageIcon material-icons folder"></span>';
|
||||||
html += configPageUrl ? '</a>' : '</div>';
|
html += configPageUrl ? '</a>' : '</div>';
|
||||||
|
html += '</div>';
|
||||||
|
html += '<div class="cardFooter">';
|
||||||
|
|
||||||
|
if (configPage || plugin.CanUninstall) {
|
||||||
|
html += '<div style="text-align:right; float:right;padding-top:5px;">';
|
||||||
|
html += '<button type="button" is="paper-icon-button-light" class="btnCardMenu autoSize"><span class="material-icons more_vert"></span></button>';
|
||||||
html += '</div>';
|
html += '</div>';
|
||||||
html += '<div class="cardFooter">';
|
}
|
||||||
|
|
||||||
if (configPage || plugin.CanUninstall) {
|
html += "<div class='cardText'>";
|
||||||
html += '<div style="text-align:right; float:right;padding-top:5px;">';
|
html += configPage && configPage.DisplayName ? configPage.DisplayName : plugin.Name;
|
||||||
html += '<button type="button" is="paper-icon-button-light" class="btnCardMenu autoSize"><span class="material-icons more_vert"></span></button>';
|
html += '</div>';
|
||||||
html += '</div>';
|
html += "<div class='cardText cardText-secondary'>";
|
||||||
|
html += plugin.Version;
|
||||||
|
html += '</div>';
|
||||||
|
html += '</div>';
|
||||||
|
html += '</div>';
|
||||||
|
html += '</div>';
|
||||||
|
return html;
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderPlugins(page, plugins) {
|
||||||
|
ApiClient.getJSON(ApiClient.getUrl('web/configurationpages') + '?pageType=PluginConfiguration').then(function (configPages) {
|
||||||
|
populateList(page, plugins, configPages);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function populateList(page, plugins, pluginConfigurationPages) {
|
||||||
|
plugins = plugins.sort(function (plugin1, plugin2) {
|
||||||
|
if (plugin1.Name > plugin2.Name) {
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
html += "<div class='cardText'>";
|
return -1;
|
||||||
html += configPage && configPage.DisplayName ? configPage.DisplayName : plugin.Name;
|
|
||||||
html += '</div>';
|
|
||||||
html += "<div class='cardText cardText-secondary'>";
|
|
||||||
html += plugin.Version;
|
|
||||||
html += '</div>';
|
|
||||||
html += '</div>';
|
|
||||||
html += '</div>';
|
|
||||||
html += '</div>';
|
|
||||||
return html;
|
|
||||||
}
|
|
||||||
|
|
||||||
function renderPlugins(page, plugins) {
|
|
||||||
ApiClient.getJSON(ApiClient.getUrl('web/configurationpages') + '?pageType=PluginConfiguration').then(function (configPages) {
|
|
||||||
populateList(page, plugins, configPages);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function populateList(page, plugins, pluginConfigurationPages) {
|
|
||||||
plugins = plugins.sort(function (plugin1, plugin2) {
|
|
||||||
if (plugin1.Name > plugin2.Name) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
});
|
|
||||||
|
|
||||||
var html = plugins.map(function (p) {
|
|
||||||
return getPluginCardHtml(p, pluginConfigurationPages);
|
|
||||||
}).join('');
|
|
||||||
|
|
||||||
var installedPluginsElement = page.querySelector('.installedPlugins');
|
|
||||||
installedPluginsElement.removeEventListener('click', onInstalledPluginsClick);
|
|
||||||
installedPluginsElement.addEventListener('click', onInstalledPluginsClick);
|
|
||||||
|
|
||||||
if (plugins.length) {
|
|
||||||
installedPluginsElement.classList.add('itemsContainer');
|
|
||||||
installedPluginsElement.classList.add('vertical-wrap');
|
|
||||||
} else {
|
|
||||||
html += '<div class="centerMessage">';
|
|
||||||
html += '<h1>' + globalize.translate('MessageNoPluginsInstalled') + '</h1>';
|
|
||||||
html += '<p><a is="emby-linkbutton" class="button-link" href="availableplugins.html">';
|
|
||||||
html += globalize.translate('BrowsePluginCatalogMessage');
|
|
||||||
html += '</a></p>';
|
|
||||||
html += '</div>';
|
|
||||||
}
|
|
||||||
|
|
||||||
installedPluginsElement.innerHTML = html;
|
|
||||||
loading.hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
function showPluginMenu(page, elem) {
|
|
||||||
var card = dom.parentWithClass(elem, 'card');
|
|
||||||
var id = card.getAttribute('data-id');
|
|
||||||
var name = card.getAttribute('data-name');
|
|
||||||
var removable = card.getAttribute('data-removable');
|
|
||||||
var configHref = card.querySelector('.cardContent').getAttribute('href');
|
|
||||||
var menuItems = [];
|
|
||||||
|
|
||||||
if (configHref) {
|
|
||||||
menuItems.push({
|
|
||||||
name: globalize.translate('ButtonSettings'),
|
|
||||||
id: 'open',
|
|
||||||
icon: 'mode_edit'
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (removable === 'true') {
|
|
||||||
menuItems.push({
|
|
||||||
name: globalize.translate('ButtonUninstall'),
|
|
||||||
id: 'delete',
|
|
||||||
icon: 'delete'
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
require(['actionsheet'], function (actionsheet) {
|
|
||||||
actionsheet.show({
|
|
||||||
items: menuItems,
|
|
||||||
positionTo: elem,
|
|
||||||
callback: function (resultId) {
|
|
||||||
switch (resultId) {
|
|
||||||
case 'open':
|
|
||||||
Dashboard.navigate(configHref);
|
|
||||||
break;
|
|
||||||
case 'delete':
|
|
||||||
deletePlugin(page, id, name);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function reloadList(page) {
|
|
||||||
loading.show();
|
|
||||||
ApiClient.getInstalledPlugins().then(function (plugins) {
|
|
||||||
renderPlugins(page, plugins);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function getTabs() {
|
|
||||||
return [{
|
|
||||||
href: 'installedplugins.html',
|
|
||||||
name: globalize.translate('TabMyPlugins')
|
|
||||||
}, {
|
|
||||||
href: 'availableplugins.html',
|
|
||||||
name: globalize.translate('TabCatalog')
|
|
||||||
}, {
|
|
||||||
href: 'repositories.html',
|
|
||||||
name: globalize.translate('TabRepositories')
|
|
||||||
}];
|
|
||||||
}
|
|
||||||
|
|
||||||
function onInstalledPluginsClick(e) {
|
|
||||||
if (dom.parentWithClass(e.target, 'noConfigPluginCard')) {
|
|
||||||
showNoConfigurationMessage();
|
|
||||||
} else if (dom.parentWithClass(e.target, 'connectModePluginCard')) {
|
|
||||||
showConnectMessage();
|
|
||||||
} else {
|
|
||||||
var btnCardMenu = dom.parentWithClass(e.target, 'btnCardMenu');
|
|
||||||
if (btnCardMenu) {
|
|
||||||
showPluginMenu(dom.parentWithClass(btnCardMenu, 'page'), btnCardMenu);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pageIdOn('pageshow', 'pluginsPage', function () {
|
|
||||||
libraryMenu.setTabs('plugins', 0, getTabs);
|
|
||||||
reloadList(this);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
window.PluginsPage = {
|
let html = plugins.map(function (p) {
|
||||||
renderPlugins: renderPlugins
|
return getPluginCardHtml(p, pluginConfigurationPages);
|
||||||
};
|
}).join('');
|
||||||
|
|
||||||
|
const installedPluginsElement = page.querySelector('.installedPlugins');
|
||||||
|
installedPluginsElement.removeEventListener('click', onInstalledPluginsClick);
|
||||||
|
installedPluginsElement.addEventListener('click', onInstalledPluginsClick);
|
||||||
|
|
||||||
|
if (plugins.length) {
|
||||||
|
installedPluginsElement.classList.add('itemsContainer');
|
||||||
|
installedPluginsElement.classList.add('vertical-wrap');
|
||||||
|
} else {
|
||||||
|
html += '<div class="centerMessage">';
|
||||||
|
html += '<h1>' + globalize.translate('MessageNoPluginsInstalled') + '</h1>';
|
||||||
|
html += '<p><a is="emby-linkbutton" class="button-link" href="availableplugins.html">';
|
||||||
|
html += globalize.translate('MessageBrowsePluginCatalog');
|
||||||
|
html += '</a></p>';
|
||||||
|
html += '</div>';
|
||||||
|
}
|
||||||
|
|
||||||
|
installedPluginsElement.innerHTML = html;
|
||||||
|
loading.hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
function showPluginMenu(page, elem) {
|
||||||
|
const card = dom.parentWithClass(elem, 'card');
|
||||||
|
const id = card.getAttribute('data-id');
|
||||||
|
const name = card.getAttribute('data-name');
|
||||||
|
const removable = card.getAttribute('data-removable');
|
||||||
|
const configHref = card.querySelector('.cardContent').getAttribute('href');
|
||||||
|
const menuItems = [];
|
||||||
|
|
||||||
|
if (configHref) {
|
||||||
|
menuItems.push({
|
||||||
|
name: globalize.translate('ButtonSettings'),
|
||||||
|
id: 'open',
|
||||||
|
icon: 'mode_edit'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (removable === 'true') {
|
||||||
|
menuItems.push({
|
||||||
|
name: globalize.translate('ButtonUninstall'),
|
||||||
|
id: 'delete',
|
||||||
|
icon: 'delete'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
import('actionsheet').then(({default: actionsheet}) => {
|
||||||
|
actionsheet.show({
|
||||||
|
items: menuItems,
|
||||||
|
positionTo: elem,
|
||||||
|
callback: function (resultId) {
|
||||||
|
switch (resultId) {
|
||||||
|
case 'open':
|
||||||
|
Dashboard.navigate(configHref);
|
||||||
|
break;
|
||||||
|
case 'delete':
|
||||||
|
deletePlugin(page, id, name);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function reloadList(page) {
|
||||||
|
loading.show();
|
||||||
|
ApiClient.getInstalledPlugins().then(function (plugins) {
|
||||||
|
renderPlugins(page, plugins);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function getTabs() {
|
||||||
|
return [{
|
||||||
|
href: 'installedplugins.html',
|
||||||
|
name: globalize.translate('TabMyPlugins')
|
||||||
|
}, {
|
||||||
|
href: 'availableplugins.html',
|
||||||
|
name: globalize.translate('TabCatalog')
|
||||||
|
}, {
|
||||||
|
href: 'repositories.html',
|
||||||
|
name: globalize.translate('TabRepositories')
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
|
||||||
|
function onInstalledPluginsClick(e) {
|
||||||
|
if (dom.parentWithClass(e.target, 'noConfigPluginCard')) {
|
||||||
|
showNoConfigurationMessage();
|
||||||
|
} else if (dom.parentWithClass(e.target, 'connectModePluginCard')) {
|
||||||
|
showConnectMessage();
|
||||||
|
} else {
|
||||||
|
const btnCardMenu = dom.parentWithClass(e.target, 'btnCardMenu');
|
||||||
|
if (btnCardMenu) {
|
||||||
|
showPluginMenu(dom.parentWithClass(btnCardMenu, 'page'), btnCardMenu);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pageIdOn('pageshow', 'pluginsPage', function () {
|
||||||
|
libraryMenu.setTabs('plugins', 0, getTabs);
|
||||||
|
reloadList(this);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
window.PluginsPage = {
|
||||||
|
renderPlugins: renderPlugins
|
||||||
|
};
|
||||||
|
|
|
@ -89,7 +89,7 @@ import 'emby-checkbox';
|
||||||
});
|
});
|
||||||
}, function (response) {
|
}, function (response) {
|
||||||
import('toast').then(({default: toast}) => {
|
import('toast').then(({default: toast}) => {
|
||||||
toast(globalize.translate('DefaultErrorMessage'));
|
toast(globalize.translate('ErrorDefault'));
|
||||||
});
|
});
|
||||||
|
|
||||||
loading.hide();
|
loading.hide();
|
||||||
|
|
|
@ -145,14 +145,14 @@ import 'emby-button';
|
||||||
function resetPassword() {
|
function resetPassword() {
|
||||||
const msg = globalize.translate('PasswordResetConfirmation');
|
const msg = globalize.translate('PasswordResetConfirmation');
|
||||||
import('confirm').then(({default: confirm}) => {
|
import('confirm').then(({default: confirm}) => {
|
||||||
confirm(msg, globalize.translate('PasswordResetHeader')).then(function () {
|
confirm(msg, globalize.translate('HeaderResetPassword')).then(function () {
|
||||||
const userId = params.userId;
|
const userId = params.userId;
|
||||||
loading.show();
|
loading.show();
|
||||||
ApiClient.resetUserPassword(userId).then(function () {
|
ApiClient.resetUserPassword(userId).then(function () {
|
||||||
loading.hide();
|
loading.hide();
|
||||||
Dashboard.alert({
|
Dashboard.alert({
|
||||||
message: globalize.translate('PasswordResetComplete'),
|
message: globalize.translate('PasswordResetComplete'),
|
||||||
title: globalize.translate('PasswordResetHeader')
|
title: globalize.translate('HeaderResetPassword')
|
||||||
});
|
});
|
||||||
loadUser(view, params);
|
loadUser(view, params);
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,31 +1,30 @@
|
||||||
define(['loading', 'scripts/editorsidebar'], function (loading) {
|
import loading from 'loading';
|
||||||
'use strict';
|
import 'scripts/editorsidebar';
|
||||||
|
|
||||||
function reload(context, itemId) {
|
function reload(context, itemId) {
|
||||||
loading.show();
|
loading.show();
|
||||||
|
|
||||||
if (itemId) {
|
if (itemId) {
|
||||||
require(['metadataEditor'], function ({default: metadataEditor}) {
|
import('metadataEditor').then(({ default: metadataEditor }) => {
|
||||||
metadataEditor.embed(context.querySelector('.editPageInnerContent'), itemId, ApiClient.serverInfo().Id);
|
metadataEditor.embed(context.querySelector('.editPageInnerContent'), itemId, ApiClient.serverInfo().Id);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
context.querySelector('.editPageInnerContent').innerHTML = '';
|
context.querySelector('.editPageInnerContent').innerHTML = '';
|
||||||
loading.hide();
|
loading.hide();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return function (view, params) {
|
export default function (view, params) {
|
||||||
view.addEventListener('viewshow', function () {
|
view.addEventListener('viewshow', function () {
|
||||||
reload(this, MetadataEditor.getCurrentItemId());
|
reload(this, MetadataEditor.getCurrentItemId());
|
||||||
});
|
});
|
||||||
MetadataEditor.setCurrentItemId(null);
|
MetadataEditor.setCurrentItemId(null);
|
||||||
view.querySelector('.libraryTree').addEventListener('itemclicked', function (event) {
|
view.querySelector('.libraryTree').addEventListener('itemclicked', function (event) {
|
||||||
var data = event.detail;
|
var data = event.detail;
|
||||||
|
|
||||||
if (data.id != MetadataEditor.getCurrentItemId()) {
|
if (data.id != MetadataEditor.getCurrentItemId()) {
|
||||||
MetadataEditor.setCurrentItemId(data.id);
|
MetadataEditor.setCurrentItemId(data.id);
|
||||||
reload(view, data.id);
|
reload(view, data.id);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
});
|
|
||||||
|
|
|
@ -1,5 +1,15 @@
|
||||||
define(['appRouter', 'cardBuilder', 'dom', 'globalize', 'connectionManager', 'apphost', 'layoutManager', 'focusManager', 'emby-itemscontainer', 'emby-scroller'], function (appRouter, cardBuilder, dom, globalize, connectionManager, appHost, layoutManager, focusManager) {
|
import appRouter from 'appRouter';
|
||||||
'use strict';
|
import cardBuilder from 'cardBuilder';
|
||||||
|
import dom from 'dom';
|
||||||
|
import globalize from 'globalize';
|
||||||
|
import connectionManager from 'connectionManager';
|
||||||
|
import appHost from 'apphost';
|
||||||
|
import layoutManager from 'layoutManager';
|
||||||
|
import focusManager from 'focusManager';
|
||||||
|
import 'emby-itemscontainer';
|
||||||
|
import 'emby-scroller';
|
||||||
|
|
||||||
|
/* eslint-disable indent */
|
||||||
|
|
||||||
function enableScrollX() {
|
function enableScrollX() {
|
||||||
return true;
|
return true;
|
||||||
|
@ -133,8 +143,8 @@ define(['appRouter', 'cardBuilder', 'dom', 'globalize', 'connectionManager', 'ap
|
||||||
|
|
||||||
function getFetchDataFn(section) {
|
function getFetchDataFn(section) {
|
||||||
return function () {
|
return function () {
|
||||||
var apiClient = this.apiClient;
|
const apiClient = this.apiClient;
|
||||||
var options = {
|
const options = {
|
||||||
SortBy: (section.types, 'SeriesName,SortName'),
|
SortBy: (section.types, 'SeriesName,SortName'),
|
||||||
SortOrder: 'Ascending',
|
SortOrder: 'Ascending',
|
||||||
Filters: 'IsFavorite',
|
Filters: 'IsFavorite',
|
||||||
|
@ -145,7 +155,7 @@ define(['appRouter', 'cardBuilder', 'dom', 'globalize', 'connectionManager', 'ap
|
||||||
EnableTotalRecordCount: false
|
EnableTotalRecordCount: false
|
||||||
};
|
};
|
||||||
options.Limit = 20;
|
options.Limit = 20;
|
||||||
var userId = apiClient.getCurrentUserId();
|
const userId = apiClient.getCurrentUserId();
|
||||||
|
|
||||||
if (section.types === 'MusicArtist') {
|
if (section.types === 'MusicArtist') {
|
||||||
return apiClient.getArtists(userId, options);
|
return apiClient.getArtists(userId, options);
|
||||||
|
@ -170,16 +180,16 @@ define(['appRouter', 'cardBuilder', 'dom', 'globalize', 'connectionManager', 'ap
|
||||||
|
|
||||||
function getItemsHtmlFn(section) {
|
function getItemsHtmlFn(section) {
|
||||||
return function (items) {
|
return function (items) {
|
||||||
var cardLayout = appHost.preferVisualCards && section.autoCardLayout && section.showTitle;
|
let cardLayout = appHost.preferVisualCards && section.autoCardLayout && section.showTitle;
|
||||||
cardLayout = false;
|
cardLayout = false;
|
||||||
var serverId = this.apiClient.serverId();
|
const serverId = this.apiClient.serverId();
|
||||||
var leadingButtons = layoutManager.tv ? [{
|
const leadingButtons = layoutManager.tv ? [{
|
||||||
name: globalize.translate('All'),
|
name: globalize.translate('All'),
|
||||||
id: 'more',
|
id: 'more',
|
||||||
icon: 'favorite',
|
icon: 'favorite',
|
||||||
routeUrl: getRouteUrl(section, serverId)
|
routeUrl: getRouteUrl(section, serverId)
|
||||||
}] : null;
|
}] : null;
|
||||||
var lines = 0;
|
let lines = 0;
|
||||||
|
|
||||||
if (section.showTitle) {
|
if (section.showTitle) {
|
||||||
lines++;
|
lines++;
|
||||||
|
@ -215,23 +225,12 @@ define(['appRouter', 'cardBuilder', 'dom', 'globalize', 'connectionManager', 'ap
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function FavoritesTab(view, params) {
|
|
||||||
this.view = view;
|
|
||||||
this.params = params;
|
|
||||||
this.apiClient = connectionManager.currentApiClient();
|
|
||||||
this.sectionsContainer = view.querySelector('.sections');
|
|
||||||
createSections(this, this.sectionsContainer, this.apiClient);
|
|
||||||
}
|
|
||||||
|
|
||||||
function createSections(instance, elem, apiClient) {
|
function createSections(instance, elem, apiClient) {
|
||||||
var i;
|
const sections = getSections();
|
||||||
var length;
|
let html = '';
|
||||||
var sections = getSections();
|
|
||||||
var html = '';
|
|
||||||
|
|
||||||
for (i = 0, length = sections.length; i < length; i++) {
|
for (const section of sections) {
|
||||||
var section = sections[i];
|
let sectionClass = 'verticalSection';
|
||||||
var sectionClass = 'verticalSection';
|
|
||||||
|
|
||||||
if (!section.showTitle) {
|
if (!section.showTitle) {
|
||||||
sectionClass += ' verticalSection-extrabottompadding';
|
sectionClass += ' verticalSection-extrabottompadding';
|
||||||
|
@ -257,23 +256,32 @@ define(['appRouter', 'cardBuilder', 'dom', 'globalize', 'connectionManager', 'ap
|
||||||
}
|
}
|
||||||
|
|
||||||
elem.innerHTML = html;
|
elem.innerHTML = html;
|
||||||
var elems = elem.querySelectorAll('.itemsContainer');
|
const elems = elem.querySelectorAll('.itemsContainer');
|
||||||
|
|
||||||
for (i = 0, length = elems.length; i < length; i++) {
|
for (let i = 0, length = elems.length; i < length; i++) {
|
||||||
var itemsContainer = elems[i];
|
const itemsContainer = elems[i];
|
||||||
itemsContainer.fetchData = getFetchDataFn(sections[i]).bind(instance);
|
itemsContainer.fetchData = getFetchDataFn(sections[i]).bind(instance);
|
||||||
itemsContainer.getItemsHtml = getItemsHtmlFn(sections[i]).bind(instance);
|
itemsContainer.getItemsHtml = getItemsHtmlFn(sections[i]).bind(instance);
|
||||||
itemsContainer.parentContainer = dom.parentWithClass(itemsContainer, 'verticalSection');
|
itemsContainer.parentContainer = dom.parentWithClass(itemsContainer, 'verticalSection');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FavoritesTab.prototype.onResume = function (options) {
|
class FavoritesTab {
|
||||||
var promises = (this.apiClient, []);
|
constructor(view, params) {
|
||||||
var view = this.view;
|
this.view = view;
|
||||||
var elems = this.sectionsContainer.querySelectorAll('.itemsContainer');
|
this.params = params;
|
||||||
|
this.apiClient = connectionManager.currentApiClient();
|
||||||
|
this.sectionsContainer = view.querySelector('.sections');
|
||||||
|
createSections(this, this.sectionsContainer, this.apiClient);
|
||||||
|
}
|
||||||
|
|
||||||
for (var i = 0, length = elems.length; i < length; i++) {
|
onResume(options) {
|
||||||
promises.push(elems[i].resume(options));
|
const promises = (this.apiClient, []);
|
||||||
|
const view = this.view;
|
||||||
|
const elems = this.sectionsContainer.querySelectorAll('.itemsContainer');
|
||||||
|
|
||||||
|
for (const elem of elems) {
|
||||||
|
promises.push(elem.resume(options));
|
||||||
}
|
}
|
||||||
|
|
||||||
Promise.all(promises).then(function () {
|
Promise.all(promises).then(function () {
|
||||||
|
@ -281,30 +289,32 @@ define(['appRouter', 'cardBuilder', 'dom', 'globalize', 'connectionManager', 'ap
|
||||||
focusManager.autoFocus(view);
|
focusManager.autoFocus(view);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
FavoritesTab.prototype.onPause = function () {
|
onPause() {
|
||||||
var elems = this.sectionsContainer.querySelectorAll('.itemsContainer');
|
const elems = this.sectionsContainer.querySelectorAll('.itemsContainer');
|
||||||
|
|
||||||
for (var i = 0, length = elems.length; i < length; i++) {
|
for (const elem of elems) {
|
||||||
elems[i].pause();
|
elem.pause();
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
FavoritesTab.prototype.destroy = function () {
|
destroy() {
|
||||||
this.view = null;
|
this.view = null;
|
||||||
this.params = null;
|
this.params = null;
|
||||||
this.apiClient = null;
|
this.apiClient = null;
|
||||||
var elems = this.sectionsContainer.querySelectorAll('.itemsContainer');
|
const elems = this.sectionsContainer.querySelectorAll('.itemsContainer');
|
||||||
|
|
||||||
for (var i = 0, length = elems.length; i < length; i++) {
|
for (const elem of elems) {
|
||||||
elems[i].fetchData = null;
|
elem.fetchData = null;
|
||||||
elems[i].getItemsHtml = null;
|
elem.getItemsHtml = null;
|
||||||
elems[i].parentContainer = null;
|
elem.parentContainer = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.sectionsContainer = null;
|
this.sectionsContainer = null;
|
||||||
};
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return FavoritesTab;
|
export default FavoritesTab;
|
||||||
});
|
|
||||||
|
/* eslint-enable indent */
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue