1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

Merge branch 'master' into migrate-to-ES6-47

This commit is contained in:
Cameron 2020-07-31 21:27:48 +01:00 committed by GitHub
commit ee14ae76db
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
107 changed files with 1532 additions and 2239 deletions

View file

@ -16,7 +16,7 @@ import 'listViewStyle';
let color = '#00a4dc';
let icon = 'notifications';
if ('Error' == entry.Severity || 'Fatal' == entry.Severity || 'Warn' == entry.Severity) {
if (entry.Severity == 'Error' || entry.Severity == 'Fatal' || entry.Severity == 'Warn') {
color = '#cc0000';
icon = 'notification_important';
}
@ -60,13 +60,13 @@ import 'listViewStyle';
}
function reloadData(instance, elem, apiClient, startIndex, limit) {
if (null == startIndex) {
if (startIndex == null) {
startIndex = parseInt(elem.getAttribute('data-activitystartindex') || '0');
}
limit = limit || parseInt(elem.getAttribute('data-activitylimit') || '7');
const minDate = new Date();
const hasUserId = 'false' !== elem.getAttribute('data-useractivity');
const hasUserId = elem.getAttribute('data-useractivity') !== 'false';
// TODO: Use date-fns
if (hasUserId) {

View file

@ -47,7 +47,7 @@ define(['appSettings', 'browser', 'events', 'htmlMediaHelper', 'webSettings', 'g
profile = window.NativeShell.AppHost.getDeviceProfile(profileBuilder);
} else {
var builderOpts = getBaseProfileOptions(item);
builderOpts.enableSsaRender = (item && !options.isRetry && 'allcomplexformats' !== appSettings.get('subtitleburnin'));
builderOpts.enableSsaRender = (item && !options.isRetry && appSettings.get('subtitleburnin') !== 'allcomplexformats');
profile = profileBuilder(builderOpts);
}
@ -370,7 +370,7 @@ define(['appSettings', 'browser', 'events', 'htmlMediaHelper', 'webSettings', 'g
return window.NativeShell.AppHost.supports(command);
}
return -1 !== supportedFeatures.indexOf(command.toLowerCase());
return supportedFeatures.indexOf(command.toLowerCase()) !== -1;
},
preferVisualCards: browser.android || browser.chrome,
getSyncProfile: getSyncProfile,

View file

@ -277,7 +277,7 @@ import 'programStyles';
*/
function getImageWidth(shape, screenWidth, isOrientationLandscape) {
const imagesPerRow = getPostersPerRow(shape, screenWidth, isOrientationLandscape);
return Math.round(screenWidth / imagesPerRow) * 2;
return Math.round(screenWidth / imagesPerRow);
}
/**

View file

@ -73,7 +73,7 @@ import browser from 'browser';
if (ImageTag) {
return apiClient.getScaledImageUrl(Id, {
maxWidth: maxWidth * 2,
maxWidth: maxWidth,
tag: ImageTag,
type: 'Chapter',
index

View file

@ -129,7 +129,7 @@ import 'emby-itemscontainer';
let promise;
if ('MusicArtist' === section.types) {
if (section.types === 'MusicArtist') {
promise = ApiClient.getArtists(userId, options);
} else {
options.IncludeItemTypes = section.types;
@ -169,7 +169,7 @@ import 'emby-itemscontainer';
preferThumb: section.preferThumb,
shape: section.shape,
centerText: section.centerText && !cardLayout,
overlayText: false !== section.overlayText,
overlayText: section.overlayText !== false,
showTitle: section.showTitle,
showParentTitle: section.showParentTitle,
scalable: true,
@ -201,7 +201,7 @@ import 'emby-itemscontainer';
if (types) {
sections = sections.filter(function (s) {
return -1 !== types.indexOf(s.id);
return types.indexOf(s.id) !== -1;
});
}
@ -222,7 +222,7 @@ import 'emby-itemscontainer';
for (let i = 0, length = sections.length; i < length; i++) {
const section = sections[i];
elem = page.querySelector('.section' + section.id);
promises.push(loadSection(elem, userId, topParentId, section, 1 === sections.length));
promises.push(loadSection(elem, userId, topParentId, section, sections.length === 1));
}
Promise.all(promises).then(function () {

View file

@ -21,7 +21,7 @@ import connectionManager from 'connectionManager';
if (!actionableParent || actionableParent.classList.contains('cardContent')) {
apiClient.getJSON(apiClient.getUrl('Users/' + userId + '/Items/Latest', options)).then(function (items) {
if (1 === items.length) {
if (items.length === 1) {
return void appRouter.showItem(items[0]);
}

View file

@ -16,7 +16,7 @@ import 'emby-input';
return {
Type: type,
MinWidth: 0,
Limit: 'Primary' === type ? 1 : 0
Limit: type === 'Primary' ? 1 : 0
};
}

View file

@ -1,342 +1,350 @@
define(['apphost', 'globalize'], function (appHost, globalize) {
'use strict';
import appHost from 'apphost';
import globalize from 'globalize';
function getDisplayName(item, options = {}) {
if (!item) {
throw new Error('null item passed into getDisplayName');
export function getDisplayName(item, options = {}) {
if (!item) {
throw new Error('null item passed into getDisplayName');
}
if (item.Type === 'Timer') {
item = item.ProgramInfo || item;
}
let name = ((item.Type === 'Program' || item.Type === 'Recording') && (item.IsSeries || item.EpisodeTitle) ? item.EpisodeTitle : item.Name) || '';
if (item.Type === 'TvChannel') {
if (item.ChannelNumber) {
return item.ChannelNumber + ' ' + name;
}
if (item.Type === 'Timer') {
item = item.ProgramInfo || item;
}
var name = ((item.Type === 'Program' || item.Type === 'Recording') && (item.IsSeries || item.EpisodeTitle) ? item.EpisodeTitle : item.Name) || '';
if (item.Type === 'TvChannel') {
if (item.ChannelNumber) {
return item.ChannelNumber + ' ' + name;
}
return name;
}
if (item.Type === 'Episode' && item.ParentIndexNumber === 0) {
name = globalize.translate('ValueSpecialEpisodeName', name);
} else if ((item.Type === 'Episode' || item.Type === 'Program') && item.IndexNumber != null && item.ParentIndexNumber != null && options.includeIndexNumber !== false) {
var displayIndexNumber = item.IndexNumber;
var number = displayIndexNumber;
var nameSeparator = ' - ';
if (options.includeParentInfo !== false) {
number = 'S' + item.ParentIndexNumber + ':E' + number;
} else {
nameSeparator = '. ';
}
if (item.IndexNumberEnd) {
displayIndexNumber = item.IndexNumberEnd;
number += '-' + displayIndexNumber;
}
if (number) {
name = name ? (number + nameSeparator + name) : number;
}
}
return name;
}
if (item.Type === 'Episode' && item.ParentIndexNumber === 0) {
name = globalize.translate('ValueSpecialEpisodeName', name);
} else if ((item.Type === 'Episode' || item.Type === 'Program') && item.IndexNumber != null && item.ParentIndexNumber != null && options.includeIndexNumber !== false) {
let displayIndexNumber = item.IndexNumber;
function supportsAddingToCollection(item) {
var invalidTypes = ['Genre', 'MusicGenre', 'Studio', 'UserView', 'CollectionFolder', 'Audio', 'Program', 'Timer', 'SeriesTimer'];
let number = displayIndexNumber;
let nameSeparator = ' - ';
if (item.Type === 'Recording') {
if (item.Status !== 'Completed') {
return false;
}
if (options.includeParentInfo !== false) {
number = 'S' + item.ParentIndexNumber + ':E' + number;
} else {
nameSeparator = '. ';
}
return !item.CollectionType && invalidTypes.indexOf(item.Type) === -1 && item.MediaType !== 'Photo' && !isLocalItem(item);
if (item.IndexNumberEnd) {
displayIndexNumber = item.IndexNumberEnd;
number += '-' + displayIndexNumber;
}
if (number) {
name = name ? (number + nameSeparator + name) : number;
}
}
function supportsAddingToPlaylist(item) {
if (item.Type === 'Program') {
return false;
}
if (item.Type === 'TvChannel') {
return false;
}
if (item.Type === 'Timer') {
return false;
}
if (item.Type === 'SeriesTimer') {
return false;
}
if (item.MediaType === 'Photo') {
return false;
}
return name;
}
if (item.Type === 'Recording') {
if (item.Status !== 'Completed') {
return false;
}
}
export function supportsAddingToCollection(item) {
const invalidTypes = ['Genre', 'MusicGenre', 'Studio', 'UserView', 'CollectionFolder', 'Audio', 'Program', 'Timer', 'SeriesTimer'];
if (isLocalItem(item)) {
if (item.Type === 'Recording') {
if (item.Status !== 'Completed') {
return false;
}
if (item.CollectionType === 'livetv') {
return false;
}
return item.MediaType || item.IsFolder || item.Type === 'Genre' || item.Type === 'MusicGenre' || item.Type === 'MusicArtist';
}
function canEdit(user, item) {
var itemType = item.Type;
return !item.CollectionType && invalidTypes.indexOf(item.Type) === -1 && item.MediaType !== 'Photo' && !isLocalItem(item);
}
if (itemType === 'UserRootFolder' || itemType === 'UserView') {
return false;
}
if (itemType === 'Program') {
return false;
}
if (itemType === 'Timer') {
return false;
}
if (itemType === 'SeriesTimer') {
return false;
}
if (item.Type === 'Recording') {
if (item.Status !== 'Completed') {
return false;
}
}
if (isLocalItem(item)) {
return false;
}
return user.Policy.IsAdministrator;
export function supportsAddingToPlaylist(item) {
if (item.Type === 'Program') {
return false;
}
if (item.Type === 'TvChannel') {
return false;
}
if (item.Type === 'Timer') {
return false;
}
if (item.Type === 'SeriesTimer') {
return false;
}
if (item.MediaType === 'Photo') {
return false;
}
function isLocalItem(item) {
if (item && item.Id && item.Id.indexOf('local') === 0) {
if (item.Type === 'Recording') {
if (item.Status !== 'Completed') {
return false;
}
}
if (isLocalItem(item)) {
return false;
}
if (item.CollectionType === 'livetv') {
return false;
}
return item.MediaType || item.IsFolder || item.Type === 'Genre' || item.Type === 'MusicGenre' || item.Type === 'MusicArtist';
}
export function canEdit(user, item) {
const itemType = item.Type;
if (itemType === 'UserRootFolder' || itemType === 'UserView') {
return false;
}
if (itemType === 'Program') {
return false;
}
if (itemType === 'Timer') {
return false;
}
if (itemType === 'SeriesTimer') {
return false;
}
if (item.Type === 'Recording') {
if (item.Status !== 'Completed') {
return false;
}
}
if (isLocalItem(item)) {
return false;
}
return user.Policy.IsAdministrator;
}
export function isLocalItem(item) {
if (item && item.Id && item.Id.indexOf('local') === 0) {
return true;
}
return false;
}
export function canIdentify (user, item) {
const itemType = item.Type;
if (itemType === 'Movie' ||
itemType === 'Trailer' ||
itemType === 'Series' ||
itemType === 'BoxSet' ||
itemType === 'Person' ||
itemType === 'Book' ||
itemType === 'MusicAlbum' ||
itemType === 'MusicArtist' ||
itemType === 'MusicVideo') {
if (user.Policy.IsAdministrator) {
if (!isLocalItem(item)) {
return true;
}
}
}
return false;
}
export function canEditImages (user, item) {
const itemType = item.Type;
if (item.MediaType === 'Photo') {
return false;
}
if (itemType === 'UserView') {
if (user.Policy.IsAdministrator) {
return true;
}
return false;
}
return {
getDisplayName: getDisplayName,
supportsAddingToCollection: supportsAddingToCollection,
supportsAddingToPlaylist: supportsAddingToPlaylist,
isLocalItem: isLocalItem,
canIdentify: function (user, item) {
var itemType = item.Type;
if (itemType === 'Movie' ||
itemType === 'Trailer' ||
itemType === 'Series' ||
itemType === 'BoxSet' ||
itemType === 'Person' ||
itemType === 'Book' ||
itemType === 'MusicAlbum' ||
itemType === 'MusicArtist' ||
itemType === 'MusicVideo') {
if (user.Policy.IsAdministrator) {
if (!isLocalItem(item)) {
return true;
}
}
}
if (item.Type === 'Recording') {
if (item.Status !== 'Completed') {
return false;
},
}
}
canEdit: canEdit,
return itemType !== 'Timer' && itemType !== 'SeriesTimer' && canEdit(user, item) && !isLocalItem(item);
}
canEditImages: function (user, item) {
var itemType = item.Type;
export function canSync (user, item) {
if (user && !user.Policy.EnableContentDownloading) {
return false;
}
if (item.MediaType === 'Photo') {
return false;
}
if (isLocalItem(item)) {
return false;
}
if (itemType === 'UserView') {
if (user.Policy.IsAdministrator) {
return true;
}
return false;
}
if (item.Type === 'Recording') {
if (item.Status !== 'Completed') {
return false;
}
}
return itemType !== 'Timer' && itemType !== 'SeriesTimer' && canEdit(user, item) && !isLocalItem(item);
},
canSync: function (user, item) {
if (user && !user.Policy.EnableContentDownloading) {
return false;
}
if (isLocalItem(item)) {
return false;
}
return item.SupportsSync;
},
canShare: function (item, user) {
if (item.Type === 'Program') {
return false;
}
if (item.Type === 'TvChannel') {
return false;
}
if (item.Type === 'Timer') {
return false;
}
if (item.Type === 'SeriesTimer') {
return false;
}
if (item.Type === 'Recording') {
if (item.Status !== 'Completed') {
return false;
}
}
if (isLocalItem(item)) {
return false;
}
return user.Policy.EnablePublicSharing && appHost.supports('sharing');
},
enableDateAddedDisplay: function (item) {
return !item.IsFolder && item.MediaType && item.Type !== 'Program' && item.Type !== 'TvChannel' && item.Type !== 'Trailer';
},
canMarkPlayed: function (item) {
if (item.Type === 'Program') {
return false;
}
if (item.MediaType === 'Video') {
if (item.Type !== 'TvChannel') {
return true;
}
} else if (item.MediaType === 'Audio') {
if (item.Type === 'AudioPodcast') {
return true;
}
if (item.Type === 'AudioBook') {
return true;
}
}
if (item.Type === 'Series' ||
item.Type === 'Season' ||
item.Type === 'BoxSet' ||
item.MediaType === 'Book' ||
item.MediaType === 'Recording') {
return true;
}
return item.SupportsSync;
}
export function canShare (item, user) {
if (item.Type === 'Program') {
return false;
}
if (item.Type === 'TvChannel') {
return false;
}
if (item.Type === 'Timer') {
return false;
}
if (item.Type === 'SeriesTimer') {
return false;
}
if (item.Type === 'Recording') {
if (item.Status !== 'Completed') {
return false;
},
}
}
if (isLocalItem(item)) {
return false;
}
return user.Policy.EnablePublicSharing && appHost.supports('sharing');
}
canRate: function (item) {
if (item.Type === 'Program'
|| item.Type === 'Timer'
|| item.Type === 'SeriesTimer'
|| item.Type === 'CollectionFolder'
|| item.Type === 'UserView'
|| item.Type === 'Channel'
|| !item.UserData) {
return false;
}
export function enableDateAddedDisplay (item) {
return !item.IsFolder && item.MediaType && item.Type !== 'Program' && item.Type !== 'TvChannel' && item.Type !== 'Trailer';
}
return true;
},
canConvert: function (item, user) {
if (!user.Policy.EnableMediaConversion) {
return false;
}
if (isLocalItem(item)) {
return false;
}
var mediaType = item.MediaType;
if (mediaType === 'Book' || mediaType === 'Photo' || mediaType === 'Audio') {
return false;
}
var collectionType = item.CollectionType;
if (collectionType === 'livetv') {
return false;
}
var type = item.Type;
if (type === 'Channel' || type === 'Person' || type === 'Year' || type === 'Program' || type === 'Timer' || type === 'SeriesTimer') {
return false;
}
if (item.LocationType === 'Virtual' && !item.IsFolder) {
return false;
}
if (item.IsPlaceHolder) {
return false;
}
return true;
},
canRefreshMetadata: function (item, user) {
if (user.Policy.IsAdministrator) {
var collectionType = item.CollectionType;
if (collectionType === 'livetv') {
return false;
}
if (item.Type !== 'Timer' && item.Type !== 'SeriesTimer' && item.Type !== 'Program' && item.Type !== 'TvChannel' && !(item.Type === 'Recording' && item.Status !== 'Completed')) {
if (!isLocalItem(item)) {
return true;
}
}
}
return false;
},
supportsMediaSourceSelection: function (item) {
if (item.MediaType !== 'Video') {
return false;
}
if (item.Type === 'TvChannel') {
return false;
}
if (!item.MediaSources || (item.MediaSources.length === 1 && item.MediaSources[0].Type === 'Placeholder')) {
return false;
}
if (item.EnableMediaSourceDisplay === false) {
return false;
}
if (item.EnableMediaSourceDisplay == null && item.SourceType && item.SourceType !== 'Library') {
return false;
}
export function canMarkPlayed (item) {
if (item.Type === 'Program') {
return false;
}
if (item.MediaType === 'Video') {
if (item.Type !== 'TvChannel') {
return true;
}
};
});
} else if (item.MediaType === 'Audio') {
if (item.Type === 'AudioPodcast') {
return true;
}
if (item.Type === 'AudioBook') {
return true;
}
}
if (item.Type === 'Series' ||
item.Type === 'Season' ||
item.Type === 'BoxSet' ||
item.MediaType === 'Book' ||
item.MediaType === 'Recording') {
return true;
}
return false;
}
export function canRate (item) {
if (item.Type === 'Program'
|| item.Type === 'Timer'
|| item.Type === 'SeriesTimer'
|| item.Type === 'CollectionFolder'
|| item.Type === 'UserView'
|| item.Type === 'Channel'
|| !item.UserData) {
return false;
}
return true;
}
export function canConvert (item, user) {
if (!user.Policy.EnableMediaConversion) {
return false;
}
if (isLocalItem(item)) {
return false;
}
const mediaType = item.MediaType;
if (mediaType === 'Book' || mediaType === 'Photo' || mediaType === 'Audio') {
return false;
}
const collectionType = item.CollectionType;
if (collectionType === 'livetv') {
return false;
}
const type = item.Type;
if (type === 'Channel' || type === 'Person' || type === 'Year' || type === 'Program' || type === 'Timer' || type === 'SeriesTimer') {
return false;
}
if (item.LocationType === 'Virtual' && !item.IsFolder) {
return false;
}
if (item.IsPlaceHolder) {
return false;
}
return true;
}
export function canRefreshMetadata (item, user) {
if (user.Policy.IsAdministrator) {
const collectionType = item.CollectionType;
if (collectionType === 'livetv') {
return false;
}
if (item.Type !== 'Timer' && item.Type !== 'SeriesTimer' && item.Type !== 'Program' && item.Type !== 'TvChannel' && !(item.Type === 'Recording' && item.Status !== 'Completed')) {
if (!isLocalItem(item)) {
return true;
}
}
}
return false;
}
export function supportsMediaSourceSelection (item) {
if (item.MediaType !== 'Video') {
return false;
}
if (item.Type === 'TvChannel') {
return false;
}
if (!item.MediaSources || (item.MediaSources.length === 1 && item.MediaSources[0].Type === 'Placeholder')) {
return false;
}
if (item.EnableMediaSourceDisplay === false) {
return false;
}
if (item.EnableMediaSourceDisplay == null && item.SourceType && item.SourceType !== 'Library') {
return false;
}
return true;
}
export default {
getDisplayName: getDisplayName,
supportsAddingToCollection: supportsAddingToCollection,
supportsAddingToPlaylist: supportsAddingToPlaylist,
isLocalItem: isLocalItem,
canIdentify: canIdentify,
canEdit: canEdit,
canEditImages: canEditImages,
canSync: canSync,
canShare: canShare,
enableDateAddedDisplay: enableDateAddedDisplay,
canMarkPlayed: canMarkPlayed,
canRate: canRate,
canConvert: canConvert,
canRefreshMetadata: canRefreshMetadata,
supportsMediaSourceSelection: supportsMediaSourceSelection
};

View file

@ -219,7 +219,7 @@ import 'emby-input';
html += '<div class="flex align-items-center" style="margin:1.5em 0 .5em;">';
html += '<h3 class="checkboxListLabel" style="margin:0;">' + globalize.translate('HeaderTypeImageFetchers', availableTypeOptions.Type) + '</h3>';
const supportedImageTypes = availableTypeOptions.SupportedImageTypes || [];
if (supportedImageTypes.length > 1 || 1 === supportedImageTypes.length && 'Primary' !== supportedImageTypes[0]) {
if (supportedImageTypes.length > 1 || supportedImageTypes.length === 1 && supportedImageTypes[0] !== 'Primary') {
html += '<button is="emby-button" class="raised btnImageOptionsForType" type="button" style="margin-left:1.5em;font-size:90%;"><span>' + globalize.translate('HeaderFetcherSettings') + '</span></button>';
}
html += '</div>';
@ -362,7 +362,7 @@ import 'emby-input';
TypeOptions: []
};
currentAvailableOptions = null;
const isNewLibrary = null === libraryOptions;
const isNewLibrary = libraryOptions === null;
isNewLibrary && parent.classList.add('newlibrary');
const response = await fetch('components/libraryoptionseditor/libraryoptionseditor.template.html');
const template = await response.text();
@ -578,7 +578,7 @@ import 'emby-input';
parent.querySelector('#chkSkipIfAudioTrackPresent').checked = options.SkipSubtitlesIfAudioTrackMatches;
parent.querySelector('#chkRequirePerfectMatch').checked = options.RequirePerfectSubtitleMatch;
Array.prototype.forEach.call(parent.querySelectorAll('.chkMetadataSaver'), elem => {
elem.checked = options.MetadataSavers ? options.MetadataSavers.includes(elem.getAttribute('data-pluginname')) : 'true' === elem.getAttribute('data-defaultenabled');
elem.checked = options.MetadataSavers ? options.MetadataSavers.includes(elem.getAttribute('data-pluginname')) : elem.getAttribute('data-defaultenabled') === 'true';
});
Array.prototype.forEach.call(parent.querySelectorAll('.chkSubtitleLanguage'), elem => {
elem.checked = !!options.SubtitleDownloadLanguages && options.SubtitleDownloadLanguages.includes(elem.getAttribute('data-lang'));

View file

@ -81,7 +81,7 @@ import 'emby-playstatebutton';
let itemId;
const options = {
maxWidth: width * 2,
maxWidth: width,
type: 'Primary'
};
@ -108,7 +108,7 @@ import 'emby-playstatebutton';
function getChannelImageUrl(item, width) {
const apiClient = connectionManager.getApiClient(item.ServerId);
const options = {
maxWidth: width * 2,
maxWidth: width,
type: 'Primary'
};

View file

@ -98,8 +98,8 @@ import 'flexStyles';
if (listItem) {
const index = parseInt(listItem.getAttribute('data-index'));
const pathInfos = (currentOptions.library.LibraryOptions || {}).PathInfos || [];
const pathInfo = null == index ? {} : pathInfos[index] || {};
const originalPath = pathInfo.Path || (null == index ? null : currentOptions.library.Locations[index]);
const pathInfo = index == null ? {} : pathInfos[index] || {};
const originalPath = pathInfo.Path || (index == null ? null : currentOptions.library.Locations[index]);
const btnRemovePath = dom.parentWithClass(e.target, 'btnRemovePath');
if (btnRemovePath) {
@ -171,7 +171,7 @@ import 'flexStyles';
const picker = new directoryBrowser();
picker.show({
enableNetworkSharePath: true,
pathReadOnly: null != originalPath,
pathReadOnly: originalPath != null,
path: originalPath,
networkSharePath: networkPath,
callback: function (path, networkSharePath) {

View file

@ -85,7 +85,7 @@
<div class="selectContainer">
<select is="emby-select" class="selectChromecastVersion" label="${LabelChromecastVersion}">
<option value="stable">${LabelStable}</option>
<option value="nightly">${LabelNightly}</option>
<option value="unstable">${LabelUnstable}</option>
</select>
</div>

View file

@ -48,7 +48,7 @@ define(['browser', 'datetime', 'backdrop', 'libraryBrowser', 'listView', 'imageL
menuItems.unshift({
id: -1,
name: globalize.translate('ButtonOff'),
selected: null == currentIndex
selected: currentIndex == null
});
require(['actionsheet'], function (actionsheet) {
@ -69,18 +69,18 @@ define(['browser', 'datetime', 'backdrop', 'libraryBrowser', 'listView', 'imageL
}
function seriesImageUrl(item, options) {
if ('Episode' !== item.Type) {
if (item.Type !== 'Episode') {
return null;
}
options = options || {};
options.type = options.type || 'Primary';
if ('Primary' === options.type && item.SeriesPrimaryImageTag) {
if (options.type === 'Primary' && item.SeriesPrimaryImageTag) {
options.tag = item.SeriesPrimaryImageTag;
return connectionManager.getApiClient(item.ServerId).getScaledImageUrl(item.SeriesId, options);
}
if ('Thumb' === options.type) {
if (options.type === 'Thumb') {
if (item.SeriesThumbImageTag) {
options.tag = item.SeriesThumbImageTag;
return connectionManager.getApiClient(item.ServerId).getScaledImageUrl(item.SeriesId, options);
@ -171,9 +171,9 @@ define(['browser', 'datetime', 'backdrop', 'libraryBrowser', 'listView', 'imageL
}
var url = item ? seriesImageUrl(item, {
maxHeight: 300 * 2
maxHeight: 300
}) || imageUrl(item, {
maxHeight: 300 * 2
maxHeight: 300
}) : null;
let contextButton = context.querySelector('.btnToggleContextMenu');
@ -210,7 +210,7 @@ define(['browser', 'datetime', 'backdrop', 'libraryBrowser', 'listView', 'imageL
backdrop.setBackdrops([item]);
apiClient.getItem(apiClient.getCurrentUserId(), item.Id).then(function (fullItem) {
var userData = fullItem.UserData || {};
var likes = null == userData.Likes ? '' : userData.Likes;
var likes = userData.Likes == null ? '' : userData.Likes;
context.querySelector('.nowPlayingPageUserDataButtonsTitle').innerHTML = '<button is="emby-ratingbutton" type="button" class="listItemButton paper-icon-button-light" data-id="' + fullItem.Id + '" data-serverid="' + fullItem.ServerId + '" data-itemtype="' + fullItem.Type + '" data-likes="' + likes + '" data-isfavorite="' + userData.IsFavorite + '"><span class="material-icons favorite"></span></button>';
context.querySelector('.nowPlayingPageUserDataButtons').innerHTML = '<button is="emby-ratingbutton" type="button" class="listItemButton paper-icon-button-light" data-id="' + fullItem.Id + '" data-serverid="' + fullItem.ServerId + '" data-itemtype="' + fullItem.Type + '" data-likes="' + likes + '" data-isfavorite="' + userData.IsFavorite + '"><span class="material-icons favorite"></span></button>';
});
@ -251,7 +251,7 @@ define(['browser', 'datetime', 'backdrop', 'libraryBrowser', 'listView', 'imageL
var all = context.querySelectorAll('.btnCommand');
for (var i = 0, length = all.length; i < length; i++) {
var enableButton = -1 !== commands.indexOf(all[i].getAttribute('data-command'));
var enableButton = commands.indexOf(all[i].getAttribute('data-command')) !== -1;
all[i].disabled = !enableButton;
}
}
@ -278,7 +278,7 @@ define(['browser', 'datetime', 'backdrop', 'libraryBrowser', 'listView', 'imageL
currentPlayerSupportedCommands = supportedCommands;
var playState = state.PlayState || {};
var isSupportedCommands = supportedCommands.includes('DisplayMessage') || supportedCommands.includes('SendString') || supportedCommands.includes('Select');
buttonVisible(context.querySelector('.btnToggleFullscreen'), item && 'Video' == item.MediaType && supportedCommands.includes('ToggleFullscreen'));
buttonVisible(context.querySelector('.btnToggleFullscreen'), item && item.MediaType == 'Video' && supportedCommands.includes('ToggleFullscreen'));
updateAudioTracksDisplay(player, context);
updateSubtitleTracksDisplay(player, context);
@ -306,15 +306,15 @@ define(['browser', 'datetime', 'backdrop', 'libraryBrowser', 'listView', 'imageL
context.querySelector('.remoteControlSection').classList.add('hide');
}
buttonVisible(context.querySelector('.btnStop'), null != item);
buttonVisible(context.querySelector('.btnNextTrack'), null != item);
buttonVisible(context.querySelector('.btnPreviousTrack'), null != item);
buttonVisible(context.querySelector('.btnStop'), item != null);
buttonVisible(context.querySelector('.btnNextTrack'), item != null);
buttonVisible(context.querySelector('.btnPreviousTrack'), item != null);
if (layoutManager.mobile) {
buttonVisible(context.querySelector('.btnRewind'), false);
buttonVisible(context.querySelector('.btnFastForward'), false);
} else {
buttonVisible(context.querySelector('.btnRewind'), null != item);
buttonVisible(context.querySelector('.btnFastForward'), null != item);
buttonVisible(context.querySelector('.btnRewind'), item != null);
buttonVisible(context.querySelector('.btnFastForward'), item != null);
}
var positionSlider = context.querySelector('.nowPlayingPositionSlider');
@ -325,15 +325,15 @@ define(['browser', 'datetime', 'backdrop', 'libraryBrowser', 'listView', 'imageL
if (positionSlider && !positionSlider.dragging) {
positionSlider.disabled = !playState.CanSeek;
var isProgressClear = state.MediaSource && null == state.MediaSource.RunTimeTicks;
var isProgressClear = state.MediaSource && state.MediaSource.RunTimeTicks == null;
positionSlider.setIsClear(isProgressClear);
}
updatePlayPauseState(playState.IsPaused, null != item);
updatePlayPauseState(playState.IsPaused, item != null);
updateTimeDisplay(playState.PositionTicks, item ? item.RunTimeTicks : null);
updatePlayerVolumeState(context, playState.IsMuted, playState.VolumeLevel);
if (item && 'Video' == item.MediaType) {
if (item && item.MediaType == 'Video') {
context.classList.remove('hideVideoButtons');
} else {
context.classList.add('hideVideoButtons');
@ -346,12 +346,12 @@ define(['browser', 'datetime', 'backdrop', 'libraryBrowser', 'listView', 'imageL
function updateAudioTracksDisplay(player, context) {
var supportedCommands = currentPlayerSupportedCommands;
buttonVisible(context.querySelector('.btnAudioTracks'), playbackManager.audioTracks(player).length > 1 && -1 != supportedCommands.indexOf('SetAudioStreamIndex'));
buttonVisible(context.querySelector('.btnAudioTracks'), playbackManager.audioTracks(player).length > 1 && supportedCommands.indexOf('SetAudioStreamIndex') != -1);
}
function updateSubtitleTracksDisplay(player, context) {
var supportedCommands = currentPlayerSupportedCommands;
buttonVisible(context.querySelector('.btnSubtitles'), playbackManager.subtitleTracks(player).length && -1 != supportedCommands.indexOf('SetSubtitleStreamIndex'));
buttonVisible(context.querySelector('.btnSubtitles'), playbackManager.subtitleTracks(player).length && supportedCommands.indexOf('SetSubtitleStreamIndex') != -1);
}
function updateRepeatModeDisplay(repeatMode) {
@ -383,11 +383,11 @@ define(['browser', 'datetime', 'backdrop', 'libraryBrowser', 'listView', 'imageL
var view = context;
var supportedCommands = currentPlayerSupportedCommands;
if (-1 === supportedCommands.indexOf('Mute')) {
if (supportedCommands.indexOf('Mute') === -1) {
showMuteButton = false;
}
if (-1 === supportedCommands.indexOf('SetVolume')) {
if (supportedCommands.indexOf('SetVolume') === -1) {
showVolumeSlider = false;
}
@ -452,8 +452,8 @@ define(['browser', 'datetime', 'backdrop', 'libraryBrowser', 'listView', 'imageL
}
}
context.querySelector('.positionTime').innerHTML = null == positionTicks ? '--:--' : datetime.getDisplayRunningTime(positionTicks);
context.querySelector('.runtime').innerHTML = null != runtimeTicks ? datetime.getDisplayRunningTime(runtimeTicks) : '--:--';
context.querySelector('.positionTime').innerHTML = positionTicks == null ? '--:--' : datetime.getDisplayRunningTime(positionTicks);
context.querySelector('.runtime').innerHTML = runtimeTicks != null ? datetime.getDisplayRunningTime(runtimeTicks) : '--:--';
}
function getPlaylistItems(player) {

View file

@ -44,7 +44,7 @@ define(['jQuery', 'loading', 'globalize', 'emby-checkbox', 'listViewStyle', 'emb
for (var region in result) {
var countries = result[region];
if (countries.length && 'ZZZ' !== region) {
if (countries.length && region !== 'ZZZ') {
for (i = 0, length = countries.length; i < length; i++) {
countryList.push({
name: countries[i].fullName,
@ -239,7 +239,7 @@ define(['jQuery', 'loading', 'globalize', 'emby-checkbox', 'listViewStyle', 'emb
var device = devices[i];
html += '<div class="listItem">';
var enabledTuners = providerInfo.EnabledTuners || [];
var isChecked = providerInfo.EnableAllTuners || -1 !== enabledTuners.indexOf(device.Id);
var isChecked = providerInfo.EnableAllTuners || enabledTuners.indexOf(device.Id) !== -1;
var checkedAttribute = isChecked ? ' checked' : '';
html += '<label class="checkboxContainer listItemCheckboxContainer"><input type="checkbox" is="emby-checkbox" data-id="' + device.Id + '" class="chkTuner" ' + checkedAttribute + '/><span></span></label>';
html += '<div class="listItemBody two-line">';

View file

@ -86,7 +86,7 @@ define(['jQuery', 'loading', 'globalize', 'emby-checkbox', 'emby-input', 'listVi
}).then(function (result) {
loading.hide();
if (false !== options.showConfirmation) {
if (options.showConfirmation !== false) {
Dashboard.processServerConfigurationUpdateResult();
}
@ -120,7 +120,7 @@ define(['jQuery', 'loading', 'globalize', 'emby-checkbox', 'emby-input', 'listVi
var device = devices[i];
html += '<div class="listItem">';
var enabledTuners = providerInfo.EnabledTuners || [];
var isChecked = providerInfo.EnableAllTuners || -1 !== enabledTuners.indexOf(device.Id);
var isChecked = providerInfo.EnableAllTuners || enabledTuners.indexOf(device.Id) !== -1;
var checkedAttribute = isChecked ? ' checked' : '';
html += '<label class="listItemCheckboxContainer"><input type="checkbox" is="emby-checkbox" class="chkTuner" data-id="' + device.Id + '" ' + checkedAttribute + '><span></span></label>';
html += '<div class="listItemBody two-line">';

View file

@ -9,7 +9,7 @@ define(['browser', 'dom', 'layoutManager', 'css!components/viewManager/viewConta
var controllerUrl = view.getAttribute('data-controller');
if (controllerUrl) {
if (0 === controllerUrl.indexOf('__plugin/')) {
if (controllerUrl.indexOf('__plugin/') === 0) {
controllerUrl = controllerUrl.substring('__plugin/'.length);
}
@ -31,14 +31,14 @@ define(['browser', 'dom', 'layoutManager', 'css!components/viewManager/viewConta
function loadView(options) {
if (!options.cancel) {
var selected = selectedPageIndex;
var previousAnimatable = -1 === selected ? null : allPages[selected];
var previousAnimatable = selected === -1 ? null : allPages[selected];
var pageIndex = selected + 1;
if (pageIndex >= pageContainerCount) {
pageIndex = 0;
}
var isPluginpage = -1 !== options.url.toLowerCase().indexOf('/configurationpage');
var isPluginpage = options.url.toLowerCase().indexOf('/configurationpage') !== -1;
var newViewInfo = normalizeNewView(options, isPluginpage);
var newView = newViewInfo.elem;
var modulesToLoad = [];
@ -53,7 +53,7 @@ define(['browser', 'dom', 'layoutManager', 'css!components/viewManager/viewConta
var view = newView;
if ('string' == typeof view) {
if (typeof view == 'string') {
view = document.createElement('div');
view.innerHTML = newView;
}
@ -133,15 +133,15 @@ define(['browser', 'dom', 'layoutManager', 'css!components/viewManager/viewConta
function normalizeNewView(options, isPluginpage) {
var viewHtml = options.view;
if (-1 === viewHtml.indexOf('data-role="page"')) {
if (viewHtml.indexOf('data-role="page"') === -1) {
return viewHtml;
}
var hasScript = -1 !== viewHtml.indexOf('<script');
var hasScript = viewHtml.indexOf('<script') !== -1;
var elem = parseHtml(viewHtml, hasScript);
if (hasScript) {
hasScript = null != elem.querySelector('script');
hasScript = elem.querySelector('script') != null;
}
var hasjQuery = false;
@ -149,9 +149,9 @@ define(['browser', 'dom', 'layoutManager', 'css!components/viewManager/viewConta
var hasjQueryChecked = false;
if (isPluginpage) {
hasjQuery = -1 != viewHtml.indexOf('jQuery') || -1 != viewHtml.indexOf('$(') || -1 != viewHtml.indexOf('$.');
hasjQueryChecked = -1 != viewHtml.indexOf('.checked(');
hasjQuerySelect = -1 != viewHtml.indexOf('.selectmenu(');
hasjQuery = viewHtml.indexOf('jQuery') != -1 || viewHtml.indexOf('$(') != -1 || viewHtml.indexOf('$.') != -1;
hasjQueryChecked = viewHtml.indexOf('.checked(') != -1;
hasjQuerySelect = viewHtml.indexOf('.selectmenu(') != -1;
}
return {
@ -187,7 +187,7 @@ define(['browser', 'dom', 'layoutManager', 'css!components/viewManager/viewConta
var url = options.url;
var index = currentUrls.indexOf(url);
if (-1 !== index) {
if (index !== -1) {
var animatable = allPages[index];
var view = animatable;
@ -197,7 +197,7 @@ define(['browser', 'dom', 'layoutManager', 'css!components/viewManager/viewConta
}
var selected = selectedPageIndex;
var previousAnimatable = -1 === selected ? null : allPages[selected];
var previousAnimatable = selected === -1 ? null : allPages[selected];
return setControllerClass(view, options).then(function () {
if (onBeforeChange) {
onBeforeChange(view, true, options);