mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Merge pull request #1420 from Influence365/Migrate-to-ES6-1
Migrate htmlMediaHelper, groupedCards and themeLoader to es6 Modules
This commit is contained in:
commit
26f71df7ea
5 changed files with 59 additions and 70 deletions
|
@ -193,4 +193,4 @@ module.exports = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
};
|
||||||
|
|
|
@ -116,6 +116,8 @@
|
||||||
"src/components/playback/remotecontrolautoplay.js",
|
"src/components/playback/remotecontrolautoplay.js",
|
||||||
"src/components/playback/volumeosd.js",
|
"src/components/playback/volumeosd.js",
|
||||||
"src/components/playlisteditor/playlisteditor.js",
|
"src/components/playlisteditor/playlisteditor.js",
|
||||||
|
"src/components/groupedcards.js",
|
||||||
|
"src/components/htmlMediaHelper.js",
|
||||||
"src/components/playmenu.js",
|
"src/components/playmenu.js",
|
||||||
"src/components/sanatizefilename.js",
|
"src/components/sanatizefilename.js",
|
||||||
"src/components/scrollManager.js",
|
"src/components/scrollManager.js",
|
||||||
|
@ -142,6 +144,7 @@
|
||||||
"src/scripts/keyboardNavigation.js",
|
"src/scripts/keyboardNavigation.js",
|
||||||
"src/scripts/settings/appSettings.js",
|
"src/scripts/settings/appSettings.js",
|
||||||
"src/scripts/settings/userSettings.js",
|
"src/scripts/settings/userSettings.js",
|
||||||
|
"src/scripts/themeLoader.js",
|
||||||
"src/scripts/settings/webSettings.js"
|
"src/scripts/settings/webSettings.js"
|
||||||
],
|
],
|
||||||
"plugins": [
|
"plugins": [
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
define(['dom', 'appRouter', 'connectionManager'], function (dom, appRouter, connectionManager) {
|
/* eslint-disable indent */
|
||||||
'use strict';
|
|
||||||
|
import dom from 'dom';
|
||||||
|
import appRouter from 'appRouter';
|
||||||
|
import connectionManager from 'connectionManager';
|
||||||
|
|
||||||
function onGroupedCardClick(e, card) {
|
function onGroupedCardClick(e, card) {
|
||||||
var itemId = card.getAttribute('data-id');
|
var itemId = card.getAttribute('data-id');
|
||||||
|
@ -31,7 +34,7 @@ define(['dom', 'appRouter', 'connectionManager'], function (dom, appRouter, conn
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function onItemsContainerClick(e) {
|
export function onItemsContainerClick(e) {
|
||||||
var groupedCard = dom.parentWithClass(e.target, 'groupedCard');
|
var groupedCard = dom.parentWithClass(e.target, 'groupedCard');
|
||||||
|
|
||||||
if (groupedCard) {
|
if (groupedCard) {
|
||||||
|
@ -39,7 +42,4 @@ define(['dom', 'appRouter', 'connectionManager'], function (dom, appRouter, conn
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
/* eslint-enable indent */
|
||||||
onItemsContainerClick: onItemsContainerClick
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
|
@ -1,17 +1,20 @@
|
||||||
define(['appSettings', 'browser', 'events'], function (appSettings, browser, events) {
|
/* eslint-disable indent */
|
||||||
'use strict';
|
|
||||||
|
|
||||||
function getSavedVolume() {
|
import appSettings from 'appSettings' ;
|
||||||
|
import browser from 'browser';
|
||||||
|
import events from 'events';
|
||||||
|
|
||||||
|
export function getSavedVolume() {
|
||||||
return appSettings.get('volume') || 1;
|
return appSettings.get('volume') || 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
function saveVolume(value) {
|
export function saveVolume(value) {
|
||||||
if (value) {
|
if (value) {
|
||||||
appSettings.set('volume', value);
|
appSettings.set('volume', value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCrossOriginValue(mediaSource) {
|
export function getCrossOriginValue(mediaSource) {
|
||||||
if (mediaSource.IsRemote) {
|
if (mediaSource.IsRemote) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -30,7 +33,7 @@ define(['appSettings', 'browser', 'events'], function (appSettings, browser, eve
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function enableHlsShakaPlayer(item, mediaSource, mediaType) {
|
export function enableHlsShakaPlayer(item, mediaSource, mediaType) {
|
||||||
/* eslint-disable-next-line compat/compat */
|
/* eslint-disable-next-line compat/compat */
|
||||||
if (!!window.MediaSource && !!MediaSource.isTypeSupported) {
|
if (!!window.MediaSource && !!MediaSource.isTypeSupported) {
|
||||||
|
|
||||||
|
@ -56,7 +59,7 @@ define(['appSettings', 'browser', 'events'], function (appSettings, browser, eve
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function enableHlsJsPlayer(runTimeTicks, mediaType) {
|
export function enableHlsJsPlayer(runTimeTicks, mediaType) {
|
||||||
|
|
||||||
if (window.MediaSource == null) {
|
if (window.MediaSource == null) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -98,7 +101,7 @@ define(['appSettings', 'browser', 'events'], function (appSettings, browser, eve
|
||||||
|
|
||||||
var recoverDecodingErrorDate;
|
var recoverDecodingErrorDate;
|
||||||
var recoverSwapAudioCodecDate;
|
var recoverSwapAudioCodecDate;
|
||||||
function handleHlsJsMediaError(instance, reject) {
|
export function handleHlsJsMediaError(instance, reject) {
|
||||||
|
|
||||||
var hlsPlayer = instance._hlsPlayer;
|
var hlsPlayer = instance._hlsPlayer;
|
||||||
|
|
||||||
|
@ -134,7 +137,7 @@ define(['appSettings', 'browser', 'events'], function (appSettings, browser, eve
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function onErrorInternal(instance, type) {
|
export function onErrorInternal(instance, type) {
|
||||||
|
|
||||||
// Needed for video
|
// Needed for video
|
||||||
if (instance.destroyCustomTrack) {
|
if (instance.destroyCustomTrack) {
|
||||||
|
@ -148,7 +151,7 @@ define(['appSettings', 'browser', 'events'], function (appSettings, browser, eve
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function isValidDuration(duration) {
|
export function isValidDuration(duration) {
|
||||||
if (duration && !isNaN(duration) && duration !== Number.POSITIVE_INFINITY && duration !== Number.NEGATIVE_INFINITY) {
|
if (duration && !isNaN(duration) && duration !== Number.POSITIVE_INFINITY && duration !== Number.NEGATIVE_INFINITY) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -162,7 +165,7 @@ define(['appSettings', 'browser', 'events'], function (appSettings, browser, eve
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function seekOnPlaybackStart(instance, element, ticks, onMediaReady) {
|
export function seekOnPlaybackStart(instance, element, ticks, onMediaReady) {
|
||||||
|
|
||||||
var seconds = (ticks || 0) / 10000000;
|
var seconds = (ticks || 0) / 10000000;
|
||||||
|
|
||||||
|
@ -200,7 +203,7 @@ define(['appSettings', 'browser', 'events'], function (appSettings, browser, eve
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function applySrc(elem, src, options) {
|
export function applySrc(elem, src, options) {
|
||||||
|
|
||||||
if (window.Windows && options.mediaSource && options.mediaSource.IsLocal) {
|
if (window.Windows && options.mediaSource && options.mediaSource.IsLocal) {
|
||||||
|
|
||||||
|
@ -228,7 +231,7 @@ define(['appSettings', 'browser', 'events'], function (appSettings, browser, eve
|
||||||
elem.addEventListener('error', onErrorFn);
|
elem.addEventListener('error', onErrorFn);
|
||||||
}
|
}
|
||||||
|
|
||||||
function playWithPromise(elem, onErrorFn) {
|
export function playWithPromise(elem, onErrorFn) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
var promise = elem.play();
|
var promise = elem.play();
|
||||||
|
@ -256,7 +259,7 @@ define(['appSettings', 'browser', 'events'], function (appSettings, browser, eve
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function destroyCastPlayer(instance) {
|
export function destroyCastPlayer(instance) {
|
||||||
|
|
||||||
var player = instance._castPlayer;
|
var player = instance._castPlayer;
|
||||||
if (player) {
|
if (player) {
|
||||||
|
@ -270,7 +273,7 @@ define(['appSettings', 'browser', 'events'], function (appSettings, browser, eve
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function destroyShakaPlayer(instance) {
|
export function destroyShakaPlayer(instance) {
|
||||||
var player = instance._shakaPlayer;
|
var player = instance._shakaPlayer;
|
||||||
if (player) {
|
if (player) {
|
||||||
try {
|
try {
|
||||||
|
@ -283,7 +286,7 @@ define(['appSettings', 'browser', 'events'], function (appSettings, browser, eve
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function destroyHlsPlayer(instance) {
|
export function destroyHlsPlayer(instance) {
|
||||||
var player = instance._hlsPlayer;
|
var player = instance._hlsPlayer;
|
||||||
if (player) {
|
if (player) {
|
||||||
try {
|
try {
|
||||||
|
@ -296,7 +299,7 @@ define(['appSettings', 'browser', 'events'], function (appSettings, browser, eve
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function destroyFlvPlayer(instance) {
|
export function destroyFlvPlayer(instance) {
|
||||||
var player = instance._flvPlayer;
|
var player = instance._flvPlayer;
|
||||||
if (player) {
|
if (player) {
|
||||||
try {
|
try {
|
||||||
|
@ -311,7 +314,7 @@ define(['appSettings', 'browser', 'events'], function (appSettings, browser, eve
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function bindEventsToHlsPlayer(instance, hls, elem, onErrorFn, resolve, reject) {
|
export function bindEventsToHlsPlayer(instance, hls, elem, onErrorFn, resolve, reject) {
|
||||||
|
|
||||||
hls.on(Hls.Events.MANIFEST_PARSED, function () {
|
hls.on(Hls.Events.MANIFEST_PARSED, function () {
|
||||||
playWithPromise(elem, onErrorFn).then(resolve, function () {
|
playWithPromise(elem, onErrorFn).then(resolve, function () {
|
||||||
|
@ -403,7 +406,7 @@ define(['appSettings', 'browser', 'events'], function (appSettings, browser, eve
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function onEndedInternal(instance, elem, onErrorFn) {
|
export function onEndedInternal(instance, elem, onErrorFn) {
|
||||||
|
|
||||||
elem.removeEventListener('error', onErrorFn);
|
elem.removeEventListener('error', onErrorFn);
|
||||||
|
|
||||||
|
@ -427,7 +430,7 @@ define(['appSettings', 'browser', 'events'], function (appSettings, browser, eve
|
||||||
instance._currentPlayOptions = null;
|
instance._currentPlayOptions = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getBufferedRanges(instance, elem) {
|
export function getBufferedRanges(instance, elem) {
|
||||||
|
|
||||||
var ranges = [];
|
var ranges = [];
|
||||||
var seekable = elem.buffered || [];
|
var seekable = elem.buffered || [];
|
||||||
|
@ -462,23 +465,4 @@ define(['appSettings', 'browser', 'events'], function (appSettings, browser, eve
|
||||||
return ranges;
|
return ranges;
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
/* eslint-enable indent */
|
||||||
getSavedVolume: getSavedVolume,
|
|
||||||
saveVolume: saveVolume,
|
|
||||||
enableHlsJsPlayer: enableHlsJsPlayer,
|
|
||||||
enableHlsShakaPlayer: enableHlsShakaPlayer,
|
|
||||||
handleHlsJsMediaError: handleHlsJsMediaError,
|
|
||||||
isValidDuration: isValidDuration,
|
|
||||||
onErrorInternal: onErrorInternal,
|
|
||||||
seekOnPlaybackStart: seekOnPlaybackStart,
|
|
||||||
applySrc: applySrc,
|
|
||||||
playWithPromise: playWithPromise,
|
|
||||||
destroyHlsPlayer: destroyHlsPlayer,
|
|
||||||
destroyFlvPlayer: destroyFlvPlayer,
|
|
||||||
destroyCastPlayer: destroyCastPlayer,
|
|
||||||
bindEventsToHlsPlayer: bindEventsToHlsPlayer,
|
|
||||||
onEndedInternal: onEndedInternal,
|
|
||||||
getCrossOriginValue: getCrossOriginValue,
|
|
||||||
getBufferedRanges: getBufferedRanges
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
define(['userSettings', 'skinManager', 'connectionManager', 'events'], function (userSettings, skinManager, connectionManager, events) {
|
import * as userSettings from 'userSettings';
|
||||||
'use strict';
|
import skinManager from 'skinManager';
|
||||||
|
import connectionManager from 'connectionManager';
|
||||||
|
import events from 'events';
|
||||||
|
|
||||||
var currentViewType;
|
var currentViewType;
|
||||||
pageClassOn('viewbeforeshow', 'page', function () {
|
pageClassOn('viewbeforeshow', 'page', function () {
|
||||||
|
@ -21,7 +23,7 @@ define(['userSettings', 'skinManager', 'connectionManager', 'events'], function
|
||||||
skinManager.setTheme(theme, context);
|
skinManager.setTheme(theme, context);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
events.on(connectionManager, 'localusersignedin', function (e, user) {
|
events.on(connectionManager, 'localusersignedin', function (e, user) {
|
||||||
currentViewType = null;
|
currentViewType = null;
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue