mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
add eslint no-nested-ternary rule and fix violations
This commit is contained in:
parent
ab5fad6d5b
commit
d895a4fc6a
15 changed files with 89 additions and 30 deletions
|
@ -52,9 +52,10 @@ module.exports = {
|
||||||
'no-trailing-spaces': ['error'],
|
'no-trailing-spaces': ['error'],
|
||||||
'@babel/no-unused-expressions': ['error', { 'allowShortCircuit': true, 'allowTernary': true, 'allowTaggedTemplates': true }],
|
'@babel/no-unused-expressions': ['error', { 'allowShortCircuit': true, 'allowTernary': true, 'allowTaggedTemplates': true }],
|
||||||
'no-void': ['error', { 'allowAsStatement': true }],
|
'no-void': ['error', { 'allowAsStatement': true }],
|
||||||
|
'no-nested-ternary': ['error'],
|
||||||
'one-var': ['error', 'never'],
|
'one-var': ['error', 'never'],
|
||||||
'padded-blocks': ['error', 'never'],
|
'padded-blocks': ['error', 'never'],
|
||||||
'prefer-const': ['error', {'destructuring': 'all'}],
|
'prefer-const': ['error', { 'destructuring': 'all' }],
|
||||||
'quotes': ['error', 'single', { 'avoidEscape': true, 'allowTemplateLiterals': false }],
|
'quotes': ['error', 'single', { 'avoidEscape': true, 'allowTemplateLiterals': false }],
|
||||||
'@babel/semi': ['error'],
|
'@babel/semi': ['error'],
|
||||||
'no-var': ['error'],
|
'no-var': ['error'],
|
||||||
|
|
|
@ -121,10 +121,14 @@ import '../elements/emby-itemscontainer/emby-itemscontainer';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isSingleSection) {
|
if (!isSingleSection) {
|
||||||
options.Limit = screenWidth >= 1920 ? 10 : screenWidth >= 1440 ? 8 : 6;
|
options.Limit = 6;
|
||||||
|
|
||||||
if (enableScrollX()) {
|
if (enableScrollX()) {
|
||||||
options.Limit = 20;
|
options.Limit = 20;
|
||||||
|
} else if (screenWidth >= 1920) {
|
||||||
|
options.Limit = 10;
|
||||||
|
} else if (screenWidth >= 1440) {
|
||||||
|
options.Limit = 8;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import escapeHtml from 'escape-html';
|
import escapeHtml from 'escape-html';
|
||||||
import cardBuilder from '../cardbuilder/cardBuilder';
|
import cardBuilder from '../cardbuilder/cardBuilder';
|
||||||
import dom from '../../scripts/dom';
|
|
||||||
import layoutManager from '../layoutManager';
|
import layoutManager from '../layoutManager';
|
||||||
import imageLoader from '../images/imageLoader';
|
import imageLoader from '../images/imageLoader';
|
||||||
import globalize from '../../scripts/globalize';
|
import globalize from '../../scripts/globalize';
|
||||||
|
@ -401,15 +400,8 @@ import ServerConnections from '../ServerConnections';
|
||||||
function getItemsToResumeFn(mediaType, serverId) {
|
function getItemsToResumeFn(mediaType, serverId) {
|
||||||
return function () {
|
return function () {
|
||||||
const apiClient = ServerConnections.getApiClient(serverId);
|
const apiClient = ServerConnections.getApiClient(serverId);
|
||||||
const screenWidth = dom.getWindowSize().innerWidth;
|
|
||||||
|
|
||||||
let limit;
|
const limit = enableScrollX() ? 12 : 5;
|
||||||
if (enableScrollX()) {
|
|
||||||
limit = 12;
|
|
||||||
} else {
|
|
||||||
limit = screenWidth >= 1920 ? 8 : (screenWidth >= 1600 ? 8 : (screenWidth >= 1200 ? 9 : 6));
|
|
||||||
limit = Math.min(limit, 5);
|
|
||||||
}
|
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
Limit: limit,
|
Limit: limit,
|
||||||
|
|
|
@ -520,7 +520,14 @@ import toast from './toast/toast';
|
||||||
}
|
}
|
||||||
|
|
||||||
function play(item, resume, queue, queueNext) {
|
function play(item, resume, queue, queueNext) {
|
||||||
const method = queue ? (queueNext ? 'queueNext' : 'queue') : 'play';
|
let method = 'play';
|
||||||
|
if (queue) {
|
||||||
|
if (queueNext) {
|
||||||
|
method = 'queueNext';
|
||||||
|
} else {
|
||||||
|
method = 'queue';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let startPosition = 0;
|
let startPosition = 0;
|
||||||
if (resume && item.UserData && item.UserData.PlaybackPositionTicks) {
|
if (resume && item.UserData && item.UserData.PlaybackPositionTicks) {
|
||||||
|
|
|
@ -550,7 +550,13 @@ import template from './libraryoptionseditor.template.html';
|
||||||
function getOrderedPlugins(plugins, configuredOrder) {
|
function getOrderedPlugins(plugins, configuredOrder) {
|
||||||
plugins = plugins.slice(0);
|
plugins = plugins.slice(0);
|
||||||
plugins.sort((a, b) => {
|
plugins.sort((a, b) => {
|
||||||
return a = configuredOrder.indexOf(a.Name), b = configuredOrder.indexOf(b.Name), a < b ? -1 : a > b ? 1 : 0;
|
let order = 0;
|
||||||
|
if (a < b) {
|
||||||
|
order = -1;
|
||||||
|
} else if (a > b) {
|
||||||
|
order = 1;
|
||||||
|
}
|
||||||
|
return a = configuredOrder.indexOf(a.Name), b = configuredOrder.indexOf(b.Name), order;
|
||||||
});
|
});
|
||||||
return plugins;
|
return plugins;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1827,12 +1827,18 @@ class PlaybackManager {
|
||||||
Limit: UNLIMITED_ITEMS
|
Limit: UNLIMITED_ITEMS
|
||||||
}, queryOptions));
|
}, queryOptions));
|
||||||
} else if (firstItem.IsFolder) {
|
} else if (firstItem.IsFolder) {
|
||||||
|
let sortBy = null;
|
||||||
|
if (options.shuffle) {
|
||||||
|
sortBy = 'Random';
|
||||||
|
} else if (firstItem.Type !== 'BoxSet') {
|
||||||
|
sortBy = 'SortName';
|
||||||
|
}
|
||||||
promise = getItemsForPlayback(serverId, mergePlaybackQueries({
|
promise = getItemsForPlayback(serverId, mergePlaybackQueries({
|
||||||
ParentId: firstItem.Id,
|
ParentId: firstItem.Id,
|
||||||
Filters: 'IsNotFolder',
|
Filters: 'IsNotFolder',
|
||||||
Recursive: true,
|
Recursive: true,
|
||||||
// These are pre-sorted
|
// These are pre-sorted
|
||||||
SortBy: options.shuffle ? 'Random' : (['BoxSet'].indexOf(firstItem.Type) === -1 ? 'SortName' : null),
|
SortBy: sortBy,
|
||||||
MediaTypes: 'Audio,Video'
|
MediaTypes: 'Audio,Video'
|
||||||
}, queryOptions));
|
}, queryOptions));
|
||||||
} else if (firstItem.Type === 'Episode' && items.length === 1 && getPlayer(firstItem, options).supportsProgress !== false) {
|
} else if (firstItem.Type === 'Episode' && items.length === 1 && getPlayer(firstItem, options).supportsProgress !== false) {
|
||||||
|
|
|
@ -61,7 +61,12 @@ import layoutManager from './layoutManager';
|
||||||
* @return {number} Clamped value.
|
* @return {number} Clamped value.
|
||||||
*/
|
*/
|
||||||
function clamp(value, min, max) {
|
function clamp(value, min, max) {
|
||||||
return value <= min ? min : value >= max ? max : value;
|
if (value <= min) {
|
||||||
|
return min;
|
||||||
|
} else if (value >= max) {
|
||||||
|
return max;
|
||||||
|
}
|
||||||
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -173,12 +173,18 @@ export function translateItemsForPlayback(apiClient, items, options) {
|
||||||
MediaTypes: 'Audio'
|
MediaTypes: 'Audio'
|
||||||
});
|
});
|
||||||
} else if (firstItem.IsFolder) {
|
} else if (firstItem.IsFolder) {
|
||||||
|
let sortBy = null;
|
||||||
|
if (options.shuffle) {
|
||||||
|
sortBy = 'Random';
|
||||||
|
} else if (firstItem.Type === 'BoxSet') {
|
||||||
|
sortBy = 'SortName';
|
||||||
|
}
|
||||||
promise = getItemsForPlayback(apiClient, mergePlaybackQueries({
|
promise = getItemsForPlayback(apiClient, mergePlaybackQueries({
|
||||||
ParentId: firstItem.Id,
|
ParentId: firstItem.Id,
|
||||||
Filters: 'IsNotFolder',
|
Filters: 'IsNotFolder',
|
||||||
Recursive: true,
|
Recursive: true,
|
||||||
// These are pre-sorted.
|
// These are pre-sorted.
|
||||||
SortBy: options.shuffle ? 'Random' : (['BoxSet'].indexOf(firstItem.Type) === -1 ? 'SortName' : null),
|
SortBy: sortBy,
|
||||||
MediaTypes: 'Audio,Video'
|
MediaTypes: 'Audio,Video'
|
||||||
}, queryOptions));
|
}, queryOptions));
|
||||||
} else if (firstItem.Type === 'Episode' && items.length === 1) {
|
} else if (firstItem.Type === 'Episode' && items.length === 1) {
|
||||||
|
|
|
@ -23,7 +23,13 @@ import '../../../elements/emby-button/emby-button';
|
||||||
tasks = tasks.sort(function(a, b) {
|
tasks = tasks.sort(function(a, b) {
|
||||||
a = a.Category + ' ' + a.Name;
|
a = a.Category + ' ' + a.Name;
|
||||||
b = b.Category + ' ' + b.Name;
|
b = b.Category + ' ' + b.Name;
|
||||||
return a == b ? 0 : a < b ? -1 : 1;
|
if (a > b) {
|
||||||
|
return 1;
|
||||||
|
} else if (a < b) {
|
||||||
|
return -1;
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
let currentCategory;
|
let currentCategory;
|
||||||
|
|
|
@ -66,7 +66,7 @@ import Dashboard from '../../utils/dashboard';
|
||||||
SortOrder: 'Descending',
|
SortOrder: 'Descending',
|
||||||
IncludeItemTypes: 'Movie',
|
IncludeItemTypes: 'Movie',
|
||||||
Filters: 'IsResumable',
|
Filters: 'IsResumable',
|
||||||
Limit: screenWidth >= 1920 ? 5 : screenWidth >= 1600 ? 5 : 3,
|
Limit: screenWidth >= 1600 ? 5 : 3,
|
||||||
Recursive: true,
|
Recursive: true,
|
||||||
Fields: 'PrimaryImageAspectRatio,MediaSourceCount,BasicSyncInfo',
|
Fields: 'PrimaryImageAspectRatio,MediaSourceCount,BasicSyncInfo',
|
||||||
CollapseBoxSetItems: false,
|
CollapseBoxSetItems: false,
|
||||||
|
@ -157,10 +157,17 @@ import Dashboard from '../../utils/dashboard';
|
||||||
|
|
||||||
function loadSuggestions(page, userId) {
|
function loadSuggestions(page, userId) {
|
||||||
const screenWidth = dom.getWindowSize().innerWidth;
|
const screenWidth = dom.getWindowSize().innerWidth;
|
||||||
|
let itemLimit = 5;
|
||||||
|
if (screenWidth >= 1600) {
|
||||||
|
itemLimit = 8;
|
||||||
|
} else if (screenWidth >= 1200) {
|
||||||
|
itemLimit = 6;
|
||||||
|
}
|
||||||
|
|
||||||
const url = ApiClient.getUrl('Movies/Recommendations', {
|
const url = ApiClient.getUrl('Movies/Recommendations', {
|
||||||
userId: userId,
|
userId: userId,
|
||||||
categoryLimit: 6,
|
categoryLimit: 6,
|
||||||
ItemLimit: screenWidth >= 1920 ? 8 : screenWidth >= 1600 ? 8 : screenWidth >= 1200 ? 6 : 5,
|
ItemLimit: itemLimit,
|
||||||
Fields: 'PrimaryImageAspectRatio,MediaSourceCount,BasicSyncInfo',
|
Fields: 'PrimaryImageAspectRatio,MediaSourceCount,BasicSyncInfo',
|
||||||
ImageTypeLimit: 1,
|
ImageTypeLimit: 1,
|
||||||
EnableImageTypes: 'Primary,Backdrop,Banner,Thumb'
|
EnableImageTypes: 'Primary,Backdrop,Banner,Thumb'
|
||||||
|
|
|
@ -587,7 +587,12 @@ import { setBackdropTransparency, TRANSPARENCY_LEVEL } from '../../../components
|
||||||
|
|
||||||
function showComingUpNextIfNeeded(player, currentItem, currentTimeTicks, runtimeTicks) {
|
function showComingUpNextIfNeeded(player, currentItem, currentTimeTicks, runtimeTicks) {
|
||||||
if (runtimeTicks && currentTimeTicks && !comingUpNextDisplayed && !currentVisibleMenu && currentItem.Type === 'Episode' && userSettings.enableNextVideoInfoOverlay()) {
|
if (runtimeTicks && currentTimeTicks && !comingUpNextDisplayed && !currentVisibleMenu && currentItem.Type === 'Episode' && userSettings.enableNextVideoInfoOverlay()) {
|
||||||
const showAtSecondsLeft = runtimeTicks >= 3e10 ? 40 : runtimeTicks >= 24e9 ? 35 : 30;
|
let showAtSecondsLeft = 30;
|
||||||
|
if (runtimeTicks >= 3e10) {
|
||||||
|
showAtSecondsLeft = 40;
|
||||||
|
} else if (runtimeTicks >= 2.4e10) {
|
||||||
|
showAtSecondsLeft = 35;
|
||||||
|
}
|
||||||
const showAtTicks = runtimeTicks - 1e3 * showAtSecondsLeft * 1e4;
|
const showAtTicks = runtimeTicks - 1e3 * showAtSecondsLeft * 1e4;
|
||||||
const timeRemainingTicks = runtimeTicks - currentTimeTicks;
|
const timeRemainingTicks = runtimeTicks - currentTimeTicks;
|
||||||
|
|
||||||
|
|
|
@ -98,7 +98,7 @@ import autoFocuser from '../../components/autoFocuser';
|
||||||
SortOrder: 'Descending',
|
SortOrder: 'Descending',
|
||||||
IncludeItemTypes: 'Episode',
|
IncludeItemTypes: 'Episode',
|
||||||
Filters: 'IsResumable',
|
Filters: 'IsResumable',
|
||||||
Limit: screenWidth >= 1920 ? 5 : screenWidth >= 1600 ? 5 : 3,
|
Limit: screenWidth >= 1600 ? 5 : 3,
|
||||||
Recursive: true,
|
Recursive: true,
|
||||||
Fields: 'PrimaryImageAspectRatio,MediaSourceCount,BasicSyncInfo',
|
Fields: 'PrimaryImageAspectRatio,MediaSourceCount,BasicSyncInfo',
|
||||||
CollapseBoxSetItems: false,
|
CollapseBoxSetItems: false,
|
||||||
|
|
|
@ -53,7 +53,12 @@ function disableOneEvent(event) {
|
||||||
* @return {Number}
|
* @return {Number}
|
||||||
*/
|
*/
|
||||||
function within(number, min, max) {
|
function within(number, min, max) {
|
||||||
return number < min ? min : number > max ? max : number;
|
if (number < min) {
|
||||||
|
return min;
|
||||||
|
} else if (number > max) {
|
||||||
|
return max;
|
||||||
|
}
|
||||||
|
return number;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Other global values
|
// Other global values
|
||||||
|
|
|
@ -288,10 +288,16 @@ import browser from './browser';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return browser.ps4 ? 8000000 :
|
let bitrate = null;
|
||||||
(browser.xboxOne ? 12000000 :
|
if (browser.ps4) {
|
||||||
(browser.edgeUwp ? null :
|
bitrate = 8000000;
|
||||||
(browser.tizen && isTizenFhd ? 20000000 : null)));
|
} else if (browser.xboxOne) {
|
||||||
|
bitrate = 12000000;
|
||||||
|
} else if (browser.tizen && isTizenFhd) {
|
||||||
|
bitrate = 20000000;
|
||||||
|
}
|
||||||
|
|
||||||
|
return bitrate;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSpeakerCount() {
|
function getSpeakerCount() {
|
||||||
|
@ -381,9 +387,7 @@ import browser from './browser';
|
||||||
}
|
}
|
||||||
|
|
||||||
/* eslint-disable compat/compat */
|
/* eslint-disable compat/compat */
|
||||||
let maxVideoWidth = browser.xboxOne ?
|
let maxVideoWidth = (browser.xboxOne && window.screen) ? window.screen.width : null;
|
||||||
(window.screen ? window.screen.width : null) :
|
|
||||||
null;
|
|
||||||
|
|
||||||
/* eslint-enable compat/compat */
|
/* eslint-enable compat/compat */
|
||||||
if (options.maxVideoWidth) {
|
if (options.maxVideoWidth) {
|
||||||
|
|
|
@ -793,7 +793,12 @@ import { getParameterByName } from '../utils/url.ts';
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateMenuForPageType(isDashboardPage, isLibraryPage) {
|
function updateMenuForPageType(isDashboardPage, isLibraryPage) {
|
||||||
const newPageType = isDashboardPage ? 2 : isLibraryPage ? 1 : 3;
|
let newPageType = 3;
|
||||||
|
if (isDashboardPage) {
|
||||||
|
newPageType = 2;
|
||||||
|
} else if (isLibraryPage) {
|
||||||
|
newPageType = 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (currentPageType !== newPageType) {
|
if (currentPageType !== newPageType) {
|
||||||
currentPageType = newPageType;
|
currentPageType = newPageType;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue