Merge branch 'master' into osd-tweak

This commit is contained in:
dkanada 2020-11-21 22:15:49 +09:00 committed by GitHub
commit 36344af64f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
291 changed files with 6833 additions and 6332 deletions

View File

@ -8,8 +8,6 @@ jobs:
BuildConfiguration: development
Production:
BuildConfiguration: production
Standalone:
BuildConfiguration: standalone
pool:
vmImage: 'ubuntu-latest'
@ -21,15 +19,15 @@ jobs:
versionSpec: '12.x'
- task: Cache@2
displayName: 'Check Cache'
displayName: 'Cache node_modules'
inputs:
key: 'yarn | yarn.lock'
path: 'node_modules'
cacheHitVar: CACHE_RESTORED
- script: 'yarn install --frozen-lockfile'
displayName: 'Install Dependencies'
condition: ne(variables.CACHE_RESTORED, 'true')
env:
SKIP_PREPARE: 'true'
- script: 'yarn build:development'
displayName: 'Build Development'
@ -39,10 +37,6 @@ jobs:
displayName: 'Build Production'
condition: eq(variables['BuildConfiguration'], 'production')
- script: 'yarn build:standalone'
displayName: 'Build Standalone'
condition: eq(variables['BuildConfiguration'], 'standalone')
- script: 'test -d dist'
displayName: 'Check Build'

View File

@ -12,15 +12,15 @@ jobs:
versionSpec: '12.x'
- task: Cache@2
displayName: 'Check Cache'
displayName: 'Cache node_modules'
inputs:
key: 'yarn | yarn.lock'
path: 'node_modules'
cacheHitVar: CACHE_RESTORED
- script: 'yarn install --frozen-lockfile'
displayName: 'Install Dependencies'
condition: ne(variables.CACHE_RESTORED, 'true')
env:
SKIP_PREPARE: 'true'
- script: 'yarn run lint --quiet'
displayName: 'Run ESLint'

View File

