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 fix_long_getItems_request_URL

This commit is contained in:
dann-merlin 2023-03-14 22:03:44 +00:00 committed by GitHub
commit 09a6ef2cdb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
85 changed files with 358 additions and 320 deletions

View file

@ -19,7 +19,7 @@ import template from './accessSchedule.template.html';
const pct = hours % 1;
if (pct) {
minutes = parseInt(60 * pct);
minutes = parseInt(60 * pct, 10);
}
return datetime.getDisplayTime(new Date(2000, 1, 1, hours, minutes, 0, 0));

View file

@ -64,10 +64,10 @@ import { toBoolean } from '../utils/string.ts';
function reloadData(instance, elem, apiClient, startIndex, limit) {
if (startIndex == null) {
startIndex = parseInt(elem.getAttribute('data-activitystartindex') || '0');
startIndex = parseInt(elem.getAttribute('data-activitystartindex') || '0', 10);
}
limit = limit || parseInt(elem.getAttribute('data-activitylimit') || '7');
limit = limit || parseInt(elem.getAttribute('data-activitylimit') || '7', 10);
const minDate = new Date();
const hasUserId = toBoolean(elem.getAttribute('data-useractivity'), true);

View file

@ -18,6 +18,7 @@ import browser from '../../scripts/browser';
import { playbackManager } from '../playback/playbackmanager';
import itemShortcuts from '../shortcuts';
import imageHelper from '../../scripts/imagehelper';
import { randomInt } from '../../utils/number.ts';
import './card.scss';
import '../../elements/emby-button/paper-icon-button-light';
import '../guide/programs.scss';
@ -640,16 +641,6 @@ import { appRouter } from '../appRouter';
};
}
/**
* Generates a random integer in a given range.
* @param {number} min - Minimum of the range.
* @param {number} max - Maximum of the range.
* @returns {number} Randomly generated number.
*/
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
/**
* Generates an index used to select the default color of a card based on a string.
* @param {?string} [str] - String to use for generating the index.
@ -663,13 +654,13 @@ import { appRouter } from '../appRouter';
const character = String(str.slice(charIndex, charIndex + 1).charCodeAt());
let sum = 0;
for (let i = 0; i < character.length; i++) {
sum += parseInt(character.charAt(i));
sum += parseInt(character.charAt(i), 10);
}
const index = String(sum).slice(-1);
return (index % numRandomColors) + 1;
} else {
return getRandomInt(1, numRandomColors);
return randomInt(1, numRandomColors);
}
}

View file

@ -8,6 +8,7 @@ import datetime from '../../scripts/datetime';
import globalize from '../../scripts/globalize';
import loading from '../loading/loading';
import skinManager from '../../scripts/themeManager';
import { PluginType } from '../../types/plugin.ts';
import Events from '../../utils/events.ts';
import '../../elements/emby-select/emby-select';
import '../../elements/emby-checkbox/emby-checkbox';
@ -35,7 +36,7 @@ import template from './displaySettings.template.html';
function loadScreensavers(context, userSettings) {
const selectScreensaver = context.querySelector('.selectScreensaver');
const options = pluginManager.ofType('screensaver').map(plugin => {
const options = pluginManager.ofType(PluginType.Screensaver).map(plugin => {
return {
name: plugin.name,
value: plugin.id

View file

@ -13,7 +13,7 @@ import ServerConnections from './ServerConnections';
const playedIndicator = card.querySelector('.playedIndicator');
const playedIndicatorHtml = playedIndicator ? playedIndicator.innerHTML : null;
const options = {
Limit: parseInt(playedIndicatorHtml || '10'),
Limit: parseInt(playedIndicatorHtml || '10', 10),
Fields: 'PrimaryImageAspectRatio,DateCreated',
ParentId: itemId,
GroupItems: false

View file

@ -1149,12 +1149,12 @@ function Guide(options) {
guideContext.querySelector('.guideDateTabs').addEventListener('tabchange', function (e) {
const allTabButtons = e.target.querySelectorAll('.guide-date-tab-button');
const tabButton = allTabButtons[parseInt(e.detail.selectedTabIndex)];
const tabButton = allTabButtons[parseInt(e.detail.selectedTabIndex, 10)];
if (tabButton) {
const previousButton = e.detail.previousIndex == null ? null : allTabButtons[parseInt(e.detail.previousIndex)];
const previousButton = e.detail.previousIndex == null ? null : allTabButtons[parseInt(e.detail.previousIndex, 10)];
const date = new Date();
date.setTime(parseInt(tabButton.getAttribute('data-date')));
date.setTime(parseInt(tabButton.getAttribute('data-date'), 10));
const scrollWidth = programGrid.scrollWidth;
let scrollToTimeMs;
@ -1166,7 +1166,7 @@ function Guide(options) {
if (previousButton) {
const previousDate = new Date();
previousDate.setTime(parseInt(previousButton.getAttribute('data-date')));
previousDate.setTime(parseInt(previousButton.getAttribute('data-date'), 10));
scrollToTimeMs += (previousDate.getHours() * 60 * 60 * 1000);
scrollToTimeMs += (previousDate.getMinutes() * 60 * 1000);

View file

@ -278,9 +278,9 @@ import template from './imageeditor.template.html';
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'));
const index = parseInt(imageCard.getAttribute('data-index'), 10);
const providerCount = parseInt(imageCard.getAttribute('data-providers'), 10);
const numImages = parseInt(imageCard.getAttribute('data-numimages'), 10);
import('../actionSheet/actionSheet').then(({default: actionSheet}) => {
const commands = [];
@ -385,7 +385,7 @@ import template from './imageeditor.template.html';
addListeners(context, 'btnDeleteImage', 'click', function () {
const type = this.getAttribute('data-imagetype');
let index = this.getAttribute('data-index');
index = index === 'null' ? null : parseInt(index);
index = index === 'null' ? null : parseInt(index, 10);
const apiClient = ServerConnections.getApiClient(currentItem.ServerId);
deleteImage(context, currentItem.Id, type, index, apiClient, true);
});

View file

@ -15,7 +15,6 @@ import toast from './toast/toast';
const user = options.user;
const canPlay = playbackManager.canPlay(item);
const restrictOptions = (browser.operaTv || browser.web0s) && !user.Policy.IsAdministrator;
const commands = [];
@ -99,8 +98,8 @@ import toast from './toast/toast';
});
}
if (!restrictOptions) {
if (itemHelper.supportsAddingToCollection(item)) {
if (!browser.tv) {
if (itemHelper.supportsAddingToCollection(item) && options.EnableCollectionManagement) {
commands.push({
name: globalize.translate('AddToCollection'),
id: 'addtocollection',
@ -272,7 +271,7 @@ import toast from './toast/toast';
});
}
if (!restrictOptions && options.share === true && itemHelper.canShare(item, user)) {
if (!browser.tv && options.share === true && itemHelper.canShare(item, user)) {
commands.push({
name: globalize.translate('Share'),
id: 'share',

View file

@ -138,7 +138,7 @@ const attributeDelimiterHtml = layoutManager.tv ? '' : '<span class="hide">: </s
attributes.push(createAttribute(globalize.translate('MediaInfoChannels'), `${stream.Channels} ch`));
}
if (stream.BitRate) {
attributes.push(createAttribute(globalize.translate('MediaInfoBitrate'), `${parseInt(stream.BitRate / 1000)} kbps`));
attributes.push(createAttribute(globalize.translate('MediaInfoBitrate'), `${parseInt(stream.BitRate / 1000, 10)} kbps`));
}
if (stream.SampleRate) {
attributes.push(createAttribute(globalize.translate('MediaInfoSampleRate'), `${stream.SampleRate} Hz`));

View file

@ -52,7 +52,7 @@ import datetime from '../../scripts/datetime';
if (value) {
if (identifyField[i].type === 'number') {
value = parseInt(value);
value = parseInt(value, 10);
}
lookupInfo[identifyField[i].getAttribute('data-lookup')] = value;
@ -123,7 +123,7 @@ import datetime from '../../scripts/datetime';
elem.innerHTML = html;
function onSearchImageClick() {
const index = parseInt(this.getAttribute('data-index'));
const index = parseInt(this.getAttribute('data-index'), 10);
const currentResult = results[index];

View file

@ -531,7 +531,7 @@ import template from './libraryoptionseditor.template.html';
PreferredMetadataLanguage: parent.querySelector('#selectLanguage').value,
MetadataCountryCode: parent.querySelector('#selectCountry').value,
SeasonZeroDisplayName: parent.querySelector('#txtSeasonZeroName').value,
AutomaticRefreshIntervalDays: parseInt(parent.querySelector('#selectAutoRefreshInterval').value),
AutomaticRefreshIntervalDays: parseInt(parent.querySelector('#selectAutoRefreshInterval').value, 10),
EnableEmbeddedTitles: parent.querySelector('#chkEnableEmbeddedTitles').checked,
EnableEmbeddedExtrasTitles: parent.querySelector('#chkEnableEmbeddedExtrasTitles').checked,
EnableEmbeddedEpisodeInfos: parent.querySelector('#chkEnableEmbeddedEpisodeInfos').checked,

View file

@ -168,7 +168,7 @@ import template from './mediaLibraryCreator.template.html';
function onRemoveClick(e) {
const button = dom.parentWithClass(e.target, 'btnRemovePath');
const index = parseInt(button.getAttribute('data-index'));
const index = parseInt(button.getAttribute('data-index'), 10);
const location = pathInfos[index].Path;
const locationLower = location.toLowerCase();
pathInfos = pathInfos.filter(p => {

View file

@ -93,7 +93,7 @@ import template from './mediaLibraryEditor.template.html';
const listItem = dom.parentWithClass(e.target, 'listItem');
if (listItem) {
const index = parseInt(listItem.getAttribute('data-index'));
const index = parseInt(listItem.getAttribute('data-index'), 10);
const pathInfos = (currentOptions.library.LibraryOptions || {}).PathInfos || [];
const pathInfo = index == null ? {} : pathInfos[index] || {};
const originalPath = pathInfo.Path || (index == null ? null : currentOptions.library.Locations[index]);

View file

@ -357,14 +357,14 @@ import template from './metadataEditor.template.html';
let index;
const btnDeletePerson = dom.parentWithClass(e.target, 'btnDeletePerson');
if (btnDeletePerson) {
index = parseInt(btnDeletePerson.getAttribute('data-index'));
index = parseInt(btnDeletePerson.getAttribute('data-index'), 10);
currentItem.People.splice(index, 1);
populatePeople(context, currentItem.People);
}
const btnEditPerson = dom.parentWithClass(e.target, 'btnEditPerson');
if (btnEditPerson) {
index = parseInt(btnEditPerson.getAttribute('data-index'));
index = parseInt(btnEditPerson.getAttribute('data-index'), 10);
editPerson(context, currentItem.People[index], index);
}
});

View file

@ -114,8 +114,8 @@ import shell from '../../scripts/shell';
const itemId = item.Id;
// Convert to ms
const duration = parseInt(item.RunTimeTicks ? (item.RunTimeTicks / 10000) : 0);
const currentTime = parseInt(playState.PositionTicks ? (playState.PositionTicks / 10000) : 0);
const duration = parseInt(item.RunTimeTicks ? (item.RunTimeTicks / 10000) : 0, 10);
const currentTime = parseInt(playState.PositionTicks ? (playState.PositionTicks / 10000) : 0, 10);
const isPaused = playState.IsPaused || false;
const canSeek = playState.CanSeek || false;
@ -247,7 +247,7 @@ import shell from '../../scripts/shell';
navigator.mediaSession.setActionHandler('seekto', function (object) {
const item = playbackManager.getPlayerState(currentPlayer).NowPlayingItem;
// Convert to ms
const duration = parseInt(item.RunTimeTicks ? (item.RunTimeTicks / 10000) : 0);
const duration = parseInt(item.RunTimeTicks ? (item.RunTimeTicks / 10000) : 0, 10);
const wantedTime = object.seekTime * 1000;
playbackManager.seekPercent(wantedTime / duration * 100, currentPlayer);
});

View file

@ -11,6 +11,7 @@ import { appHost } from '../apphost';
import Screenfull from 'screenfull';
import ServerConnections from '../ServerConnections';
import alert from '../alert';
import { PluginType } from '../../types/plugin.ts';
import { includesAny } from '../../utils/container.ts';
import { getItems } from '../../utils/jellyfin-apiclient/getItems.ts';
@ -1693,7 +1694,7 @@ class PlaybackManager {
function changeStream(player, ticks, params) {
if (canPlayerSeek(player) && params == null) {
player.currentTime(parseInt(ticks / 10000));
player.currentTime(parseInt(ticks / 10000, 10));
return;
}
@ -1717,7 +1718,7 @@ class PlaybackManager {
const apiClient = ServerConnections.getApiClient(currentItem.ServerId);
if (ticks) {
ticks = parseInt(ticks);
ticks = parseInt(ticks, 10);
}
const maxBitrate = params.MaxStreamingBitrate || self.getMaxStreamingBitrate(player);
@ -2268,7 +2269,7 @@ class PlaybackManager {
function runInterceptors(item, playOptions) {
return new Promise(function (resolve, reject) {
const interceptors = pluginManager.ofType('preplayintercept');
const interceptors = pluginManager.ofType(PluginType.PreplayIntercept);
interceptors.sort(function (a, b) {
return (a.order || 0) - (b.order || 0);
@ -3429,12 +3430,12 @@ class PlaybackManager {
}
Events.on(pluginManager, 'registered', function (e, plugin) {
if (plugin.type === 'mediaplayer') {
if (plugin.type === PluginType.MediaPlayer) {
initMediaPlayer(plugin);
}
});
pluginManager.ofType('mediaplayer').forEach(initMediaPlayer);
pluginManager.ofType(PluginType.MediaPlayer).forEach(initMediaPlayer);
function sendProgressUpdate(player, progressEventName, reportPlaylist) {
if (!player) {
@ -3649,7 +3650,7 @@ class PlaybackManager {
percent /= 100;
ticks *= percent;
this.seek(parseInt(ticks), player);
this.seek(parseInt(ticks, 10), player);
}
seekMs(ms, player = this._currentPlayer) {
@ -4036,13 +4037,13 @@ class PlaybackManager {
this.setBrightness(cmd.Arguments.Brightness, player);
break;
case 'SetAudioStreamIndex':
this.setAudioStreamIndex(parseInt(cmd.Arguments.Index), player);
this.setAudioStreamIndex(parseInt(cmd.Arguments.Index, 10), player);
break;
case 'SetSubtitleStreamIndex':
this.setSubtitleStreamIndex(parseInt(cmd.Arguments.Index), player);
this.setSubtitleStreamIndex(parseInt(cmd.Arguments.Index, 10), player);
break;
case 'SetMaxStreamingBitrate':
this.setMaxStreamingBitrate(parseInt(cmd.Arguments.Bitrate), player);
this.setMaxStreamingBitrate(parseInt(cmd.Arguments.Bitrate, 10), player);
break;
case 'ToggleFullscreen':
this.toggleFullscreen(player);

View file

@ -43,7 +43,7 @@ function showQualityMenu(player, btn) {
items: menuItems,
positionTo: btn
}).then(function (id) {
const bitrate = parseInt(id);
const bitrate = parseInt(id, 10);
if (bitrate !== selectedBitrate) {
playbackManager.setMaxStreamingBitrate({
enableAutomaticBitrateDetection: bitrate ? false : true,

View file

@ -1,4 +1,4 @@
/*eslint prefer-const: "error"*/
import { randomInt } from '../../utils/number.ts';
let currentId = 0;
function addUniquePlaylistItemId(item) {
@ -58,7 +58,7 @@ class PlayQueueManager {
const currentPlaylistItem = this._playlist.splice(this.getCurrentPlaylistIndex(), 1)[0];
for (let i = this._playlist.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * i);
const j = randomInt(0, i - 1);
const temp = this._playlist[i];
this._playlist[i] = this._playlist[j];
this._playlist[j] = temp;

View file

@ -12,8 +12,6 @@ import ServerConnections from '../ServerConnections';
import toast from '../toast/toast';
import template from './recordingfields.template.html';
/*eslint prefer-const: "error"*/
function loadData(parent, program) {
if (program.IsSeries) {
parent.querySelector('.recordSeriesContainer').classList.remove('hide');

View file

@ -5,8 +5,6 @@ import toast from '../toast/toast';
import confirm from '../confirm/confirm';
import dialog from '../dialog/dialog';
/*eslint prefer-const: "error"*/
function changeRecordingToSeries(apiClient, timerId, programId, confirmTimerCancellation) {
loading.show();

View file

@ -17,8 +17,6 @@ import '../../styles/flexstyles.scss';
import ServerConnections from '../ServerConnections';
import template from './seriesrecordingeditor.template.html';
/*eslint prefer-const: "error"*/
let currentDialog;
let recordingUpdated = false;
let recordingDeleted = false;

View file

@ -13,8 +13,6 @@ import '../formdialog.scss';
import ServerConnections from '../ServerConnections';
import toast from '../toast/toast';
/*eslint prefer-const: "error"*/
function getEditorHtml() {
let html = '';

View file

@ -20,8 +20,6 @@ import ServerConnections from '../ServerConnections';
import toast from '../toast/toast';
import { appRouter } from '../appRouter';
/*eslint prefer-const: "error"*/
let showMuteButton = true;
let showVolumeSlider = true;
@ -46,7 +44,7 @@ function showAudioMenu(context, player, button) {
items: menuItems,
positionTo: button,
callback: function (id) {
playbackManager.setAudioStreamIndex(parseInt(id), player);
playbackManager.setAudioStreamIndex(parseInt(id, 10), player);
}
});
});
@ -78,7 +76,7 @@ function showSubtitleMenu(context, player, button) {
items: menuItems,
positionTo: button,
callback: function (id) {
playbackManager.setSubtitleStreamIndex(parseInt(id), player);
playbackManager.setSubtitleStreamIndex(parseInt(id, 10), player);
}
});
});

View file

@ -150,7 +150,7 @@ import toast from './toast/toast';
StartDate: card.getAttribute('data-startdate'),
EndDate: card.getAttribute('data-enddate'),
UserData: {
PlaybackPositionTicks: parseInt(card.getAttribute('data-positionticks') || '0')
PlaybackPositionTicks: parseInt(card.getAttribute('data-positionticks') || '0', 10)
}
};
}
@ -201,7 +201,7 @@ import toast from './toast/toast';
ServerId: serverId
});
} else if (action === 'play' || action === 'resume') {
const startPositionTicks = parseInt(card.getAttribute('data-positionticks') || '0');
const startPositionTicks = parseInt(card.getAttribute('data-positionticks') || '0', 10);
if (playbackManager.canPlay(item)) {
playbackManager.play({