@ -25,7 +25,6 @@ module.exports = {
'eslint:recommended',
// 'plugin:promise/recommended',
'plugin:import/errors',
'plugin:import/warnings',
'plugin:eslint-comments/recommended',
'plugin:compat/recommended'
],
@ -79,16 +78,12 @@ module.exports = {
// Dependency globals
'$': 'readonly',
'jQuery': 'readonly',
'requirejs': 'readonly',
// Jellyfin globals
'ApiClient': 'writable',
'AppInfo': 'writable',
'chrome': 'writable',
'DlnaProfilePage': 'writable',
'Dashboard': 'writable',
'DashboardPage': 'writable',
'Emby': 'readonly',
'Events': 'writable',
'getParameterByName': 'writable',
'getWindowLocationSearch': 'writable',
'Globalize': 'writable',
@ -98,8 +93,6 @@ module.exports = {
'LinkParser': 'writable',
'LiveTvHelpers': 'writable',
'MetadataEditor': 'writable',
'pageClassOn': 'writable',
'pageIdOn': 'writable',
'PlaylistViewer': 'writable',
'UserParentalControlPage': 'writable',
'Windows': 'readonly'

View File

@ -10,14 +10,13 @@
"@babel/eslint-plugin": "^7.12.1",
"@babel/plugin-proposal-class-properties": "^7.10.1",
"@babel/plugin-proposal-private-methods": "^7.12.1",
"@babel/plugin-transform-modules-amd": "^7.12.1",
"@babel/polyfill": "^7.12.1",
"@babel/preset-env": "^7.12.1",
"autoprefixer": "^9.8.6",
"babel-loader": "^8.2.1",
"browser-sync": "^2.26.13",
"clean-webpack-plugin": "^3.0.0",
"confusing-browser-globals": "^1.0.10",
"copy-webpack-plugin": "^5.1.1",
"copy-webpack-plugin": "^6.0.3",
"css-loader": "^5.0.1",
"cssnano": "^4.1.10",
"del": "^6.0.0",
@ -26,6 +25,7 @@
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-promise": "^4.2.1",
"expose-loader": "^1.0.1",
"file-loader": "^6.2.0",
"gulp": "^4.0.2",
"gulp-babel": "^8.0.0",
@ -40,19 +40,24 @@
"gulp-sass": "^4.0.2",
"gulp-sourcemaps": "^3.0.0",
"gulp-terser": "^1.4.1",
"html-loader": "^1.1.0",
"html-webpack-plugin": "^4.5.0",
"lazypipe": "^1.0.2",
"node-sass": "^5.0.0",
"postcss-loader": "^3.0.0",
"postcss-preset-env": "^6.7.0",
"source-map-loader": "^1.1.1",
"style-loader": "^2.0.0",
"stylelint": "^13.7.2",
"stylelint-config-rational-order": "^0.1.2",
"stylelint-no-browser-hacks": "^1.2.1",
"stylelint-order": "^4.1.0",
"webpack": "^5.4.0",
"webpack-cli": "^4.0.0",
"webpack-dev-server": "^3.11.0",
"webpack-merge": "^4.2.2",
"webpack-stream": "^6.1.1",
"workbox-webpack-plugin": "^5.1.4",
"worker-plugin": "^5.0.0"
},
"dependencies": {
@ -62,7 +67,6 @@
"core-js": "^3.7.0",
"date-fns": "^2.16.1",
"epubjs": "^0.3.85",
"pdfjs-dist": "2.5.207",
"fast-text-encoding": "^1.0.3",
"flv.js": "^1.5.0",
"headroom.js": "^0.12.0",
@ -70,6 +74,7 @@
"howler": "^2.2.1",
"intersection-observer": "^0.11.0",
"jellyfin-apiclient": "^1.4.2",
"jellyfin-noto": "https://github.com/jellyfin/jellyfin-noto",
"jquery": "^3.5.1",
"jstree": "^3.3.10",
"libarchive.js": "^1.3.0",
@ -77,302 +82,31 @@
"material-design-icons-iconfont": "^6.1.0",
"native-promise-only": "^0.8.0-a",
"page": "^1.11.6",
"query-string": "^6.13.7",
"pdfjs-dist": "2.5.207",
"resize-observer-polyfill": "^1.5.1",
"sass": "^1.29.0",
"sass-loader": "^10.0.5",
"screenfull": "^5.0.2",
"sortablejs": "^1.12.0",
"swiper": "^6.3.5",
"webcomponents.js": "^0.7.24",
"whatwg-fetch": "^3.5.0"
"whatwg-fetch": "^3.5.0",
"workbox-core": "^5.1.4",
"workbox-precaching": "^5.1.4"
},
"babel": {
"presets": [
"@babel/preset-env"
[
"@babel/preset-env",
{
"useBuiltIns": "usage",
"corejs": 3
}
]
],
"overrides": [
{
"test": [
"src/components/accessSchedule/accessSchedule.js",
"src/components/actionSheet/actionSheet.js",
"src/components/activitylog.js",
"src/components/alert.js",
"src/components/alphaPicker/alphaPicker.js",
"src/components/appFooter/appFooter.js",
"src/components/apphost.js",
"src/components/appRouter.js",
"src/components/autoFocuser.js",
"src/components/backdrop/backdrop.js",
"src/components/cardbuilder/cardBuilder.js",
"src/components/cardbuilder/chaptercardbuilder.js",
"src/components/cardbuilder/peoplecardbuilder.js",
"src/components/channelMapper/channelMapper.js",
"src/components/collectionEditor/collectionEditor.js",
"src/components/confirm/confirm.js",
"src/components/dialog/dialog.js",
"src/components/dialogHelper/dialogHelper.js",
"src/components/directorybrowser/directorybrowser.js",
"src/components/displaySettings/displaySettings.js",
"src/components/favoriteitems.js",
"src/components/fetchhelper.js",
"src/components/filterdialog/filterdialog.js",
"src/components/filtermenu/filtermenu.js",
"src/components/focusManager.js",
"src/components/groupedcards.js",
"src/components/guide/guide.js",
"src/components/guide/guide-settings.js",
"src/components/homeScreenSettings/homeScreenSettings.js",
"src/components/homesections/homesections.js",
"src/components/htmlMediaHelper.js",
"src/components/imageOptionsEditor/imageOptionsEditor.js",
"src/components/images/imageLoader.js",
"src/components/imageDownloader/imageDownloader.js",
"src/components/imageeditor/imageeditor.js",
"src/components/imageUploader/imageUploader.js",
"src/components/indicators/indicators.js",
"src/components/itemContextMenu.js",
"src/components/itemHelper.js",
"src/components/itemidentifier/itemidentifier.js",
"src/components/itemMediaInfo/itemMediaInfo.js",
"src/components/itemsrefresher.js",
"src/components/layoutManager.js",
"src/components/lazyLoader/lazyLoaderIntersectionObserver.js",
"src/components/libraryoptionseditor/libraryoptionseditor.js",
"src/components/listview/listview.js",
"src/components/loading/loading.js",
"src/components/maintabsmanager.js",
"src/components/mediainfo/mediainfo.js",
"src/components/mediaLibraryCreator/mediaLibraryCreator.js",
"src/components/mediaLibraryEditor/mediaLibraryEditor.js",
"src/components/metadataEditor/metadataEditor.js",
"src/components/metadataEditor/personEditor.js",
"src/components/multiSelect/multiSelect.js",
"src/components/notifications/notifications.js",
"src/components/nowPlayingBar/nowPlayingBar.js",
"src/components/packageManager.js",
"src/components/playback/brightnessosd.js",
"src/components/playback/mediasession.js",
"src/components/playback/nowplayinghelper.js",
"src/components/playback/playbackorientation.js",
"src/components/playback/playbackmanager.js",
"src/components/playback/playerSelectionMenu.js",
"src/components/playback/playersettingsmenu.js",
"src/components/playback/playmethodhelper.js",
"src/components/playback/playqueuemanager.js",
"src/components/playback/remotecontrolautoplay.js",
"src/components/playback/volumeosd.js",
"src/components/playbackSettings/playbackSettings.js",
"src/components/playerstats/playerstats.js",
"src/components/playlisteditor/playlisteditor.js",
"src/components/playmenu.js",
"src/components/pluginManager.js",
"src/components/prompt/prompt.js",
"src/components/qualityOptions.js",
"src/components/quickConnectSettings/quickConnectSettings.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/recordingcreator/recordingeditor.js",
"src/components/recordingcreator/recordingfields.js",
"src/components/remotecontrol/remotecontrol.js",
"src/components/sanatizefilename.js",
"src/components/scrollManager.js",
"src/plugins/experimentalWarnings/plugin.js",
"src/plugins/sessionPlayer/plugin.js",
"src/plugins/htmlAudioPlayer/plugin.js",
"src/plugins/comicsPlayer/plugin.js",
"src/plugins/chromecastPlayer/plugin.js",
"src/components/slideshow/slideshow.js",
"src/components/sortmenu/sortmenu.js",
"src/plugins/htmlVideoPlayer/plugin.js",
"src/plugins/logoScreensaver/plugin.js",
"src/plugins/playAccessValidation/plugin.js",
"src/components/search/searchfields.js",
"src/components/search/searchresults.js",
"src/components/settingshelper.js",
"src/components/shortcuts.js",
"src/components/subtitleeditor/subtitleeditor.js",
"src/components/subtitlesync/subtitlesync.js",
"src/components/subtitlesettings/subtitleappearancehelper.js",
"src/components/subtitlesettings/subtitlesettings.js",
"src/components/syncPlay/groupSelectionMenu.js",
"src/components/syncPlay/playbackPermissionManager.js",
"src/components/syncPlay/syncPlayManager.js",
"src/components/syncPlay/timeSyncManager.js",
"src/components/themeMediaPlayer.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/tunerPicker.js",
"src/components/upnextdialog/upnextdialog.js",
"src/components/userdatabuttons/userdatabuttons.js",
"src/components/viewContainer.js",
"src/components/viewSettings/viewSettings.js",
"src/components/castSenderApi.js",
"src/controllers/session/addServer/index.js",
"src/controllers/session/forgotPassword/index.js",
"src/controllers/session/resetPassword/index.js",
"src/controllers/session/login/index.js",
"src/controllers/session/selectServer/index.js",
"src/controllers/dashboard/apikeys.js",
"src/controllers/dashboard/dashboard.js",
"src/controllers/dashboard/devices/device.js",
"src/controllers/dashboard/devices/devices.js",
"src/controllers/dashboard/dlna/profile.js",
"src/controllers/dashboard/dlna/profiles.js",
"src/controllers/dashboard/dlna/settings.js",
"src/controllers/dashboard/encodingsettings.js",
"src/controllers/dashboard/general.js",
"src/controllers/dashboard/librarydisplay.js",
"src/controllers/dashboard/logs.js",
"src/controllers/music/musicalbums.js",
"src/controllers/music/musicartists.js",
"src/controllers/music/musicgenres.js",
"src/controllers/music/musicplaylists.js",
"src/controllers/music/musicrecommended.js",
"src/controllers/music/songs.js",
"src/controllers/dashboard/library.js",
"src/controllers/dashboard/metadataImages.js",
"src/controllers/dashboard/metadatanfo.js",
"src/controllers/dashboard/networking.js",
"src/controllers/dashboard/notifications/notification/index.js",
"src/controllers/dashboard/notifications/notifications/index.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/quickConnect.js",
"src/controllers/dashboard/scheduledtasks/scheduledtask.js",
"src/controllers/dashboard/scheduledtasks/scheduledtasks.js",
"src/controllers/dashboard/serveractivity.js",
"src/controllers/dashboard/streaming.js",
"src/controllers/dashboard/users/useredit.js",
"src/controllers/dashboard/users/userlibraryaccess.js",
"src/controllers/dashboard/users/usernew.js",
"src/controllers/dashboard/users/userparentalcontrol.js",
"src/controllers/dashboard/users/userpasswordpage.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/playback/queue/index.js",
"src/controllers/playback/video/index.js",
"src/controllers/searchpage.js",
"src/controllers/livetv/livetvguide.js",
"src/controllers/livetvtuner.js",
"src/controllers/livetv/livetvsuggested.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/tvgenres.js",
"src/controllers/shows/tvlatest.js",
"src/controllers/shows/tvrecommended.js",
"src/controllers/shows/tvshows.js",
"src/controllers/shows/tvstudios.js",
"src/controllers/shows/tvupcoming.js",
"src/controllers/user/display/index.js",
"src/controllers/user/home/index.js",
"src/controllers/user/menu/index.js",
"src/controllers/user/playback/index.js",
"src/controllers/user/profile/index.js",
"src/controllers/user/quickConnect/index.js",
"src/controllers/user/subtitles/index.js",
"src/controllers/wizard/finish/index.js",
"src/controllers/wizard/remote/index.js",
"src/controllers/wizard/settings/index.js",
"src/controllers/wizard/start/index.js",
"src/controllers/wizard/user/index.js",
"src/elements/emby-button/emby-button.js",
"src/elements/emby-button/paper-icon-button-light.js",
"src/elements/emby-checkbox/emby-checkbox.js",
"src/elements/emby-collapse/emby-collapse.js",
"src/elements/emby-input/emby-input.js",
"src/elements/emby-itemrefreshindicator/emby-itemrefreshindicator.js",
"src/elements/emby-itemscontainer/emby-itemscontainer.js",
"src/elements/emby-playstatebutton/emby-playstatebutton.js",
"src/elements/emby-programcell/emby-programcell.js",
"src/elements/emby-progressbar/emby-progressbar.js",
"src/elements/emby-progressring/emby-progressring.js",
"src/elements/emby-radio/emby-radio.js",
"src/elements/emby-ratingbutton/emby-ratingbutton.js",
"src/elements/emby-scrollbuttons/emby-scrollbuttons.js",
"src/elements/emby-scroller/emby-scroller.js",
"src/elements/emby-select/emby-select.js",
"src/elements/emby-slider/emby-slider.js",
"src/elements/emby-tabs/emby-tabs.js",
"src/elements/emby-textarea/emby-textarea.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/bookPlayer/plugin.js",
"src/plugins/pdfPlayer/plugin.js",
"src/plugins/bookPlayer/tableOfContents.js",
"src/plugins/chromecastPlayer/chromecastHelper.js",
"src/plugins/photoPlayer/plugin.js",
"src/plugins/youtubePlayer/plugin.js",
"src/scripts/alphanumericshortcuts.js",
"src/scripts/autoBackdrops.js",
"src/scripts/autocast.js",
"src/scripts/browser.js",
"src/scripts/clientUtils.js",
"src/scripts/datetime.js",
"src/scripts/deleteHelper.js",
"src/scripts/dfnshelper.js",
"src/scripts/dom.js",
"src/scripts/editorsidebar.js",
"src/scripts/fileDownloader.js",
"src/scripts/filesystem.js",
"src/scripts/globalize.js",
"src/scripts/imagehelper.js",
"src/scripts/itembynamedetailpage.js",
"src/scripts/inputManager.js",
"src/scripts/autoThemes.js",
"src/scripts/themeManager.js",
"src/scripts/keyboardNavigation.js",
"src/scripts/libraryMenu.js",
"src/scripts/libraryBrowser.js",
"src/scripts/livetvcomponents.js",
"src/scripts/mouseManager.js",
"src/scripts/multiDownload.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/userSettings.js",
"src/scripts/settings/webSettings.js",
"src/scripts/shell.js",
"src/scripts/taskbutton.js",
"src/scripts/themeLoader.js",
"src/scripts/touchHelper.js"
],
"plugins": [
"@babel/plugin-transform-modules-amd",
"@babel/plugin-proposal-class-properties",
"@babel/plugin-proposal-private-methods"
]
}
"plugins": [
"@babel/plugin-proposal-class-properties",
"@babel/plugin-proposal-private-methods"
]
},
"browserslist": [
@ -393,11 +127,10 @@
],
"scripts": {
"start": "yarn serve",
"serve": "gulp serve --development",
"prepare": "gulp --production",
"build:development": "gulp --development",
"build:production": "gulp --production",
"build:standalone": "gulp standalone --development",
"serve": "webpack serve --config webpack.dev.js",
"prepare": "./scripts/prepare.sh",
"build:development": "webpack --config webpack.dev.js",
"build:production": "webpack --config webpack.prod.js",
"lint": "eslint \".\"",
"stylelint": "stylelint \"src/**/*.css\""
}

5
scripts/prepare.sh Executable file
View File

@ -0,0 +1,5 @@
#!/usr/bin/env bash
if [ -z "${SKIP_PREPARE}" ]; then
webpack --config webpack.prod.js
fi

View File

@ -1,182 +0,0 @@
/**
* require.js module definitions bundled by webpack
*/
// Use define from require.js not webpack's define
const _define = window.define;
// fetch
const fetch = require('whatwg-fetch');
_define('fetch', function() {
return fetch;
});
// Blurhash
const blurhash = require('blurhash');
_define('blurhash', function() {
return blurhash;
});
// query-string
const query = require('query-string');
_define('queryString', function() {
return query;
});
// flvjs
const flvjs = require('flv.js/dist/flv').default;
_define('flvjs', function() {
return flvjs;
});
// jstree
const jstree = require('jstree');
require('jstree/dist/themes/default/style.css');
_define('jstree', function() {
return jstree;
});
// jquery
const jquery = require('jquery');
_define('jQuery', function() {
return jquery;
});
// hlsjs
const hlsjs = require('hls.js');
_define('hlsjs', function() {
return hlsjs;
});
// howler
const howler = require('howler');
_define('howler', function() {
return howler;
});
// resize-observer-polyfill
const resize = require('resize-observer-polyfill').default;
_define('resize-observer-polyfill', function() {
return resize;
});
// swiper
const swiper = require('swiper/swiper-bundle');
require('swiper/swiper-bundle.css');
_define('swiper', function() {
return swiper;
});
// sortable
const sortable = require('sortablejs').default;
_define('sortable', function() {
return sortable;
});
// webcomponents
const webcomponents = require('webcomponents.js/webcomponents-lite');
_define('webcomponents', function() {
return webcomponents;
});
// libass-wasm
const libassWasm = require('libass-wasm');
_define('JavascriptSubtitlesOctopus', function() {
return libassWasm;
});
// material-icons
const materialIcons = require('material-design-icons-iconfont/dist/material-design-icons.css');
_define('material-icons', function() {
return materialIcons;
});
const epubjs = require('epubjs');
_define('epubjs', function () {
return epubjs;
});
const pdfjs = require('pdfjs-dist/build/pdf');
_define('pdfjs', function () {
return pdfjs;
});
// page.js
const page = require('page');
_define('page', function() {
return page;
});
// core-js
const polyfill = require('@babel/polyfill/dist/polyfill');
_define('polyfill', function () {
return polyfill;
});
// domtokenlist-shim
const classlist = require('classlist.js');
_define('classlist-polyfill', function () {
return classlist;
});
// Date-FNS
const dateFns = require('date-fns');
_define('date-fns', function () {
return dateFns;
});
const dateFnsLocale = require('date-fns/locale');
_define('date-fns/locale', function () {
return dateFnsLocale;
});
const fast_text_encoding = require('fast-text-encoding');
_define('fast-text-encoding', function () {
return fast_text_encoding;
});
// intersection-observer
const intersection_observer = require('intersection-observer');
_define('intersection-observer', function () {
return intersection_observer;
});
// screenfull
const screenfull = require('screenfull');
_define('screenfull', function () {
return screenfull;
});
// headroom.js
const headroom = require('headroom.js/dist/headroom');
_define('headroom', function () {
return headroom;
});
// apiclient
const apiclient = require('jellyfin-apiclient');
_define('apiclient', function () {
return apiclient.ApiClient;
});
_define('events', function () {
return apiclient.Events;
});
_define('credentialprovider', function () {
return apiclient.Credentials;
});
_define('connectionManagerFactory', function () {
return apiclient.ConnectionManager;
});
_define('appStorage', function () {
return apiclient.AppStorage;
});
// libarchive.js
const libarchive = require('libarchive.js');
_define('libarchive', function () {
return libarchive;
});

View File

@ -0,0 +1,4 @@
export default {
isNativeApp: false
};

View File

@ -0,0 +1,82 @@
import { ConnectionManager, Credentials, ApiClient, Events } from 'jellyfin-apiclient';
import { appHost } from './apphost';
import Dashboard from '../scripts/clientUtils';
import AppInfo from './AppInfo';
import { setUserInfo } from '../scripts/settings/userSettings';
class ServerConnections extends ConnectionManager {
constructor() {
super(...arguments);
this.localApiClient = null;
Events.on(this, 'localusersignedout', function () {
setUserInfo(null, null);
});
}
initApiClient() {
if (!AppInfo.isNativeApp) {
console.debug('creating ApiClient singleton');
const apiClient = new ApiClient(
Dashboard.serverAddress(),
appHost.appName(),
appHost.appVersion(),
appHost.deviceName(),
appHost.deviceId()
);
apiClient.enableAutomaticNetworking = false;
apiClient.manualAddressOnly = true;
this.addApiClient(apiClient);
this.setLocalApiClient(apiClient);
console.debug('loaded ApiClient singleton');
}
}
setLocalApiClient(apiClient) {
if (apiClient) {
this.localApiClient = apiClient;
window.ApiClient = apiClient;
}
}
getLocalApiClient() {
return this.localApiClient;
}
currentApiClient() {
let apiClient = this.getLocalApiClient();
if (!apiClient) {
const server = this.getLastUsedServer();
if (server) {
apiClient = this.getApiClient(server.Id);
}
}
return apiClient;
}
onLocalUserSignedIn(user) {
const apiClient = this.getApiClient(user.ServerId);
this.setLocalApiClient(apiClient);
return setUserInfo(user.Id, apiClient);
}
}
const credentials = new Credentials();
const capabilities = Dashboard.capabilities(appHost);
export default new ServerConnections(
credentials,
appHost.appName(),
appHost.appVersion(),
appHost.deviceName(),
appHost.deviceId(),
capabilities);

View File

@ -1,3 +1,4 @@
/* eslint-disable indent */
/**
@ -5,12 +6,12 @@
* @module components/accessSchedule/accessSchedule
*/
import dialogHelper from 'dialogHelper';
import datetime from 'datetime';
import globalize from 'globalize';
import 'emby-select';
import 'paper-icon-button-light';
import 'formDialogStyle';
import dialogHelper from '../dialogHelper/dialogHelper';
import datetime from '../../scripts/datetime';
import globalize from '../../scripts/globalize';
import '../../elements/emby-select/emby-select';
import '../../elements/emby-button/paper-icon-button-light';
import '../formdialog.css';
function getDisplayTime(hours) {
let minutes = 0;
@ -59,7 +60,7 @@ import 'formDialogStyle';
export function show(options) {
return new Promise((resolve, reject) => {
import('text!./accessSchedule.template.html').then(({default: template}) => {
import('./accessSchedule.template.html').then(({default: template}) => {
const dlg = dialogHelper.createDialog({
removeOnClose: true,
size: 'small'

View File

@ -1,12 +1,12 @@
import dialogHelper from 'dialogHelper';
import layoutManager from 'layoutManager';
import globalize from 'globalize';
import dom from 'dom';
import 'emby-button';
import 'css!./actionSheet';
import 'material-icons';
import 'scrollStyles';
import 'listViewStyle';
import dialogHelper from '../dialogHelper/dialogHelper';
import layoutManager from '../layoutManager';
import globalize from '../../scripts/globalize';
import dom from '../../scripts/dom';
import '../../elements/emby-button/emby-button';
import './actionSheet.css';
import 'material-design-icons-iconfont';
import '../../assets/css/scrollstyles.css';
import '../../components/listview/listview.css';
function getOffsets(elems) {
const results = [];
@ -71,7 +71,7 @@ function getPosition(options, dlg) {
}
function centerFocus(elem, horiz, on) {
import('scrollHelper').then(({default: scrollHelper}) => {
import('../../scripts/scrollHelper').then((scrollHelper) => {
const fn = on ? 'on' : 'off';
scrollHelper.centerFocus[fn](elem, horiz);
});

View File

@ -1,11 +1,13 @@
import events from 'events';
import globalize from 'globalize';
import dom from 'dom';
import { Events } from 'jellyfin-apiclient';
import globalize from '../scripts/globalize';
import dom from '../scripts/dom';
import * as datefns from 'date-fns';
import dfnshelper from 'dfnshelper';
import serverNotifications from 'serverNotifications';
import 'emby-button';
import 'listViewStyle';
import dfnshelper from '../scripts/dfnshelper';
import serverNotifications from '../scripts/serverNotifications';
import '../elements/emby-button/emby-button';
import './listview/listview.css';
import ServerConnections from './ServerConnections';
import alert from './alert';
/* eslint-disable indent */
@ -127,10 +129,8 @@ import 'listViewStyle';
}
function showItemOverview(item) {
import('alert').then(({default: alert}) => {
alert({
text: item.Overview
});
alert({
text: item.Overview
});
}
@ -140,11 +140,11 @@ class ActivityLog {
const element = options.element;
element.classList.add('activityLogListWidget');
element.addEventListener('click', onListClick.bind(this));
const apiClient = window.connectionManager.getApiClient(options.serverId);
const apiClient = ServerConnections.getApiClient(options.serverId);
reloadData(this, element, apiClient);
const onUpdate = onActivityLogUpdate.bind(this);
this.updateFn = onUpdate;
events.on(serverNotifications, 'ActivityLogEntry', onUpdate);
Events.on(serverNotifications, 'ActivityLogEntry', onUpdate);
apiClient.sendMessage('ActivityLogEntryStart', '0,1500');
}
destroy() {
@ -152,13 +152,13 @@ class ActivityLog {
if (options) {
options.element.classList.remove('activityLogListWidget');
window.connectionManager.getApiClient(options.serverId).sendMessage('ActivityLogEntryStop', '0,1500');
ServerConnections.getApiClient(options.serverId).sendMessage('ActivityLogEntryStop', '0,1500');
}
const onUpdate = this.updateFn;
if (onUpdate) {
events.off(serverNotifications, 'ActivityLogEntry', onUpdate);
Events.off(serverNotifications, 'ActivityLogEntry', onUpdate);
}
this.items = null;

View File

@ -1,6 +1,7 @@
import browser from 'browser';
import dialog from 'dialog';
import globalize from 'globalize';
import browser from '../scripts/browser';
import dialog from './dialog/dialog';
import globalize from '../scripts/globalize';
/* eslint-disable indent */

View File

@ -5,12 +5,12 @@
* @module components/alphaPicker/alphaPicker
*/
import focusManager from 'focusManager';
import layoutManager from 'layoutManager';
import dom from 'dom';
import 'css!./style.css';
import 'paper-icon-button-light';
import 'material-icons';
import focusManager from '../focusManager';
import layoutManager from '../layoutManager';
import dom from '../../scripts/dom';
import './style.css';
import '../../elements/emby-button/paper-icon-button-light';
import 'material-design-icons-iconfont';
const selectedButtonClass = 'alphaPickerButton-selected';

View File

@ -1,4 +1,4 @@
import 'css!./appFooter';
import './appFooter.css';
function render(options) {
const elem = document.createElement('div');
@ -33,4 +33,4 @@ class appFooter {
}
}
export default appFooter;
export default new appFooter({});

View File

@ -1,13 +1,17 @@
import appHost from 'apphost';
import appSettings from 'appSettings';
import backdrop from 'backdrop';
import browser from 'browser';
import events from 'events';
import globalize from 'globalize';
import itemHelper from 'itemHelper';
import loading from 'loading';
import { appHost } from './apphost';
import appSettings from '../scripts/settings/appSettings';
import backdrop from './backdrop/backdrop';
import browser from '../scripts/browser';
import { Events } from 'jellyfin-apiclient';
import globalize from '../scripts/globalize';
import itemHelper from './itemHelper';
import loading from './loading/loading';
import page from 'page';
import viewManager from 'viewManager';
import viewManager from './viewManager/viewManager';
import AppInfo from './AppInfo';
import Dashboard from '../scripts/clientUtils';
import ServerConnections from './ServerConnections';
import alert from './alert';
class AppRouter {
allRoutes = [];
@ -94,7 +98,7 @@ class AppRouter {
beginConnectionWizard() {
backdrop.clearBackdrop();
loading.show();
window.connectionManager.connect({
ServerConnections.connect({
enableAutoLogin: appSettings.enableAutoLogin()
}).then((result) => {
this.handleConnectionResult(result);
@ -150,10 +154,10 @@ class AppRouter {
loading.show();
this.initApiClients();
events.on(appHost, 'beforeexit', this.onBeforeExit);
events.on(appHost, 'resume', this.onAppResume);
Events.on(appHost, 'beforeexit', this.onBeforeExit);
Events.on(appHost, 'resume', this.onAppResume);
window.connectionManager.connect({
ServerConnections.connect({
enableAutoLogin: appSettings.enableAutoLogin()
}).then((result) => {
this.firstConnectionResult = result;
@ -209,7 +213,7 @@ class AppRouter {
showItem(item, serverId, options) {
// TODO: Refactor this so it only gets items, not strings.
if (typeof (item) === 'string') {
const apiClient = serverId ? window.connectionManager.getApiClient(serverId) : window.connectionManager.currentApiClient();
const apiClient = serverId ? ServerConnections.getApiClient(serverId) : ServerConnections.currentApiClient();
apiClient.getItem(apiClient.getCurrentUserId(), item).then((itemObject) => {
this.showItem(itemObject, options);
});
@ -268,7 +272,7 @@ class AppRouter {
switch (result.State) {
case 'SignedIn':
loading.hide();
Emby.Page.goHome();
this.goHome();
break;
case 'ServerSignIn':
result.ApiClient.getPublicUsers().then((users) => {
@ -286,13 +290,11 @@ class AppRouter {
this.showWelcome();
break;
case 'ServerUpdateNeeded':
import('alert').then(({default: alert}) =>{
alert({
text: globalize.translate('ServerUpdateNeeded', 'https://github.com/jellyfin/jellyfin'),
html: globalize.translate('ServerUpdateNeeded', '<a href="https://github.com/jellyfin/jellyfin">https://github.com/jellyfin/jellyfin</a>')
}).then(() => {
this.showSelectServer();
});
alert({
text: globalize.translate('ServerUpdateNeeded', 'https://github.com/jellyfin/jellyfin'),
html: globalize.translate('ServerUpdateNeeded', '<a href="https://github.com/jellyfin/jellyfin">https://github.com/jellyfin/jellyfin</a>')
}).then(() => {
this.showSelectServer();
});
break;
default:
@ -308,22 +310,20 @@ class AppRouter {
url = route.contentPath || route.path;
}
if (url.includes('configurationpage')) {
url = ApiClient.getUrl('/web' + url);
} else if (url.indexOf('://') === -1) {
// Put a slash at the beginning but make sure to avoid a double slash
if (url.indexOf('/') !== 0) {
url = '/' + url;
}
url = this.baseUrl() + url;
}
if (ctx.querystring && route.enableContentQueryString) {
url += '?' + ctx.querystring;
}
import('text!' + url).then(({default: html}) => {
let promise;
if (route.serverRequest) {
const apiClient = ServerConnections.currentApiClient();
url = apiClient.getUrl(`/web${url}`);
promise = apiClient.get(url);
} else {
promise = import(/* webpackChunkName: "[request]" */ `../controllers/${url}`);
}
promise.then((html) => {
this.loadContent(ctx, route, html, request);
});
}
@ -340,7 +340,7 @@ class AppRouter {
};
if (route.controller) {
import('controllers/' + route.controller).then(onInitComplete);
import('../controllers/' + route.controller).then(onInitComplete);
} else {
onInitComplete();
}
@ -407,9 +407,7 @@ class AppRouter {
this.forcedLogoutMsg = null;
if (msg) {
import('alert').then((alert) => {
alert(msg);
});
alert(msg);
}
}
@ -484,8 +482,8 @@ class AppRouter {
newApiClient.getMaxBandwidth = this.getMaxBandwidth;
}
events.off(newApiClient, 'requestfail', this.onRequestFail);
events.on(newApiClient, 'requestfail', this.onRequestFail);
Events.off(newApiClient, 'requestfail', this.onRequestFail);
Events.on(newApiClient, 'requestfail', this.onRequestFail);
}
initApiClient(apiClient, instance) {
@ -493,15 +491,15 @@ class AppRouter {
}
initApiClients() {
window.connectionManager.getApiClients().forEach((apiClient) => {
ServerConnections.getApiClients().forEach((apiClient) => {
this.initApiClient(apiClient, this);
});
events.on(window.connectionManager, 'apiclientcreated', this.onApiClientCreated);
Events.on(ServerConnections, 'apiclientcreated', this.onApiClientCreated);
}
onAppResume() {
const apiClient = window.connectionManager.currentApiClient();
const apiClient = ServerConnections.currentApiClient();
if (apiClient) {
apiClient.ensureWebSocket();
@ -519,7 +517,7 @@ class AppRouter {
}
}
const apiClient = window.connectionManager.currentApiClient();
const apiClient = ServerConnections.currentApiClient();
const pathname = ctx.pathname.toLowerCase();
console.debug('appRouter - processing path request ' + pathname);
@ -546,7 +544,7 @@ class AppRouter {
if (route.isDefaultRoute) {
console.debug('appRouter - loading skin home page');
Emby.Page.goHome();
this.goHome();
return;
} else if (route.roles) {
this.validateRoles(apiClient, route.roles).then(() => {
@ -846,4 +844,8 @@ class AppRouter {
}
}
export default new AppRouter();
export const appRouter = new AppRouter();
window.Emby = window.Emby || {};
window.Emby.Page = appRouter;

View File

@ -1,9 +1,11 @@
import appSettings from 'appSettings';
import browser from 'browser';
import events from 'events';
import * as htmlMediaHelper from 'htmlMediaHelper';
import * as webSettings from 'webSettings';
import globalize from 'globalize';
import appSettings from '../scripts/settings/appSettings';
import browser from '../scripts/browser';
import { Events } from 'jellyfin-apiclient';
import * as htmlMediaHelper from '../components/htmlMediaHelper';
import * as webSettings from '../scripts/settings/webSettings';
import globalize from '../scripts/globalize';
import profileBuilder from '../scripts/browserDeviceProfile';
function getBaseProfileOptions(item) {
const disableHlsVideoAudioCodecs = [];
@ -26,19 +28,16 @@ function getBaseProfileOptions(item) {
function getDeviceProfile(item, options = {}) {
return new Promise(function (resolve) {
import('browserdeviceprofile').then(({default: profileBuilder}) => {
let profile;
let profile;
if (window.NativeShell) {
profile = window.NativeShell.AppHost.getDeviceProfile(profileBuilder);
} else {
const builderOpts = getBaseProfileOptions(item);
builderOpts.enableSsaRender = (item && !options.isRetry && appSettings.get('subtitleburnin') !== 'allcomplexformats');
profile = profileBuilder(builderOpts);
}
if (window.NativeShell) {
profile = window.NativeShell.AppHost.getDeviceProfile(profileBuilder);
} else {
const builderOpts = getBaseProfileOptions(item);
profile = profileBuilder(builderOpts);
}
resolve(profile);
});
resolve(profile);
});
}
@ -57,60 +56,62 @@ function generateDeviceId() {
if (keys.push(navigator.userAgent), keys.push(new Date().getTime()), window.btoa) {
const result = replaceAll(btoa(keys.join('|')), '=', '1');
return Promise.resolve(result);
return result;
}
return Promise.resolve(new Date().getTime());
return new Date().getTime();
}
function getDeviceId() {
const key = '_deviceId2';
const deviceId = appSettings.get(key);
if (!deviceId) {
const key = '_deviceId2';
if (deviceId) {
return Promise.resolve(deviceId);
deviceId = appSettings.get(key);
if (!deviceId) {
deviceId = generateDeviceId();
appSettings.set(key, deviceId);
}
}
return generateDeviceId().then(function (deviceId) {
appSettings.set(key, deviceId);
return deviceId;
});
return deviceId;
}
function getDeviceName() {
let deviceName;
if (browser.tizen) {
deviceName = 'Samsung Smart TV';
} else if (browser.web0s) {
deviceName = 'LG Smart TV';
} else if (browser.operaTv) {
deviceName = 'Opera TV';
} else if (browser.xboxOne) {
deviceName = 'Xbox One';
} else if (browser.ps4) {
deviceName = 'Sony PS4';
} else if (browser.chrome) {
deviceName = 'Chrome';
} else if (browser.edgeChromium) {
deviceName = 'Edge Chromium';
} else if (browser.edge) {
deviceName = 'Edge';
} else if (browser.firefox) {
deviceName = 'Firefox';
} else if (browser.opera) {
deviceName = 'Opera';
} else if (browser.safari) {
deviceName = 'Safari';
} else {
deviceName = 'Web Browser';
}
if (!deviceName) {
if (browser.tizen) {
deviceName = 'Samsung Smart TV';
} else if (browser.web0s) {
deviceName = 'LG Smart TV';
} else if (browser.operaTv) {
deviceName = 'Opera TV';
} else if (browser.xboxOne) {
deviceName = 'Xbox One';
} else if (browser.ps4) {
deviceName = 'Sony PS4';
} else if (browser.chrome) {
deviceName = 'Chrome';
} else if (browser.edgeChromium) {
deviceName = 'Edge Chromium';
} else if (browser.edge) {
deviceName = 'Edge';
} else if (browser.firefox) {
deviceName = 'Firefox';
} else if (browser.opera) {
deviceName = 'Opera';
} else if (browser.safari) {
deviceName = 'Safari';
} else {
deviceName = 'Web Browser';
}
if (browser.ipad) {
deviceName += ' iPad';
} else if (browser.iphone) {
deviceName += ' iPhone';
} else if (browser.android) {
deviceName += ' Android';
if (browser.ipad) {
deviceName += ' iPad';
} else if (browser.iphone) {
deviceName += ' iPhone';
} else if (browser.android) {
deviceName += ' Android';
}
}
return deviceName;
@ -172,7 +173,7 @@ function supportsCue() {
function onAppVisible() {
if (isHidden) {
isHidden = false;
events.trigger(appHost, 'resume');
Events.trigger(appHost, 'resume');
}
}
@ -296,7 +297,7 @@ function askForExit() {
return;
}
import('actionsheet').then(({default: actionsheet}) => {
import('../components/actionSheet/actionSheet').then((actionsheet) => {
exitPromise = actionsheet.show({
title: globalize.translate('MessageConfirmAppExit'),
items: [
@ -318,7 +319,7 @@ let deviceName;
const appName = 'Jellyfin Web';
const appVersion = '10.7.0';
const appHost = {
export const appHost = {
getWindowState: function () {
return document.windowState || 'Normal';
},
@ -353,16 +354,16 @@ const appHost = {
return window.NativeShell.AppHost.init();
}
deviceName = getDeviceName();
getDeviceId().then(function (id) {
deviceId = id;
});
return {
deviceId: getDeviceId(),
deviceName: getDeviceName()
};
},
deviceName: function () {
return window.NativeShell ? window.NativeShell.AppHost.deviceName() : deviceName;
return window.NativeShell ? window.NativeShell.AppHost.deviceName() : getDeviceName();
},
deviceId: function () {
return window.NativeShell ? window.NativeShell.AppHost.deviceId() : deviceId;
return window.NativeShell ? window.NativeShell.AppHost.deviceId() : getDeviceId();
},
appName: function () {
return window.NativeShell ? window.NativeShell.AppHost.appName() : appName;
@ -407,4 +408,5 @@ if (window.addEventListener) {
window.addEventListener('blur', onAppHidden);
}
export default appHost;
// load app host on module load
appHost.init();

View File

@ -5,8 +5,8 @@
* @module components/autoFocuser
*/
import focusManager from 'focusManager';
import layoutManager from 'layoutManager';
import focusManager from './focusManager';
import layoutManager from './layoutManager';
/**
* Previously selected element.

View File

@ -1,8 +1,9 @@
import browser from 'browser';
import playbackManager from 'playbackManager';
import dom from 'dom';
import * as userSettings from 'userSettings';
import 'css!./backdrop';
import browser from '../../scripts/browser';
import { playbackManager } from '../playback/playbackmanager';
import dom from '../../scripts/dom';
import * as userSettings from '../../scripts/settings/userSettings';
import './backdrop.css';
import ServerConnections from '../ServerConnections';
/* eslint-disable indent */
@ -176,7 +177,7 @@ import 'css!./backdrop';
function getItemImageUrls(item, imageOptions) {
imageOptions = imageOptions || {};
const apiClient = window.connectionManager.getApiClient(item.ServerId);
const apiClient = ServerConnections.getApiClient(item.ServerId);
if (item.BackdropImageTags && item.BackdropImageTags.length > 0) {
return item.BackdropImageTags.map((imgTag, index) => {
return apiClient.getScaledImageUrl(item.BackdropItemId || item.Id, Object.assign(imageOptions, {

View File

@ -5,21 +5,22 @@
* @module components/cardBuilder/cardBuilder
*/
import datetime from 'datetime';
import imageLoader from 'imageLoader';
import itemHelper from 'itemHelper';
import focusManager from 'focusManager';
import indicators from 'indicators';
import globalize from 'globalize';
import layoutManager from 'layoutManager';
import dom from 'dom';
import browser from 'browser';
import playbackManager from 'playbackManager';
import itemShortcuts from 'itemShortcuts';
import imageHelper from 'scripts/imagehelper';
import 'css!./card';
import 'paper-icon-button-light';
import 'programStyles';
import datetime from '../../scripts/datetime';
import imageLoader from '../images/imageLoader';
import itemHelper from '../itemHelper';
import focusManager from '../focusManager';
import indicators from '../indicators/indicators';
import globalize from '../../scripts/globalize';
import layoutManager from '../layoutManager';
import dom from '../../scripts/dom';
import browser from '../../scripts/browser';
import { playbackManager } from '../playback/playbackmanager';
import itemShortcuts from '../shortcuts';
import imageHelper from '../../scripts/imagehelper';
import './card.css';
import '../../elements/emby-button/paper-icon-button-light';
import '../guide/programs.css';
import ServerConnections from '../ServerConnections';
const enableFocusTransform = !browser.slow && !browser.edge;
@ -370,7 +371,7 @@ import 'programStyles';
if (serverId !== lastServerId) {
lastServerId = serverId;
apiClient = window.connectionManager.getApiClient(lastServerId);
apiClient = ServerConnections.getApiClient(lastServerId);
}
if (options.indexBy) {
@ -1121,7 +1122,7 @@ import 'programStyles';
if (!refreshIndicatorLoaded) {
refreshIndicatorLoaded = true;
/* eslint-disable-next-line @babel/no-unused-expressions */
import('emby-itemrefreshindicator');
import('../../elements/emby-itemrefreshindicator/emby-itemrefreshindicator');
}
}
@ -1453,7 +1454,7 @@ import 'programStyles';
if (itemHelper.canMarkPlayed(item)) {
/* eslint-disable-next-line @babel/no-unused-expressions */
import('emby-playstatebutton');
import('../../elements/emby-playstatebutton/emby-playstatebutton');
html += '<button is="emby-playstatebutton" type="button" data-action="none" class="' + btnCssClass + '" data-id="' + item.Id + '" data-serverid="' + item.ServerId + '" data-itemtype="' + item.Type + '" data-played="' + (userData.Played) + '"><span class="material-icons cardOverlayButtonIcon cardOverlayButtonIcon-hover check"></span></button>';
}
@ -1461,7 +1462,7 @@ import 'programStyles';
const likes = userData.Likes == null ? '' : userData.Likes;
/* eslint-disable-next-line @babel/no-unused-expressions */
import('emby-ratingbutton');
import('../../elements/emby-ratingbutton/emby-ratingbutton');
html += '<button is="emby-ratingbutton" type="button" data-action="none" class="' + btnCssClass + '" data-id="' + item.Id + '" data-serverid="' + item.ServerId + '" data-itemtype="' + item.Type + '" data-likes="' + likes + '" data-isfavorite="' + (userData.IsFavorite) + '"><span class="material-icons cardOverlayButtonIcon cardOverlayButtonIcon-hover favorite"></span></button>';
}

View File

@ -5,10 +5,11 @@
* @module components/cardBuilder/chaptercardbuilder
*/
import datetime from 'datetime';
import imageLoader from 'imageLoader';
import layoutManager from 'layoutManager';
import browser from 'browser';
import datetime from '../../scripts/datetime';
import imageLoader from '../images/imageLoader';
import layoutManager from '../layoutManager';
import browser from '../../scripts/browser';
import ServerConnections from '../ServerConnections';
const enableFocusTransform = !browser.slow && !browser.edge;
@ -47,7 +48,7 @@ import browser from 'browser';
let html = '';
let itemsInRow = 0;
const apiClient = window.connectionManager.getApiClient(item.ServerId);
const apiClient = ServerConnections.getApiClient(item.ServerId);
for (let i = 0, length = chapters.length; i < length; i++) {
if (options.rows && itemsInRow === 0) {

View File

@ -5,7 +5,7 @@
* @module components/cardBuilder/peoplecardbuilder
*/
import cardBuilder from 'cardBuilder';
import cardBuilder from './cardBuilder';
export function buildPeopleCards(items, options) {
options = Object.assign(options || {}, {

View File

@ -1,21 +1,22 @@
import dom from 'dom';
import dialogHelper from 'dialogHelper';
import loading from 'loading';
import globalize from 'globalize';
import actionsheet from 'actionsheet';
import 'emby-input';
import 'paper-icon-button-light';
import 'emby-button';
import 'listViewStyle';
import 'material-icons';
import 'formDialogStyle';
import dom from '../../scripts/dom';
import dialogHelper from '../dialogHelper/dialogHelper';
import loading from '../loading/loading';
import globalize from '../../scripts/globalize';
import actionsheet from '../actionSheet/actionSheet';
import '../../elements/emby-input/emby-input';
import '../../elements/emby-button/paper-icon-button-light';
import '../../elements/emby-button/emby-button';
import '../listview/listview.css';
import 'material-design-icons-iconfont';
import '../formdialog.css';
import ServerConnections from '../ServerConnections';
export default class channelMapper {
constructor(options) {
function mapChannel(button, channelId, providerChannelId) {
loading.show();
const providerId = options.providerId;
window.connectionManager.getApiClient(options.serverId).ajax({
ServerConnections.getApiClient(options.serverId).ajax({
type: 'POST',
url: ApiClient.getUrl('LiveTv/ChannelMappings'),
data: JSON.stringify({
@ -58,7 +59,7 @@ export default class channelMapper {
}
function getChannelMappingOptions(serverId, providerId) {
const apiClient = window.connectionManager.getApiClient(serverId);
const apiClient = ServerConnections.getApiClient(serverId);
return apiClient.getJSON(apiClient.getUrl('LiveTv/ChannelMappingOptions', {
providerId: providerId
}));

View File

@ -1,17 +1,19 @@
import dom from 'dom';
import dialogHelper from 'dialogHelper';
import loading from 'loading';
import layoutManager from 'layoutManager';
import appRouter from 'appRouter';
import globalize from 'globalize';
import 'emby-checkbox';
import 'emby-input';
import 'paper-icon-button-light';
import 'emby-select';
import 'material-icons';
import 'css!./../formdialog';
import 'emby-button';
import 'flexStyles';
import dom from '../../scripts/dom';
import dialogHelper from '../dialogHelper/dialogHelper';
import loading from '../loading/loading';
import layoutManager from '../layoutManager';
import { appRouter } from '../appRouter';
import globalize from '../../scripts/globalize';
import '../../elements/emby-button/emby-button';
import '../../elements/emby-button/paper-icon-button-light';
import '../../elements/emby-checkbox/emby-checkbox';
import '../../elements/emby-input/emby-input';
import '../../elements/emby-select/emby-select';
import 'material-design-icons-iconfont';
import '../formdialog.css';
import '../../assets/css/flexstyles.scss';
import ServerConnections from '../ServerConnections';
import toast from '../toast/toast';
/* eslint-disable indent */
@ -24,7 +26,7 @@ import 'flexStyles';
const collectionId = panel.querySelector('#selectCollectionToAddTo').value;
const apiClient = window.connectionManager.getApiClient(currentServerId);
const apiClient = ServerConnections.getApiClient(currentServerId);
if (collectionId) {
addToCollection(apiClient, panel, collectionId);
@ -80,9 +82,7 @@ import 'flexStyles';
dlg.submitted = true;
dialogHelper.close(dlg);
import('toast').then(({default: toast}) => {
toast(globalize.translate('MessageItemsAdded'));
});
toast(globalize.translate('MessageItemsAdded'));
});
}
@ -105,7 +105,7 @@ import 'flexStyles';
EnableTotalRecordCount: false
};
const apiClient = window.connectionManager.getApiClient(currentServerId);
const apiClient = ServerConnections.getApiClient(currentServerId);
apiClient.getItems(apiClient.getCurrentUserId(), options).then(result => {
let html = '';
@ -199,7 +199,7 @@ import 'flexStyles';
}
function centerFocus(elem, horiz, on) {
import('scrollHelper').then((scrollHelper) => {
import('../../scripts/scrollHelper').then((scrollHelper) => {
const fn = on ? 'on' : 'off';
scrollHelper.centerFocus[fn](elem, horiz);
});

View File

@ -1,69 +1,65 @@
import browser from 'browser';
import dialog from 'dialog';
import globalize from 'globalize';
import browser from '../../scripts/browser';
import dialog from '../dialog/dialog';
import globalize from '../../scripts/globalize';
/* eslint-disable indent */
export default (() => {
function replaceAll(str, find, replace) {
return str.split(find).join(replace);
function replaceAll(str, find, replace) {
return str.split(find).join(replace);
}
function nativeConfirm(options) {
if (typeof options === 'string') {
options = {
title: '',
text: options
};
}
if (browser.tv && window.confirm) {
// Use the native confirm dialog
return options => {
if (typeof options === 'string') {
options = {
title: '',
text: options
};
}
const text = replaceAll(options.text || '', '<br/>', '\n');
const result = window.confirm(text);
const text = replaceAll(options.text || '', '<br/>', '\n');
const result = window.confirm(text);
if (result) {
return Promise.resolve();
} else {
return Promise.reject();
}
}
if (result) {
return Promise.resolve();
} else {
return Promise.reject();
}
function customConfirm(text, title) {
let options;
if (typeof text === 'string') {
options = {
title: title,
text: text
};
} else {
// Use our own dialog
return (text, title) => {
let options;
if (typeof text === 'string') {
options = {
title: title,
text: text
};
} else {
options = text;
}
const items = [];
items.push({
name: options.cancelText || globalize.translate('ButtonCancel'),
id: 'cancel',
type: 'cancel'
});
items.push({
name: options.confirmText || globalize.translate('ButtonOk'),
id: 'ok',
type: options.primary === 'delete' ? 'delete' : 'submit'
});
options.buttons = items;
return dialog.show(options).then(result => {
if (result === 'ok') {
return Promise.resolve();
}
return Promise.reject();
});
};
options = text;
}
})();
/* eslint-enable indent */
const items = [];
items.push({
name: options.cancelText || globalize.translate('ButtonCancel'),
id: 'cancel',
type: 'cancel'
});
items.push({
name: options.confirmText || globalize.translate('ButtonOk'),
id: 'ok',
type: options.primary === 'delete' ? 'delete' : 'submit'
});
options.buttons = items;
return dialog.show(options).then(result => {
if (result === 'ok') {
return Promise.resolve();
}
return Promise.reject();
});
}
const confirm = browser.tv && window.confirm ? nativeConfirm : customConfirm;
export default confirm;

View File

@ -1,14 +1,14 @@
import dialogHelper from 'dialogHelper';
import dom from 'dom';
import layoutManager from 'layoutManager';
import scrollHelper from 'scrollHelper';
import globalize from 'globalize';
import 'material-icons';
import 'emby-button';
import 'paper-icon-button-light';
import 'emby-input';
import 'formDialogStyle';
import 'flexStyles';
import dialogHelper from '../dialogHelper/dialogHelper';
import dom from '../../scripts/dom';
import layoutManager from '../layoutManager';
import scrollHelper from '../../scripts/scrollHelper';
import globalize from '../../scripts/globalize';
import 'material-design-icons-iconfont';
import '../../elements/emby-button/emby-button';
import '../../elements/emby-button/paper-icon-button-light';
import '../../elements/emby-input/emby-input';
import '../formdialog.css';
import '../../assets/css/flexstyles.scss';
/* eslint-disable indent */
@ -128,7 +128,7 @@ import 'flexStyles';
options = text;
}
const { default: template } = await import('text!./dialog.template.html');
const { default: template } = await import('./dialog.template.html');
return new Promise((resolve, reject) => {
showDialog(options, template).then(resolve, reject);
});

View File

@ -1,11 +1,11 @@
import appRouter from 'appRouter';
import focusManager from 'focusManager';
import browser from 'browser';
import layoutManager from 'layoutManager';
import inputManager from 'inputManager';
import dom from 'dom';
import 'css!./dialoghelper.css';
import 'scrollStyles';
import { appRouter } from '../appRouter';
import focusManager from '../focusManager';
import browser from '../../scripts/browser';
import layoutManager from '../layoutManager';
import inputManager from '../../scripts/inputManager';
import dom from '../../scripts/dom';
import './dialoghelper.css';
import '../../assets/css/scrollstyles.css';
/* eslint-disable indent */
@ -354,7 +354,7 @@ import 'scrollStyles';
}
function centerFocus(elem, horiz, on) {
import('scrollHelper').then((scrollHelper) => {
import('../../scripts/scrollHelper').then((scrollHelper) => {
const fn = on ? 'on' : 'off';
scrollHelper.centerFocus[fn](elem, horiz);
});

View File

@ -1,13 +1,14 @@
import loading from 'loading';
import dialogHelper from 'dialogHelper';
import dom from 'dom';
import globalize from 'globalize';
import 'listViewStyle';
import 'emby-input';
import 'paper-icon-button-light';
import 'css!./directorybrowser';
import 'formDialogStyle';
import 'emby-button';
import loading from '../loading/loading';
import dialogHelper from '../dialogHelper/dialogHelper';
import dom from '../../scripts/dom';
import globalize from '../../scripts/globalize';
import '../listview/listview.css';
import '../../elements/emby-input/emby-input';
import '../../elements/emby-button/paper-icon-button-light';
import './directorybrowser.css';
import '../formdialog.css';
import '../../elements/emby-button/emby-button';
import alert from '../alert';
/* eslint-disable indent */
@ -157,9 +158,7 @@ import 'emby-button';
}
function alertTextWithOptions(options) {
import('alert').then(({default: alert}) => {
alert(options);
});
alert(options);
}
function validatePath(path, validateWriteable, apiClient) {

View File

@ -1,16 +1,18 @@
import browser from 'browser';
import layoutManager from 'layoutManager';
import pluginManager from 'pluginManager';
import appHost from 'apphost';
import focusManager from 'focusManager';
import datetime from 'datetime';
import globalize from 'globalize';
import loading from 'loading';
import skinManager from 'skinManager';
import events from 'events';
import 'emby-select';
import 'emby-checkbox';
import 'emby-button';
import browser from '../../scripts/browser';
import layoutManager from '../layoutManager';
import { pluginManager } from '../pluginManager';
import { appHost } from '../apphost';
import focusManager from '../focusManager';
import datetime from '../../scripts/datetime';
import globalize from '../../scripts/globalize';
import loading from '../loading/loading';
import skinManager from '../../scripts/themeManager';
import { Events } from 'jellyfin-apiclient';
import '../../elements/emby-select/emby-select';
import '../../elements/emby-checkbox/emby-checkbox';
import '../../elements/emby-button/emby-button';
import ServerConnections from '../ServerConnections';
import toast from '../toast/toast';
/* eslint-disable indent */
@ -168,11 +170,9 @@ import 'emby-button';
saveUser(context, user, userSettings, apiClient).then(() => {
loading.hide();
if (enableSaveConfirmation) {
import('toast').then(({default: toast}) => {
toast(globalize.translate('SettingsSaved'));
});
toast(globalize.translate('SettingsSaved'));
}
events.trigger(instance, 'saved');
Events.trigger(instance, 'saved');
}, () => {
loading.hide();
});
@ -181,7 +181,7 @@ import 'emby-button';
function onSubmit(e) {
const self = this;
const apiClient = window.connectionManager.getApiClient(self.options.serverId);
const apiClient = ServerConnections.getApiClient(self.options.serverId);
const userId = self.options.userId;
const userSettings = self.options.userSettings;
@ -198,7 +198,7 @@ import 'emby-button';
}
async function embed(options, self) {
const { default: template } = await import('text!./displaySettings.template.html');
const { default: template } = await import('./displaySettings.template.html');
options.element.innerHTML = globalize.translateHtml(template, 'core');
options.element.querySelector('form').addEventListener('submit', onSubmit.bind(self));
if (options.enableSaveButton) {
@ -220,7 +220,7 @@ import 'emby-button';
loading.show();
const userId = self.options.userId;
const apiClient = window.connectionManager.getApiClient(self.options.serverId);
const apiClient = ServerConnections.getApiClient(self.options.serverId);
const userSettings = self.options.userSettings;
return apiClient.getUser(userId).then(user => {

View File

@ -1,12 +1,12 @@
import loading from 'loading';
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';
import loading from './loading/loading';
import cardBuilder from './cardbuilder/cardBuilder';
import dom from '../scripts/dom';
import { appHost } from './apphost';
import imageLoader from './images/imageLoader';
import globalize from '../scripts/globalize';
import layoutManager from './layoutManager';
import '../assets/css/scrollstyles.css';
import '../elements/emby-itemscontainer/emby-itemscontainer';
/* eslint-disable indent */

View File

@ -1,10 +1,11 @@
import dom from 'dom';
import dialogHelper from 'dialogHelper';
import globalize from 'globalize';
import events from 'events';
import 'emby-checkbox';
import 'emby-collapse';
import 'css!./style.css';
import dom from '../../scripts/dom';
import dialogHelper from '../dialogHelper/dialogHelper';
import globalize from '../../scripts/globalize';
import { Events } from 'jellyfin-apiclient';
import '../../elements/emby-checkbox/emby-checkbox';
import '../../elements/emby-collapse/emby-collapse';
import './style.css';
import ServerConnections from '../ServerConnections';
/* eslint-disable indent */
function renderOptions(context, selector, cssClass, items, isCheckedFn) {
@ -108,7 +109,7 @@ import 'css!./style.css';
* @param instance {FilterDialog} An instance of FilterDialog
*/
function triggerChange(instance) {
events.trigger(instance, 'filterchange');
Events.trigger(instance, 'filterchange');
}
function setVisibility(context, options) {
@ -401,7 +402,7 @@ import 'css!./style.css';
}
show() {
return import('text!./filterdialog.template.html').then(({default: template}) => {
return import('./filterdialog.template.html').then(({default: template}) => {
return new Promise((resolve) => {
const dlg = dialogHelper.createDialog({
removeOnClose: true,
@ -419,7 +420,7 @@ import 'css!./style.css';
this.bindEvents(dlg);
if (enableDynamicFilters(this.options.mode)) {
dlg.classList.add('dynamicFilterDialog');
const apiClient = window.connectionManager.getApiClient(this.options.serverId);
const apiClient = ServerConnections.getApiClient(this.options.serverId);
loadDynamicFilters(dlg, apiClient, apiClient.getCurrentUserId(), this.options.query);
}
});

View File

@ -1,18 +1,19 @@
import dom from 'dom';
import focusManager from 'focusManager';
import dialogHelper from 'dialogHelper';
import inputManager from 'inputManager';
import layoutManager from 'layoutManager';
import globalize from 'globalize';
import * as userSettings from 'userSettings';
import 'emby-checkbox';
import 'emby-input';
import 'paper-icon-button-light';
import 'emby-select';
import 'material-icons';
import 'css!./../formdialog';
import 'emby-button';
import 'flexStyles';
import dom from '../../scripts/dom';
import focusManager from '../focusManager';
import dialogHelper from '../dialogHelper/dialogHelper';
import inputManager from '../../scripts/inputManager';
import layoutManager from '../layoutManager';
import globalize from '../../scripts/globalize';
import * as userSettings from '../../scripts/settings/userSettings';
import '../../elements/emby-checkbox/emby-checkbox';
import '../../elements/emby-input/emby-input';
import '../../elements/emby-button/emby-button';
import '../../elements/emby-button/paper-icon-button-light';
import '../../elements/emby-select/emby-select';
import 'material-design-icons-iconfont';
import '../formdialog.css';
import '../../assets/css/flexstyles.scss';
import ServerConnections from '../ServerConnections';
function onSubmit(e) {
e.preventDefault();
@ -80,7 +81,7 @@ function moveCheckboxFocus(elem, offset) {
}
}
function centerFocus(elem, horiz, on) {
import('scrollHelper').then(({ default: scrollHelper }) => {
import('../../scripts/scrollHelper').then((scrollHelper) => {
const fn = on ? 'on' : 'off';
scrollHelper.centerFocus[fn](elem, horiz);
});
@ -193,7 +194,7 @@ function initEditor(context, settings) {
}
}
function loadDynamicFilters(context, options) {
const apiClient = window.connectionManager.getApiClient(options.serverId);
const apiClient = ServerConnections.getApiClient(options.serverId);
const filterMenuOptions = Object.assign(options.filterMenuOptions, {
@ -209,7 +210,7 @@ function loadDynamicFilters(context, options) {
class FilterMenu {
show(options) {
return new Promise( (resolve, reject) => {
import('text!./filtermenu.template.html').then(({ default: template }) => {
import('./filtermenu.template.html').then(({ default: template }) => {
const dialogOptions = {
removeOnClose: true,
scrollY: false

View File

@ -1,7 +1,7 @@
/* eslint-disable indent */
import dom from 'dom';
import scrollManager from 'scrollManager';
import dom from '../scripts/dom';
import scrollManager from './scrollManager';
const scopes = [];
function pushScope(elem) {

View File

@ -1,12 +1,14 @@
/* eslint-disable indent */
import dom from 'dom';
import appRouter from 'appRouter';
import dom from '../scripts/dom';
import { appRouter } from './appRouter';
import Dashboard from '../scripts/clientUtils';
import ServerConnections from './ServerConnections';
function onGroupedCardClick(e, card) {
const itemId = card.getAttribute('data-id');
const serverId = card.getAttribute('data-serverid');
const apiClient = window.connectionManager.getApiClient(serverId);
const apiClient = ServerConnections.getApiClient(serverId);
const userId = apiClient.getCurrentUserId();
const playedIndicator = card.querySelector('.playedIndicator');
const playedIndicatorHtml = playedIndicator ? playedIndicator.innerHTML : null;

View File

@ -1,12 +1,12 @@
import dialogHelper from 'dialogHelper';
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';
import dialogHelper from '../dialogHelper/dialogHelper';
import globalize from '../../scripts/globalize';
import * as userSettings from '../../scripts/settings/userSettings';
import layoutManager from '../layoutManager';
import scrollHelper from '../../scripts/scrollHelper';
import '../../elements/emby-checkbox/emby-checkbox';
import '../../elements/emby-radio/emby-radio';
import '../formdialog.css';
import 'material-design-icons-iconfont';
function saveCategories(context, options) {
const categories = [];
@ -88,7 +88,7 @@ function showEditor(options) {
return new Promise(function (resolve, reject) {
let settingsChanged = false;
import('text!./guide-settings.template.html').then(({ default: template }) => {
import('./guide-settings.template.html').then(({ default: template }) => {
const dialogOptions = {
removeOnClose: true,
scrollY: false

View File

@ -1,32 +1,33 @@
import inputManager from 'inputManager';
import browser from 'browser';
import globalize from 'globalize';
import scrollHelper from 'scrollHelper';
import serverNotifications from 'serverNotifications';
import loading from 'loading';
import datetime from 'datetime';
import focusManager from 'focusManager';
import playbackManager from 'playbackManager';
import * as userSettings from 'userSettings';
import imageLoader from 'imageLoader';
import events from 'events';
import layoutManager from 'layoutManager';
import itemShortcuts from 'itemShortcuts';
import dom from 'dom';
import 'css!./guide.css';
import 'programStyles';
import 'material-icons';
import 'scrollStyles';
import 'emby-programcell';
import 'emby-button';
import 'paper-icon-button-light';
import 'emby-tabs';
import 'emby-scroller';
import 'flexStyles';
import 'webcomponents';
import inputManager from '../../scripts/inputManager';
import browser from '../../scripts/browser';
import globalize from '../../scripts/globalize';
import { Events } from 'jellyfin-apiclient';
import scrollHelper from '../../scripts/scrollHelper';
import serverNotifications from '../../scripts/serverNotifications';
import loading from '../loading/loading';
import datetime from '../../scripts/datetime';
import focusManager from '../focusManager';
import { playbackManager } from '../playback/playbackmanager';
import * as userSettings from '../../scripts/settings/userSettings';
import imageLoader from '../images/imageLoader';
import layoutManager from '../layoutManager';
import itemShortcuts from '../shortcuts';
import dom from '../../scripts/dom';
import './guide.css';
import './programs.css';
import 'material-design-icons-iconfont';
import '../../assets/css/scrollstyles.css';
import '../../elements/emby-programcell/emby-programcell';
import '../../elements/emby-button/emby-button';
import '../../elements/emby-button/paper-icon-button-light';
import '../../elements/emby-tabs/emby-tabs';
import '../../elements/emby-scroller/emby-scroller';
import '../../assets/css/flexstyles.scss';
import 'webcomponents.js/webcomponents-lite';
import ServerConnections from '../ServerConnections';
function showViewSettings(instance) {
import('guide-settings-dialog').then(({default: guideSettingsDialog}) => {
import('./guide-settings').then(({default: guideSettingsDialog}) => {
guideSettingsDialog.show(instance.categoryOptions).then(function () {
instance.refresh();
});
@ -164,10 +165,10 @@ function Guide(options) {
self.destroy = function () {
stopAutoRefresh();
events.off(serverNotifications, 'TimerCreated', onTimerCreated);
events.off(serverNotifications, 'SeriesTimerCreated', onSeriesTimerCreated);
events.off(serverNotifications, 'TimerCancelled', onTimerCancelled);
events.off(serverNotifications, 'SeriesTimerCancelled', onSeriesTimerCancelled);
Events.off(serverNotifications, 'TimerCreated', onTimerCreated);
Events.off(serverNotifications, 'SeriesTimerCreated', onSeriesTimerCreated);
Events.off(serverNotifications, 'TimerCancelled', onTimerCancelled);
Events.off(serverNotifications, 'SeriesTimerCancelled', onSeriesTimerCancelled);
setScrollEvents(options.element, false);
itemShortcuts.off(options.element);
@ -212,7 +213,7 @@ function Guide(options) {
}
function reloadGuide(context, newStartDate, scrollToTimeMs, focusToTimeMs, startTimeOfDayMs, focusProgramOnRender) {
const apiClient = window.connectionManager.getApiClient(options.serverId);
const apiClient = ServerConnections.getApiClient(options.serverId);
const channelQuery = {
@ -872,7 +873,7 @@ function Guide(options) {
function reloadPage(page) {
showLoading();
const apiClient = window.connectionManager.getApiClient(options.serverId);
const apiClient = ServerConnections.getApiClient(options.serverId);
apiClient.getLiveTvGuideInfo().then(function (guideInfo) {
setDateRange(page, guideInfo);
@ -1001,7 +1002,7 @@ function Guide(options) {
const item = items[id];
if (item) {
events.trigger(self, 'focus', [
Events.trigger(self, 'focus', [
{
item: item
}]);
@ -1091,7 +1092,7 @@ function Guide(options) {
}
}
import('text!./tvguide.template.html').then(({default: template}) => {
import('./tvguide.template.html').then(({default: template}) => {
const context = options.element;
context.classList.add('tvguide');
@ -1183,12 +1184,12 @@ function Guide(options) {
setScrollEvents(context, true);
itemShortcuts.on(context);
events.trigger(self, 'load');
Events.trigger(self, 'load');
events.on(serverNotifications, 'TimerCreated', onTimerCreated);
events.on(serverNotifications, 'SeriesTimerCreated', onSeriesTimerCreated);
events.on(serverNotifications, 'TimerCancelled', onTimerCancelled);
events.on(serverNotifications, 'SeriesTimerCancelled', onSeriesTimerCancelled);
Events.on(serverNotifications, 'TimerCreated', onTimerCreated);
Events.on(serverNotifications, 'SeriesTimerCreated', onSeriesTimerCreated);
Events.on(serverNotifications, 'TimerCancelled', onTimerCancelled);
Events.on(serverNotifications, 'SeriesTimerCancelled', onSeriesTimerCancelled);
self.refresh();
});

View File

@ -1,13 +1,16 @@
import layoutManager from 'layoutManager';
import focusManager from 'focusManager';
import globalize from 'globalize';
import loading from 'loading';
import homeSections from 'homeSections';
import dom from 'dom';
import events from 'events';
import 'listViewStyle';
import 'emby-select';
import 'emby-checkbox';
import layoutManager from '../layoutManager';
import focusManager from '../focusManager';
import globalize from '../../scripts/globalize';
import loading from '../loading/loading';
import { Events } from 'jellyfin-apiclient';
import homeSections from '../homesections/homesections';
import dom from '../../scripts/dom';
import '../listview/listview.css';
import '../../elements/emby-select/emby-select';
import '../../elements/emby-checkbox/emby-checkbox';
import ServerConnections from '../ServerConnections';
import toast from '../toast/toast';
/* eslint-disable indent */
@ -369,12 +372,10 @@ import 'emby-checkbox';
saveUser(context, user, userSettings, apiClient).then(() => {
loading.hide();
if (enableSaveConfirmation) {
import('toast').then(({default: toast}) => {
toast(globalize.translate('SettingsSaved'));
});
toast(globalize.translate('SettingsSaved'));
}
events.trigger(instance, 'saved');
Events.trigger(instance, 'saved');
}, () => {
loading.hide();
});
@ -383,7 +384,7 @@ import 'emby-checkbox';
function onSubmit(e) {
const self = this;
const apiClient = window.connectionManager.getApiClient(self.options.serverId);
const apiClient = ServerConnections.getApiClient(self.options.serverId);
const userId = self.options.userId;
const userSettings = self.options.userSettings;
@ -417,7 +418,7 @@ import 'emby-checkbox';
}
function embed(options, self) {
return import('text!./homeScreenSettings.template.html').then(({default: template}) => {
return import('./homeScreenSettings.template.html').then(({default: template}) => {
for (let i = 1; i <= numConfigurableSections; i++) {
template = template.replace(`{section${i}label}`, globalize.translate('LabelHomeScreenSectionValue', i));
}
@ -455,7 +456,7 @@ import 'emby-checkbox';
loading.show();
const userId = self.options.userId;
const apiClient = window.connectionManager.getApiClient(self.options.serverId);
const apiClient = ServerConnections.getApiClient(self.options.serverId);
const userSettings = self.options.userSettings;
apiClient.getUser(userId).then(user => {

View File

@ -1,15 +1,17 @@
import cardBuilder from 'cardBuilder';
import dom from 'dom';
import layoutManager from 'layoutManager';
import imageLoader from 'imageLoader';
import globalize from 'globalize';
import appRouter from 'appRouter';
import imageHelper from 'scripts/imagehelper';
import 'paper-icon-button-light';
import 'emby-itemscontainer';
import 'emby-scroller';
import 'emby-button';
import 'css!./homesections';
import cardBuilder from '../cardbuilder/cardBuilder';
import dom from '../../scripts/dom';
import layoutManager from '../layoutManager';
import imageLoader from '../images/imageLoader';
import globalize from '../../scripts/globalize';
import { appRouter } from '../appRouter';
import imageHelper from '../../scripts/imagehelper';
import '../../elements/emby-button/paper-icon-button-light';
import '../../elements/emby-itemscontainer/emby-itemscontainer';
import '../../elements/emby-scroller/emby-scroller';
import '../../elements/emby-button/emby-button';
import './homesections.css';
import Dashboard from '../../scripts/clientUtils';
import ServerConnections from '../ServerConnections';
/* eslint-disable indent */
@ -211,7 +213,7 @@ import 'css!./homesections';
function getFetchLatestItemsFn(serverId, parentId, collectionType) {
return function () {
const apiClient = window.connectionManager.getApiClient(serverId);
const apiClient = ServerConnections.getApiClient(serverId);
let limit = 16;
if (enableScrollX()) {
@ -367,7 +369,7 @@ import 'css!./homesections';
function getContinueWatchingFetchFn(serverId) {
return function () {
const apiClient = window.connectionManager.getApiClient(serverId);
const apiClient = ServerConnections.getApiClient(serverId);
const screenWidth = dom.getWindowSize().innerWidth;
let limit;
@ -440,7 +442,7 @@ import 'css!./homesections';
function getContinueListeningFetchFn(serverId) {
return function () {
const apiClient = window.connectionManager.getApiClient(serverId);
const apiClient = ServerConnections.getApiClient(serverId);
const screenWidth = dom.getWindowSize().innerWidth;
let limit;
@ -513,7 +515,7 @@ import 'css!./homesections';
function getOnNowFetchFn(serverId) {
return function () {
const apiClient = window.connectionManager.getApiClient(serverId);
const apiClient = ServerConnections.getApiClient(serverId);
return apiClient.getLiveTvRecommendedPrograms({
userId: apiClient.getCurrentUserId(),
IsAiring: true,
@ -656,7 +658,7 @@ import 'css!./homesections';
function getNextUpFetchFn(serverId) {
return function () {
const apiClient = window.connectionManager.getApiClient(serverId);
const apiClient = ServerConnections.getApiClient(serverId);
return apiClient.getNextUpEpisodes({
Limit: enableScrollX() ? 24 : 15,
Fields: 'PrimaryImageAspectRatio,SeriesInfo,DateCreated,BasicSyncInfo,Path',
@ -727,7 +729,7 @@ import 'css!./homesections';
function getLatestRecordingsFetchFn(serverId, activeRecordingsOnly) {
return function () {
const apiClient = window.connectionManager.getApiClient(serverId);
const apiClient = ServerConnections.getApiClient(serverId);
return apiClient.getLiveTvRecordings({
userId: apiClient.getCurrentUserId(),
Limit: enableScrollX() ? 12 : 5,

View File

@ -1,8 +1,9 @@
/* eslint-disable indent */
import appSettings from 'appSettings' ;
import browser from 'browser';
import events from 'events';
import appSettings from '../scripts/settings/appSettings' ;
import browser from '../scripts/browser';
import { Events } from 'jellyfin-apiclient';
export function getSavedVolume() {
return appSettings.get('volume') || 1;
@ -114,7 +115,7 @@ import events from 'events';
instance.destroyCustomTrack(instance._mediaElement);
}
events.trigger(instance, 'error', [
Events.trigger(instance, 'error', [
{
type: type
}
@ -359,7 +360,7 @@ import events from 'events';
src: instance._currentSrc
};
events.trigger(instance, 'stopped', [stopInfo]);
Events.trigger(instance, 'stopped', [stopInfo]);
instance._currentTime = null;
instance._currentSrc = null;

View File

@ -1,17 +1,18 @@
import dom from 'dom';
import loading from 'loading';
import appHost from 'apphost';
import dialogHelper from 'dialogHelper';
import imageLoader from 'imageLoader';
import browser from 'browser';
import layoutManager from 'layoutManager';
import scrollHelper from 'scrollHelper';
import globalize from 'globalize';
import 'emby-checkbox';
import 'paper-icon-button-light';
import 'emby-button';
import 'formDialogStyle';
import 'cardStyle';
import dom from '../../scripts/dom';
import loading from '../loading/loading';
import { appHost } from '../apphost';
import dialogHelper from '../dialogHelper/dialogHelper';
import imageLoader from '../images/imageLoader';
import browser from '../../scripts/browser';
import layoutManager from '../layoutManager';
import scrollHelper from '../../scripts/scrollHelper';
import globalize from '../../scripts/globalize';
import '../../elements/emby-checkbox/emby-checkbox';
import '../../elements/emby-button/paper-icon-button-light';
import '../../elements/emby-button/emby-button';
import '../formdialog.css';
import '../cardbuilder/card.css';
import ServerConnections from '../ServerConnections';
/* eslint-disable indent */
@ -315,8 +316,8 @@ import 'cardStyle';
function showEditor(itemId, serverId, itemType) {
loading.show();
import('text!./imageDownloader.template.html').then(({default: template}) => {
const apiClient = window.connectionManager.getApiClient(serverId);
import('./imageDownloader.template.html').then(({default: template}) => {
const apiClient = ServerConnections.getApiClient(serverId);
currentItemId = itemId;
currentItemType = itemType;

View File

@ -5,12 +5,12 @@
* @module components/imageOptionsEditor/imageOptionsEditor
*/
import globalize from 'globalize';
import dom from 'dom';
import dialogHelper from 'dialogHelper';
import 'emby-checkbox';
import 'emby-select';
import 'emby-input';
import globalize from '../../scripts/globalize';
import dom from '../../scripts/dom';
import dialogHelper from '../dialogHelper/dialogHelper';
import '../../elements/emby-checkbox/emby-checkbox';
import '../../elements/emby-select/emby-select';
import '../../elements/emby-input/emby-input';
function getDefaultImageConfig(itemType, type) {
return {

View File

@ -5,16 +5,18 @@
* @module components/imageUploader/imageUploader
*/
import dialogHelper from 'dialogHelper';
import dom from 'dom';
import loading from 'loading';
import scrollHelper from 'scrollHelper';
import layoutManager from 'layoutManager';
import globalize from 'globalize';
import 'emby-button';
import 'emby-select';
import 'formDialogStyle';
import 'css!./style';
import dialogHelper from '../dialogHelper/dialogHelper';
import dom from '../../scripts/dom';
import loading from '../loading/loading';
import scrollHelper from '../../scripts/scrollHelper';
import layoutManager from '../layoutManager';
import globalize from '../../scripts/globalize';
import '../../elements/emby-button/emby-button';
import '../../elements/emby-select/emby-select';
import '../formdialog.css';
import './style.css';
import ServerConnections from '../ServerConnections';
import toast from '../toast/toast';
let currentItemId;
let currentServerId;
@ -26,16 +28,12 @@ import 'css!./style';
switch (evt.target.error.code) {
case evt.target.error.NOT_FOUND_ERR:
import('toast').then(({default: toast}) => {
toast(globalize.translate('MessageFileReadError'));
});
toast(globalize.translate('MessageFileReadError'));
break;
case evt.target.error.ABORT_ERR:
break; // noop
default:
import('toast').then(({default: toast}) => {
toast(globalize.translate('MessageFileReadError'));
});
toast(globalize.translate('MessageFileReadError'));
break;
}
}
@ -87,9 +85,7 @@ import 'css!./style';
}
if (!file.type.startsWith('image/')) {
import('toast').then(({default: toast}) => {
toast(globalize.translate('MessageImageFileTypeAllowed'));
});
toast(globalize.translate('MessageImageFileTypeAllowed'));
e.preventDefault();
return false;
}
@ -100,14 +96,12 @@ import 'css!./style';
const imageType = dlg.querySelector('#selectImageType').value;
if (imageType === 'None') {
import('toast').then(({default: toast}) => {
toast(globalize.translate('MessageImageTypeNotSelected'));
});
toast(globalize.translate('MessageImageTypeNotSelected'));
e.preventDefault();
return false;
}
window.connectionManager.getApiClient(currentServerId).uploadItemImage(currentItemId, imageType, file).then(() => {
ServerConnections.getApiClient(currentServerId).uploadItemImage(currentItemId, imageType, file).then(() => {
dlg.querySelector('#uploadImage').value = '';
loading.hide();
@ -134,7 +128,7 @@ import 'css!./style';
function showEditor(options, resolve) {
options = options || {};
return import('text!./imageUploader.template.html').then(({default: template}) => {
return import('./imageUploader.template.html').then(({default: template}) => {
currentItemId = options.itemId;
currentServerId = options.serverId;

View File

@ -1,18 +1,21 @@
import dialogHelper from 'dialogHelper';
import loading from 'loading';
import dom from 'dom';
import layoutManager from 'layoutManager';
import focusManager from 'focusManager';
import globalize from 'globalize';
import scrollHelper from 'scrollHelper';
import imageLoader from 'imageLoader';
import browser from 'browser';
import appHost from 'apphost';
import 'cardStyle';
import 'formDialogStyle';
import 'emby-button';
import 'paper-icon-button-light';
import 'css!./imageeditor';
import dialogHelper from '../dialogHelper/dialogHelper';
import loading from '../loading/loading';
import dom from '../../scripts/dom';
import layoutManager from '../layoutManager';
import focusManager from '../focusManager';
import globalize from '../../scripts/globalize';
import scrollHelper from '../../scripts/scrollHelper';
import imageLoader from '../images/imageLoader';
import browser from '../../scripts/browser';
import { appHost } from '../apphost';
import '../cardbuilder/card.css';
import '../formdialog.css';
import '../../elements/emby-button/emby-button';
import '../../elements/emby-button/paper-icon-button-light';
import './imageeditor.css';
import ServerConnections from '../ServerConnections';
import alert from '../alert';
import confirm from '../confirm/confirm';
/* eslint-disable indent */
@ -35,10 +38,10 @@ import 'css!./imageeditor';
let apiClient;
if (item) {
apiClient = window.connectionManager.getApiClient(item.ServerId);
apiClient = ServerConnections.getApiClient(item.ServerId);
reloadItem(page, item, apiClient, focusContext);
} else {
apiClient = window.connectionManager.getApiClient(currentItem.ServerId);
apiClient = ServerConnections.getApiClient(currentItem.ServerId);
apiClient.getItem(apiClient.getCurrentUserId(), currentItem.Id).then(function (item) {
reloadItem(page, item, apiClient, focusContext);
});
@ -199,15 +202,11 @@ import 'css!./imageeditor';
return;
}
import('confirm').then(({default: confirm}) => {
confirm({
text: globalize.translate('ConfirmDeleteImage'),
confirmText: globalize.translate('Delete'),
primary: 'delete'
}).then(afterConfirm);
});
confirm({
text: globalize.translate('ConfirmDeleteImage'),
confirmText: globalize.translate('Delete'),
primary: 'delete'
}).then(afterConfirm);
}
function moveImage(context, apiClient, itemId, type, index, newIndex, focusContext) {
@ -215,9 +214,7 @@ import 'css!./imageeditor';
hasChanges = true;
reload(context, null, focusContext);
}, function () {
import('alert').then(({default: alert}) => {
alert(globalize.translate('ErrorDefault'));
});
alert(globalize.translate('ErrorDefault'));
});
}
@ -281,7 +278,7 @@ import 'css!./imageeditor';
}
function showImageDownloader(page, imageType) {
import('imageDownloader').then(({default: ImageDownloader}) => {
import('../imageDownloader/imageDownloader').then((ImageDownloader) => {
ImageDownloader.show(currentItem.Id, currentItem.ServerId, currentItem.Type, imageType).then(function () {
hasChanges = true;
reload(page);
@ -292,14 +289,14 @@ import 'css!./imageeditor';
function showActionSheet(context, imageCard) {
const itemId = imageCard.getAttribute('data-id');
const serverId = imageCard.getAttribute('data-serverid');
const apiClient = window.connectionManager.getApiClient(serverId);
const apiClient = ServerConnections.getApiClient(serverId);
const type = imageCard.getAttribute('data-imagetype');
const index = parseInt(imageCard.getAttribute('data-index'));
const providerCount = parseInt(imageCard.getAttribute('data-providers'));
const numImages = parseInt(imageCard.getAttribute('data-numimages'));
import('actionsheet').then(({default: actionSheet}) => {
import('../actionSheet/actionSheet').then(({default: actionSheet}) => {
const commands = [];
commands.push({
@ -370,7 +367,7 @@ import 'css!./imageeditor';
addListeners(context, 'btnOpenUploadMenu', 'click', function () {
const imageType = this.getAttribute('data-imagetype');
import('imageUploader').then(({default: imageUploader}) => {
import('../imageUploader/imageUploader').then(({default: imageUploader}) => {
imageUploader.show({
theme: options.theme,
@ -403,7 +400,7 @@ import 'css!./imageeditor';
const type = this.getAttribute('data-imagetype');
let index = this.getAttribute('data-index');
index = index === 'null' ? null : parseInt(index);
const apiClient = window.connectionManager.getApiClient(currentItem.ServerId);
const apiClient = ServerConnections.getApiClient(currentItem.ServerId);
deleteImage(context, currentItem.Id, type, index, apiClient, true);
});
@ -411,7 +408,7 @@ import 'css!./imageeditor';
const type = this.getAttribute('data-imagetype');
const index = this.getAttribute('data-index');
const newIndex = this.getAttribute('data-newindex');
const apiClient = window.connectionManager.getApiClient(currentItem.ServerId);
const apiClient = ServerConnections.getApiClient(currentItem.ServerId);
moveImage(context, apiClient, currentItem.Id, type, index, newIndex, dom.parentWithClass(this, 'itemsContainer'));
});
}
@ -422,8 +419,8 @@ import 'css!./imageeditor';
loading.show();
import('text!./imageeditor.template.html').then(({default: template}) => {
const apiClient = window.connectionManager.getApiClient(serverId);
import('./imageeditor.template.html').then(({default: template}) => {
const apiClient = ServerConnections.getApiClient(serverId);
apiClient.getItem(apiClient.getCurrentUserId(), itemId).then(function (item) {
const dialogOptions = {
removeOnClose: true

View File

@ -1,7 +1,7 @@
import * as lazyLoader from 'lazyLoader';
import * as userSettings from 'userSettings';
import * as blurhash from 'blurhash';
import 'css!./style';
import * as lazyLoader from '../lazyLoader/lazyLoaderIntersectionObserver';
import * as userSettings from '../../scripts/settings/userSettings';
import { decode, isBlurhashValid } from 'blurhash';
import './style.css';
/* eslint-disable indent */
export function lazyImage(elem, source = elem.getAttribute('data-src')) {
@ -13,7 +13,7 @@ import 'css!./style';
}
function itemBlurhashing(target, blurhashstr) {
if (blurhash.isBlurhashValid(blurhashstr)) {
if (isBlurhashValid(blurhashstr)) {
// Although the default values recommended by Blurhash developers is 32x32, a size of 18x18 seems to be the sweet spot for us,
// improving the performance and reducing the memory usage, while retaining almost full blur quality.
// Lower values had more visible pixelation
@ -21,7 +21,7 @@ import 'css!./style';
const height = 18;
let pixels;
try {
pixels = blurhash.decode(blurhashstr, width, height);
pixels = decode(blurhashstr, width, height);
} catch (err) {
console.error('Blurhash decode error: ', err);
target.classList.add('non-blurhashable');
@ -133,6 +133,7 @@ import 'css!./style';
}
}
}
lazyLoader.lazyChildren(elem, fillImage);
}

View File

@ -1,8 +1,8 @@
import datetime from 'datetime';
import itemHelper from 'itemHelper';
import 'emby-progressbar';
import 'css!./indicators.css';
import 'material-icons';
import datetime from '../../scripts/datetime';
import itemHelper from '../itemHelper';
import '../../elements/emby-progressbar/emby-progressbar';
import './indicators.css';
import 'material-design-icons-iconfont';
export function enableProgressIndicator(item) {
if (item.MediaType === 'Video' && item.Type !== 'TvChannel') {

View File

@ -1,10 +1,12 @@
import appHost from 'apphost';
import globalize from 'globalize';
import itemHelper from 'itemHelper';
import appRouter from 'appRouter';
import playbackManager from 'playbackManager';
import browser from 'browser';
import actionsheet from 'actionsheet';
import browser from '../scripts/browser';
import globalize from '../scripts/globalize';
import actionsheet from './actionSheet/actionSheet';
import { appHost } from './apphost';
import { appRouter } from './appRouter';
import itemHelper from './itemHelper';
import { playbackManager } from './playback/playbackmanager';
import ServerConnections from './ServerConnections';
import toast from './toast/toast';
/* eslint-disable indent */
export function getCommands(options) {
@ -329,12 +331,12 @@ import actionsheet from 'actionsheet';
function executeCommand(item, id, options) {
const itemId = item.Id;
const serverId = item.ServerId;
const apiClient = window.connectionManager.getApiClient(serverId);
const apiClient = ServerConnections.getApiClient(serverId);
return new Promise(function (resolve, reject) {
switch (id) {
case 'addtocollection':
import('collectionEditor').then(({default: collectionEditor}) => {
import('./collectionEditor/collectionEditor').then(({default: collectionEditor}) => {
new collectionEditor({
items: [itemId],
serverId: serverId
@ -342,7 +344,7 @@ import actionsheet from 'actionsheet';
});
break;
case 'addtoplaylist':
import('playlistEditor').then(({default: playlistEditor}) => {
import('./playlisteditor/playlisteditor').then(({default: playlistEditor}) => {
new playlistEditor({
items: [itemId],
serverId: serverId
@ -350,7 +352,7 @@ import actionsheet from 'actionsheet';
});
break;
case 'download':
import('fileDownloader').then((fileDownloader) => {
import('../scripts/fileDownloader').then((fileDownloader) => {
const downloadHref = apiClient.getItemDownloadUrl(itemId);
fileDownloader.download([{
url: downloadHref,
@ -372,9 +374,7 @@ import actionsheet from 'actionsheet';
textArea.select();
if (document.execCommand('copy')) {
import('toast').then(({default: toast}) => {
toast(globalize.translate('CopyStreamURLSuccess'));
});
toast(globalize.translate('CopyStreamURLSuccess'));
} else {
prompt(globalize.translate('CopyStreamURL'), downloadHref);
}
@ -387,9 +387,7 @@ import actionsheet from 'actionsheet';
} else {
/* eslint-disable-next-line compat/compat */
navigator.clipboard.writeText(downloadHref).then(function () {
import('toast').then(({default: toast}) => {
toast(globalize.translate('CopyStreamURLSuccess'));
});
toast(globalize.translate('CopyStreamURLSuccess'));
}).catch(function () {
textAreaCopy();
});
@ -398,7 +396,7 @@ import actionsheet from 'actionsheet';
break;
}
case 'editsubtitles':
import('subtitleEditor').then(({default: subtitleEditor}) => {
import('./subtitleeditor/subtitleeditor').then(({default: subtitleEditor}) => {
subtitleEditor.show(itemId, serverId).then(getResolveFunction(resolve, id, true), getResolveFunction(resolve, id));
});
break;
@ -406,7 +404,7 @@ import actionsheet from 'actionsheet';
editItem(apiClient, item).then(getResolveFunction(resolve, id, true), getResolveFunction(resolve, id));
break;
case 'editimages':
import('imageEditor').then(({default: imageEditor}) => {
import('./imageeditor/imageeditor').then((imageEditor) => {
imageEditor.show({
itemId: itemId,
serverId: serverId
@ -414,12 +412,12 @@ import actionsheet from 'actionsheet';
});
break;
case 'identify':
import('itemIdentifier').then(({default: itemIdentifier}) => {
import('./itemidentifier/itemidentifier').then((itemIdentifier) => {
itemIdentifier.show(itemId, serverId).then(getResolveFunction(resolve, id, true), getResolveFunction(resolve, id));
});
break;
case 'moremediainfo':
import('itemMediaInfo').then(({default: itemMediaInfo}) => {
import('./itemMediaInfo/itemMediaInfo').then((itemMediaInfo) => {
itemMediaInfo.show(itemId, serverId).then(getResolveFunction(resolve, id), getResolveFunction(resolve, id));
});
break;
@ -454,7 +452,7 @@ import actionsheet from 'actionsheet';
playbackManager.clearQueue();
break;
case 'record':
import('recordingCreator').then(({default: recordingCreator}) => {
import('./recordingcreator/recordingcreator').then(({default: recordingCreator}) => {
recordingCreator.show(itemId, serverId).then(getResolveFunction(resolve, id, true), getResolveFunction(resolve, id));
});
break;
@ -525,7 +523,7 @@ import actionsheet from 'actionsheet';
}
function deleteTimer(apiClient, item, resolve, command) {
import('recordingHelper').then(({default: recordingHelper}) => {
import('./recordingcreator/recordinghelper').then(({default: recordingHelper}) => {
const timerId = item.TimerId || item.Id;
recordingHelper.cancelTimerWithConfirmation(timerId, item.ServerId).then(function () {
getResolveFunction(resolve, command, true)();
@ -534,7 +532,7 @@ import actionsheet from 'actionsheet';
}
function deleteSeriesTimer(apiClient, item, resolve, command) {
import('recordingHelper').then(({default: recordingHelper}) => {
import('./recordingcreator/recordinghelper').then(({default: recordingHelper}) => {
recordingHelper.cancelSeriesTimerWithConfirmation(item.Id, item.ServerId).then(function () {
getResolveFunction(resolve, command, true)();
});
@ -568,15 +566,15 @@ import actionsheet from 'actionsheet';
const serverId = apiClient.serverInfo().Id;
if (item.Type === 'Timer') {
import('recordingEditor').then(({default: recordingEditor}) => {
import('./recordingcreator/recordingeditor').then(({default: recordingEditor}) => {
recordingEditor.show(item.Id, serverId).then(resolve, reject);
});
} else if (item.Type === 'SeriesTimer') {
import('seriesRecordingEditor').then(({default: recordingEditor}) => {
import('./recordingcreator/seriesrecordingeditor').then(({default: recordingEditor}) => {
recordingEditor.show(item.Id, serverId).then(resolve, reject);
});
} else {
import('metadataEditor').then(({default: metadataEditor}) => {
import('./metadataEditor/metadataEditor').then(({default: metadataEditor}) => {
metadataEditor.show(item.Id, serverId).then(resolve, reject);
});
}
@ -585,7 +583,7 @@ import actionsheet from 'actionsheet';
function deleteItem(apiClient, item) {
return new Promise(function (resolve, reject) {
import('deleteHelper').then(({default: deleteHelper}) => {
import('../scripts/deleteHelper').then((deleteHelper) => {
deleteHelper.deleteItem({
item: item,
navigate: false
@ -597,7 +595,7 @@ import actionsheet from 'actionsheet';
}
function refresh(apiClient, item) {
import('refreshDialog').then(({default: refreshDialog}) => {
import('./refreshdialog/refreshdialog').then(({default: refreshDialog}) => {
new refreshDialog({
itemIds: [item.Id],
serverId: apiClient.serverInfo().Id,

View File

@ -1,5 +1,5 @@
import appHost from 'apphost';
import globalize from 'globalize';
import { appHost } from './apphost';
import globalize from '../scripts/globalize';
export function getDisplayName(item, options = {}) {
if (!item) {

View File

@ -5,17 +5,18 @@
* @module components/itemMediaInfo/itemMediaInfo
*/
import dialogHelper from 'dialogHelper';
import layoutManager from 'layoutManager';
import globalize from 'globalize';
import loading from 'loading';
import 'emby-select';
import 'listViewStyle';
import 'paper-icon-button-light';
import 'css!./../formdialog';
import 'material-icons';
import 'emby-button';
import 'flexStyles';
import dialogHelper from '../dialogHelper/dialogHelper';
import layoutManager from '../layoutManager';
import globalize from '../../scripts/globalize';
import loading from '../loading/loading';
import '../../elements/emby-select/emby-select';
import '../listview/listview.css';
import '../../elements/emby-button/emby-button';
import '../../elements/emby-button/paper-icon-button-light';
import '../formdialog.css';
import 'material-design-icons-iconfont';
import '../../assets/css/flexstyles.scss';
import ServerConnections from '../ServerConnections';
function setMediaInfo(user, page, item) {
let html = item.MediaSources.map(version => {
@ -162,7 +163,7 @@ import 'flexStyles';
}
function loadMediaInfo(itemId, serverId, template) {
const apiClient = window.connectionManager.getApiClient(serverId);
const apiClient = ServerConnections.getApiClient(serverId);
return apiClient.getItem(apiClient.getCurrentUserId(), itemId).then(item => {
const dialogOptions = {
size: 'small',
@ -193,7 +194,7 @@ import 'flexStyles';
export function show(itemId, serverId) {
loading.show();
return import('text!./itemMediaInfo.template.html').then(({default: template}) => {
return import('./itemMediaInfo.template.html').then(({default: template}) => {
return new Promise((resolve, reject) => {
loadMediaInfo(itemId, serverId, template).then(resolve, reject);
});

View File

@ -5,19 +5,21 @@
* @module components/itemidentifier/itemidentifier
*/
import dialogHelper from 'dialogHelper';
import loading from 'loading';
import globalize from 'globalize';
import scrollHelper from 'scrollHelper';
import layoutManager from 'layoutManager';
import focusManager from 'focusManager';
import browser from 'browser';
import 'emby-input';
import 'emby-checkbox';
import 'paper-icon-button-light';
import 'css!./../formdialog';
import 'material-icons';
import 'cardStyle';
import dialogHelper from '../dialogHelper/dialogHelper';
import loading from '../loading/loading';
import globalize from '../../scripts/globalize';
import scrollHelper from '../../scripts/scrollHelper';
import layoutManager from '../layoutManager';
import focusManager from '../focusManager';
import browser from '../../scripts/browser';
import '../../elements/emby-input/emby-input';
import '../../elements/emby-checkbox/emby-checkbox';
import '../../elements/emby-button/paper-icon-button-light';
import '../formdialog.css';
import 'material-design-icons-iconfont';
import '../cardbuilder/card.css';
import ServerConnections from '../ServerConnections';
import toast from '../toast/toast';
const enableFocusTransform = !browser.slow && !browser.edge;
@ -30,7 +32,7 @@ import 'cardStyle';
let currentSearchResult;
function getApiClient() {
return window.connectionManager.getApiClient(currentServerId);
return ServerConnections.getApiClient(currentServerId);
}
function searchForIdentificationResults(page) {
@ -67,9 +69,7 @@ import 'cardStyle';
}
if (!hasId && !lookupInfo.Name) {
import('toast').then(({default: toast}) => {
toast(globalize.translate('PleaseEnterNameOrId'));
});
toast(globalize.translate('PleaseEnterNameOrId'));
return;
}
@ -334,7 +334,7 @@ import 'cardStyle';
function showEditor(itemId) {
loading.show();
return import('text!./itemidentifier.template.html').then(({default: template}) => {
return import('./itemidentifier.template.html').then(({default: template}) => {
const apiClient = getApiClient();
apiClient.getItem(apiClient.getCurrentUserId(), itemId).then(item => {
@ -416,7 +416,7 @@ import 'cardStyle';
currentItem = null;
currentItemType = itemType;
return import('text!./itemidentifier.template.html').then(({default: template}) => {
return import('./itemidentifier.template.html').then(({default: template}) => {
const dialogOptions = {
size: 'small',
removeOnClose: true,

View File

@ -1,6 +1,6 @@
import playbackManager from 'playbackManager';
import serverNotifications from 'serverNotifications';
import events from 'events';
import { playbackManager } from './playback/playbackmanager';
import serverNotifications from '../scripts/serverNotifications';
import { Events } from 'jellyfin-apiclient';
function onUserDataChanged(e, apiClient, userData) {
const instance = this;
@ -110,7 +110,7 @@ function onPlaybackStopped(e, stopInfo) {
function addNotificationEvent(instance, name, handler, owner) {
const localHandler = handler.bind(instance);
owner = owner || serverNotifications;
events.on(owner, name, localHandler);
Events.on(owner, name, localHandler);
instance['event_' + name] = localHandler;
}
@ -118,7 +118,7 @@ function removeNotificationEvent(instance, name, owner) {
const handler = instance['event_' + name];
if (handler) {
owner = owner || serverNotifications;
events.off(owner, name, handler);
Events.off(owner, name, handler);
instance['event_' + name] = null;
}
}

View File

@ -1,6 +1,8 @@
import browser from 'browser';
import appSettings from 'appSettings';
import events from 'events';
import { appHost } from './apphost';
import browser from '../scripts/browser';
import appSettings from '../scripts/settings/appSettings';
import { Events } from 'jellyfin-apiclient';
function setLayout(instance, layout, selectedLayout) {
if (layout === selectedLayout) {
@ -30,10 +32,10 @@ class LayoutManager {
}
}
events.trigger(this, 'modechange');
Events.trigger(this, 'modechange');
}
getSavedLayout(layout) {
getSavedLayout() {
return appSettings.get('layout');
}
@ -58,4 +60,12 @@ class LayoutManager {
}
}
export default new LayoutManager();
const layoutManager = new LayoutManager();
if (appHost.getDefaultLayout) {
layoutManager.defaultLayout = appHost.getDefaultLayout();
}
layoutManager.init();
export default layoutManager;

View File

@ -5,11 +5,11 @@
* @module components/libraryoptionseditor/libraryoptionseditor
*/
import globalize from 'globalize';
import dom from 'dom';
import 'emby-checkbox';
import 'emby-select';
import 'emby-input';
import globalize from '../../scripts/globalize';
import dom from '../../scripts/dom';
import '../../elements/emby-checkbox/emby-checkbox';
import '../../elements/emby-select/emby-select';
import '../../elements/emby-input/emby-input';
function populateLanguages(parent) {
return ApiClient.getCultures().then(languages => {
@ -304,7 +304,7 @@ import 'emby-input';
}
function showImageOptionsForType(type) {
import('imageoptionseditor').then(({default: ImageOptionsEditor}) => {
import('../imageOptionsEditor/imageOptionsEditor').then(({default: ImageOptionsEditor}) => {
let typeOptions = getTypeOptions(currentLibraryOptions, type);
if (!typeOptions) {
typeOptions = {
@ -362,8 +362,9 @@ import 'emby-input';
currentAvailableOptions = null;
const isNewLibrary = libraryOptions === null;
isNewLibrary && parent.classList.add('newlibrary');
const response = await fetch('components/libraryoptionseditor/libraryoptionseditor.template.html');
const template = await response.text();
const { default: template } = await import('./libraryoptionseditor.template.html');
parent.innerHTML = globalize.translateHtml(template);
populateRefreshInterval(parent.querySelector('#selectAutoRefreshInterval'));
const promises = [populateLanguages(parent), populateCountries(parent.querySelector('#selectCountry'))];

View File

@ -5,16 +5,17 @@
* @module components/listview/listview
*/
import itemHelper from 'itemHelper';
import mediaInfo from 'mediaInfo';
import indicators from 'indicators';
import layoutManager from 'layoutManager';
import globalize from 'globalize';
import datetime from 'datetime';
import cardBuilder from 'cardBuilder';
import 'css!./listview';
import 'emby-ratingbutton';
import 'emby-playstatebutton';
import itemHelper from '../itemHelper';
import mediaInfo from '../mediainfo/mediainfo';
import indicators from '../indicators/indicators';
import layoutManager from '../layoutManager';
import globalize from '../../scripts/globalize';
import datetime from '../../scripts/datetime';
import cardBuilder from '../cardbuilder/cardBuilder';
import './listview.css';
import '../../elements/emby-ratingbutton/emby-ratingbutton';
import '../../elements/emby-playstatebutton/emby-playstatebutton';
import ServerConnections from '../ServerConnections';
function getIndex(item, options) {
if (options.index === 'disc') {
@ -76,7 +77,7 @@ import 'emby-playstatebutton';
}
function getImageUrl(item, width) {
const apiClient = window.connectionManager.getApiClient(item.ServerId);
const apiClient = ServerConnections.getApiClient(item.ServerId);
let itemId;
const options = {
@ -105,7 +106,7 @@ import 'emby-playstatebutton';
}
function getChannelImageUrl(item, width) {
const apiClient = window.connectionManager.getApiClient(item.ServerId);
const apiClient = ServerConnections.getApiClient(item.ServerId);
const options = {
maxWidth: width,
type: 'Primary'

View File

@ -1,4 +1,4 @@
import 'css!./loading';
import './loading.css';
let loadingElem;
let layer1;

View File

@ -1,8 +1,8 @@
import dom from 'dom';
import browser from 'browser';
import events from 'events';
import 'emby-tabs';
import 'emby-button';
import dom from '../scripts/dom';
import browser from '../scripts/browser';
import { Events } from 'jellyfin-apiclient';
import '../elements/emby-tabs/emby-tabs';
import '../elements/emby-button/emby-button';
/* eslint-disable indent */
@ -65,11 +65,11 @@ import 'emby-button';
}
};
import('touchHelper').then(({default: TouchHelper}) => {
import('../scripts/touchHelper').then(({default: TouchHelper}) => {
const touchHelper = new TouchHelper(view.parentNode.parentNode);
events.on(touchHelper, 'swipeleft', onSwipeLeft);
events.on(touchHelper, 'swiperight', onSwipeRight);
Events.on(touchHelper, 'swipeleft', onSwipeLeft);
Events.on(touchHelper, 'swiperight', onSwipeRight);
view.addEventListener('viewdestroy', function () {
touchHelper.destroy();

View File

@ -5,20 +5,22 @@
* @module components/mediaLibraryCreator/mediaLibraryCreator
*/
import loading from 'loading';
import dialogHelper from 'dialogHelper';
import dom from 'dom';
import $ from 'jQuery';
import libraryoptionseditor from 'components/libraryoptionseditor/libraryoptionseditor';
import globalize from 'globalize';
import 'emby-toggle';
import 'emby-input';
import 'emby-select';
import 'paper-icon-button-light';
import 'listViewStyle';
import 'formDialogStyle';
import 'emby-button';
import 'flexStyles';
import loading from '../loading/loading';
import dialogHelper from '../dialogHelper/dialogHelper';
import dom from '../../scripts/dom';
import 'jquery';
import libraryoptionseditor from '../libraryoptionseditor/libraryoptionseditor';
import globalize from '../../scripts/globalize';
import '../../elements/emby-button/emby-button';
import '../../elements/emby-button/paper-icon-button-light';
import '../../elements/emby-input/emby-input';
import '../../elements/emby-select/emby-select';
import '../../elements/emby-toggle/emby-toggle';
import '../listview/listview.css';
import '../formdialog.css';
import '../../assets/css/flexstyles.scss';
import toast from '../toast/toast';
import alert from '../alert';
function onAddLibrary() {
if (isCreating) {
@ -26,11 +28,9 @@ import 'flexStyles';
}
if (pathInfos.length == 0) {
import('alert').then(({default: alert}) => {
alert({
text: globalize.translate('PleaseAddAtLeastOneFolder'),
type: 'error'
});
alert({
text: globalize.translate('PleaseAddAtLeastOneFolder'),
type: 'error'
});
return false;
@ -54,9 +54,7 @@ import 'flexStyles';
loading.hide();
dialogHelper.close(dlg);
}, () => {
import('toast').then(({default: toast}) => {
toast(globalize.translate('ErrorAddingMediaPathToVirtualFolder'));
});
toast(globalize.translate('ErrorAddingMediaPathToVirtualFolder'));
isCreating = false;
loading.hide();
@ -109,7 +107,7 @@ import 'flexStyles';
function onAddButtonClick() {
const page = dom.parentWithClass(this, 'dlg-librarycreator');
import('directorybrowser').then(({default: directoryBrowser}) => {
import('../directorybrowser/directorybrowser').then(({default: directoryBrowser}) => {
const picker = new directoryBrowser();
picker.show({
enableNetworkSharePath: true,
@ -200,7 +198,7 @@ export class showEditor {
currentOptions = options;
currentResolve = resolve;
hasChanges = false;
import('text!./components/mediaLibraryCreator/mediaLibraryCreator.template.html').then(({default: template}) => {
import('./mediaLibraryCreator.template.html').then(({default: template}) => {
const dlg = dialogHelper.createDialog({
size: 'small',
modal: false,

View File

@ -5,18 +5,20 @@
* @module components/mediaLibraryEditor/mediaLibraryEditor
*/
import jQuery from 'jQuery';
import loading from 'loading';
import dialogHelper from 'dialogHelper';
import dom from 'dom';
import libraryoptionseditor from 'components/libraryoptionseditor/libraryoptionseditor';
import globalize from 'globalize';
import 'emby-button';
import 'listViewStyle';
import 'paper-icon-button-light';
import 'formDialogStyle';
import 'emby-toggle';
import 'flexStyles';
import 'jquery';
import loading from '../loading/loading';
import dialogHelper from '../dialogHelper/dialogHelper';
import dom from '../../scripts/dom';
import libraryoptionseditor from '../libraryoptionseditor/libraryoptionseditor';
import globalize from '../../scripts/globalize';
import '../../elements/emby-button/emby-button';
import '../listview/listview.css';
import '../../elements/emby-button/paper-icon-button-light';
import '../formdialog.css';
import '../../elements/emby-toggle/emby-toggle';
import '../../assets/css/flexstyles.scss';
import toast from '../toast/toast';
import confirm from '../confirm/confirm';
function onEditLibrary() {
if (isCreating) {
@ -47,9 +49,7 @@ import 'flexStyles';
hasChanges = true;
refreshLibraryFromServer(page);
}, () => {
import('toast').then(({default: toast}) => {
toast(globalize.translate('ErrorAddingMediaPathToVirtualFolder'));
});
toast(globalize.translate('ErrorAddingMediaPathToVirtualFolder'));
});
}
@ -62,9 +62,7 @@ import 'flexStyles';
hasChanges = true;
refreshLibraryFromServer(page);
}, () => {
import('toast').then(({default: toast}) => {
toast(globalize.translate('ErrorAddingMediaPathToVirtualFolder'));
});
toast(globalize.translate('ErrorAddingMediaPathToVirtualFolder'));
});
}
@ -72,22 +70,18 @@ import 'flexStyles';
const button = btnRemovePath;
const virtualFolder = currentOptions.library;
import('confirm').then(({default: confirm}) => {
confirm({
title: globalize.translate('HeaderRemoveMediaLocation'),
text: globalize.translate('MessageConfirmRemoveMediaLocation'),
confirmText: globalize.translate('Delete'),
primary: 'delete'
}).then(() => {
const refreshAfterChange = currentOptions.refresh;
ApiClient.removeMediaPath(virtualFolder.Name, location, refreshAfterChange).then(() => {
hasChanges = true;
refreshLibraryFromServer(dom.parentWithClass(button, 'dlg-libraryeditor'));
}, () => {
import('toast').then(({default: toast}) => {
toast(globalize.translate('ErrorDefault'));
});
});
confirm({
title: globalize.translate('HeaderRemoveMediaLocation'),
text: globalize.translate('MessageConfirmRemoveMediaLocation'),
confirmText: globalize.translate('Delete'),
primary: 'delete'
}).then(() => {
const refreshAfterChange = currentOptions.refresh;
ApiClient.removeMediaPath(virtualFolder.Name, location, refreshAfterChange).then(() => {
hasChanges = true;
refreshLibraryFromServer(dom.parentWithClass(button, 'dlg-libraryeditor'));
}, () => {
toast(globalize.translate('ErrorDefault'));
});
});
}
@ -167,7 +161,7 @@ import 'flexStyles';
}
function showDirectoryBrowser(context, originalPath, networkPath) {
import('directorybrowser').then(({default: directoryBrowser}) => {
import('../directorybrowser/directorybrowser').then(({default: directoryBrowser}) => {
const picker = new directoryBrowser();
picker.show({
enableNetworkSharePath: true,
@ -215,7 +209,7 @@ export class showEditor {
currentOptions = options;
currentDeferred = deferred;
hasChanges = false;
import('text!./components/mediaLibraryEditor/mediaLibraryEditor.template.html').then(({default: template}) => {
import('./mediaLibraryEditor.template.html').then(({default: template}) => {
const dlg = dialogHelper.createDialog({
size: 'small',
modal: false,

View File

@ -1,12 +1,12 @@
import datetime from 'datetime';
import globalize from 'globalize';
import appRouter from 'appRouter';
import itemHelper from 'itemHelper';
import indicators from 'indicators';
import 'material-icons';
import 'css!./mediainfo.css';
import 'programStyles';
import 'emby-button';
import datetime from '../../scripts/datetime';
import globalize from '../../scripts/globalize';
import { appRouter } from '../appRouter';
import itemHelper from '../itemHelper';
import indicators from '../indicators/indicators';
import 'material-design-icons-iconfont';
import './mediainfo.css';
import '../guide/programs.css';
import '../../elements/emby-button/emby-button';
/* eslint-disable indent */
function getTimerIndicator(item) {

View File

@ -1,21 +1,24 @@
import dom from 'dom';
import layoutManager from 'layoutManager';
import dialogHelper from 'dialogHelper';
import datetime from 'datetime';
import loading from 'loading';
import focusManager from 'focusManager';
import globalize from 'globalize';
import shell from 'shell';
import 'emby-checkbox';
import 'emby-input';
import 'emby-select';
import 'listViewStyle';
import 'emby-textarea';
import 'emby-button';
import 'paper-icon-button-light';
import 'css!./../formdialog';
import 'clearButtonStyle';
import 'flexStyles';
import dom from '../../scripts/dom';
import layoutManager from '../layoutManager';
import dialogHelper from '../dialogHelper/dialogHelper';
import datetime from '../../scripts/datetime';
import loading from '../loading/loading';
import focusManager from '../focusManager';
import globalize from '../../scripts/globalize';
import shell from '../../scripts/shell';
import '../../elements/emby-checkbox/emby-checkbox';
import '../../elements/emby-input/emby-input';
import '../../elements/emby-select/emby-select';
import '../listview/listview.css';
import '../../elements/emby-textarea/emby-textarea';
import '../../elements/emby-button/emby-button';
import '../../elements/emby-button/paper-icon-button-light';
import '../formdialog.css';
import '../../assets/css/clearbutton.scss';
import '../../assets/css/flexstyles.scss';
import ServerConnections from '../ServerConnections';
import toast from '../toast/toast';
import { appRouter } from '../appRouter';
/* eslint-disable indent */
@ -35,9 +38,7 @@ import 'flexStyles';
function submitUpdatedItem(form, item) {
function afterContentTypeUpdated() {
import('toast').then(({default: toast}) => {
toast(globalize.translate('MessageItemSaved'));
});
toast(globalize.translate('MessageItemSaved'));
loading.hide();
closeDialog(true);
@ -207,7 +208,7 @@ import 'flexStyles';
}
function addElementToList(source, sortCallback) {
import('prompt').then(({default: prompt}) => {
import('../prompt/prompt').then(({default: prompt}) => {
prompt({
label: 'Value:'
}).then(function (text) {
@ -225,7 +226,7 @@ import 'flexStyles';
}
function editPerson(context, person, index) {
import('personEditor').then(({default: personEditor}) => {
import('./personEditor').then(({default: personEditor}) => {
personEditor.show(person).then(function (updatedPerson) {
const isNew = index === -1;
@ -244,14 +245,12 @@ import 'flexStyles';
if (parentId) {
reload(context, parentId, item.ServerId);
} else {
import('appRouter').then(({default: appRouter}) => {
appRouter.goHome();
});
appRouter.goHome();
}
}
function showMoreMenu(context, button, user) {
import('itemContextMenu').then(({default: itemContextMenu}) => {
import('../itemContextMenu').then(({default: itemContextMenu}) => {
const item = currentItem;
itemContextMenu.show({
@ -289,7 +288,7 @@ import 'flexStyles';
}
function getApiClient() {
return window.connectionManager.getApiClient(currentItem.ServerId);
return ServerConnections.getApiClient(currentItem.ServerId);
}
function bindAll(elems, eventName, fn) {
@ -369,7 +368,7 @@ import 'flexStyles';
}
function getItem(itemId, serverId) {
const apiClient = window.connectionManager.getApiClient(serverId);
const apiClient = ServerConnections.getApiClient(serverId);
if (itemId) {
return apiClient.getItem(apiClient.getCurrentUserId(), itemId);
@ -379,7 +378,7 @@ import 'flexStyles';
}
function getEditorConfig(itemId, serverId) {
const apiClient = window.connectionManager.getApiClient(serverId);
const apiClient = ServerConnections.getApiClient(serverId);
if (itemId) {
return apiClient.getJSON(apiClient.getUrl('Items/' + itemId + '/MetadataEditor'));
@ -1020,7 +1019,7 @@ import 'flexStyles';
}
function centerFocus(elem, horiz, on) {
import('scrollHelper').then(({default: scrollHelper}) => {
import('../../scripts/scrollHelper').then((scrollHelper) => {
const fn = on ? 'on' : 'off';
scrollHelper.centerFocus[fn](elem, horiz);
});
@ -1029,7 +1028,7 @@ import 'flexStyles';
function show(itemId, serverId, resolve, reject) {
loading.show();
import('text!./metadataEditor.template.html').then(({default: template}) => {
import('./metadataEditor.template.html').then(({default: template}) => {
const dialogOptions = {
removeOnClose: true,
scrollY: false
@ -1067,7 +1066,7 @@ import 'flexStyles';
currentContext = dlg;
init(dlg, window.connectionManager.getApiClient(serverId));
init(dlg, ServerConnections.getApiClient(serverId));
reload(dlg, itemId, serverId);
});
@ -1084,7 +1083,7 @@ import 'flexStyles';
return new Promise(function (resolve, reject) {
loading.show();
import('text!./metadataEditor.template.html').then(({default: template}) => {
import('./metadataEditor.template.html').then(({default: template}) => {
elem.innerHTML = globalize.translateHtml(template, 'core');
elem.querySelector('.formDialogFooter').classList.remove('formDialogFooter');
@ -1094,7 +1093,7 @@ import 'flexStyles';
currentContext = elem;
init(elem, window.connectionManager.getApiClient(serverId));
init(elem, ServerConnections.getApiClient(serverId));
reload(elem, itemId, serverId);
focusManager.autoFocus(elem);

View File

@ -1,15 +1,16 @@
import dialogHelper from 'dialogHelper';
import layoutManager from 'layoutManager';
import globalize from 'globalize';
import 'paper-icon-button-light';
import 'emby-input';
import 'emby-select';
import 'css!./../formdialog';
import dialogHelper from '../dialogHelper/dialogHelper';
import layoutManager from '../layoutManager';
import globalize from '../../scripts/globalize';
import '../../elements/emby-button/paper-icon-button-light';
import '../../elements/emby-input/emby-input';
import '../../elements/emby-select/emby-select';
import '../formdialog.css';
/* eslint-disable indent */
function centerFocus(elem, horiz, on) {
import('scrollHelper').then(({default: scrollHelper}) => {
import('../../scripts/scrollHelper').then((scrollHelper) => {
const fn = on ? 'on' : 'off';
scrollHelper.centerFocus[fn](elem, horiz);
});
@ -17,7 +18,7 @@ import 'css!./../formdialog';
function show(person) {
return new Promise(function (resolve, reject) {
import('text!./personEditor.template.html').then(({default: template}) => {
import('./personEditor.template.html').then(({default: template}) => {
const dialogOptions = {
removeOnClose: true,
scrollY: false

View File

@ -1,3 +1,4 @@
.itemSelectionPanel {
position: absolute;
bottom: 0;

View File

@ -1,9 +1,13 @@
import browser from 'browser';
import appHost from 'apphost';
import loading from 'loading';
import globalize from 'globalize';
import dom from 'dom';
import 'css!./multiSelect';
import browser from '../../scripts/browser';
import { appHost } from '../apphost';
import loading from '../loading/loading';
import globalize from '../../scripts/globalize';
import dom from '../../scripts/dom';
import './multiSelect.css';
import ServerConnections from '../ServerConnections';
import alert from '../alert';
import playlistEditor from '../playlisteditor/playlisteditor';
import confirm from '../confirm/confirm';
/* eslint-disable indent */
@ -137,10 +141,8 @@ import 'css!./multiSelect';
}
function alertText(options) {
return new Promise((resolve, reject) => {
import('alert').then(({default: alert}) => {
alert(options).then(resolve, resolve);
});
return new Promise((resolve) => {
alert(options).then(resolve, resolve);
});
}
@ -154,22 +156,20 @@ import 'css!./multiSelect';
title = globalize.translate('HeaderDeleteItems');
}
import('confirm').then(({default: confirm}) => {
confirm(msg, title).then(() => {
const promises = itemIds.map(itemId => {
apiClient.deleteItem(itemId);
});
confirm(msg, title).then(() => {
const promises = itemIds.map(itemId => {
apiClient.deleteItem(itemId);
});
Promise.all(promises).then(resolve, () => {
alertText(globalize.translate('ErrorDeletingItem')).then(reject, reject);
});
}, reject);
});
Promise.all(promises).then(resolve, () => {
alertText(globalize.translate('ErrorDeletingItem')).then(reject, reject);
});
}, reject);
});
}
function showMenuForSelectedItems(e) {
const apiClient = window.connectionManager.currentApiClient();
const apiClient = ServerConnections.currentApiClient();
apiClient.getCurrentUser().then(user => {
const menuItems = [];
@ -229,7 +229,7 @@ import 'css!./multiSelect';
icon: 'refresh'
});
import('actionsheet').then(({default: actionsheet}) => {
import('../actionSheet/actionSheet').then((actionsheet) => {
actionsheet.show({
items: menuItems,
positionTo: e.target,
@ -239,7 +239,7 @@ import 'css!./multiSelect';
switch (id) {
case 'addtocollection':
import('collectionEditor').then(({default: collectionEditor}) => {
import('../collectionEditor/collectionEditor').then(({default: collectionEditor}) => {
new collectionEditor({
items: items,
serverId: serverId
@ -249,11 +249,9 @@ import 'css!./multiSelect';
dispatchNeedsRefresh();
break;
case 'playlist':
import('playlistEditor').then(({default: playlistEditor}) => {
new playlistEditor({
items: items,
serverId: serverId
});
new playlistEditor({
items: items,
serverId: serverId
});
hideSelections();
dispatchNeedsRefresh();
@ -281,7 +279,7 @@ import 'css!./multiSelect';
dispatchNeedsRefresh();
break;
case 'refresh':
import('refreshDialog').then(({default: refreshDialog}) => {
import('../refreshdialog/refreshdialog').then(({default: refreshDialog}) => {
new refreshDialog({
itemIds: items,
serverId: serverId
@ -317,11 +315,8 @@ import 'css!./multiSelect';
function combineVersions(apiClient, selection) {
if (selection.length < 2) {
import('alert').then(({default: alert}) => {
alert({
text: globalize.translate('PleaseSelectTwoItems')
});
alert({
text: globalize.translate('PleaseSelectTwoItems')
});
return;
}
@ -341,7 +336,7 @@ import 'css!./multiSelect';
}
function showSelections(initialCard) {
import('emby-checkbox').then(() => {
import('../../elements/emby-checkbox/emby-checkbox').then(() => {
const cards = document.querySelectorAll('.card');
for (let i = 0, length = cards.length; i < length; i++) {
showSelection(cards[i], initialCard === cards[i]);

View File

@ -1,7 +1,7 @@
import serverNotifications from 'serverNotifications';
import playbackManager from 'playbackManager';
import events from 'events';
import globalize from 'globalize';
import serverNotifications from '../../scripts/serverNotifications';
import { playbackManager } from '../playback/playbackmanager';
import { Events } from 'jellyfin-apiclient';
import globalize from '../../scripts/globalize';
function onOneDocumentClick() {
document.removeEventListener('click', onOneDocumentClick);
@ -199,27 +199,27 @@ function showPackageInstallNotification(apiClient, installation, status) {
});
}
events.on(serverNotifications, 'LibraryChanged', function (e, apiClient, data) {
Events.on(serverNotifications, 'LibraryChanged', function (e, apiClient, data) {
onLibraryChanged(data, apiClient);
});
events.on(serverNotifications, 'PackageInstallationCompleted', function (e, apiClient, data) {
Events.on(serverNotifications, 'PackageInstallationCompleted', function (e, apiClient, data) {
showPackageInstallNotification(apiClient, data, 'completed');
});
events.on(serverNotifications, 'PackageInstallationFailed', function (e, apiClient, data) {
Events.on(serverNotifications, 'PackageInstallationFailed', function (e, apiClient, data) {
showPackageInstallNotification(apiClient, data, 'failed');
});
events.on(serverNotifications, 'PackageInstallationCancelled', function (e, apiClient, data) {
Events.on(serverNotifications, 'PackageInstallationCancelled', function (e, apiClient, data) {
showPackageInstallNotification(apiClient, data, 'cancelled');
});
events.on(serverNotifications, 'PackageInstalling', function (e, apiClient, data) {
Events.on(serverNotifications, 'PackageInstalling', function (e, apiClient, data) {
showPackageInstallNotification(apiClient, data, 'progress');
});
events.on(serverNotifications, 'ServerShuttingDown', function (e, apiClient, data) {
Events.on(serverNotifications, 'ServerShuttingDown', function (e, apiClient, data) {
const serverId = apiClient.serverInfo().Id;
const notification = {
tag: 'restart' + serverId,
@ -228,7 +228,7 @@ events.on(serverNotifications, 'ServerShuttingDown', function (e, apiClient, dat
showNotification(notification, 0, apiClient);
});
events.on(serverNotifications, 'ServerRestarting', function (e, apiClient, data) {
Events.on(serverNotifications, 'ServerRestarting', function (e, apiClient, data) {
const serverId = apiClient.serverInfo().Id;
const notification = {
tag: 'restart' + serverId,
@ -237,7 +237,7 @@ events.on(serverNotifications, 'ServerRestarting', function (e, apiClient, data)
showNotification(notification, 0, apiClient);
});
events.on(serverNotifications, 'RestartRequired', function (e, apiClient) {
Events.on(serverNotifications, 'RestartRequired', function (e, apiClient) {
const serverId = apiClient.serverInfo().Id;
const notification = {
tag: 'restart' + serverId,

View File

@ -1,15 +1,21 @@
import datetime from 'datetime';
import events from 'events';
import browser from 'browser';
import imageLoader from 'imageLoader';
import layoutManager from 'layoutManager';
import playbackManager from 'playbackManager';
import nowPlayingHelper from 'nowPlayingHelper';
import appHost from 'apphost';
import dom from 'dom';
import itemContextMenu from 'itemContextMenu';
import 'paper-icon-button-light';
import 'emby-ratingbutton';
import datetime from '../../scripts/datetime';
import { Events } from 'jellyfin-apiclient';
import browser from '../../scripts/browser';
import imageLoader from '../images/imageLoader';
import layoutManager from '../layoutManager';
import { playbackManager } from '../playback/playbackmanager';
import nowPlayingHelper from '../playback/nowplayinghelper';
import { appHost } from '../apphost';
import dom from '../../scripts/dom';
import itemContextMenu from '../itemContextMenu';
import '../../elements/emby-button/paper-icon-button-light';
import '../../elements/emby-ratingbutton/emby-ratingbutton';
import ServerConnections from '../ServerConnections';
import appFooter from '../appFooter/appFooter';
import itemShortcuts from '../shortcuts';
import './nowPlayingBar.css';
import '../../elements/emby-slider/emby-slider';
import { appRouter } from '../appRouter';
/* eslint-disable indent */
@ -243,52 +249,42 @@ import 'emby-ratingbutton';
}
function showRemoteControl() {
import('appRouter').then(({default: appRouter}) => {
appRouter.showNowPlaying();
});
appRouter.showNowPlaying();
}
let nowPlayingBarElement;
function getNowPlayingBar() {
if (nowPlayingBarElement) {
return Promise.resolve(nowPlayingBarElement);
return nowPlayingBarElement;
}
return new Promise(function (resolve, reject) {
Promise.all([
import('appFooter-shared'),
import('itemShortcuts'),
import('css!./nowPlayingBar.css'),
import('emby-slider')
])
.then(([appfooter, itemShortcuts]) => {
const parentContainer = appfooter.element;
nowPlayingBarElement = parentContainer.querySelector('.nowPlayingBar');
const parentContainer = appFooter.element;
nowPlayingBarElement = parentContainer.querySelector('.nowPlayingBar');
if (nowPlayingBarElement) {
resolve(nowPlayingBarElement);
return;
}
if (nowPlayingBarElement) {
return nowPlayingBarElement;
}
parentContainer.insertAdjacentHTML('afterbegin', getNowPlayingBarHtml());
nowPlayingBarElement = parentContainer.querySelector('.nowPlayingBar');
parentContainer.insertAdjacentHTML('afterbegin', getNowPlayingBarHtml());
window.CustomElements.upgradeSubtree(parentContainer);
if (layoutManager.mobile) {
hideButton(nowPlayingBarElement.querySelector('.btnShuffleQueue'));
hideButton(nowPlayingBarElement.querySelector('.nowPlayingBarCenter'));
}
nowPlayingBarElement = parentContainer.querySelector('.nowPlayingBar');
if (browser.safari && browser.slow) {
// Not handled well here. The wrong elements receive events, bar doesn't update quickly enough, etc.
nowPlayingBarElement.classList.add('noMediaProgress');
}
if (layoutManager.mobile) {
hideButton(nowPlayingBarElement.querySelector('.btnShuffleQueue'));
hideButton(nowPlayingBarElement.querySelector('.nowPlayingBarCenter'));
}
itemShortcuts.on(nowPlayingBarElement);
if (browser.safari && browser.slow) {
// Not handled well here. The wrong elements receive events, bar doesn't update quickly enough, etc.
nowPlayingBarElement.classList.add('noMediaProgress');
}
bindEvents(nowPlayingBarElement);
resolve(nowPlayingBarElement);
});
});
itemShortcuts.on(nowPlayingBarElement);
bindEvents(nowPlayingBarElement);
return nowPlayingBarElement;
}
function showButton(button) {
@ -451,7 +447,7 @@ import 'emby-ratingbutton';
if (item.SeriesPrimaryImageTag) {
options.tag = item.SeriesPrimaryImageTag;
return window.connectionManager.getApiClient(item.ServerId).getScaledImageUrl(item.SeriesId, options);
return ServerConnections.getApiClient(item.ServerId).getScaledImageUrl(item.SeriesId, options);
}
}
@ -459,12 +455,12 @@ import 'emby-ratingbutton';
if (item.SeriesThumbImageTag) {
options.tag = item.SeriesThumbImageTag;
return window.connectionManager.getApiClient(item.ServerId).getScaledImageUrl(item.SeriesId, options);
return ServerConnections.getApiClient(item.ServerId).getScaledImageUrl(item.SeriesId, options);
}
if (item.ParentThumbImageTag) {
options.tag = item.ParentThumbImageTag;
return window.connectionManager.getApiClient(item.ServerId).getScaledImageUrl(item.ParentThumbItemId, options);
return ServerConnections.getApiClient(item.ServerId).getScaledImageUrl(item.ParentThumbItemId, options);
}
}
@ -481,12 +477,12 @@ import 'emby-ratingbutton';
if (item.ImageTags && item.ImageTags[options.type]) {
options.tag = item.ImageTags[options.type];
return window.connectionManager.getApiClient(item.ServerId).getScaledImageUrl(item.PrimaryImageItemId || item.Id, options);
return ServerConnections.getApiClient(item.ServerId).getScaledImageUrl(item.PrimaryImageItemId || item.Id, options);
}
if (item.AlbumId && item.AlbumPrimaryImageTag) {
options.tag = item.AlbumPrimaryImageTag;
return window.connectionManager.getApiClient(item.ServerId).getScaledImageUrl(item.AlbumId, options);
return ServerConnections.getApiClient(item.ServerId).getScaledImageUrl(item.AlbumId, options);
}
return null;
@ -547,7 +543,7 @@ import 'emby-ratingbutton';
if (nowPlayingItem.Id) {
if (isRefreshing) {
const apiClient = window.connectionManager.getApiClient(nowPlayingItem.ServerId);
const apiClient = ServerConnections.getApiClient(nowPlayingItem.ServerId);
apiClient.getItem(apiClient.getCurrentUserId(), nowPlayingItem.Id).then(function (item) {
const userData = item.UserData || {};
const likes = userData.Likes == null ? '' : userData.Likes;
@ -620,7 +616,7 @@ import 'emby-ratingbutton';
return;
}
getNowPlayingBar().then(slideUp);
slideUp(getNowPlayingBar());
}
function hideNowPlayingBar() {
@ -681,9 +677,8 @@ import 'emby-ratingbutton';
return;
}
getNowPlayingBar().then(function () {
updatePlayerStateInternal(event, state, player);
});
getNowPlayingBar();
updatePlayerStateInternal(event, state, player);
}
function onTimeUpdate(e) {
@ -707,15 +702,15 @@ import 'emby-ratingbutton';
const player = currentPlayer;
if (player) {
events.off(player, 'playbackstart', onPlaybackStart);
events.off(player, 'statechange', onPlaybackStart);
events.off(player, 'repeatmodechange', onRepeatModeChange);
events.off(player, 'shufflequeuemodechange', onQueueShuffleModeChange);
events.off(player, 'playbackstop', onPlaybackStopped);
events.off(player, 'volumechange', onVolumeChanged);
events.off(player, 'pause', onPlayPauseStateChanged);
events.off(player, 'unpause', onPlayPauseStateChanged);
events.off(player, 'timeupdate', onTimeUpdate);
Events.off(player, 'playbackstart', onPlaybackStart);
Events.off(player, 'statechange', onPlaybackStart);
Events.off(player, 'repeatmodechange', onRepeatModeChange);
Events.off(player, 'shufflequeuemodechange', onQueueShuffleModeChange);
Events.off(player, 'playbackstop', onPlaybackStopped);
Events.off(player, 'volumechange', onVolumeChanged);
Events.off(player, 'pause', onPlayPauseStateChanged);
Events.off(player, 'unpause', onPlayPauseStateChanged);
Events.off(player, 'timeupdate', onTimeUpdate);
currentPlayer = null;
hideNowPlayingBar();
@ -753,18 +748,18 @@ import 'emby-ratingbutton';
refreshFromPlayer(player);
events.on(player, 'playbackstart', onPlaybackStart);
events.on(player, 'statechange', onPlaybackStart);
events.on(player, 'repeatmodechange', onRepeatModeChange);
events.on(player, 'shufflequeuemodechange', onQueueShuffleModeChange);
events.on(player, 'playbackstop', onPlaybackStopped);
events.on(player, 'volumechange', onVolumeChanged);
events.on(player, 'pause', onPlayPauseStateChanged);
events.on(player, 'unpause', onPlayPauseStateChanged);
events.on(player, 'timeupdate', onTimeUpdate);
Events.on(player, 'playbackstart', onPlaybackStart);
Events.on(player, 'statechange', onPlaybackStart);
Events.on(player, 'repeatmodechange', onRepeatModeChange);
Events.on(player, 'shufflequeuemodechange', onQueueShuffleModeChange);
Events.on(player, 'playbackstop', onPlaybackStopped);
Events.on(player, 'volumechange', onVolumeChanged);
Events.on(player, 'pause', onPlayPauseStateChanged);
Events.on(player, 'unpause', onPlayPauseStateChanged);
Events.on(player, 'timeupdate', onTimeUpdate);
}
events.on(playbackManager, 'playerchange', function () {
Events.on(playbackManager, 'playerchange', function () {
bindToPlayer(playbackManager.getCurrentPlayer());
});

View File

@ -1,5 +1,5 @@
import appSettings from 'appSettings';
import pluginManager from 'pluginManager';
import appSettings from '../scripts/settings/appSettings';
import { pluginManager } from './pluginManager';
/* eslint-disable indent */
class PackageManager {

View File

@ -1,9 +1,9 @@
import events from 'events';
import playbackManager from 'playbackManager';
import dom from 'dom';
import browser from 'browser';
import 'css!./iconosd';
import 'material-icons';
import { Events } from 'jellyfin-apiclient';
import { playbackManager } from './playbackmanager';
import dom from '../../scripts/dom';
import browser from '../../scripts/browser';
import './iconosd.css';
import 'material-design-icons-iconfont';
let currentPlayer;
let osdElement;
@ -121,8 +121,8 @@ function releaseCurrentPlayer() {
const player = currentPlayer;
if (player) {
events.off(player, 'brightnesschange', onBrightnessChanged);
events.off(player, 'playbackstop', hideOsd);
Events.off(player, 'brightnesschange', onBrightnessChanged);
Events.off(player, 'playbackstop', hideOsd);
currentPlayer = null;
}
}
@ -151,11 +151,11 @@ function bindToPlayer(player) {
}
hideOsd();
events.on(player, 'brightnesschange', onBrightnessChanged);
events.on(player, 'playbackstop', hideOsd);
Events.on(player, 'brightnesschange', onBrightnessChanged);
Events.on(player, 'playbackstop', hideOsd);
}
events.on(playbackManager, 'playerchange', function () {
Events.on(playbackManager, 'playerchange', function () {
bindToPlayer(playbackManager.getCurrentPlayer());
});

View File

@ -1,7 +1,9 @@
import playbackManager from 'playbackManager';
import nowPlayingHelper from 'nowPlayingHelper';
import shell from 'shell';
import events from 'events';
import { playbackManager } from '../playback/playbackmanager';
import nowPlayingHelper from '../playback/nowplayinghelper';
import { Events } from 'jellyfin-apiclient';
import ServerConnections from '../ServerConnections';
import shell from '../../scripts/shell';
/* eslint-disable indent */
// Reports media playback to the device for lock screen control
@ -16,16 +18,16 @@ import events from 'events';
} else if (options.type === 'Primary' && item.SeriesPrimaryImageTag) {
options.tag = item.SeriesPrimaryImageTag;
return window.connectionManager.getApiClient(item.ServerId).getScaledImageUrl(item.SeriesId, options);
return ServerConnections.getApiClient(item.ServerId).getScaledImageUrl(item.SeriesId, options);
} else if (options.type === 'Thumb') {
if (item.SeriesThumbImageTag) {
options.tag = item.SeriesThumbImageTag;
return window.connectionManager.getApiClient(item.ServerId).getScaledImageUrl(item.SeriesId, options);
return ServerConnections.getApiClient(item.ServerId).getScaledImageUrl(item.SeriesId, options);
} else if (item.ParentThumbImageTag) {
options.tag = item.ParentThumbImageTag;
return window.connectionManager.getApiClient(item.ServerId).getScaledImageUrl(item.ParentThumbItemId, options);
return ServerConnections.getApiClient(item.ServerId).getScaledImageUrl(item.ParentThumbItemId, options);
}
}
@ -38,11 +40,11 @@ import events from 'events';
if (item.ImageTags && item.ImageTags[options.type]) {
options.tag = item.ImageTags[options.type];
return window.connectionManager.getApiClient(item.ServerId).getScaledImageUrl(item.Id, options);
return ServerConnections.getApiClient(item.ServerId).getScaledImageUrl(item.Id, options);
} else if (item.AlbumId && item.AlbumPrimaryImageTag) {
options.tag = item.AlbumPrimaryImageTag;
return window.connectionManager.getApiClient(item.ServerId).getScaledImageUrl(item.AlbumId, options);
return ServerConnections.getApiClient(item.ServerId).getScaledImageUrl(item.AlbumId, options);
}
return null;
@ -164,12 +166,12 @@ import events from 'events';
function releaseCurrentPlayer() {
if (currentPlayer) {
events.off(currentPlayer, 'playbackstart', onPlaybackStart);
events.off(currentPlayer, 'playbackstop', onPlaybackStopped);
events.off(currentPlayer, 'unpause', onGeneralEvent);
events.off(currentPlayer, 'pause', onGeneralEvent);
events.off(currentPlayer, 'statechange', onStateChanged);
events.off(currentPlayer, 'timeupdate', onGeneralEvent);
Events.off(currentPlayer, 'playbackstart', onPlaybackStart);
Events.off(currentPlayer, 'playbackstop', onPlaybackStopped);
Events.off(currentPlayer, 'unpause', onGeneralEvent);
Events.off(currentPlayer, 'pause', onGeneralEvent);
Events.off(currentPlayer, 'statechange', onStateChanged);
Events.off(currentPlayer, 'timeupdate', onGeneralEvent);
currentPlayer = null;
@ -198,12 +200,12 @@ import events from 'events';
const state = playbackManager.getPlayerState(player);
updatePlayerState(player, state, 'init');
events.on(currentPlayer, 'playbackstart', onPlaybackStart);
events.on(currentPlayer, 'playbackstop', onPlaybackStopped);
events.on(currentPlayer, 'unpause', onGeneralEvent);
events.on(currentPlayer, 'pause', onGeneralEvent);
events.on(currentPlayer, 'statechange', onStateChanged);
events.on(currentPlayer, 'timeupdate', onGeneralEvent);
Events.on(currentPlayer, 'playbackstart', onPlaybackStart);
Events.on(currentPlayer, 'playbackstop', onPlaybackStopped);
Events.on(currentPlayer, 'unpause', onGeneralEvent);
Events.on(currentPlayer, 'pause', onGeneralEvent);
Events.on(currentPlayer, 'statechange', onStateChanged);
Events.on(currentPlayer, 'timeupdate', onGeneralEvent);
}
function execute(name) {
@ -251,7 +253,7 @@ import events from 'events';
});
}
events.on(playbackManager, 'playerchange', function () {
Events.on(playbackManager, 'playerchange', function () {
bindToPlayer(playbackManager.getCurrentPlayer());
});

View File

@ -1,14 +1,16 @@
import events from 'events';
import datetime from 'datetime';
import appSettings from 'appSettings';
import itemHelper from 'itemHelper';
import pluginManager from 'pluginManager';
import PlayQueueManager from 'playQueueManager';
import * as userSettings from 'userSettings';
import globalize from 'globalize';
import loading from 'loading';
import appHost from 'apphost';
import screenfull from 'screenfull';
import { Events } from 'jellyfin-apiclient';
import datetime from '../../scripts/datetime';
import appSettings from '../../scripts/settings/appSettings';
import itemHelper from '../itemHelper';
import { pluginManager } from '../pluginManager';
import PlayQueueManager from './playqueuemanager';
import * as userSettings from '../../scripts/settings/userSettings';
import globalize from '../../scripts/globalize';
import loading from '../loading/loading';
import { appHost } from '../apphost';
import * as Screenfull from 'screenfull';
import ServerConnections from '../ServerConnections';
import alert from '../alert';
function enableLocalPlaylistManagement(player) {
if (player.getPlaylist) {
@ -23,14 +25,14 @@ function enableLocalPlaylistManagement(player) {
}
function bindToFullscreenChange(player) {
if (screenfull.isEnabled) {
screenfull.on('change', function () {
events.trigger(player, 'fullscreenchange');
if (Screenfull.isEnabled) {
Screenfull.on('change', function () {
Events.trigger(player, 'fullscreenchange');
});
} else {
// iOS Safari
document.addEventListener('webkitfullscreenchange', function () {
events.trigger(player, 'fullscreenchange');
Events.trigger(player, 'fullscreenchange');
}, false);
}
}
@ -46,14 +48,14 @@ function triggerPlayerChange(playbackManagerInstance, newPlayer, newTarget, prev
}
}
events.trigger(playbackManagerInstance, 'playerchange', [newPlayer, newTarget, previousPlayer]);
Events.trigger(playbackManagerInstance, 'playerchange', [newPlayer, newTarget, previousPlayer]);
}
function reportPlayback(playbackManagerInstance, state, player, reportPlaylist, serverId, method, progressEventName) {
if (!serverId) {
// Not a server item
// We can expand on this later and possibly report them
events.trigger(playbackManagerInstance, 'reportplayback', [false]);
Events.trigger(playbackManagerInstance, 'reportplayback', [false]);
return;
}
@ -68,11 +70,11 @@ function reportPlayback(playbackManagerInstance, state, player, reportPlaylist,
addPlaylistToPlaybackReport(playbackManagerInstance, info, player, serverId);
}
const apiClient = window.connectionManager.getApiClient(serverId);
const apiClient = ServerConnections.getApiClient(serverId);
const reportPlaybackPromise = apiClient[method](info);
// Notify that report has been sent
reportPlaybackPromise.then(() => {
events.trigger(playbackManagerInstance, 'reportplayback', [true]);
Events.trigger(playbackManagerInstance, 'reportplayback', [true]);
});
}
@ -105,7 +107,7 @@ function normalizeName(t) {
}
function getItemsForPlayback(serverId, query) {
const apiClient = window.connectionManager.getApiClient(serverId);
const apiClient = ServerConnections.getApiClient(serverId);
if (query.Ids && query.Ids.split(',').length === 1) {
const itemId = query.Ids.split(',');
@ -619,7 +621,7 @@ function supportsDirectPlay(apiClient, item, mediaSource) {
} else if (mediaSource.Protocol === 'File') {
return new Promise(function (resolve, reject) {
// Determine if the file can be accessed directly
import('filesystem').then((filesystem) => {
import('../../scripts/filesystem').then((filesystem) => {
const method = isFolderRip ?
'directoryExists' :
'fileExists';
@ -647,11 +649,9 @@ function validatePlaybackInfoResult(instance, result) {
}
function showPlaybackInfoErrorMessage(instance, errorCode) {
import('alert').then(({ default: alert }) => {
alert({
text: globalize.translate(errorCode),
title: globalize.translate('HeaderPlaybackError')
});
alert({
text: globalize.translate(errorCode),
title: globalize.translate('HeaderPlaybackError')
});
}
@ -852,13 +852,13 @@ class PlaybackManager {
player.tryPair(targetInfo) :
Promise.resolve();
events.trigger(self, 'pairing');
Events.trigger(self, 'pairing');
promise.then(function () {
events.trigger(self, 'paired');
Events.trigger(self, 'paired');
setCurrentPlayerInternal(player, targetInfo);
}, function () {
events.trigger(self, 'pairerror');
Events.trigger(self, 'pairerror');
if (currentPairingId === targetInfo.id) {
currentPairingId = null;
}
@ -869,7 +869,7 @@ class PlaybackManager {
const promises = players.filter(displayPlayerIndividually).map(getPlayerTargets);
return Promise.all(promises).then(function (responses) {
return window.connectionManager.currentApiClient().getCurrentUser().then(function (user) {
return ServerConnections.currentApiClient().getCurrentUser().then(function (user) {
const targets = [];
targets.push({
@ -1161,7 +1161,7 @@ class PlaybackManager {
if (!brightnessOsdLoaded) {
brightnessOsdLoaded = true;
// TODO: Have this trigger an event instead to get the osd out of here
import('brightnessOsd').then();
import('./brightnessosd').then();
}
player.setBrightness(val);
}
@ -1367,7 +1367,7 @@ class PlaybackManager {
function getSavedMaxStreamingBitrate(apiClient, mediaType) {
if (!apiClient) {
// This should hopefully never happen
apiClient = window.connectionManager.currentApiClient();
apiClient = ServerConnections.currentApiClient();
}
const endpointInfo = apiClient.getSavedEndpointInfo() || {};
@ -1390,7 +1390,7 @@ class PlaybackManager {
const mediaType = playerData.streamInfo ? playerData.streamInfo.mediaType : null;
const currentItem = self.currentItem(player);
const apiClient = currentItem ? window.connectionManager.getApiClient(currentItem.ServerId) : window.connectionManager.currentApiClient();
const apiClient = currentItem ? ServerConnections.getApiClient(currentItem.ServerId) : ServerConnections.currentApiClient();
return getSavedMaxStreamingBitrate(apiClient, mediaType);
};
@ -1404,7 +1404,7 @@ class PlaybackManager {
const mediaType = playerData.streamInfo ? playerData.streamInfo.mediaType : null;
const currentItem = self.currentItem(player);
const apiClient = currentItem ? window.connectionManager.getApiClient(currentItem.ServerId) : window.connectionManager.currentApiClient();
const apiClient = currentItem ? ServerConnections.getApiClient(currentItem.ServerId) : ServerConnections.currentApiClient();
const endpointInfo = apiClient.getSavedEndpointInfo() || {};
return appSettings.enableAutomaticBitrateDetection(endpointInfo.IsInNetwork, mediaType);
@ -1416,7 +1416,7 @@ class PlaybackManager {
return player.setMaxStreamingBitrate(options);
}
const apiClient = window.connectionManager.getApiClient(self.currentItem(player).ServerId);
const apiClient = ServerConnections.getApiClient(self.currentItem(player).ServerId);
apiClient.getEndpointInfo().then(function (endpointInfo) {
const playerData = getPlayerData(player);
@ -1447,12 +1447,12 @@ class PlaybackManager {
return player.isFullscreen();
}
if (!screenfull.isEnabled) {
if (!Screenfull.isEnabled) {
// iOS Safari
return document.webkitIsFullScreen;
}
return screenfull.isFullscreen;
return Screenfull.isFullscreen;
};
self.toggleFullscreen = function (player) {
@ -1461,8 +1461,8 @@ class PlaybackManager {
return player.toggleFullscreen();
}
if (screenfull.isEnabled) {
screenfull.toggle();
if (Screenfull.isEnabled) {
Screenfull.toggle();
} else {
// iOS Safari
if (document.webkitIsFullScreen && document.webkitCancelFullscreen) {
@ -1678,7 +1678,7 @@ class PlaybackManager {
const subtitleStreamIndex = params.SubtitleStreamIndex == null ? getPlayerData(player).subtitleStreamIndex : params.SubtitleStreamIndex;
let currentMediaSource = self.currentMediaSource(player);
const apiClient = window.connectionManager.getApiClient(currentItem.ServerId);
const apiClient = ServerConnections.getApiClient(currentItem.ServerId);
if (ticks) {
ticks = parseInt(ticks);
@ -1834,7 +1834,7 @@ class PlaybackManager {
}, queryOptions));
} else if (firstItem.Type === 'Episode' && items.length === 1 && getPlayer(firstItem, options).supportsProgress !== false) {
promise = new Promise(function (resolve, reject) {
const apiClient = window.connectionManager.getApiClient(firstItem.ServerId);
const apiClient = ServerConnections.getApiClient(firstItem.ServerId);
apiClient.getCurrentUser().then(function (user) {
if (!user.Configuration.EnableNextEpisodeAutoPlay || !firstItem.SeriesId) {
@ -2065,7 +2065,7 @@ class PlaybackManager {
return playOther(items, options, user);
}
const apiClient = window.connectionManager.getApiClient(firstItem.ServerId);
const apiClient = ServerConnections.getApiClient(firstItem.ServerId);
return getIntros(firstItem, apiClient, options).then(function (introsResult) {
const introItems = introsResult.Items;
@ -2128,14 +2128,14 @@ class PlaybackManager {
const mediaType = item.MediaType;
const onBitrateDetectionFailure = function () {
return playAfterBitrateDetect(getSavedMaxStreamingBitrate(window.connectionManager.getApiClient(item.ServerId), mediaType), item, playOptions, onPlaybackStartedFn);
return playAfterBitrateDetect(getSavedMaxStreamingBitrate(ServerConnections.getApiClient(item.ServerId), mediaType), item, playOptions, onPlaybackStartedFn);
};
if (!isServerItem(item) || itemHelper.isLocalItem(item)) {
return onBitrateDetectionFailure();
}
const apiClient = window.connectionManager.getApiClient(item.ServerId);
const apiClient = ServerConnections.getApiClient(item.ServerId);
apiClient.getEndpointInfo().then(function (endpointInfo) {
if ((mediaType === 'Video' || mediaType === 'Audio') && appSettings.enableAutomaticBitrateDetection(endpointInfo.IsInNetwork, mediaType)) {
return apiClient.detectBitrate().then(function (bitrate) {
@ -2158,7 +2158,7 @@ class PlaybackManager {
removeCurrentPlayer(player);
}
events.trigger(self, 'playbackcancelled');
Events.trigger(self, 'playbackcancelled');
return Promise.reject();
}
@ -2254,7 +2254,7 @@ class PlaybackManager {
return Promise.all([promise, player.getDeviceProfile(item)]).then(function (responses) {
const deviceProfile = responses[1];
const apiClient = window.connectionManager.getApiClient(item.ServerId);
const apiClient = ServerConnections.getApiClient(item.ServerId);
const mediaSourceId = playOptions.mediaSourceId;
const audioStreamIndex = playOptions.audioStreamIndex;
@ -2299,11 +2299,11 @@ class PlaybackManager {
const startPosition = options.startPositionTicks || 0;
const mediaType = options.mediaType || item.MediaType;
const player = getPlayer(item, options);
const apiClient = window.connectionManager.getApiClient(item.ServerId);
const apiClient = ServerConnections.getApiClient(item.ServerId);
// Call this just to ensure the value is recorded, it is needed with getSavedMaxStreamingBitrate
return apiClient.getEndpointInfo().then(function () {
const maxBitrate = getSavedMaxStreamingBitrate(window.connectionManager.getApiClient(item.ServerId), mediaType);
const maxBitrate = getSavedMaxStreamingBitrate(ServerConnections.getApiClient(item.ServerId), mediaType);
return player.getDeviceProfile(item).then(function (deviceProfile) {
return getPlaybackMediaSource(player, apiClient, deviceProfile, maxBitrate, item, startPosition, options.mediaSourceId, options.audioStreamIndex, options.subtitleStreamIndex).then(function (mediaSource) {
@ -2319,11 +2319,11 @@ class PlaybackManager {
const mediaType = options.mediaType || item.MediaType;
// TODO: Remove the true forceLocalPlayer hack
const player = getPlayer(item, options, true);
const apiClient = window.connectionManager.getApiClient(item.ServerId);
const apiClient = ServerConnections.getApiClient(item.ServerId);
// Call this just to ensure the value is recorded, it is needed with getSavedMaxStreamingBitrate
return apiClient.getEndpointInfo().then(function () {
const maxBitrate = getSavedMaxStreamingBitrate(window.connectionManager.getApiClient(item.ServerId), mediaType);
const maxBitrate = getSavedMaxStreamingBitrate(ServerConnections.getApiClient(item.ServerId), mediaType);
return player.getDeviceProfile(item).then(function (deviceProfile) {
return getPlaybackInfo(player, apiClient, item, deviceProfile, maxBitrate, startPosition, false, null, null, null, null).then(function (playbackInfoResult) {
@ -2548,7 +2548,7 @@ class PlaybackManager {
const isCurrentIndex = removeResult.isCurrentIndex;
events.trigger(player, 'playlistitemremove', [
Events.trigger(player, 'playlistitemremove', [
{
playlistItemIds: playlistItemIds
}
@ -2573,7 +2573,7 @@ class PlaybackManager {
return;
}
events.trigger(player, 'playlistitemmove', [
Events.trigger(player, 'playlistitemmove', [
{
playlistItemId: moveResult.playlistItemId,
newIndex: moveResult.newIndex
@ -2707,7 +2707,7 @@ class PlaybackManager {
const queueDirectToPlayer = player && !enableLocalPlaylistManagement(player);
if (queueDirectToPlayer) {
const apiClient = window.connectionManager.getApiClient(items[0].ServerId);
const apiClient = ServerConnections.getApiClient(items[0].ServerId);
player.getDeviceProfile(items[0]).then(function (profile) {
setStreamUrls(items, profile, self.getMaxStreamingBitrate(player), apiClient, 0).then(function () {
@ -2727,7 +2727,7 @@ class PlaybackManager {
} else {
self._playQueueManager.queue(items);
}
events.trigger(player, 'playlistitemadd');
Events.trigger(player, 'playlistitemadd');
}
function onPlayerProgressInterval() {
@ -2779,8 +2779,8 @@ class PlaybackManager {
state.IsFirstItem = isFirstItem;
state.IsFullscreen = fullscreen;
events.trigger(player, 'playbackstart', [state]);
events.trigger(self, 'playbackstart', [player, state]);
Events.trigger(player, 'playbackstart', [state]);
Events.trigger(self, 'playbackstart', [player, state]);
// only used internally as a safeguard to avoid reporting other events to the server before playback start
streamInfo.started = true;
@ -2810,8 +2810,8 @@ class PlaybackManager {
state.IsFirstItem = isFirstItem;
state.IsFullscreen = fullscreen;
events.trigger(player, 'playbackstart', [state]);
events.trigger(self, 'playbackstart', [player, state]);
Events.trigger(player, 'playbackstart', [state]);
Events.trigger(self, 'playbackstart', [player, state]);
// only used internally as a safeguard to avoid reporting other events to the server before playback start
streamInfo.started = true;
@ -2850,8 +2850,8 @@ class PlaybackManager {
state.NextItem = playbackStopInfo.nextItem;
events.trigger(player, 'playbackstop', [state]);
events.trigger(self, 'playbackstop', [playbackStopInfo]);
Events.trigger(player, 'playbackstop', [state]);
Events.trigger(self, 'playbackstop', [playbackStopInfo]);
const nextItemPlayOptions = nextItem ? (nextItem.item.playOptions || getDefaultPlayOptions()) : getDefaultPlayOptions();
const newPlayer = nextItem ? getPlayer(nextItem.item, nextItemPlayOptions) : null;
@ -2952,8 +2952,8 @@ class PlaybackManager {
self._playQueueManager.reset();
}
events.trigger(player, 'playbackstop', [state]);
events.trigger(self, 'playbackstop', [playbackStopInfo]);
Events.trigger(player, 'playbackstop', [state]);
Events.trigger(self, 'playbackstop', [playbackStopInfo]);
const nextItemPlayOptions = nextItem ? (nextItem.item.playOptions || getDefaultPlayOptions()) : getDefaultPlayOptions();
const newPlayer = nextItem ? getPlayer(nextItem.item, nextItemPlayOptions) : null;
@ -2999,7 +2999,7 @@ class PlaybackManager {
reportPlayback(self, state, activePlayer, true, serverId, 'reportPlaybackStopped');
}
events.trigger(self, 'playbackstop', [{
Events.trigger(self, 'playbackstop', [{
player: activePlayer,
state: state,
nextItem: newItem,
@ -3010,8 +3010,8 @@ class PlaybackManager {
function bindStopped(player) {
if (enableLocalPlaylistManagement(player)) {
events.off(player, 'stopped', onPlaybackStopped);
events.on(player, 'stopped', onPlaybackStopped);
Events.off(player, 'stopped', onPlaybackStopped);
Events.on(player, 'stopped', onPlaybackStopped);
}
}
@ -3061,7 +3061,7 @@ class PlaybackManager {
}
function unbindStopped(player) {
events.off(player, 'stopped', onPlaybackStopped);
Events.off(player, 'stopped', onPlaybackStopped);
}
function initLegacyVolumeMethods(player) {
@ -3090,28 +3090,28 @@ class PlaybackManager {
}
if (enableLocalPlaylistManagement(player)) {
events.on(player, 'error', onPlaybackError);
events.on(player, 'timeupdate', onPlaybackTimeUpdate);
events.on(player, 'pause', onPlaybackPause);
events.on(player, 'unpause', onPlaybackUnpause);
events.on(player, 'volumechange', onPlaybackVolumeChange);
events.on(player, 'repeatmodechange', onRepeatModeChange);
events.on(player, 'shufflequeuemodechange', onShuffleQueueModeChange);
events.on(player, 'playlistitemmove', onPlaylistItemMove);
events.on(player, 'playlistitemremove', onPlaylistItemRemove);
events.on(player, 'playlistitemadd', onPlaylistItemAdd);
Events.on(player, 'error', onPlaybackError);
Events.on(player, 'timeupdate', onPlaybackTimeUpdate);
Events.on(player, 'pause', onPlaybackPause);
Events.on(player, 'unpause', onPlaybackUnpause);
Events.on(player, 'volumechange', onPlaybackVolumeChange);
Events.on(player, 'repeatmodechange', onRepeatModeChange);
Events.on(player, 'shufflequeuemodechange', onShuffleQueueModeChange);
Events.on(player, 'playlistitemmove', onPlaylistItemMove);
Events.on(player, 'playlistitemremove', onPlaylistItemRemove);
Events.on(player, 'playlistitemadd', onPlaylistItemAdd);
} else if (player.isLocalPlayer) {
events.on(player, 'itemstarted', onPlaybackStartedFromSelfManagingPlayer);
events.on(player, 'itemstopped', onPlaybackStoppedFromSelfManagingPlayer);
events.on(player, 'timeupdate', onPlaybackTimeUpdate);
events.on(player, 'pause', onPlaybackPause);
events.on(player, 'unpause', onPlaybackUnpause);
events.on(player, 'volumechange', onPlaybackVolumeChange);
events.on(player, 'repeatmodechange', onRepeatModeChange);
events.on(player, 'shufflequeuemodechange', onShuffleQueueModeChange);
events.on(player, 'playlistitemmove', onPlaylistItemMove);
events.on(player, 'playlistitemremove', onPlaylistItemRemove);
events.on(player, 'playlistitemadd', onPlaylistItemAdd);
Events.on(player, 'itemstarted', onPlaybackStartedFromSelfManagingPlayer);
Events.on(player, 'itemstopped', onPlaybackStoppedFromSelfManagingPlayer);
Events.on(player, 'timeupdate', onPlaybackTimeUpdate);
Events.on(player, 'pause', onPlaybackPause);
Events.on(player, 'unpause', onPlaybackUnpause);
Events.on(player, 'volumechange', onPlaybackVolumeChange);
Events.on(player, 'repeatmodechange', onRepeatModeChange);
Events.on(player, 'shufflequeuemodechange', onShuffleQueueModeChange);
Events.on(player, 'playlistitemmove', onPlaylistItemMove);
Events.on(player, 'playlistitemremove', onPlaylistItemRemove);
Events.on(player, 'playlistitemadd', onPlaylistItemAdd);
}
if (player.isLocalPlayer) {
@ -3120,13 +3120,13 @@ class PlaybackManager {
bindStopped(player);
}
events.on(pluginManager, 'registered', function (e, plugin) {
Events.on(pluginManager, 'registered', function (e, plugin) {
if (plugin.type === 'mediaplayer') {
initMediaPlayer(plugin);
}
});
pluginManager.ofType('mediaplayer').map(initMediaPlayer);
pluginManager.ofType('mediaplayer').forEach(initMediaPlayer);
function sendProgressUpdate(player, progressEventName, reportPlaylist) {
if (!player) {
@ -3157,15 +3157,15 @@ class PlaybackManager {
streamInfo.lastMediaInfoQuery = new Date().getTime();
const apiClient = window.connectionManager.getApiClient(serverId);
const apiClient = ServerConnections.getApiClient(serverId);
if (!apiClient.isMinServerVersion('3.2.70.7')) {
return;
}
window.connectionManager.getApiClient(serverId).getLiveStreamMediaInfo(liveStreamId).then(function (info) {
ServerConnections.getApiClient(serverId).getLiveStreamMediaInfo(liveStreamId).then(function (info) {
mediaSource.MediaStreams = info.MediaStreams;
events.trigger(player, 'mediastreamschange');
Events.trigger(player, 'mediastreamschange');
}, function () {
});
}
@ -3190,9 +3190,9 @@ class PlaybackManager {
};
if (appHost.supports('remotecontrol')) {
import('serverNotifications').then(({ default: serverNotifications }) => {
events.on(serverNotifications, 'ServerShuttingDown', self.setDefaultPlayerActive.bind(self));
events.on(serverNotifications, 'ServerRestarting', self.setDefaultPlayerActive.bind(self));
import('../../scripts/serverNotifications').then(({ default: serverNotifications }) => {
Events.on(serverNotifications, 'ServerShuttingDown', self.setDefaultPlayerActive.bind(self));
Events.on(serverNotifications, 'ServerRestarting', self.setDefaultPlayerActive.bind(self));
});
}
}
@ -3220,7 +3220,7 @@ class PlaybackManager {
return Promise.reject();
}
const apiClient = window.connectionManager.getApiClient(nextItem.item.ServerId);
const apiClient = ServerConnections.getApiClient(nextItem.item.ServerId);
return apiClient.getItem(apiClient.getCurrentUserId(), nextItem.item.Id);
}
@ -3361,7 +3361,7 @@ class PlaybackManager {
return player.playTrailers(item);
}
const apiClient = window.connectionManager.getApiClient(item.ServerId);
const apiClient = ServerConnections.getApiClient(item.ServerId);
const instance = this;
@ -3393,7 +3393,7 @@ class PlaybackManager {
}
getSubtitleUrl(textStream, serverId) {
const apiClient = window.connectionManager.getApiClient(serverId);
const apiClient = ServerConnections.getApiClient(serverId);
return !textStream.IsExternalUrl ? apiClient.getUrl(textStream.DeliveryUrl) : textStream.DeliveryUrl;
}
@ -3473,7 +3473,7 @@ class PlaybackManager {
return player.instantMix(item);
}
const apiClient = window.connectionManager.getApiClient(item.ServerId);
const apiClient = ServerConnections.getApiClient(item.ServerId);
const options = {};
options.UserId = apiClient.getCurrentUserId();
@ -3588,7 +3588,7 @@ class PlaybackManager {
}
this._playQueueManager.setRepeatMode(value);
events.trigger(player, 'repeatmodechange');
Events.trigger(player, 'repeatmodechange');
}
getRepeatMode(player = this._currentPlayer) {
@ -3605,7 +3605,7 @@ class PlaybackManager {
}
this._playQueueManager.setShuffleMode(value);
events.trigger(player, 'shufflequeuemodechange');
Events.trigger(player, 'shufflequeuemodechange');
}
getQueueShuffleMode(player = this._currentPlayer) {
@ -3633,7 +3633,7 @@ class PlaybackManager {
} else {
this._playQueueManager.toggleShuffleMode();
}
events.trigger(player, 'shufflequeuemodechange');
Events.trigger(player, 'shufflequeuemodechange');
}
clearQueue(clearCurrentItem = false, player = this._currentPlayer) {
@ -3642,7 +3642,7 @@ class PlaybackManager {
}
this._playQueueManager.clearPlaylist(clearCurrentItem);
events.trigger(player, 'playlistitemremove');
Events.trigger(player, 'playlistitemremove');
}
trySetActiveDeviceName(name) {
@ -3757,4 +3757,12 @@ class PlaybackManager {
}
}
export default new PlaybackManager();
export const playbackManager = new PlaybackManager();
window.addEventListener('beforeunload', function () {
try {
playbackManager.onAppClose();
} catch (err) {
console.error('error in onAppClose: ' + err);
}
});

View File

@ -1,6 +1,7 @@
import playbackManager from 'playbackManager';
import layoutManager from 'layoutManager';
import events from 'events';
import { playbackManager } from './playbackmanager';
import layoutManager from '../layoutManager';
import { Events } from 'jellyfin-apiclient';
let orientationLocked;
@ -13,7 +14,7 @@ function onOrientationChangeError(err) {
console.error('error locking orientation: ' + err);
}
events.on(playbackManager, 'playbackstart', function (e, player, state) {
Events.on(playbackManager, 'playbackstart', function (e, player, state) {
const isLocalVideo = player.isLocalPlayer && !player.isExternalPlayer && playbackManager.isPlayingVideo(player);
if (isLocalVideo && layoutManager.mobile) {
@ -36,7 +37,7 @@ events.on(playbackManager, 'playbackstart', function (e, player, state) {
}
});
events.on(playbackManager, 'playbackstop', function (e, playbackStopInfo) {
Events.on(playbackManager, 'playbackstop', function (e, playbackStopInfo) {
if (orientationLocked && !playbackStopInfo.nextMediaType) {
/* eslint-disable-next-line compat/compat */
const unlockOrientation = window.screen.unlockOrientation || window.screen.mozUnlockOrientation || window.screen.msUnlockOrientation || (window.screen.orientation && window.screen.orientation.unlock);

View File

@ -1,12 +1,16 @@
import appSettings from 'appSettings';
import events from 'events';
import browser from 'browser';
import loading from 'loading';
import playbackManager from 'playbackManager';
import appRouter from 'appRouter';
import globalize from 'globalize';
import appHost from 'apphost';
import * as autocast from 'autocast';
import appSettings from '../../scripts/settings/appSettings';
import { Events } from 'jellyfin-apiclient';
import browser from '../../scripts/browser';
import loading from '../loading/loading';
import { playbackManager } from '../playback/playbackmanager';
import { appRouter } from '../appRouter';
import globalize from '../../scripts/globalize';
import { appHost } from '../apphost';
import { enable, isEnabled, supported } from '../../scripts/autocast';
import '../../elements/emby-checkbox/emby-checkbox';
import '../../elements/emby-button/emby-button';
import dialog from '../dialog/dialog';
import dialogHelper from '../dialogHelper/dialogHelper';
function mirrorItem(info, player) {
const item = info.item;
@ -108,7 +112,7 @@ export function show(button) {
};
});
import('actionsheet').then(({default: actionsheet}) => {
import('../actionSheet/actionSheet').then((actionsheet) => {
loading.hide();
const menuOptions = {
@ -140,54 +144,45 @@ export function show(button) {
}
function showActivePlayerMenu(playerInfo) {
Promise.all([
import('dialogHelper'),
import('dialog'),
import('emby-checkbox'),
import('emby-button')
]).then(([dialogHelper]) => {
showActivePlayerMenuInternal(dialogHelper, playerInfo);
});
showActivePlayerMenuInternal(playerInfo);
}
function disconnectFromPlayer(currentDeviceName) {
if (playbackManager.getSupportedCommands().indexOf('EndSession') !== -1) {
import('dialog').then(({default: dialog}) => {
const menuItems = [];
const menuItems = [];
menuItems.push({
name: globalize.translate('Yes'),
id: 'yes'
});
menuItems.push({
name: globalize.translate('No'),
id: 'no'
});
menuItems.push({
name: globalize.translate('Yes'),
id: 'yes'
});
menuItems.push({
name: globalize.translate('No'),
id: 'no'
});
dialog({
buttons: menuItems,
text: globalize.translate('ConfirmEndPlayerSession', currentDeviceName)
dialog.show({
buttons: menuItems,
text: globalize.translate('ConfirmEndPlayerSession', currentDeviceName)
}).then(function (id) {
switch (id) {
case 'yes':
playbackManager.getCurrentPlayer().endSession();
playbackManager.setDefaultPlayerActive();
break;
case 'no':
playbackManager.setDefaultPlayerActive();
break;
default:
break;
}
});
}).then(function (id) {
switch (id) {
case 'yes':
playbackManager.getCurrentPlayer().endSession();
playbackManager.setDefaultPlayerActive();
break;
case 'no':
playbackManager.setDefaultPlayerActive();
break;
default:
break;
}
});
} else {
playbackManager.setDefaultPlayerActive();
}
}
function showActivePlayerMenuInternal(dialogHelper, playerInfo) {
function showActivePlayerMenuInternal(playerInfo) {
let html = '';
const dialogOptions = {
@ -222,9 +217,9 @@ function showActivePlayerMenuInternal(dialogHelper, playerInfo) {
html += '</div>';
if (autocast.supported()) {
if (supported()) {
html += '<div><label class="checkboxContainer">';
const checkedHtmlAC = autocast.isEnabled() ? ' checked' : '';
const checkedHtmlAC = isEnabled() ? ' checked' : '';
html += '<input type="checkbox" is="emby-checkbox" class="chkAutoCast"' + checkedHtmlAC + '/>';
html += '<span>' + globalize.translate('EnableAutoCast') + '</span>';
html += '</label></div>';
@ -285,7 +280,7 @@ function onMirrorChange() {
}
function onAutoCastChange() {
autocast.enable(this.checked);
enable(this.checked);
}
document.addEventListener('viewshow', function (e) {
@ -300,21 +295,21 @@ document.addEventListener('viewshow', function (e) {
}
});
events.on(appSettings, 'change', function (e, name) {
Events.on(appSettings, 'change', function (e, name) {
if (name === 'displaymirror') {
mirrorIfEnabled();
}
});
events.on(playbackManager, 'pairing', function (e) {
Events.on(playbackManager, 'pairing', function (e) {
loading.show();
});
events.on(playbackManager, 'paired', function (e) {
Events.on(playbackManager, 'paired', function (e) {
loading.hide();
});
events.on(playbackManager, 'pairerror', function (e) {
Events.on(playbackManager, 'pairerror', function (e) {
loading.hide();
});

View File

@ -1,7 +1,8 @@
import actionsheet from 'actionsheet';
import playbackManager from 'playbackManager';
import globalize from 'globalize';
import qualityoptions from 'qualityoptions';
import actionsheet from '../actionSheet/actionSheet';
import { playbackManager } from '../playback/playbackmanager';
import globalize from '../../scripts/globalize';
import qualityoptions from '../qualityOptions';
import ServerConnections from '../ServerConnections';
function showQualityMenu(player, btn) {
const videoStream = playbackManager.currentMediaSource(player).MediaStreams.filter(function (stream) {
@ -32,18 +33,18 @@ function showQualityMenu(player, btn) {
return opt;
});
let selectedId = options.filter(function (o) {
const selectedId = options.filter(function (o) {
return o.selected;
});
selectedId = selectedId.length ? selectedId[0].bitrate : null;
const selectedBitrate = selectedId.length ? selectedId[0].bitrate : null;
return actionsheet.show({
items: menuItems,
positionTo: btn
}).then(function (id) {
const bitrate = parseInt(id);
if (bitrate !== selectedId) {
if (bitrate !== selectedBitrate) {
playbackManager.setMaxStreamingBitrate({
enableAutomaticBitrateDetection: bitrate ? false : true,
maxBitrate: bitrate
@ -250,7 +251,7 @@ export function show(options) {
return showWithUser(options, player, null);
}
const apiClient = window.connectionManager.getApiClient(currentItem.ServerId);
const apiClient = ServerConnections.getApiClient(currentItem.ServerId);
return apiClient.getCurrentUser().then(function (user) {
return showWithUser(options, player, user);
});

View File

@ -3,7 +3,9 @@ export function getDisplayPlayMethod(session) {
return null;
}
if (session.TranscodingInfo && session.TranscodingInfo.IsVideoDirect) {
if (session.TranscodingInfo && session.TranscodingInfo.IsVideoDirect && session.TranscodingInfo.IsAudioDirect) {
return 'Remux';
} else if (session.TranscodingInfo && session.TranscodingInfo.IsVideoDirect) {
return 'DirectStream';
} else if (session.PlayState.PlayMethod === 'Transcode') {
return 'Transcode';

View File

@ -1,5 +1,5 @@
import events from 'events';
import playbackManager from 'playbackManager';
import { Events } from 'jellyfin-apiclient';
import { playbackManager } from '../playback/playbackmanager';
function transferPlayback(oldPlayer, newPlayer) {
const state = playbackManager.getPlayerState(oldPlayer);
@ -26,7 +26,7 @@ function transferPlayback(oldPlayer, newPlayer) {
});
}
events.on(playbackManager, 'playerchange', (e, newPlayer, newTarget, oldPlayer) => {
Events.on(playbackManager, 'playerchange', (e, newPlayer, newTarget, oldPlayer) => {
if (!oldPlayer || !newPlayer) {
return;
}

View File

@ -1,9 +1,10 @@
import events from 'events';
import playbackManager from 'playbackManager';
import dom from 'dom';
import browser from 'browser';
import 'css!./iconosd';
import 'material-icons';
import { Events } from 'jellyfin-apiclient';
import { playbackManager } from './playbackmanager';
import dom from '../../scripts/dom';
import browser from '../../scripts/browser';
import './iconosd.css';
import 'material-design-icons-iconfont';
let currentPlayer;
let osdElement;
@ -111,8 +112,8 @@ function releaseCurrentPlayer() {
const player = currentPlayer;
if (player) {
events.off(player, 'volumechange', onVolumeChanged);
events.off(player, 'playbackstop', hideOsd);
Events.off(player, 'volumechange', onVolumeChanged);
Events.off(player, 'playbackstop', hideOsd);
currentPlayer = null;
}
}
@ -141,11 +142,11 @@ function bindToPlayer(player) {
}
hideOsd();
events.on(player, 'volumechange', onVolumeChanged);
events.on(player, 'playbackstop', hideOsd);
Events.on(player, 'volumechange', onVolumeChanged);
Events.on(player, 'playbackstop', hideOsd);
}
events.on(playbackManager, 'playerchange', function () {
Events.on(playbackManager, 'playerchange', function () {
bindToPlayer(playbackManager.getCurrentPlayer());
});

View File

@ -1,13 +1,15 @@
import browser from 'browser';
import appSettings from 'appSettings';
import appHost from 'apphost';
import focusManager from 'focusManager';
import qualityoptions from 'qualityoptions';
import globalize from 'globalize';
import loading from 'loading';
import events from 'events';
import 'emby-select';
import 'emby-checkbox';
import browser from '../../scripts/browser';
import appSettings from '../../scripts/settings/appSettings';
import { appHost } from '../apphost';
import focusManager from '../focusManager';
import qualityoptions from '../qualityOptions';
import globalize from '../../scripts/globalize';
import loading from '../loading/loading';
import { Events } from 'jellyfin-apiclient';
import '../../elements/emby-select/emby-select';
import '../../elements/emby-checkbox/emby-checkbox';
import ServerConnections from '../ServerConnections';
import toast from '../toast/toast';
/* eslint-disable indent */
@ -145,6 +147,8 @@ import 'emby-checkbox';
showHideQualityFields(context, user, apiClient);
context.querySelector('#selectAllowedAudioChannels').value = userSettings.allowedAudioChannels();
apiClient.getCultures().then(allCultures => {
populateLanguages(context.querySelector('#selectAudioLanguage'), allCultures);
@ -187,6 +191,7 @@ import 'emby-checkbox';
}
context.querySelector('.chkPlayDefaultAudioTrack').checked = user.Configuration.PlayDefaultAudioTrack || false;
context.querySelector('.chkPreferFmp4HlsContainer').checked = userSettings.preferFmp4HlsContainer();
context.querySelector('.chkEnableCinemaMode').checked = userSettings.enableCinemaMode();
context.querySelector('.chkEnableNextVideoOverlay').checked = userSettings.enableNextVideoInfoOverlay();
context.querySelector('.chkExternalVideoPlayer').checked = appSettings.enableSystemExternalPlayers();
@ -222,10 +227,11 @@ import 'emby-checkbox';
setMaxBitrateFromField(context.querySelector('.selectVideoInternetQuality'), false, 'Video');
setMaxBitrateFromField(context.querySelector('.selectMusicInternetQuality'), false, 'Audio');
userSettingsInstance.allowedAudioChannels(context.querySelector('#selectAllowedAudioChannels').value);
user.Configuration.AudioLanguagePreference = context.querySelector('#selectAudioLanguage').value;
user.Configuration.PlayDefaultAudioTrack = context.querySelector('.chkPlayDefaultAudioTrack').checked;
user.Configuration.EnableNextEpisodeAutoPlay = context.querySelector('.chkEpisodeAutoPlay').checked;
userSettingsInstance.preferFmp4HlsContainer(context.querySelector('.chkPreferFmp4HlsContainer').checked);
userSettingsInstance.enableCinemaMode(context.querySelector('.chkEnableCinemaMode').checked);
userSettingsInstance.enableNextVideoInfoOverlay(context.querySelector('.chkEnableNextVideoOverlay').checked);
@ -243,12 +249,10 @@ import 'emby-checkbox';
saveUser(context, user, userSettings, apiClient).then(() => {
loading.hide();
if (enableSaveConfirmation) {
import('toast').then(({default: toast}) => {
toast(globalize.translate('SettingsSaved'));
});
toast(globalize.translate('SettingsSaved'));
}
events.trigger(instance, 'saved');
Events.trigger(instance, 'saved');
}, () => {
loading.hide();
});
@ -257,7 +261,7 @@ import 'emby-checkbox';
function onSubmit(e) {
const self = this;
const apiClient = window.connectionManager.getApiClient(self.options.serverId);
const apiClient = ServerConnections.getApiClient(self.options.serverId);
const userId = self.options.userId;
const userSettings = self.options.userSettings;
@ -274,7 +278,7 @@ import 'emby-checkbox';
}
function embed(options, self) {
return import('text!./playbackSettings.template.html').then(({default: template}) => {
return import('./playbackSettings.template.html').then(({default: template}) => {
options.element.innerHTML = globalize.translateHtml(template, 'core');
options.element.querySelector('form').addEventListener('submit', onSubmit.bind(self));
@ -304,7 +308,7 @@ import 'emby-checkbox';
loading.show();
const userId = self.options.userId;
const apiClient = window.connectionManager.getApiClient(self.options.serverId);
const apiClient = ServerConnections.getApiClient(self.options.serverId);
const userSettings = self.options.userSettings;
apiClient.getUser(userId).then(user => {

View File

@ -4,6 +4,16 @@
${HeaderAudioSettings}
</h2>
<div class="selectContainer">
<select is="emby-select" id="selectAllowedAudioChannels" label="${LabelAllowedAudioChannels}">
<option value="-1">${Auto}</option>
<option value="1">${LabelSelectMono}</option>
<option value="2">${LabelSelectStereo}</option>
<option value="6">5.1 ${LabelSelectAudioChannels}</option>
<option value="8">7.1 ${LabelSelectAudioChannels}</option>
</select>
</div>
<div class="selectContainer">
<select is="emby-select" id="selectAudioLanguage" label="${LabelAudioLanguagePreference}"></select>
</div>
@ -49,6 +59,14 @@
${TabAdvanced}
</h2>
<div class="checkboxContainer checkboxContainer-withDescription">
<label>
<input type="checkbox" is="emby-checkbox" class="chkPreferFmp4HlsContainer" />
<span>${PreferFmp4HlsContainer}</span>
</label>
<div class="fieldDescription checkboxFieldDescription">${PreferFmp4HlsContainerHelp}</div>
</div>
<div class="checkboxContainer checkboxContainer-withDescription cinemaModeOptions">
<label>
<input type="checkbox" is="emby-checkbox" class="chkEnableCinemaMode" />

View File

@ -1,11 +1,12 @@
import events from 'events';
import globalize from 'globalize';
import playbackManager from 'playbackManager';
import syncPlayManager from 'syncPlayManager';
import playMethodHelper from 'playMethodHelper';
import layoutManager from 'layoutManager';
import 'paper-icon-button-light';
import 'css!./playerstats';
import { Events } from 'jellyfin-apiclient';
import '../../elements/emby-button/paper-icon-button-light';
import globalize from '../../scripts/globalize';
import layoutManager from '../layoutManager';
import { playbackManager } from '../playback/playbackmanager';
import playMethodHelper from '../playback/playmethodhelper';
import syncPlayManager from '../syncPlay/syncPlayManager';
import './playerstats.css';
import ServerConnections from '../ServerConnections';
/* eslint-disable indent */
@ -94,7 +95,7 @@ import 'css!./playerstats';
return Promise.resolve(instance.lastSession);
}
const apiClient = window.connectionManager.getApiClient(playbackManager.currentItem(player).ServerId);
const apiClient = ServerConnections.getApiClient(playbackManager.currentItem(player).ServerId);
return apiClient.getSessions({
deviceId: apiClient.deviceId()
@ -413,7 +414,7 @@ import 'css!./playerstats';
name: 'Original Media Info'
});
const apiClient = window.connectionManager.getApiClient(playbackManager.currentItem(player).ServerId);
const apiClient = ServerConnections.getApiClient(playbackManager.currentItem(player).ServerId);
if (syncPlayManager.isSyncPlayEnabled() && apiClient.isMinServerVersion('10.6.0')) {
categories.push({
stats: getSyncPlayStats(),
@ -450,14 +451,14 @@ import 'css!./playerstats';
};
instance.onTimeUpdate = localOnTimeUpdate;
events.on(player, 'timeupdate', localOnTimeUpdate);
Events.on(player, 'timeupdate', localOnTimeUpdate);
}
function unbindEvents(instance, player) {
const localOnTimeUpdate = instance.onTimeUpdate;
if (localOnTimeUpdate) {
events.off(player, 'timeupdate', localOnTimeUpdate);
Events.off(player, 'timeupdate', localOnTimeUpdate);
}
}

View File

@ -1,17 +1,18 @@
import dom from 'dom';
import dialogHelper from 'dialogHelper';
import loading from 'loading';
import layoutManager from 'layoutManager';
import playbackManager from 'playbackManager';
import * as userSettings from 'userSettings';
import appRouter from 'appRouter';
import globalize from 'globalize';
import 'emby-input';
import 'paper-icon-button-light';
import 'emby-select';
import 'material-icons';
import 'css!./../formdialog';
import 'emby-button';
import dom from '../../scripts/dom';
import dialogHelper from '../dialogHelper/dialogHelper';
import loading from '../loading/loading';
import layoutManager from '../layoutManager';
import { playbackManager } from '../playback/playbackmanager';
import * as userSettings from '../../scripts/settings/userSettings';
import { appRouter } from '../appRouter';
import globalize from '../../scripts/globalize';
import '../../elements/emby-button/emby-button';
import '../../elements/emby-input/emby-input';
import '../../elements/emby-button/paper-icon-button-light';
import '../../elements/emby-select/emby-select';
import 'material-design-icons-iconfont';
import '../formdialog.css';
import ServerConnections from '../ServerConnections';
/* eslint-disable indent */
@ -21,7 +22,7 @@ import 'emby-button';
const panel = dom.parentWithClass(this, 'dialog');
const playlistId = panel.querySelector('#selectPlaylistToAddTo').value;
const apiClient = window.connectionManager.getApiClient(currentServerId);
const apiClient = ServerConnections.getApiClient(currentServerId);
if (playlistId) {
userSettings.set('playlisteditor-lastplaylistid', playlistId);
@ -112,7 +113,7 @@ import 'emby-button';
EnableTotalRecordCount: false
};
const apiClient = window.connectionManager.getApiClient(currentServerId);
const apiClient = ServerConnections.getApiClient(currentServerId);
apiClient.getItems(apiClient.getCurrentUserId(), options).then(result => {
let html = '';
@ -209,7 +210,7 @@ import 'emby-button';
}
function centerFocus(elem, horiz, on) {
import('scrollHelper').then((scrollHelper) => {
import('../../scripts/scrollHelper').then((scrollHelper) => {
const fn = on ? 'on' : 'off';
scrollHelper.centerFocus[fn](elem, horiz);
});

View File

@ -1,7 +1,7 @@
import actionsheet from 'actionsheet';
import datetime from 'datetime';
import playbackManager from 'playbackManager';
import globalize from 'globalize';
import actionsheet from './actionSheet/actionSheet';
import datetime from '../scripts/datetime';
import { playbackManager } from './playback/playbackmanager';
import globalize from '../scripts/globalize';
export function show(options) {
const item = options.item;

View File

@ -1,5 +1,9 @@
import events from 'events';
import globalize from 'globalize';
import { Events } from 'jellyfin-apiclient';
import globalize from '../scripts/globalize';
import loading from './loading/loading';
import appSettings from '../scripts/settings/appSettings';
import { playbackManager } from './playback/playbackmanager';
/* eslint-disable indent */
// TODO: replace with each plugin version
@ -27,7 +31,7 @@ import globalize from 'globalize';
Emby.App.defineRoute(route, plugin.id);
}
#registerPlugin(plugin) {
async #registerPlugin(plugin) {
this.#register(plugin);
if (plugin.getRoutes) {
@ -38,63 +42,62 @@ import globalize from 'globalize';
if (plugin.type === 'skin') {
// translations won't be loaded for skins until needed
return Promise.resolve(plugin);
return plugin;
} else {
return new Promise((resolve, reject) => {
this.#loadStrings(plugin)
.then(function () {
resolve(plugin);
})
.catch(reject);
});
return await this.#loadStrings(plugin);
}
}
loadPlugin(pluginSpec) {
async #preparePlugin(pluginSpec, plugin) {
if (typeof pluginSpec === 'string') {
console.debug('Loading plugin (via deprecated requirejs method): ' + pluginSpec);
// See if it's already installed
const existing = this.plugins.filter(function (p) {
return p.id === plugin.id;
})[0];
return new Promise((resolve, reject) => {
require([pluginSpec], (pluginFactory) => {
const plugin = pluginFactory.default ? new pluginFactory.default() : new pluginFactory();
if (existing) {
return pluginSpec;
}
// See if it's already installed
const existing = this.pluginsList.filter(function (p) {
return p.id === plugin.id;
})[0];
plugin.installUrl = pluginSpec;
if (existing) {
resolve(pluginSpec);
}
plugin.installUrl = pluginSpec;
const separatorIndex = Math.max(pluginSpec.lastIndexOf('/'), pluginSpec.lastIndexOf('\\'));
plugin.baseUrl = pluginSpec.substring(0, separatorIndex);
const paths = {};
paths[plugin.id] = plugin.baseUrl;
requirejs.config({
waitSeconds: 0,
paths: paths
});
this.#registerPlugin(plugin).then(resolve).catch(reject);
});
});
} else if (pluginSpec.then) {
return pluginSpec.then(pluginBuilder => {
return pluginBuilder();
}).then((plugin) => {
console.debug(`Plugin loaded: ${plugin.id}`);
return this.#registerPlugin(plugin);
});
} else {
const err = new TypeError('Plugins have to be a Promise that resolves to a plugin builder function or a RequireJS url (deprecated)');
console.error(err);
return Promise.reject(err);
const separatorIndex = Math.max(pluginSpec.lastIndexOf('/'), pluginSpec.lastIndexOf('\\'));
plugin.baseUrl = pluginSpec.substring(0, separatorIndex);
}
return this.#registerPlugin(plugin);
}
async loadPlugin(pluginSpec) {
let plugin;
if (typeof pluginSpec === 'string') {
if (pluginSpec in window) {
console.log(`Loading plugin (via window): ${pluginSpec}`);
// init plugin and pass basic dependencies
plugin = new window[pluginSpec]({
events: Events,
loading,
appSettings,
playbackManager
});
} else {
console.debug(`Loading plugin (via dynamic import): ${pluginSpec}`);
plugin = await import(/* webpackChunkName: "[request]" */ `../plugins/${pluginSpec}`);
}
} else if (pluginSpec.then) {
console.debug('Loading plugin (via promise/async function)');
const pluginResult = await pluginSpec;
plugin = new pluginResult.default;
} else {
const err = new TypeError('Plugins have to be a Promise that resolves to a plugin builder function');
console.error(err);
throw err;
}
return this.#preparePlugin(pluginSpec, plugin);
}
// In lieu of automatic discovery, plugins will register dynamic objects
@ -103,7 +106,7 @@ import globalize from 'globalize';
// type (skin, screensaver, etc)
#register(obj) {
this.pluginsList.push(obj);
events.trigger(this, 'registered', [obj]);
Events.trigger(this, 'registered', [obj]);
}
ofType(type) {
@ -148,4 +151,4 @@ import globalize from 'globalize';
/* eslint-enable indent */
export default new PluginManager();
export const pluginManager = new PluginManager();

View File

@ -1,14 +1,14 @@
import browser from 'browser';
import dialogHelper from 'dialogHelper';
import layoutManager from 'layoutManager';
import scrollHelper from 'scrollHelper';
import globalize from 'globalize';
import dom from 'dom';
import 'material-icons';
import 'emby-button';
import 'paper-icon-button-light';
import 'emby-input';
import 'formDialogStyle';
import browser from '../../scripts/browser';
import dialogHelper from '../dialogHelper/dialogHelper';
import layoutManager from '../layoutManager';
import scrollHelper from '../../scripts/scrollHelper';
import globalize from '../../scripts/globalize';
import dom from '../../scripts/dom';
import 'material-design-icons-iconfont';
import '../../elements/emby-button/emby-button';
import '../../elements/emby-button/paper-icon-button-light';
import '../../elements/emby-input/emby-input';
import '../formdialog.css';
/* eslint-disable indent */
export default (() => {
@ -117,7 +117,7 @@ export default (() => {
} else {
return options => {
return new Promise((resolve, reject) => {
import('text!./prompt.template.html').then(({default: template}) => {
import('./prompt.template.html').then(({default: template}) => {
if (typeof options === 'string') {
options = {
title: '',

View File

@ -1,4 +1,4 @@
import globalize from 'globalize';
import globalize from '../scripts/globalize';
export function getVideoQualityOptions(options) {
const maxStreamingBitrate = options.currentMaxBitrate;

View File

@ -1,5 +1,6 @@
import globalize from 'globalize';
import toast from 'toast';
import globalize from '../../scripts/globalize';
import toast from '../toast/toast';
import Dashboard from '../../scripts/clientUtils';
export class QuickConnectSettings {
constructor() { }

View File

@ -1,8 +1,9 @@
import dom from 'dom';
import recordingHelper from 'recordingHelper';
import 'paper-icon-button-light';
import 'emby-button';
import 'css!./recordingfields';
import dom from '../../scripts/dom';
import recordingHelper from './recordinghelper';
import '../../elements/emby-button/paper-icon-button-light';
import '../../elements/emby-button/emby-button';
import './recordingfields.css';
import ServerConnections from '../ServerConnections';
function onRecordingButtonClick(e) {
const item = this.item;
@ -52,7 +53,7 @@ class RecordingButton {
}
refresh(serverId, itemId) {
const apiClient = window.connectionManager.getApiClient(serverId);
const apiClient = ServerConnections.getApiClient(serverId);
const self = this;
apiClient.getItem(apiClient.getCurrentUserId(), itemId).then(function (item) {
self.refreshItem(item);

View File

@ -1,22 +1,23 @@
import dialogHelper from 'dialogHelper';
import globalize from 'globalize';
import layoutManager from 'layoutManager';
import mediaInfo from 'mediaInfo';
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';
import dialogHelper from '../dialogHelper/dialogHelper';
import globalize from '../../scripts/globalize';
import layoutManager from '../layoutManager';
import mediaInfo from '../mediainfo/mediainfo';
import loading from '../loading/loading';
import scrollHelper from '../../scripts/scrollHelper';
import datetime from '../../scripts/datetime';
import imageLoader from '../images/imageLoader';
import recordingFields from './recordingfields';
import { Events } from 'jellyfin-apiclient';
import '../../elements/emby-button/emby-button';
import '../../elements/emby-button/paper-icon-button-light';
import '../../elements/emby-checkbox/emby-checkbox';
import '../../elements/emby-collapse/emby-collapse';
import '../../elements/emby-input/emby-input';
import '../formdialog.css';
import './recordingcreator.css';
import 'material-design-icons-iconfont';
import ServerConnections from '../ServerConnections';
import { playbackManager } from '../playback/playbackmanager';
let currentDialog;
let closeAction;
@ -68,7 +69,7 @@ function renderRecording(context, defaultTimer, program, apiClient, refreshRecor
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.innerHTML = '<img src="./empty.png" data-src="' + imgUrl + '" class="recordingDialog-img lazy" />';
imageContainer.classList.remove('hide');
imageLoader.lazyChildren(imageContainer);
@ -102,7 +103,7 @@ function renderRecording(context, defaultTimer, program, apiClient, refreshRecor
function reload(context, programId, serverId, refreshRecordingStateOnly) {
loading.show();
const apiClient = window.connectionManager.getApiClient(serverId);
const apiClient = ServerConnections.getApiClient(serverId);
const promise1 = apiClient.getNewLiveTvTimerDefaults({ programId: programId });
const promise2 = apiClient.getLiveTvProgram(programId, apiClient.getCurrentUserId());
@ -117,14 +118,12 @@ function reload(context, programId, serverId, refreshRecordingStateOnly) {
function executeCloseAction(action, programId, serverId) {
if (action === 'play') {
import('playbackManager').then(({ default: playbackManager }) => {
const apiClient = window.connectionManager.getApiClient(serverId);
const apiClient = ServerConnections.getApiClient(serverId);
apiClient.getLiveTvProgram(programId, apiClient.getCurrentUserId()).then(function (item) {
playbackManager.play({
ids: [item.ChannelId],
serverId: serverId
});
apiClient.getLiveTvProgram(programId, apiClient.getCurrentUserId()).then(function (item) {
playbackManager.play({
ids: [item.ChannelId],
serverId: serverId
});
});
return;
@ -137,7 +136,7 @@ function showEditor(itemId, serverId) {
loading.show();
import('text!./recordingcreator.template.html').then(({ default: template }) => {
import('./recordingcreator.template.html').then(({ default: template }) => {
const dialogOptions = {
removeOnClose: true,
scrollY: false
@ -167,7 +166,7 @@ function showEditor(itemId, serverId) {
}
dlg.addEventListener('close', function () {
events.off(currentRecordingFields, 'recordingchanged', onRecordingChanged);
Events.off(currentRecordingFields, 'recordingchanged', onRecordingChanged);
executeCloseAction(closeAction, itemId, serverId);
if (currentRecordingFields && currentRecordingFields.hasChanged()) {
@ -191,7 +190,7 @@ function showEditor(itemId, serverId) {
serverId: serverId
});
events.on(currentRecordingFields, 'recordingchanged', onRecordingChanged);
Events.on(currentRecordingFields, 'recordingchanged', onRecordingChanged);
dialogHelper.open(dlg);
});

View File

@ -1,17 +1,19 @@
import dialogHelper from 'dialogHelper';
import globalize from 'globalize';
import layoutManager from 'layoutManager';
import loading from 'loading';
import scrollHelper from 'scrollHelper';
import 'scrollStyles';
import 'emby-button';
import 'emby-collapse';
import 'emby-input';
import 'paper-icon-button-light';
import 'css!./../formdialog';
import 'css!./recordingcreator';
import 'material-icons';
import 'flexStyles';
import dialogHelper from '../dialogHelper/dialogHelper';
import globalize from '../../scripts/globalize';
import layoutManager from '../layoutManager';
import loading from '../loading/loading';
import scrollHelper from '../../scripts/scrollHelper';
import '../../assets/css/scrollstyles.css';
import '../../elements/emby-button/emby-button';
import '../../elements/emby-collapse/emby-collapse';
import '../../elements/emby-input/emby-input';
import '../../elements/emby-button/paper-icon-button-light';
import '../formdialog.css';
import './recordingcreator.css';
import 'material-design-icons-iconfont';
import '../../assets/css/flexstyles.scss';
import ServerConnections from '../ServerConnections';
let currentDialog;
let recordingDeleted = false;
@ -20,7 +22,7 @@ let currentServerId;
let currentResolve;
function deleteTimer(apiClient, timerId) {
return import('recordingHelper').then(({ default: recordingHelper }) => {
return import('./recordinghelper').then(({ default: recordingHelper }) => {
recordingHelper.cancelTimerWithConfirmation(timerId, apiClient.serverId());
});
}
@ -40,7 +42,7 @@ function closeDialog(isDeleted) {
function onSubmit(e) {
const form = this;
const apiClient = window.connectionManager.getApiClient(currentServerId);
const apiClient = ServerConnections.getApiClient(currentServerId);
apiClient.getLiveTvTimer(currentItemId).then(function (item) {
item.PrePaddingSeconds = form.querySelector('#txtPrePaddingMinutes').value * 60;
@ -60,7 +62,7 @@ function init(context) {
});
context.querySelector('.btnCancelRecording').addEventListener('click', function () {
const apiClient = window.connectionManager.getApiClient(currentServerId);
const apiClient = ServerConnections.getApiClient(currentServerId);
deleteTimer(apiClient, currentItemId).then(function () {
closeDialog(true);
@ -74,7 +76,7 @@ function reload(context, id) {
loading.show();
currentItemId = id;
const apiClient = window.connectionManager.getApiClient(currentServerId);
const apiClient = ServerConnections.getApiClient(currentServerId);
apiClient.getLiveTvTimer(id).then(function (result) {
renderTimer(context, result, apiClient);
loading.hide();
@ -89,7 +91,7 @@ function showEditor(itemId, serverId, options) {
options = options || {};
currentResolve = resolve;
import('text!./recordingeditor.template.html').then(({default: template}) => {
import('./recordingeditor.template.html').then(({default: template}) => {
const dialogOptions = {
removeOnClose: true,
scrollY: false

View File

@ -1,13 +1,15 @@
import globalize from 'globalize';
import serverNotifications from 'serverNotifications';
import loading from 'loading';
import dom from 'dom';
import recordingHelper from 'recordingHelper';
import events from 'events';
import 'paper-icon-button-light';
import 'emby-button';
import 'css!./recordingfields';
import 'flexStyles';
import globalize from '../../scripts/globalize';
import { Events } from 'jellyfin-apiclient';
import serverNotifications from '../../scripts/serverNotifications';
import loading from '../loading/loading';
import dom from '../../scripts/dom';
import recordingHelper from './recordinghelper';
import '../../elements/emby-button/emby-button';
import '../../elements/emby-button/paper-icon-button-light';
import './recordingfields.css';
import '../../assets/css/flexstyles.scss';
import ServerConnections from '../ServerConnections';
import toast from '../toast/toast';
/*eslint prefer-const: "error"*/
@ -45,7 +47,7 @@ function loadData(parent, program, apiClient) {
function fetchData(instance) {
const options = instance.options;
const apiClient = window.connectionManager.getApiClient(options.serverId);
const apiClient = ServerConnections.getApiClient(options.serverId);
options.parent.querySelector('.recordingFields').classList.remove('hide');
return apiClient.getLiveTvProgram(options.programId, apiClient.getCurrentUserId()).then(function (program) {
@ -104,20 +106,20 @@ class RecordingEditor {
const timerChangedHandler = onTimerChangedExternally.bind(this);
this.timerChangedHandler = timerChangedHandler;
events.on(serverNotifications, 'TimerCreated', timerChangedHandler);
events.on(serverNotifications, 'TimerCancelled', timerChangedHandler);
Events.on(serverNotifications, 'TimerCreated', timerChangedHandler);
Events.on(serverNotifications, 'TimerCancelled', timerChangedHandler);
const seriesTimerChangedHandler = onSeriesTimerChangedExternally.bind(this);
this.seriesTimerChangedHandler = seriesTimerChangedHandler;
events.on(serverNotifications, 'SeriesTimerCreated', seriesTimerChangedHandler);
events.on(serverNotifications, 'SeriesTimerCancelled', seriesTimerChangedHandler);
Events.on(serverNotifications, 'SeriesTimerCreated', seriesTimerChangedHandler);
Events.on(serverNotifications, 'SeriesTimerCancelled', seriesTimerChangedHandler);
}
embed() {
const self = this;
return new Promise(function (resolve, reject) {
import('text!./recordingfields.template.html').then(({default: template}) => {
import('./recordingfields.template.html').then(({default: template}) => {
const options = self.options;
const context = options.parent;
context.innerHTML = globalize.translateHtml(template, 'core');
@ -144,14 +146,14 @@ class RecordingEditor {
const timerChangedHandler = this.timerChangedHandler;
this.timerChangedHandler = null;
events.off(serverNotifications, 'TimerCreated', timerChangedHandler);
events.off(serverNotifications, 'TimerCancelled', timerChangedHandler);
Events.off(serverNotifications, 'TimerCreated', timerChangedHandler);
Events.off(serverNotifications, 'TimerCancelled', timerChangedHandler);
const seriesTimerChangedHandler = this.seriesTimerChangedHandler;
this.seriesTimerChangedHandler = null;
events.off(serverNotifications, 'SeriesTimerCreated', seriesTimerChangedHandler);
events.off(serverNotifications, 'SeriesTimerCancelled', seriesTimerChangedHandler);
Events.off(serverNotifications, 'SeriesTimerCreated', seriesTimerChangedHandler);
Events.off(serverNotifications, 'SeriesTimerCancelled', seriesTimerChangedHandler);
}
}
@ -162,7 +164,7 @@ function onManageRecordingClick(e) {
}
const self = this;
import('recordingEditor').then(({default: recordingEditor}) => {
import('./recordingeditor').then(({default: recordingEditor}) => {
recordingEditor.show(self.TimerId, options.serverId, {
enableCancel: false
}).then(function () {
@ -180,7 +182,7 @@ function onManageSeriesRecordingClick(e) {
const self = this;
import('seriesRecordingEditor').then(({default: seriesRecordingEditor}) => {
import('./seriesrecordingeditor').then(({default: seriesRecordingEditor}) => {
seriesRecordingEditor.show(self.SeriesTimerId, options.serverId, {
enableCancel: false
@ -196,7 +198,7 @@ function onRecordChange(e) {
const self = this;
const options = this.options;
const apiClient = window.connectionManager.getApiClient(options.serverId);
const apiClient = ServerConnections.getApiClient(options.serverId);
const button = dom.parentWithTag(e.target, 'BUTTON');
const isChecked = !button.querySelector('.material-icons').classList.contains('recordingIcon-active');
@ -207,7 +209,7 @@ function onRecordChange(e) {
if (!hasEnabledTimer) {
loading.show();
recordingHelper.createRecording(apiClient, options.programId, false).then(function () {
events.trigger(self, 'recordingchanged');
Events.trigger(self, 'recordingchanged');
fetchData(self);
loading.hide();
});
@ -216,7 +218,7 @@ function onRecordChange(e) {
if (hasEnabledTimer) {
loading.show();
recordingHelper.cancelTimer(apiClient, this.TimerId, true).then(function () {
events.trigger(self, 'recordingchanged');
Events.trigger(self, 'recordingchanged');
fetchData(self);
loading.hide();
});
@ -225,9 +227,7 @@ function onRecordChange(e) {
}
function sendToast(msg) {
import('toast').then(({default: toast}) => {
toast(msg);
});
toast(msg);
}
function onRecordSeriesChange(e) {
@ -235,7 +235,7 @@ function onRecordSeriesChange(e) {
const self = this;
const options = this.options;
const apiClient = window.connectionManager.getApiClient(options.serverId);
const apiClient = ServerConnections.getApiClient(options.serverId);
const button = dom.parentWithTag(e.target, 'BUTTON');
const isChecked = !button.querySelector('.material-icons').classList.contains('recordingIcon-active');

View File

@ -1,5 +1,9 @@
import globalize from 'globalize';
import loading from 'loading';
import globalize from '../../scripts/globalize';
import loading from '../loading/loading';
import ServerConnections from '../ServerConnections';
import toast from '../toast/toast';
import confirm from '../confirm/confirm';
import dialog from '../dialog/dialog';
/*eslint prefer-const: "error"*/
@ -28,48 +32,42 @@ function changeRecordingToSeries(apiClient, timerId, programId, confirmTimerCanc
function cancelTimerWithConfirmation(timerId, serverId) {
return new Promise(function (resolve, reject) {
import('confirm').then(({ default: confirm }) => {
confirm.default({
confirm({
text: globalize.translate('MessageConfirmRecordingCancellation'),
primary: 'delete',
confirmText: globalize.translate('HeaderCancelRecording'),
cancelText: globalize.translate('HeaderKeepRecording')
text: globalize.translate('MessageConfirmRecordingCancellation'),
primary: 'delete',
confirmText: globalize.translate('HeaderCancelRecording'),
cancelText: globalize.translate('HeaderKeepRecording')
}).then(function () {
loading.show();
}).then(function () {
loading.show();
const apiClient = window.connectionManager.getApiClient(serverId);
cancelTimer(apiClient, timerId, true).then(resolve, reject);
}, reject);
});
const apiClient = ServerConnections.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({
confirm({
text: globalize.translate('MessageConfirmRecordingCancellation'),
primary: 'delete',
confirmText: globalize.translate('HeaderCancelSeries'),
cancelText: globalize.translate('HeaderKeepSeries')
text: globalize.translate('MessageConfirmRecordingCancellation'),
primary: 'delete',
confirmText: globalize.translate('HeaderCancelSeries'),
cancelText: globalize.translate('HeaderKeepSeries')
}).then(function () {
loading.show();
}).then(function () {
loading.show();
const apiClient = window.connectionManager.getApiClient(serverId);
apiClient.cancelLiveTvSeriesTimer(timerId).then(function () {
import('toast').then(({default: toast}) => {
toast(globalize.translate('SeriesCancelled'));
});
const apiClient = ServerConnections.getApiClient(serverId);
apiClient.cancelLiveTvSeriesTimer(timerId).then(function () {
toast(globalize.translate('SeriesCancelled'));
loading.hide();
resolve();
}, reject);
loading.hide();
resolve();
}, reject);
});
}, reject);
});
}
@ -98,75 +96,66 @@ function createRecording(apiClient, programId, isSeries) {
}
function sendToast(msg) {
import('toast').then(({ default: toast }) => {
toast(msg);
});
toast(msg);
}
function showMultiCancellationPrompt(serverId, programId, timerId, timerStatus, seriesTimerId) {
return new Promise(function (resolve, reject) {
import('dialog').then(({ default: dialog }) => {
const items = [];
const items = [];
items.push({
name: globalize.translate('HeaderKeepRecording'),
id: 'cancel',
type: 'submit'
});
if (timerStatus === 'InProgress') {
items.push({
name: globalize.translate('HeaderKeepRecording'),
id: 'cancel',
type: 'submit'
});
if (timerStatus === 'InProgress') {
items.push({
name: globalize.translate('HeaderStopRecording'),
id: 'canceltimer',
type: 'cancel'
});
} else {
items.push({
name: globalize.translate('HeaderCancelRecording'),
id: 'canceltimer',
type: 'cancel'
});
}
items.push({
name: globalize.translate('HeaderCancelSeries'),
id: 'cancelseriestimer',
name: globalize.translate('HeaderStopRecording'),
id: 'canceltimer',
type: 'cancel'
});
} else {
items.push({
name: globalize.translate('HeaderCancelRecording'),
id: 'canceltimer',
type: 'cancel'
});
}
dialog({
text: globalize.translate('MessageConfirmRecordingCancellation'),
buttons: items
}).then(function (result) {
const apiClient = window.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 () {
import('toast').then(({ default: toast }) => {
toast(globalize.translate('SeriesCancelled'));
});
loading.hide();
resolve();
}, reject);
} else {
resolve();
}
}, reject);
items.push({
name: globalize.translate('HeaderCancelSeries'),
id: 'cancelseriestimer',
type: 'cancel'
});
dialog.show({
text: globalize.translate('MessageConfirmRecordingCancellation'),
buttons: items
}).then(function (result) {
const apiClient = ServerConnections.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 () {
toast(globalize.translate('SeriesCancelled'));
loading.hide();
resolve();
}, reject);
} else {
resolve();
}
}, reject);
});
}
function toggleRecording(serverId, programId, timerId, timerStatus, seriesTimerId) {
const apiClient = window.connectionManager.getApiClient(serverId);
const apiClient = ServerConnections.getApiClient(serverId);
const hasTimer = timerId && timerStatus !== 'Cancelled';
if (seriesTimerId && hasTimer) {
// cancel

View File

@ -1,19 +1,20 @@
import dialogHelper from 'dialogHelper';
import globalize from 'globalize';
import layoutManager from 'layoutManager';
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';
import dialogHelper from '../dialogHelper/dialogHelper';
import globalize from '../../scripts/globalize';
import layoutManager from '../layoutManager';
import loading from '../loading/loading';
import scrollHelper from '../../scripts/scrollHelper';
import datetime from '../../scripts/datetime';
import '../../assets/css/scrollstyles.css';
import '../../elements/emby-button/emby-button';
import '../../elements/emby-checkbox/emby-checkbox';
import '../../elements/emby-input/emby-input';
import '../../elements/emby-select/emby-select';
import '../../elements/emby-button/paper-icon-button-light';
import '../formdialog.css';
import './recordingcreator.css';
import 'material-design-icons-iconfont';
import '../../assets/css/flexstyles.scss';
import ServerConnections from '../ServerConnections';
/*eslint prefer-const: "error"*/
@ -25,7 +26,7 @@ let currentServerId;
function deleteTimer(apiClient, timerId) {
return new Promise(function (resolve, reject) {
import('recordingHelper').then(({ default: recordingHelper }) => {
import('./recordinghelper').then(({ default: recordingHelper }) => {
recordingHelper.cancelSeriesTimerWithConfirmation(timerId, apiClient.serverId()).then(resolve, reject);
});
});
@ -63,7 +64,7 @@ function closeDialog(isDeleted) {
function onSubmit(e) {
const form = this;
const apiClient = window.connectionManager.getApiClient(currentServerId);
const apiClient = ServerConnections.getApiClient(currentServerId);
apiClient.getLiveTvSeriesTimer(currentItemId).then(function (item) {
item.PrePaddingSeconds = form.querySelector('#txtPrePaddingMinutes').value * 60;
@ -91,7 +92,7 @@ function init(context) {
});
context.querySelector('.btnCancelRecording').addEventListener('click', function () {
const apiClient = window.connectionManager.getApiClient(currentServerId);
const apiClient = ServerConnections.getApiClient(currentServerId);
deleteTimer(apiClient, currentItemId).then(function () {
closeDialog(true);
});
@ -101,7 +102,7 @@ function init(context) {
}
function reload(context, id) {
const apiClient = window.connectionManager.getApiClient(currentServerId);
const apiClient = ServerConnections.getApiClient(currentServerId);
loading.show();
if (typeof id === 'string') {
@ -150,7 +151,7 @@ function embed(itemId, serverId, options) {
loading.show();
options = options || {};
import('text!./seriesrecordingeditor.template.html').then(({ default: template }) => {
import('./seriesrecordingeditor.template.html').then(({ default: template }) => {
const dialogOptions = {
removeOnClose: true,
scrollY: false
@ -192,7 +193,7 @@ function showEditor(itemId, serverId, options) {
loading.show();
options = options || {};
import('text!./seriesrecordingeditor.template.html').then(({ default: template }) => {
import('./seriesrecordingeditor.template.html').then(({ default: template }) => {
const dialogOptions = {
removeOnClose: true,
scrollY: false

View File

@ -1,15 +1,17 @@
import dom from 'dom';
import dialogHelper from 'dialogHelper';
import loading from 'loading';
import layoutManager from 'layoutManager';
import globalize from 'globalize';
import 'emby-input';
import 'emby-checkbox';
import 'paper-icon-button-light';
import 'emby-select';
import 'material-icons';
import 'css!./../formdialog';
import 'emby-button';
import dom from '../../scripts/dom';
import dialogHelper from '../dialogHelper/dialogHelper';
import loading from '../loading/loading';
import layoutManager from '../layoutManager';
import globalize from '../../scripts/globalize';
import '../../elements/emby-input/emby-input';
import '../../elements/emby-button/emby-button';
import '../../elements/emby-button/paper-icon-button-light';
import '../../elements/emby-checkbox/emby-checkbox';
import '../../elements/emby-select/emby-select';
import 'material-design-icons-iconfont';
import '../formdialog.css';
import ServerConnections from '../ServerConnections';
import toast from '../toast/toast';
/*eslint prefer-const: "error"*/
@ -52,7 +54,7 @@ function getEditorHtml() {
}
function centerFocus(elem, horiz, on) {
import('scrollHelper').then(({default: scrollHelper}) => {
import('../../scripts/scrollHelper').then((scrollHelper) => {
const fn = on ? 'on' : 'off';
scrollHelper.centerFocus[fn](elem, horiz);
});
@ -65,7 +67,7 @@ function onSubmit(e) {
const dlg = dom.parentWithClass(e.target, 'dialog');
const options = instance.options;
const apiClient = window.connectionManager.getApiClient(options.serverId);
const apiClient = ServerConnections.getApiClient(options.serverId);
const replaceAllMetadata = dlg.querySelector('#selectMetadataRefreshMode').value === 'all';
@ -85,9 +87,7 @@ function onSubmit(e) {
dialogHelper.close(dlg);
import('toast').then(({default: toast}) => {
toast(globalize.translate('RefreshQueued'));
});
toast(globalize.translate('RefreshQueued'));
loading.hide();

View File

@ -1,20 +1,23 @@
import datetime from 'datetime';
import backdrop from 'backdrop';
import listView from 'listView';
import imageLoader from 'imageLoader';
import playbackManager from 'playbackManager';
import nowPlayingHelper from 'nowPlayingHelper';
import events from 'events';
import appHost from 'apphost';
import globalize from 'globalize';
import layoutManager from 'layoutManager';
import * as userSettings from 'userSettings';
import cardBuilder from 'cardBuilder';
import itemContextMenu from 'itemContextMenu';
import 'cardStyle';
import 'emby-itemscontainer';
import 'css!./remotecontrol.css';
import 'emby-ratingbutton';
import datetime from '../../scripts/datetime';
import backdrop from '../backdrop/backdrop';
import listView from '../listview/listview';
import imageLoader from '../images/imageLoader';
import { playbackManager } from '../playback/playbackmanager';
import nowPlayingHelper from '../playback/nowplayinghelper';
import { Events } from 'jellyfin-apiclient';
import { appHost } from '../apphost';
import globalize from '../../scripts/globalize';
import layoutManager from '../layoutManager';
import * as userSettings from '../../scripts/settings/userSettings';
import cardBuilder from '../cardbuilder/cardBuilder';
import itemContextMenu from '../itemContextMenu';
import '../cardbuilder/card.css';
import '../../elements/emby-itemscontainer/emby-itemscontainer';
import './remotecontrol.css';
import '../../elements/emby-ratingbutton/emby-ratingbutton';
import ServerConnections from '../ServerConnections';
import toast from '../toast/toast';
import { appRouter } from '../appRouter';
/*eslint prefer-const: "error"*/
@ -37,7 +40,7 @@ function showAudioMenu(context, player, button, item) {
return menuItem;
});
import('actionsheet').then(({ default: actionsheet }) => {
import('../actionSheet/actionSheet').then((actionsheet) => {
actionsheet.show({
items: menuItems,
positionTo: button,
@ -69,7 +72,7 @@ function showSubtitleMenu(context, player, button, item) {
selected: currentIndex == null
});
import('actionsheet').then(({ default: actionsheet }) => {
import('../actionSheet/actionSheet').then((actionsheet) => {
actionsheet.show({
items: menuItems,
positionTo: button,
@ -95,18 +98,18 @@ function seriesImageUrl(item, options) {
options.type = options.type || 'Primary';
if (options.type === 'Primary' && item.SeriesPrimaryImageTag) {
options.tag = item.SeriesPrimaryImageTag;
return window.connectionManager.getApiClient(item.ServerId).getScaledImageUrl(item.SeriesId, options);
return ServerConnections.getApiClient(item.ServerId).getScaledImageUrl(item.SeriesId, options);
}
if (options.type === 'Thumb') {
if (item.SeriesThumbImageTag) {
options.tag = item.SeriesThumbImageTag;
return window.connectionManager.getApiClient(item.ServerId).getScaledImageUrl(item.SeriesId, options);
return ServerConnections.getApiClient(item.ServerId).getScaledImageUrl(item.SeriesId, options);
}
if (item.ParentThumbImageTag) {
options.tag = item.ParentThumbImageTag;
return window.connectionManager.getApiClient(item.ServerId).getScaledImageUrl(item.ParentThumbItemId, options);
return ServerConnections.getApiClient(item.ServerId).getScaledImageUrl(item.ParentThumbItemId, options);
}
}
@ -119,12 +122,12 @@ function imageUrl(item, options) {
if (item.ImageTags && item.ImageTags[options.type]) {
options.tag = item.ImageTags[options.type];
return window.connectionManager.getApiClient(item.ServerId).getScaledImageUrl(item.PrimaryImageItemId || item.Id, options);
return ServerConnections.getApiClient(item.ServerId).getScaledImageUrl(item.PrimaryImageItemId || item.Id, options);
}
if (item.AlbumId && item.AlbumPrimaryImageTag) {
options.tag = item.AlbumPrimaryImageTag;
return window.connectionManager.getApiClient(item.ServerId).getScaledImageUrl(item.AlbumId, options);
return ServerConnections.getApiClient(item.ServerId).getScaledImageUrl(item.AlbumId, options);
}
return null;
@ -215,7 +218,7 @@ function updateNowPlayingInfo(context, state, serverId) {
openAlbum: false,
positionTo: contextButton
};
const apiClient = window.connectionManager.getApiClient(item.ServerId);
const apiClient = ServerConnections.getApiClient(item.ServerId);
apiClient.getItem(apiClient.getCurrentUserId(), item.Id).then(function (fullItem) {
apiClient.getCurrentUser().then(function (user) {
contextButton.addEventListener('click', function () {
@ -597,7 +600,7 @@ export default function () {
if (!state.NextMediaType) {
updatePlayerState(player, dlg, {});
Emby.Page.back();
appRouter.back();
}
}
@ -631,18 +634,18 @@ export default function () {
const player = currentPlayer;
if (player) {
events.off(player, 'playbackstart', onPlaybackStart);
events.off(player, 'statechange', onStateChanged);
events.off(player, 'repeatmodechange', onRepeatModeChange);
events.off(player, 'shufflequeuemodechange', onShuffleQueueModeChange);
events.off(player, 'playlistitemremove', onPlaylistItemRemoved);
events.off(player, 'playlistitemmove', onPlaylistUpdate);
events.off(player, 'playlistitemadd', onPlaylistUpdate);
events.off(player, 'playbackstop', onPlaybackStopped);
events.off(player, 'volumechange', onVolumeChanged);
events.off(player, 'pause', onPlayPauseStateChanged);
events.off(player, 'unpause', onPlayPauseStateChanged);
events.off(player, 'timeupdate', onTimeUpdate);
Events.off(player, 'playbackstart', onPlaybackStart);
Events.off(player, 'statechange', onStateChanged);
Events.off(player, 'repeatmodechange', onRepeatModeChange);
Events.off(player, 'shufflequeuemodechange', onShuffleQueueModeChange);
Events.off(player, 'playlistitemremove', onPlaylistItemRemoved);
Events.off(player, 'playlistitemmove', onPlaylistUpdate);
Events.off(player, 'playlistitemadd', onPlaylistUpdate);
Events.off(player, 'playbackstop', onPlaybackStopped);
Events.off(player, 'volumechange', onVolumeChanged);
Events.off(player, 'pause', onPlayPauseStateChanged);
Events.off(player, 'unpause', onPlayPauseStateChanged);
Events.off(player, 'timeupdate', onTimeUpdate);
currentPlayer = null;
}
}
@ -653,18 +656,18 @@ export default function () {
onStateChanged.call(player, {
type: 'init'
}, state);
events.on(player, 'playbackstart', onPlaybackStart);
events.on(player, 'statechange', onStateChanged);
events.on(player, 'repeatmodechange', onRepeatModeChange);
events.on(player, 'shufflequeuemodechange', onShuffleQueueModeChange);
events.on(player, 'playlistitemremove', onPlaylistItemRemoved);
events.on(player, 'playlistitemmove', onPlaylistUpdate);
events.on(player, 'playlistitemadd', onPlaylistUpdate);
events.on(player, 'playbackstop', onPlaybackStopped);
events.on(player, 'volumechange', onVolumeChanged);
events.on(player, 'pause', onPlayPauseStateChanged);
events.on(player, 'unpause', onPlayPauseStateChanged);
events.on(player, 'timeupdate', onTimeUpdate);
Events.on(player, 'playbackstart', onPlaybackStart);
Events.on(player, 'statechange', onStateChanged);
Events.on(player, 'repeatmodechange', onRepeatModeChange);
Events.on(player, 'shufflequeuemodechange', onShuffleQueueModeChange);
Events.on(player, 'playlistitemremove', onPlaylistItemRemoved);
Events.on(player, 'playlistitemmove', onPlaylistUpdate);
Events.on(player, 'playlistitemadd', onPlaylistUpdate);
Events.on(player, 'playbackstop', onPlaybackStopped);
Events.on(player, 'volumechange', onVolumeChanged);
Events.on(player, 'pause', onPlayPauseStateChanged);
Events.on(player, 'unpause', onPlayPauseStateChanged);
Events.on(player, 'timeupdate', onTimeUpdate);
const playerInfo = playbackManager.getPlayerInfo();
const supportedCommands = playerInfo.supportedCommands;
currentPlayerSupportedCommands = supportedCommands;
@ -693,7 +696,7 @@ export default function () {
}
function savePlaylist() {
import('playlistEditor').then(({ default: playlistEditor }) => {
import('../playlisteditor/playlisteditor').then(({ default: playlistEditor }) => {
getSaveablePlaylistItems().then(function (items) {
const serverId = items.length ? items[0].ServerId : ApiClient.serverId();
new playlistEditor({
@ -863,9 +866,7 @@ export default function () {
}, currentPlayer);
form.querySelector('input').value = '';
import('toast').then(({ default: toast }) => {
toast('Message sent.');
});
toast('Message sent.');
e.preventDefault();
e.stopPropagation();
@ -882,9 +883,7 @@ export default function () {
}, currentPlayer);
form.querySelector('input').value = '';
import('toast').then(({ default: toast }) => {
toast('Text sent.');
});
toast('Text sent.');
e.preventDefault();
e.stopPropagation();
@ -915,7 +914,7 @@ export default function () {
bindEvents(context);
context.querySelector('.sendMessageForm').addEventListener('submit', onMessageSubmit);
context.querySelector('.typeTextForm').addEventListener('submit', onSendStringSubmit);
events.on(playbackManager, 'playerchange', onPlayerChange);
Events.on(playbackManager, 'playerchange', onPlayerChange);
if (layoutManager.tv) {
const positionSlider = context.querySelector('.nowPlayingPositionSlider');
@ -926,7 +925,7 @@ export default function () {
function onDialogClosed(e) {
releaseCurrentPlayer();
events.off(playbackManager, 'playerchange', onPlayerChange);
Events.off(playbackManager, 'playerchange', onPlayerChange);
lastPlayerState = null;
}

View File

@ -1,72 +0,0 @@
define(function () {
'use strict';
const requireCss = {};
requireCss.normalize = function (name, normalize) {
if (name.substr(name.length - 4, 4) === '.css') {
name = name.substr(0, name.length - 4);
}
return normalize(name);
};
let importedCss = [];
function isLoaded(url) {
return importedCss.indexOf(url) !== -1;
}
function removeFromLoadHistory(url) {
url = url.toLowerCase();
importedCss = importedCss.filter(function (c) {
return url.indexOf(c.toLowerCase()) === -1;
});
}
requireCss.load = function (cssId, req, load, config) {
// Somehow if the url starts with /css, require will get all screwed up since this extension is also called css
const srch = 'components/require/requirecss';
const index = cssId.indexOf(srch);
if (index !== -1) {
cssId = 'css' + cssId.substring(index + srch.length);
}
let url = cssId + '.css';
if (url.indexOf('://') === -1) {
url = config.baseUrl + url;
}
if (!isLoaded(url)) {
importedCss.push(url);
const link = document.createElement('link');
link.setAttribute('rel', 'stylesheet');
link.setAttribute('type', 'text/css');
link.onload = load;
let linkUrl = url;
if (config.urlArgs) {
linkUrl += config.urlArgs(cssId, url);
}
link.setAttribute('href', linkUrl);
document.head.appendChild(link);
} else {
load();
}
};
window.requireCss = {
removeStylesheet: function (stylesheet) {
stylesheet.parentNode.removeChild(stylesheet);
removeFromLoadHistory(stylesheet.href);
}
};
return requireCss;
});

View File

@ -1,42 +0,0 @@
define(function () {
'use strict';
// hack to work around the server's auto-redirection feature
const addRedirectPrevention = window.dashboardVersion != null && window.Dashboard && !window.AppInfo.isNativeApp;
return {
load: function (url, req, load, config) {
if (url.indexOf('://') === -1) {
url = config.baseUrl + url;
}
if (config.urlArgs) {
url += config.urlArgs(url, url);
}
if (addRedirectPrevention) {
if (url.indexOf('?') === -1) {
url += '?';
} else {
url += '&';
}
url += 'r=0';
}
const xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.onload = function (e) {
load(this.response);
};
xhr.send();
},
normalize: function (name, normalize) {
return normalize(name);
}
};
});

View File

@ -5,9 +5,9 @@
* @module components/scrollManager
*/
import dom from 'dom';
import browser from 'browser';
import layoutManager from 'layoutManager';
import dom from '../scripts/dom';
import browser from '../scripts/browser';
import layoutManager from './layoutManager';
/**
* Scroll time in ms.

View File

@ -1,12 +1,12 @@
import layoutManager from 'layoutManager';
import globalize from 'globalize';
import events from 'events';
import browser from 'browser';
import AlphaPicker from 'alphaPicker';
import 'emby-input';
import 'flexStyles';
import 'material-icons';
import 'css!./searchfields';
import layoutManager from '../layoutManager';
import globalize from '../../scripts/globalize';
import { Events } from 'jellyfin-apiclient';
import browser from '../../scripts/browser';
import AlphaPicker from '../alphaPicker/alphaPicker';
import '../../elements/emby-input/emby-input';
import '../../assets/css/flexstyles.scss';
import 'material-design-icons-iconfont';
import './searchfields.css';
/* eslint-disable indent */
@ -15,7 +15,7 @@ import 'css!./searchfields';
let value = instance.nextSearchValue;
value = (value || '').trim();
events.trigger(instance, 'search', [value]);
Events.trigger(instance, 'search', [value]);
}
function triggerSearch(instance, value) {
@ -61,7 +61,7 @@ import 'css!./searchfields';
}
function embed(elem, instance, options) {
import('text!./searchfields.template.html').then(({default: template}) => {
import('./searchfields.template.html').then(({default: template}) => {
let html = globalize.translateHtml(template, 'core');
if (browser.tizen || browser.orsay) {

View File

@ -1,10 +1,11 @@
import layoutManager from 'layoutManager';
import globalize from 'globalize';
import cardBuilder from 'cardBuilder';
import appRouter from 'appRouter';
import 'emby-scroller';
import 'emby-itemscontainer';
import 'emby-button';
import layoutManager from '../layoutManager';
import globalize from '../../scripts/globalize';
import cardBuilder from '../cardbuilder/cardBuilder';
import { appRouter } from '../appRouter';
import '../../elements/emby-scroller/emby-scroller';
import '../../elements/emby-itemscontainer/emby-itemscontainer';
import '../../elements/emby-button/emby-button';
import ServerConnections from '../ServerConnections';
/* eslint-disable indent */
@ -584,7 +585,7 @@ import 'emby-button';
}
function embed(elem, instance, options) {
import('text!./searchresults.template.html').then(({default: template}) => {
import('./searchresults.template.html').then(({default: template}) => {
if (!enableScrollX()) {
template = replaceAll(template, 'data-horizontal="true"', 'data-horizontal="false"');
template = replaceAll(template, 'itemsContainer scrollSlider', 'itemsContainer scrollSlider vertical-wrap');
@ -605,7 +606,7 @@ class SearchResults {
embed(options.element, this, options);
}
search(value) {
const apiClient = window.connectionManager.getApiClient(this.options.serverId);
const apiClient = ServerConnections.getApiClient(this.options.serverId);
search(this, apiClient, this.options.element, value);
}

View File

@ -1,45 +0,0 @@
/* eslint-env serviceworker */
(function () {
'use strict';
let connectionManager;
function getApiClient(serverId) {
if (connectionManager) {
return Promise.resolve(connectionManager.getApiClient(serverId));
}
return Promise.reject();
}
function executeAction(action, data, serverId) {
return getApiClient(serverId).then(function (apiClient) {
switch (action) {
case 'cancel-install':
return apiClient.cancelPackageInstallation(data.id);
case 'restart':
return apiClient.restartServer();
default:
clients.openWindow('/');
return Promise.resolve();
}
});
}
/* eslint-disable-next-line no-restricted-globals -- self is valid in a serviceworker environment */
self.addEventListener('notificationclick', function (event) {
const notification = event.notification;
notification.close();
const data = notification.data;
const serverId = data.serverId;
const action = event.action;
if (!action) {
clients.openWindow('/');
event.waitUntil(Promise.resolve());
return;
}
event.waitUntil(executeAction(action, data, serverId));
}, false);
})();

View File

@ -1,4 +1,4 @@
import globalize from 'globalize';
import globalize from '../scripts/globalize';
/**
* Helper for handling settings.

View File

@ -5,12 +5,14 @@
* @module components/shortcuts
*/
import playbackManager from 'playbackManager';
import inputManager from 'inputManager';
import appRouter from 'appRouter';
import globalize from 'globalize';
import dom from 'dom';
import recordingHelper from 'recordingHelper';
import { playbackManager } from './playback/playbackmanager';
import inputManager from '../scripts/inputManager';
import { appRouter } from './appRouter';
import globalize from '../scripts/globalize';
import dom from '../scripts/dom';
import recordingHelper from './recordingcreator/recordinghelper';
import ServerConnections from './ServerConnections';
import toast from './toast/toast';
function playAllFromHere(card, serverId, queue) {
const parent = card.parentNode;
@ -69,7 +71,7 @@ import recordingHelper from 'recordingHelper';
}
function showProgramDialog(item) {
import('recordingCreator').then(({default:recordingCreator}) => {
import('./recordingcreator/recordingcreator').then(({default:recordingCreator}) => {
recordingCreator.show(item.Id, item.ServerId);
});
}
@ -80,7 +82,7 @@ import recordingHelper from 'recordingHelper';
const id = button.getAttribute('data-id');
const type = button.getAttribute('data-type');
const apiClient = window.connectionManager.getApiClient(serverId);
const apiClient = ServerConnections.getApiClient(serverId);
if (type === 'Timer') {
return apiClient.getLiveTvTimer(id);
@ -109,8 +111,8 @@ import recordingHelper from 'recordingHelper';
item.PlaylistItemId = elem ? elem.getAttribute('data-playlistitemid') : null;
}
import('itemContextMenu').then(({default: itemContextMenu}) => {
window.connectionManager.getApiClient(item.ServerId).getCurrentUser().then(user => {
import('./itemContextMenu').then((itemContextMenu) => {
ServerConnections.getApiClient(item.ServerId).getCurrentUser().then(user => {
itemContextMenu.show(Object.assign({
item: item,
play: true,
@ -153,7 +155,7 @@ import recordingHelper from 'recordingHelper';
function showPlayMenu(card, target) {
const item = getItemInfoFromCard(card);
import('playMenu').then(({default: playMenu}) => {
import('./playmenu').then((playMenu) => {
playMenu.show({
item: item,
@ -163,9 +165,7 @@ import recordingHelper from 'recordingHelper';
}
function sendToast(text) {
import('toast').then(({default: toast}) => {
toast(text);
});
toast(text);
}
function executeAction(card, target, action) {
@ -269,7 +269,7 @@ import recordingHelper from 'recordingHelper';
}
function addToPlaylist(item) {
import('playlistEditor').then(({default: playlistEditor}) => {
import('./playlisteditor/playlisteditor').then(({default: playlistEditor}) => {
new playlistEditor().show({
items: [item.Id],
serverId: item.ServerId
@ -279,7 +279,7 @@ import recordingHelper from 'recordingHelper';
}
function playTrailer(item) {
const apiClient = window.connectionManager.getApiClient(item.ServerId);
const apiClient = ServerConnections.getApiClient(item.ServerId);
apiClient.getLocalTrailers(apiClient.getCurrentUserId(), item.Id).then(trailers => {
playbackManager.play({ items: trailers });
@ -287,23 +287,23 @@ import recordingHelper from 'recordingHelper';
}
function editItem(item, serverId) {
const apiClient = window.connectionManager.getApiClient(serverId);
const apiClient = ServerConnections.getApiClient(serverId);
return new Promise((resolve, reject) => {
const serverId = apiClient.serverInfo().Id;
if (item.Type === 'Timer') {
if (item.ProgramId) {
import('recordingCreator').then(({default: recordingCreator}) => {
import('./recordingcreator/recordingcreator').then(({default: recordingCreator}) => {
recordingCreator.show(item.ProgramId, serverId).then(resolve, reject);
});
} else {
import('recordingEditor').then(({default: recordingEditor}) => {
import('./recordingcreator/recordingeditor').then(({default: recordingEditor}) => {
recordingEditor.show(item.Id, serverId).then(resolve, reject);
});
}
} else {
import('metadataEditor').then(({default: metadataEditor}) => {
import('./metadataEditor/metadataEditor').then(({default: metadataEditor}) => {
metadataEditor.show(item.Id, serverId).then(resolve, reject);
});
}
@ -397,4 +397,3 @@ export default {
onClick: onClick,
getShortcutAttributesHtml: getShortcutAttributesHtml
};

View File

@ -2,16 +2,20 @@
* Image viewer component
* @module components/slideshow/slideshow
*/
import dialogHelper from 'dialogHelper';
import inputManager from 'inputManager';
import layoutManager from 'layoutManager';
import focusManager from 'focusManager';
import browser from 'browser';
import appHost from 'apphost';
import dom from 'dom';
import 'css!./style';
import 'material-icons';
import 'paper-icon-button-light';
import dialogHelper from '../dialogHelper/dialogHelper';
import inputManager from '../../scripts/inputManager';
import layoutManager from '../layoutManager';
import focusManager from '../focusManager';
import browser from '../../scripts/browser';
import { appHost } from '../apphost';
import dom from '../../scripts/dom';
import './style.css';
import 'material-design-icons-iconfont';
import '../../elements/emby-button/paper-icon-button-light';
import ServerConnections from '../ServerConnections';
// eslint-disable-next-line import/named, import/namespace
import { Swiper } from 'swiper/swiper-bundle.esm';
import 'swiper/swiper-bundle.css';
/**
* Name of transition event.
@ -84,7 +88,7 @@ function getBackdropImageUrl(item, options, apiClient) {
* @returns {string} URL of the item's image.
*/
function getImgUrl(item, user) {
const apiClient = window.connectionManager.getApiClient(item.ServerId);
const apiClient = ServerConnections.getApiClient(item.ServerId);
const imageOptions = {};
if (item.BackdropImageTags && item.BackdropImageTags.length) {
@ -300,45 +304,43 @@ export default function (options) {
slides = currentOptions.items;
}
import('swiper').then(({default: Swiper}) => {
swiperInstance = new Swiper(dialog.querySelector('.slideshowSwiperContainer'), {
direction: 'horizontal',
// Loop is disabled due to the virtual slides option not supporting it.
loop: false,
zoom: {
minRatio: 1,
toggle: true
},
autoplay: !options.interactive,
keyboard: {
enabled: true
},
preloadImages: true,
slidesPerView: 1,
slidesPerColumn: 1,
initialSlide: options.startIndex || 0,
speed: 240,
navigation: {
nextEl: '.btnSlideshowNext',
prevEl: '.btnSlideshowPrevious'
},
// Virtual slides reduce memory consumption for large libraries while allowing preloading of images;
virtual: {
slides: slides,
cache: true,
renderSlide: getSwiperSlideHtml,
addSlidesBefore: 1,
addSlidesAfter: 1
}
});
swiperInstance.on('autoplayStart', onAutoplayStart);
swiperInstance.on('autoplayStop', onAutoplayStop);
if (useFakeZoomImage) {
swiperInstance.on('zoomChange', onZoomChange);
swiperInstance = new Swiper(dialog.querySelector('.slideshowSwiperContainer'), {
direction: 'horizontal',
// Loop is disabled due to the virtual slides option not supporting it.
loop: false,
zoom: {
minRatio: 1,
toggle: true
},
autoplay: !options.interactive,
keyboard: {
enabled: true
},
preloadImages: true,
slidesPerView: 1,
slidesPerColumn: 1,
initialSlide: options.startIndex || 0,
speed: 240,
navigation: {
nextEl: '.btnSlideshowNext',
prevEl: '.btnSlideshowPrevious'
},
// Virtual slides reduce memory consumption for large libraries while allowing preloading of images;
virtual: {
slides: slides,
cache: true,
renderSlide: getSwiperSlideHtml,
addSlidesBefore: 1,
addSlidesAfter: 1
}
});
swiperInstance.on('autoplayStart', onAutoplayStart);
swiperInstance.on('autoplayStop', onAutoplayStop);
if (useFakeZoomImage) {
swiperInstance.on('zoomChange', onZoomChange);
}
}
/**
@ -431,7 +433,7 @@ export default function (options) {
function download() {
const imageInfo = getCurrentImageInfo();
import('fileDownloader').then(({default: fileDownloader}) => {
import('../../scripts/fileDownloader').then((fileDownloader) => {
fileDownloader.download([imageInfo]);
});
}

View File

@ -1,13 +1,13 @@
import dialogHelper from 'dialogHelper';
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';
import dialogHelper from '../dialogHelper/dialogHelper';
import layoutManager from '../layoutManager';
import globalize from '../../scripts/globalize';
import * as userSettings from '../../scripts/settings/userSettings';
import '../../elements/emby-select/emby-select';
import '../../elements/emby-button/paper-icon-button-light';
import 'material-design-icons-iconfont';
import '../formdialog.css';
import '../../elements/emby-button/emby-button';
import '../../assets/css/flexstyles.scss';
function onSubmit(e) {
e.preventDefault();
@ -22,7 +22,7 @@ function initEditor(context, settings) {
}
function centerFocus(elem, horiz, on) {
import('scrollHelper').then(({default: scrollHelper}) => {
import('../../scripts/scrollHelper').then((scrollHelper) => {
const fn = on ? 'on' : 'off';
scrollHelper.centerFocus[fn](elem, horiz);
});
@ -44,7 +44,7 @@ function saveValues(context, settingsKey) {
class SortMenu {
show(options) {
return new Promise(function (resolve, reject) {
import('text!./sortmenu.template.html').then(({default: template}) => {
import('./sortmenu.template.html').then(({default: template}) => {
const dialogOptions = {
removeOnClose: true,
scrollY: false

Some files were not shown because too many files have changed in this diff Show More