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

Fix indentation issues

This commit is contained in:
Bill Thornton 2023-04-19 01:56:05 -04:00
parent 52c8cffc82
commit f2726653ae
120 changed files with 30271 additions and 30631 deletions

View file

@ -1,6 +1,3 @@
/* eslint-disable indent */
/**
* Module for controlling user parental control from.
* @module components/accessSchedule/accessSchedule
@ -14,7 +11,7 @@ import '../../elements/emby-button/paper-icon-button-light';
import '../formdialog.scss';
import template from './accessSchedule.template.html';
function getDisplayTime(hours) {
function getDisplayTime(hours) {
let minutes = 0;
const pct = hours % 1;
@ -23,9 +20,9 @@ import template from './accessSchedule.template.html';
}
return datetime.getDisplayTime(new Date(2000, 1, 1, hours, minutes, 0, 0));
}
}
function populateHours(context) {
function populateHours(context) {
let html = '';
for (let i = 0; i < 24; i += 0.5) {
@ -35,15 +32,15 @@ import template from './accessSchedule.template.html';
html += `<option value="24">${getDisplayTime(0)}</option>`;
context.querySelector('#selectStart').innerHTML = html;
context.querySelector('#selectEnd').innerHTML = html;
}
}
function loadSchedule(context, { DayOfWeek, StartHour, EndHour }) {
function loadSchedule(context, { DayOfWeek, StartHour, EndHour }) {
context.querySelector('#selectDay').value = DayOfWeek || 'Sunday';
context.querySelector('#selectStart').value = StartHour || 0;
context.querySelector('#selectEnd').value = EndHour || 0;
}
}
function submitSchedule(context, options) {
function submitSchedule(context, options) {
const updatedSchedule = {
DayOfWeek: context.querySelector('#selectDay').value,
StartHour: context.querySelector('#selectStart').value,
@ -58,9 +55,9 @@ import template from './accessSchedule.template.html';
context.submitted = true;
options.schedule = Object.assign(options.schedule, updatedSchedule);
dialogHelper.close(context);
}
}
export function show(options) {
export function show(options) {
return new Promise((resolve, reject) => {
const dlg = dialogHelper.createDialog({
removeOnClose: true,
@ -89,9 +86,7 @@ import template from './accessSchedule.template.html';
return false;
});
});
}
/* eslint-enable indent */
}
export default {
show: show

View file

@ -11,9 +11,7 @@ import alert from './alert';
import { getLocale } from '../utils/dateFnsLocale.ts';
import { toBoolean } from '../utils/string.ts';
/* eslint-disable indent */
function getEntryHtml(entry, apiClient) {
function getEntryHtml(entry, apiClient) {
let html = '';
html += '<div class="listItem listItem-border">';
let color = '#00a4dc';
@ -54,15 +52,15 @@ import { toBoolean } from '../utils/string.ts';
html += '</div>';
return html;
}
}
function renderList(elem, apiClient, result) {
function renderList(elem, apiClient, result) {
elem.innerHTML = result.Items.map(function (i) {
return getEntryHtml(i, apiClient);
}).join('');
}
}
function reloadData(instance, elem, apiClient, startIndex, limit) {
function reloadData(instance, elem, apiClient, startIndex, limit) {
if (startIndex == null) {
startIndex = parseInt(elem.getAttribute('data-activitystartindex') || '0', 10);
}
@ -101,17 +99,17 @@ import { toBoolean } from '../utils/string.ts';
instance.items = result.Items;
renderList(elem, apiClient, result);
});
}
}
function onActivityLogUpdate(e, apiClient) {
function onActivityLogUpdate(e, apiClient) {
const options = this.options;
if (options && options.serverId === apiClient.serverId()) {
reloadData(this, options.element, apiClient);
}
}
}
function onListClick(e) {
function onListClick(e) {
const btnEntryInfo = dom.parentWithClass(e.target, 'btnEntryInfo');
if (btnEntryInfo) {
@ -128,13 +126,13 @@ import { toBoolean } from '../utils/string.ts';
}
}
}
}
}
function showItemOverview(item) {
function showItemOverview(item) {
alert({
text: item.Overview
});
}
}
class ActivityLog {
constructor(options) {
@ -169,5 +167,3 @@ class ActivityLog {
}
export default ActivityLog;
/* eslint-enable indent */

View file

@ -3,18 +3,16 @@ import browser from '../scripts/browser';
import dialog from './dialog/dialog';
import globalize from '../scripts/globalize';
/* eslint-disable indent */
function useNativeAlert() {
function useNativeAlert() {
// webOS seems to block modals
// Tizen 2.x seems to block modals
return !browser.web0s
&& !(browser.tizenVersion && browser.tizenVersion < 3)
&& browser.tv
&& window.alert;
}
}
export default async function (text, title) {
export default async function (text, title) {
let options;
if (typeof text === 'string') {
options = {
@ -42,6 +40,4 @@ import globalize from '../scripts/globalize';
options.buttons = items;
return dialog.show(options);
}
}
/* eslint-enable indent */
}

View file

@ -1,5 +1,3 @@
/* eslint-disable indent */
/**
* Module alphaPicker.
* @module components/alphaPicker/alphaPicker
@ -13,9 +11,9 @@ import './style.scss';
import '../../elements/emby-button/paper-icon-button-light';
import 'material-design-icons-iconfont';
const selectedButtonClass = 'alphaPickerButton-selected';
const selectedButtonClass = 'alphaPickerButton-selected';
function focus() {
function focus() {
const scope = this;
const selected = scope.querySelector(`.${selectedButtonClass}`);
@ -24,9 +22,9 @@ import 'material-design-icons-iconfont';
} else {
focusManager.autoFocus(scope, true);
}
}
}
function getAlphaPickerButtonClassName(vertical) {
function getAlphaPickerButtonClassName(vertical) {
let alphaPickerButtonClassName = 'alphaPickerButton';
if (layoutManager.tv) {
@ -38,19 +36,19 @@ import 'material-design-icons-iconfont';
}
return alphaPickerButtonClassName;
}
}
function getLetterButton(l, vertical) {
function getLetterButton(l, vertical) {
return `<button data-value="${l}" class="${getAlphaPickerButtonClassName(vertical)}">${l}</button>`;
}
}
function mapLetters(letters, vertical) {
function mapLetters(letters, vertical) {
return letters.map(l => {
return getLetterButton(l, vertical);
});
}
}
function render(element, options) {
function render(element, options) {
element.classList.add('alphaPicker');
if (layoutManager.tv) {
@ -102,9 +100,9 @@ import 'material-design-icons-iconfont';
element.classList.add('focusable');
element.focus = focus;
}
}
export class AlphaPicker {
export class AlphaPicker {
constructor(options) {
const self = this;
@ -318,7 +316,6 @@ import 'material-design-icons-iconfont';
element.classList.remove('focuscontainer-x');
this.options = null;
}
}
}
/* eslint-enable indent */
export default AlphaPicker;

View file

@ -1,5 +1,3 @@
/* eslint-disable indent */
/**
* Module for performing auto-focus.
* @module components/autoFocuser
@ -8,22 +6,22 @@
import focusManager from './focusManager';
import layoutManager from './layoutManager';
/**
/**
* Previously selected element.
*/
let activeElement;
let activeElement;
/**
/**
* Returns _true_ if AutoFocuser is enabled.
*/
export function isEnabled() {
export function isEnabled() {
return layoutManager.tv;
}
}
/**
/**
* Start AutoFocuser.
*/
export function enable() {
export function enable() {
if (!isEnabled()) {
return;
}
@ -33,14 +31,14 @@ import layoutManager from './layoutManager';
});
console.debug('AutoFocuser enabled');
}
}
/**
/**
* Set focus on a suitable element, taking into account the previously selected.
* @param {HTMLElement} [container] - Element to limit scope.
* @returns {HTMLElement} Focused element.
*/
export function autoFocus(container) {
export function autoFocus(container) {
if (!isEnabled()) {
return null;
}
@ -92,9 +90,7 @@ import layoutManager from './layoutManager';
}
return focusedElement;
}
/* eslint-enable indent */
}
export default {
isEnabled: isEnabled,

View file

@ -7,19 +7,17 @@ import ServerConnections from '../ServerConnections';
import './backdrop.scss';
/* eslint-disable indent */
function enableAnimation() {
function enableAnimation() {
return !browser.slow;
}
}
function enableRotation() {
function enableRotation() {
return !browser.tv
// Causes high cpu usage
&& !browser.firefox;
}
}
class Backdrop {
class Backdrop {
load(url, parent, existingBackdropImage) {
const img = new Image();
const self = this;
@ -80,10 +78,10 @@ import './backdrop.scss';
this.isDestroyed = true;
this.cancelAnimation();
}
}
}
let backdropContainer;
function getBackdropContainer() {
let backdropContainer;
function getBackdropContainer() {
if (!backdropContainer) {
backdropContainer = document.querySelector('.backdropContainer');
}
@ -95,9 +93,9 @@ import './backdrop.scss';
}
return backdropContainer;
}
}
export function clearBackdrop(clearAll) {
export function clearBackdrop(clearAll) {
clearRotation();
if (currentLoadingBackdrop) {
@ -113,38 +111,38 @@ import './backdrop.scss';
}
internalBackdrop(false);
}
}
let backgroundContainer;
function getBackgroundContainer() {
let backgroundContainer;
function getBackgroundContainer() {
if (!backgroundContainer) {
backgroundContainer = document.querySelector('.backgroundContainer');
}
return backgroundContainer;
}
}
function setBackgroundContainerBackgroundEnabled() {
function setBackgroundContainerBackgroundEnabled() {
if (hasInternalBackdrop || hasExternalBackdrop) {
getBackgroundContainer().classList.add('withBackdrop');
} else {
getBackgroundContainer().classList.remove('withBackdrop');
}
}
}
let hasInternalBackdrop;
function internalBackdrop(isEnabled) {
let hasInternalBackdrop;
function internalBackdrop(isEnabled) {
hasInternalBackdrop = isEnabled;
setBackgroundContainerBackgroundEnabled();
}
}
let hasExternalBackdrop;
export function externalBackdrop(isEnabled) {
let hasExternalBackdrop;
export function externalBackdrop(isEnabled) {
hasExternalBackdrop = isEnabled;
setBackgroundContainerBackgroundEnabled();
}
}
let currentLoadingBackdrop;
function setBackdropImage(url) {
let currentLoadingBackdrop;
function setBackdropImage(url) {
if (currentLoadingBackdrop) {
currentLoadingBackdrop.destroy();
currentLoadingBackdrop = null;
@ -163,9 +161,9 @@ import './backdrop.scss';
const instance = new Backdrop();
instance.load(url, elem, existingBackdropImage);
currentLoadingBackdrop = instance;
}
}
function getItemImageUrls(item, imageOptions) {
function getItemImageUrls(item, imageOptions) {
imageOptions = imageOptions || {};
const apiClient = ServerConnections.getApiClient(item.ServerId);
@ -192,9 +190,9 @@ import './backdrop.scss';
}
return [];
}
}
function getImageUrls(items, imageOptions) {
function getImageUrls(items, imageOptions) {
const list = [];
const onImg = img => {
list.push(img);
@ -206,16 +204,16 @@ import './backdrop.scss';
}
return list;
}
}
function enabled() {
function enabled() {
return userSettings.enableBackdrops();
}
}
let rotationInterval;
let currentRotatingImages = [];
let currentRotationIndex = -1;
export function setBackdrops(items, imageOptions, enableImageRotation) {
let rotationInterval;
let currentRotatingImages = [];
let currentRotationIndex = -1;
export function setBackdrops(items, imageOptions, enableImageRotation) {
if (enabled()) {
const images = getImageUrls(items, imageOptions);
@ -225,9 +223,9 @@ import './backdrop.scss';
clearBackdrop();
}
}
}
}
function startRotation(images, enableImageRotation) {
function startRotation(images, enableImageRotation) {
if (isEqual(images, currentRotatingImages)) {
return;
}
@ -242,9 +240,9 @@ import './backdrop.scss';
}
onRotationInterval();
}
}
function onRotationInterval() {
function onRotationInterval() {
if (playbackManager.isPlayingLocally(['Video'])) {
return;
}
@ -256,9 +254,9 @@ import './backdrop.scss';
currentRotationIndex = newIndex;
setBackdropImage(currentRotatingImages[newIndex]);
}
}
function clearRotation() {
function clearRotation() {
const interval = rotationInterval;
if (interval) {
clearInterval(interval);
@ -267,9 +265,9 @@ import './backdrop.scss';
rotationInterval = null;
currentRotatingImages = [];
currentRotationIndex = -1;
}
}
export function setBackdrop(url, imageOptions) {
export function setBackdrop(url, imageOptions) {
if (url && typeof url !== 'string') {
url = getImageUrls([url], imageOptions)[0];
}
@ -280,9 +278,7 @@ import './backdrop.scss';
} else {
clearBackdrop();
}
}
/* eslint-enable indent */
}
/**
* @enum TransparencyLevel

View file

@ -1,4 +1,3 @@
/* eslint-disable indent */
/**
* Module for building cards from item data.
@ -25,31 +24,31 @@ import '../guide/programs.scss';
import ServerConnections from '../ServerConnections';
import { appRouter } from '../appRouter';
const enableFocusTransform = !browser.slow && !browser.edge;
const enableFocusTransform = !browser.slow && !browser.edge;
/**
/**
* Generate the HTML markup for cards for a set of items.
* @param items - The items used to generate cards.
* @param options - The options of the cards.
* @returns {string} The HTML markup for the cards.
*/
export function getCardsHtml(items, options) {
export function getCardsHtml(items, options) {
if (arguments.length === 1) {
options = arguments[0];
items = options.items;
}
return buildCardsHtmlInternal(items, options);
}
}
/**
/**
* Computes the number of posters per row.
* @param {string} shape - Shape of the cards.
* @param {number} screenWidth - Width of the screen.
* @param {boolean} isOrientationLandscape - Flag for the orientation of the screen.
* @returns {number} Number of cards per row for an itemsContainer.
*/
function getPostersPerRow(shape, screenWidth, isOrientationLandscape) {
function getPostersPerRow(shape, screenWidth, isOrientationLandscape) {
switch (shape) {
case 'portrait':
if (layoutManager.tv) {
@ -251,14 +250,14 @@ import { appRouter } from '../appRouter';
default:
return 4;
}
}
}
/**
/**
* Checks if the window is resizable.
* @param {number} windowWidth - Width of the device's screen.
* @returns {boolean} - Result of the check.
*/
function isResizable(windowWidth) {
function isResizable(windowWidth) {
const screen = window.screen;
if (screen) {
const screenWidth = screen.availWidth;
@ -269,26 +268,26 @@ import { appRouter } from '../appRouter';
}
return false;
}
}
/**
/**
* Gets the width of a card's image according to the shape and amount of cards per row.
* @param {string} shape - Shape of the card.
* @param {number} screenWidth - Width of the screen.
* @param {boolean} isOrientationLandscape - Flag for the orientation of the screen.
* @returns {number} Width of the image for a card.
*/
function getImageWidth(shape, screenWidth, isOrientationLandscape) {
function getImageWidth(shape, screenWidth, isOrientationLandscape) {
const imagesPerRow = getPostersPerRow(shape, screenWidth, isOrientationLandscape);
return Math.round(screenWidth / imagesPerRow);
}
}
/**
/**
* Normalizes the options for a card.
* @param {Object} items - A set of items.
* @param {Object} options - Options for handling the items.
*/
function setCardData(items, options) {
function setCardData(items, options) {
options.shape = options.shape || 'auto';
const primaryImageAspectRatio = imageLoader.getPrimaryImageAspectRatio(items);
@ -341,15 +340,15 @@ import { appRouter } from '../appRouter';
options.width = getImageWidth(options.shape, screenWidth, screenWidth > (screenHeight * 1.3));
}
}
}
/**
/**
* Generates the internal HTML markup for cards.
* @param {Object} items - Items for which to generate the markup.
* @param {Object} options - Options for generating the markup.
* @returns {string} The internal HTML markup of the cards.
*/
function buildCardsHtmlInternal(items, options) {
function buildCardsHtmlInternal(items, options) {
let isVertical = false;
if (options.shape === 'autoVertical') {
@ -459,14 +458,14 @@ import { appRouter } from '../appRouter';
}
return html;
}
}
/**
/**
* Computes the aspect ratio for a card given its shape.
* @param {string} shape - Shape for which to get the aspect ratio.
* @returns {null|number} Ratio of the shape.
*/
function getDesiredAspect(shape) {
function getDesiredAspect(shape) {
if (shape) {
shape = shape.toLowerCase();
if (shape.indexOf('portrait') !== -1) {
@ -483,9 +482,9 @@ import { appRouter } from '../appRouter';
}
}
return null;
}
}
/**
/**
* @typedef {Object} CardImageUrl
* @property {string} imgUrl - Image URL.
* @property {string} blurhash - Image blurhash.
@ -493,14 +492,14 @@ import { appRouter } from '../appRouter';
* @property {boolean} coverImage - Use cover style.
*/
/** Get the URL of the card's image.
/** Get the URL of the card's image.
* @param {Object} item - Item for which to generate a card.
* @param {Object} apiClient - API client object.
* @param {Object} options - Options of the card.
* @param {string} shape - Shape of the desired image.
* @returns {CardImageUrl} Object representing the URL of the card's image.
*/
function getCardImageUrl(item, apiClient, options, shape) {
function getCardImageUrl(item, apiClient, options, shape) {
item = item.ProgramInfo || item;
const width = options.width;
@ -639,14 +638,14 @@ import { appRouter } from '../appRouter';
forceName: forceName,
coverImage: coverImage
};
}
}
/**
/**
* 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.
* @returns {number} Index of the color.
*/
function getDefaultColorIndex(str) {
function getDefaultColorIndex(str) {
const numRandomColors = 5;
if (str) {
@ -662,9 +661,9 @@ import { appRouter } from '../appRouter';
} else {
return randomInt(1, numRandomColors);
}
}
}
/**
/**
* Generates the HTML markup for a card's text.
* @param {Array} lines - Array containing the text lines.
* @param {string} cssClass - Base CSS class to use for the lines.
@ -675,7 +674,7 @@ import { appRouter } from '../appRouter';
* @param {number} maxLines - Maximum number of lines to render.
* @returns {string} HTML markup for the card's text.
*/
function getCardTextLines(lines, cssClass, forceLines, isOuterFooter, cardLayout, addRightMargin, maxLines) {
function getCardTextLines(lines, cssClass, forceLines, isOuterFooter, cardLayout, addRightMargin, maxLines) {
let html = '';
let valid = 0;
@ -716,25 +715,25 @@ import { appRouter } from '../appRouter';
}
return html;
}
}
/**
/**
* Determines if the item is live TV.
* @param {Object} item - Item to use for the check.
* @returns {boolean} Flag showing if the item is live TV.
*/
function isUsingLiveTvNaming(item) {
function isUsingLiveTvNaming(item) {
return item.Type === 'Program' || item.Type === 'Timer' || item.Type === 'Recording';
}
}
/**
/**
* Returns the air time text for the item based on the given times.
* @param {object} item - Item used to generate the air time text.
* @param {boolean} showAirDateTime - ISO8601 date for the start of the show.
* @param {boolean} showAirEndTime - ISO8601 date for the end of the show.
* @returns {string} The air time text for the item based on the given dates.
*/
function getAirTimeText(item, showAirDateTime, showAirEndTime) {
function getAirTimeText(item, showAirDateTime, showAirEndTime) {
let airTimeText = '';
if (item.StartDate) {
@ -757,9 +756,9 @@ import { appRouter } from '../appRouter';
}
return airTimeText;
}
}
/**
/**
* Generates the HTML markup for the card's footer text.
* @param {Object} item - Item used to generate the footer text.
* @param {Object} apiClient - API client instance.
@ -770,7 +769,7 @@ import { appRouter } from '../appRouter';
* @param {Object} urls - Various urls for the footer
* @returns {string} HTML markup of the card's footer text element.
*/
function getCardFooterText(item, apiClient, options, footerClass, progressHtml, flags, urls) {
function getCardFooterText(item, apiClient, options, footerClass, progressHtml, flags, urls) {
item = item.ProgramInfo || item;
let html = '';
@ -1003,16 +1002,16 @@ import { appRouter } from '../appRouter';
}
return html;
}
}
/**
/**
* Generates the HTML markup for the action button.
* @param {Object} item - Item used to generate the action button.
* @param {string} text - Text of the action button.
* @param {string} serverId - ID of the server.
* @returns {string} HTML markup of the action button.
*/
function getTextActionButton(item, text, serverId) {
function getTextActionButton(item, text, serverId) {
if (!text) {
text = itemHelper.getDisplayName(item);
}
@ -1029,15 +1028,15 @@ import { appRouter } from '../appRouter';
html += '</a>';
return html;
}
}
/**
/**
* Generates HTML markup for the item count indicator.
* @param {Object} options - Options used to generate the item count.
* @param {Object} item - Item used to generate the item count.
* @returns {string} HTML markup for the item count indicator.
*/
function getItemCountsHtml(options, item) {
function getItemCountsHtml(options, item) {
const counts = [];
let childText;
@ -1109,31 +1108,31 @@ import { appRouter } from '../appRouter';
}
return counts.join(', ');
}
}
let refreshIndicatorLoaded;
let refreshIndicatorLoaded;
/**
/**
* Imports the refresh indicator element.
*/
function importRefreshIndicator() {
function importRefreshIndicator() {
if (!refreshIndicatorLoaded) {
refreshIndicatorLoaded = true;
/* eslint-disable-next-line @babel/no-unused-expressions */
import('../../elements/emby-itemrefreshindicator/emby-itemrefreshindicator');
}
}
}
/**
/**
* Returns the default background class for a card based on a string.
* @param {?string} [str] - Text used to generate the background class.
* @returns {string} CSS classes for default card backgrounds.
*/
export function getDefaultBackgroundClass(str) {
export function getDefaultBackgroundClass(str) {
return 'defaultCardBackground defaultCardBackground' + getDefaultColorIndex(str);
}
}
/**
/**
* Builds the HTML markup for an individual card.
* @param {number} index - Index of the card
* @param {object} item - Item used to generate the card.
@ -1141,7 +1140,7 @@ import { appRouter } from '../appRouter';
* @param {object} options - Options used to generate the card.
* @returns {string} HTML markup for the generated card.
*/
function buildCard(index, item, apiClient, options) {
function buildCard(index, item, apiClient, options) {
let action = options.action || 'link';
if (action === 'play' && item.IsFolder) {
@ -1444,15 +1443,15 @@ import { appRouter } from '../appRouter';
}
return '<' + tagName + ' data-index="' + index + '"' + timerAttributes + actionAttribute + ' data-isfolder="' + (item.IsFolder || false) + '" data-serverid="' + (item.ServerId || options.serverId) + '" data-id="' + (item.Id || item.ItemId) + '" data-type="' + item.Type + '"' + mediaTypeData + collectionTypeData + channelIdData + pathData + positionTicksData + collectionIdData + playlistIdData + contextData + parentIdData + startDate + endDate + ' data-prefix="' + escapeHtml(prefix) + '" class="' + className + '"' + ariaLabelAttribute + '>' + cardImageContainerOpen + innerCardFooter + cardImageContainerClose + overlayButtons + additionalCardContent + cardScalableClose + outerCardFooter + cardBoxClose + '</' + tagName + '>';
}
}
/**
/**
* Generates HTML markup for the card overlay.
* @param {object} item - Item used to generate the card overlay.
* @param {string} action - Action assigned to the overlay.
* @returns {string} HTML markup of the card overlay.
*/
function getHoverMenuHtml(item, action) {
function getHoverMenuHtml(item, action) {
let html = '';
html += '<div class="cardOverlayContainer itemAction" data-action="' + action + '">';
@ -1488,15 +1487,15 @@ import { appRouter } from '../appRouter';
html += '</div>';
return html;
}
}
/**
/**
* Generates the text or icon used for default card backgrounds.
* @param {object} item - Item used to generate the card overlay.
* @param {object} options - Options used to generate the card overlay.
* @returns {string} HTML markup of the card overlay.
*/
export function getDefaultText(item, options) {
export function getDefaultText(item, options) {
if (item.CollectionType) {
return '<span class="cardImageIcon material-icons ' + imageHelper.getLibraryIcon(item.CollectionType) + '" aria-hidden="true"></span>';
}
@ -1536,14 +1535,14 @@ import { appRouter } from '../appRouter';
const defaultName = isUsingLiveTvNaming(item) ? item.Name : itemHelper.getDisplayName(item);
return '<div class="cardText cardDefaultText">' + escapeHtml(defaultName) + '</div>';
}
}
/**
/**
* Builds a set of cards and inserts them into the page.
* @param {Array} items - Array of items used to build the cards.
* @param {options} options - Options of the cards to build.
*/
export function buildCards(items, options) {
export function buildCards(items, options) {
// Abort if the container has been disposed
if (!document.body.contains(options.itemsContainer)) {
return;
@ -1580,15 +1579,15 @@ import { appRouter } from '../appRouter';
if (options.autoFocus) {
focusManager.autoFocus(options.itemsContainer, true);
}
}
}
/**
/**
* Ensures the indicators for a card exist and creates them if they don't exist.
* @param {HTMLDivElement} card - DOM element of the card.
* @param {HTMLDivElement} indicatorsElem - DOM element of the indicators.
* @returns {HTMLDivElement} - DOM element of the indicators.
*/
function ensureIndicators(card, indicatorsElem) {
function ensureIndicators(card, indicatorsElem) {
if (indicatorsElem) {
return indicatorsElem;
}
@ -1603,14 +1602,14 @@ import { appRouter } from '../appRouter';
}
return indicatorsElem;
}
}
/**
/**
* Adds user data to the card such as progress indicators and played status.
* @param {HTMLDivElement} card - DOM element of the card.
* @param {Object} userData - User data to apply to the card.
*/
function updateUserData(card, userData) {
function updateUserData(card, userData) {
const type = card.getAttribute('data-type');
const enableCountIndicator = type === 'Series' || type === 'BoxSet' || type === 'Season';
let indicatorsElem = null;
@ -1682,28 +1681,28 @@ import { appRouter } from '../appRouter';
itemProgressBar.parentNode.removeChild(itemProgressBar);
}
}
}
}
/**
/**
* Handles when user data has changed.
* @param {Object} userData - User data to apply to the card.
* @param {HTMLElement} scope - DOM element to use as a scope when selecting cards.
*/
export function onUserDataChanged(userData, scope) {
export function onUserDataChanged(userData, scope) {
const cards = (scope || document.body).querySelectorAll('.card-withuserdata[data-id="' + userData.ItemId + '"]');
for (let i = 0, length = cards.length; i < length; i++) {
updateUserData(cards[i], userData);
}
}
}
/**
/**
* Handles when a timer has been created.
* @param {string} programId - ID of the program.
* @param {string} newTimerId - ID of the new timer.
* @param {HTMLElement} itemsContainer - DOM element of the itemsContainer.
*/
export function onTimerCreated(programId, newTimerId, itemsContainer) {
export function onTimerCreated(programId, newTimerId, itemsContainer) {
const cells = itemsContainer.querySelectorAll('.card[data-id="' + programId + '"]');
for (let i = 0, length = cells.length; i < length; i++) {
@ -1715,14 +1714,14 @@ import { appRouter } from '../appRouter';
}
cell.setAttribute('data-timerid', newTimerId);
}
}
}
/**
/**
* Handles when a timer has been cancelled.
* @param {string} timerId - ID of the cancelled timer.
* @param {HTMLElement} itemsContainer - DOM element of the itemsContainer.
*/
export function onTimerCancelled(timerId, itemsContainer) {
export function onTimerCancelled(timerId, itemsContainer) {
const cells = itemsContainer.querySelectorAll('.card[data-timerid="' + timerId + '"]');
for (let i = 0; i < cells.length; i++) {
@ -1733,14 +1732,14 @@ import { appRouter } from '../appRouter';
}
cell.removeAttribute('data-timerid');
}
}
}
/**
/**
* Handles when a series timer has been cancelled.
* @param {string} cancelledTimerId - ID of the cancelled timer.
* @param {HTMLElement} itemsContainer - DOM element of the itemsContainer.
*/
export function onSeriesTimerCancelled(cancelledTimerId, itemsContainer) {
export function onSeriesTimerCancelled(cancelledTimerId, itemsContainer) {
const cells = itemsContainer.querySelectorAll('.card[data-seriestimerid="' + cancelledTimerId + '"]');
for (let i = 0; i < cells.length; i++) {
@ -1751,9 +1750,7 @@ import { appRouter } from '../appRouter';
}
cell.removeAttribute('data-seriestimerid');
}
}
/* eslint-enable indent */
}
export default {
getCardsHtml: getCardsHtml,

View file

@ -1,4 +1,3 @@
/* eslint-disable indent */
/**
* Module for building cards from item data.
@ -12,9 +11,9 @@ import layoutManager from '../layoutManager';
import browser from '../../scripts/browser';
import ServerConnections from '../ServerConnections';
const enableFocusTransform = !browser.slow && !browser.edge;
const enableFocusTransform = !browser.slow && !browser.edge;
function buildChapterCardsHtml(item, chapters, options) {
function buildChapterCardsHtml(item, chapters, options) {
// TODO move card creation code to Card component
let className = 'card itemAction chapterCard';
@ -66,9 +65,9 @@ import ServerConnections from '../ServerConnections';
}
return html;
}
}
function getImgUrl({ Id }, { ImageTag }, index, maxWidth, apiClient) {
function getImgUrl({ Id }, { ImageTag }, index, maxWidth, apiClient) {
if (ImageTag) {
return apiClient.getScaledImageUrl(Id, {
@ -80,9 +79,9 @@ import ServerConnections from '../ServerConnections';
}
return null;
}
}
function buildChapterCard(item, apiClient, chapter, index, { width, coverImage }, className, shape) {
function buildChapterCard(item, apiClient, chapter, index, { width, coverImage }, className, shape) {
const imgUrl = getImgUrl(item, chapter, index, width || 400, apiClient);
let cardImageContainerClass = 'cardContent cardContent-shadow cardImageContainer chapterCardImageContainer';
@ -104,9 +103,9 @@ import ServerConnections from '../ServerConnections';
const cardScalableClass = 'cardScalable';
return `<button type="button" class="${className}"${dataAttributes}><div class="${cardBoxCssClass}"><div class="${cardScalableClass}"><div class="cardPadder-${shape}"></div>${cardImageContainer}</div><div class="innerCardFooter">${nameHtml}</div></div></div></button>`;
}
}
export function buildChapterCards(item, chapters, options) {
export function buildChapterCards(item, chapters, options) {
if (options.parentContainer) {
// Abort if the container has been disposed
if (!document.body.contains(options.parentContainer)) {
@ -126,9 +125,7 @@ import ServerConnections from '../ServerConnections';
options.itemsContainer.innerHTML = html;
imageLoader.lazyChildren(options.itemsContainer);
}
/* eslint-enable indent */
}
export default {
buildChapterCards: buildChapterCards

View file

@ -1,4 +1,3 @@
/* eslint-disable indent */
/**
* Module for building cards from item data.
@ -7,7 +6,7 @@
import cardBuilder from './cardBuilder';
export function buildPeopleCards(items, options) {
export function buildPeopleCards(items, options) {
options = Object.assign(options || {}, {
cardLayout: false,
centerText: true,
@ -18,9 +17,7 @@ import cardBuilder from './cardBuilder';
defaultCardImageIcon: 'person'
});
cardBuilder.buildCards(items, options);
}
/* eslint-enable indent */
}
export default {
buildPeopleCards: buildPeopleCards

View file

@ -16,11 +16,9 @@ import '../../styles/flexstyles.scss';
import ServerConnections from '../ServerConnections';
import toast from '../toast/toast';
/* eslint-disable indent */
let currentServerId;
let currentServerId;
function onSubmit(e) {
function onSubmit(e) {
loading.show();
const panel = dom.parentWithClass(this, 'dialog');
@ -37,9 +35,9 @@ import toast from '../toast/toast';
e.preventDefault();
return false;
}
}
function createCollection(apiClient, dlg) {
function createCollection(apiClient, dlg) {
const url = apiClient.getUrl('Collections', {
Name: dlg.querySelector('#txtNewCollectionName').value,
@ -61,13 +59,13 @@ import toast from '../toast/toast';
dialogHelper.close(dlg);
redirectToCollection(apiClient, id);
});
}
}
function redirectToCollection(apiClient, id) {
function redirectToCollection(apiClient, id) {
appRouter.showItem(id, apiClient.serverId());
}
}
function addToCollection(apiClient, dlg, id) {
function addToCollection(apiClient, dlg, id) {
const url = apiClient.getUrl(`Collections/${id}/Items`, {
Ids: dlg.querySelector('.fldSelectedItemIds').value || ''
@ -85,13 +83,13 @@ import toast from '../toast/toast';
toast(globalize.translate('MessageItemsAdded'));
});
}
}
function triggerChange(select) {
function triggerChange(select) {
select.dispatchEvent(new CustomEvent('change', {}));
}
}
function populateCollections(panel) {
function populateCollections(panel) {
loading.show();
const select = panel.querySelector('#selectCollectionToAddTo');
@ -122,9 +120,9 @@ import toast from '../toast/toast';
loading.hide();
});
}
}
function getEditorHtml() {
function getEditorHtml() {
let html = '';
html += '<div class="formDialogContent smoothScrollY" style="padding-top:2em;">';
@ -169,9 +167,9 @@ import toast from '../toast/toast';
html += '</div>';
return html;
}
}
function initEditor(content, items) {
function initEditor(content, items) {
content.querySelector('#selectCollectionToAddTo').addEventListener('change', function () {
if (this.value) {
content.querySelector('.newCollectionInfo').classList.add('hide');
@ -197,16 +195,16 @@ import toast from '../toast/toast';
selectCollectionToAddTo.value = '';
triggerChange(selectCollectionToAddTo);
}
}
}
function centerFocus(elem, horiz, on) {
function centerFocus(elem, horiz, on) {
import('../../scripts/scrollHelper').then((scrollHelper) => {
const fn = on ? 'on' : 'off';
scrollHelper.centerFocus[fn](elem, horiz);
});
}
}
class CollectionEditor {
class CollectionEditor {
show(options) {
const items = options.items || {};
currentServerId = options.serverId;
@ -263,7 +261,6 @@ import toast from '../toast/toast';
return Promise.reject();
});
}
}
}
/* eslint-enable indent */
export default CollectionEditor;

View file

@ -13,9 +13,7 @@ import '../formdialog.scss';
import '../../styles/flexstyles.scss';
import template from './dialog.template.html';
/* eslint-disable indent */
function showDialog(options = { dialogOptions: {}, buttons: [] }) {
function showDialog(options = { dialogOptions: {}, buttons: [] }) {
const dialogOptions = {
removeOnClose: true,
scrollY: false,
@ -119,9 +117,9 @@ import template from './dialog.template.html';
return Promise.reject();
}
});
}
}
export function show(text, title) {
export function show(text, title) {
let options;
if (typeof text === 'string') {
options = {
@ -133,9 +131,8 @@ import template from './dialog.template.html';
}
return showDialog(options);
}
}
/* eslint-enable indent */
export default {
show: show
};

View file

@ -9,20 +9,18 @@ import dom from '../../scripts/dom';
import './dialoghelper.scss';
import '../../styles/scrollstyles.scss';
/* eslint-disable indent */
let globalOnOpenCallback;
let globalOnOpenCallback;
function enableAnimation() {
function enableAnimation() {
// too slow
if (browser.tv) {
return false;
}
return browser.supportsCssAnimation();
}
}
function removeCenterFocus(dlg) {
function removeCenterFocus(dlg) {
if (layoutManager.tv) {
if (dlg.classList.contains('scrollX')) {
centerFocus(dlg, true, false);
@ -30,9 +28,9 @@ import '../../styles/scrollstyles.scss';
centerFocus(dlg, false, false);
}
}
}
}
function tryRemoveElement(elem) {
function tryRemoveElement(elem) {
const parentNode = elem.parentNode;
if (parentNode) {
// Seeing crashes in edge webview
@ -42,9 +40,9 @@ import '../../styles/scrollstyles.scss';
console.error('[dialogHelper] error removing dialog element: ' + err);
}
}
}
}
function DialogHashHandler(dlg, hash, resolve) {
function DialogHashHandler(dlg, hash, resolve) {
const self = this;
self.originalUrl = window.location.href;
const activeElement = document.activeElement;
@ -192,9 +190,9 @@ import '../../styles/scrollstyles.scss';
} else {
inputManager.on(dlg, onBackCommand);
}
}
}
function addBackdropOverlay(dlg) {
function addBackdropOverlay(dlg) {
const backdrop = document.createElement('div');
backdrop.classList.add('dialogBackdrop');
@ -222,13 +220,13 @@ import '../../styles/scrollstyles.scss';
e.preventDefault();
}
});
}
}
function isHistoryEnabled(dlg) {
function isHistoryEnabled(dlg) {
return dlg.getAttribute('data-history') === 'true';
}
}
export function open(dlg) {
export function open(dlg) {
if (globalOnOpenCallback) {
globalOnOpenCallback(dlg);
}
@ -247,13 +245,13 @@ import '../../styles/scrollstyles.scss';
return new Promise((resolve) => {
new DialogHashHandler(dlg, `dlg${new Date().getTime()}`, resolve);
});
}
}
function isOpened(dlg) {
function isOpened(dlg) {
return !dlg.classList.contains('hide');
}
}
export function close(dlg) {
export function close(dlg) {
if (!dlg.classList.contains('hide')) {
dlg.dispatchEvent(new CustomEvent('closing', {
bubbles: false,
@ -272,14 +270,14 @@ import '../../styles/scrollstyles.scss';
animateDialogClose(dlg, onAnimationFinish);
}
}
}
const getAnimationEndHandler = (dlg, callback) => function handler() {
const getAnimationEndHandler = (dlg, callback) => function handler() {
dom.removeEventListener(dlg, dom.whichAnimationEvent(), handler, { once: true });
callback();
};
};
function animateDialogOpen(dlg) {
function animateDialogOpen(dlg) {
const onAnimationFinish = () => {
focusManager.pushScope(dlg);
@ -304,9 +302,9 @@ import '../../styles/scrollstyles.scss';
}
onAnimationFinish();
}
}
function animateDialogClose(dlg, onAnimationFinish) {
function animateDialogClose(dlg, onAnimationFinish) {
if (enableAnimation()) {
let animated = true;
@ -337,11 +335,11 @@ import '../../styles/scrollstyles.scss';
}
onAnimationFinish();
}
}
const supportsOverscrollBehavior = 'overscroll-behavior-y' in document.body.style;
const supportsOverscrollBehavior = 'overscroll-behavior-y' in document.body.style;
function shouldLockDocumentScroll(options) {
function shouldLockDocumentScroll(options) {
if (options.lockScroll != null) {
return options.lockScroll;
}
@ -359,9 +357,9 @@ import '../../styles/scrollstyles.scss';
}
return browser.touch;
}
}
function removeBackdrop(dlg) {
function removeBackdrop(dlg) {
const backdrop = dlg.backdrop;
if (!backdrop) {
@ -383,16 +381,16 @@ import '../../styles/scrollstyles.scss';
}
onAnimationFinish();
}
}
function centerFocus(elem, horiz, on) {
function centerFocus(elem, horiz, on) {
import('../../scripts/scrollHelper').then((scrollHelper) => {
const fn = on ? 'on' : 'off';
scrollHelper.centerFocus[fn](elem, horiz);
});
}
}
export function createDialog(options = {}) {
export function createDialog(options = {}) {
// If there's no native dialog support, use a plain div
// Also not working well in samsung tizen browser, content inside not clickable
// Just go ahead and always use a plain div because we're seeing issues overlaying absoltutely positioned content over a modal dialog
@ -501,13 +499,11 @@ import '../../styles/scrollstyles.scss';
}
return dlg;
}
}
export function setOnOpen(val) {
export function setOnOpen(val) {
globalOnOpenCallback = val;
}
/* eslint-enable indent */
}
export default {
open: open,

View file

@ -18,9 +18,7 @@ import ServerConnections from '../ServerConnections';
import toast from '../toast/toast';
import template from './displaySettings.template.html';
/* eslint-disable indent */
function fillThemes(select, selectedTheme) {
function fillThemes(select, selectedTheme) {
skinManager.getThemes().then(themes => {
select.innerHTML = themes.map(t => {
return `<option value="${t.id}">${escapeHtml(t.name)}</option>`;
@ -32,9 +30,9 @@ import template from './displaySettings.template.html';
// set the current theme
select.value = selectedTheme || defaultTheme.id;
});
}
}
function loadScreensavers(context, userSettings) {
function loadScreensavers(context, userSettings) {
const selectScreensaver = context.querySelector('.selectScreensaver');
const options = pluginManager.ofType(PluginType.Screensaver).map(plugin => {
return {
@ -58,18 +56,18 @@ import template from './displaySettings.template.html';
// TODO: set the default instead of none
selectScreensaver.value = 'none';
}
}
}
function showOrHideMissingEpisodesField(context) {
function showOrHideMissingEpisodesField(context) {
if (browser.tizen || browser.web0s) {
context.querySelector('.fldDisplayMissingEpisodes').classList.add('hide');
return;
}
context.querySelector('.fldDisplayMissingEpisodes').classList.remove('hide');
}
}
function loadForm(context, user, userSettings) {
function loadForm(context, user, userSettings) {
if (appHost.supports('displaylanguage')) {
context.querySelector('.languageSection').classList.remove('hide');
} else {
@ -133,9 +131,9 @@ import template from './displaySettings.template.html';
showOrHideMissingEpisodesField(context);
loading.hide();
}
}
function saveUser(context, user, userSettingsInstance, apiClient) {
function saveUser(context, user, userSettingsInstance, apiClient) {
user.Configuration.DisplayMissingEpisodes = context.querySelector('.chkDisplayMissingEpisodes').checked;
if (appHost.supports('displaylanguage')) {
@ -170,9 +168,9 @@ import template from './displaySettings.template.html';
layoutManager.setLayout(context.querySelector('.selectLayout').value);
return apiClient.updateUserConfiguration(user.Id, user.Configuration);
}
}
function save(instance, context, userId, userSettings, apiClient, enableSaveConfirmation) {
function save(instance, context, userId, userSettings, apiClient, enableSaveConfirmation) {
loading.show();
apiClient.getUser(userId).then(user => {
@ -186,9 +184,9 @@ import template from './displaySettings.template.html';
loading.hide();
});
});
}
}
function onSubmit(e) {
function onSubmit(e) {
const self = this;
const apiClient = ServerConnections.getApiClient(self.options.serverId);
const userId = self.options.userId;
@ -204,18 +202,18 @@ import template from './displaySettings.template.html';
e.preventDefault();
}
return false;
}
}
function embed(options, self) {
function embed(options, self) {
options.element.innerHTML = globalize.translateHtml(template, 'core');
options.element.querySelector('form').addEventListener('submit', onSubmit.bind(self));
if (options.enableSaveButton) {
options.element.querySelector('.btnSave').classList.remove('hide');
}
self.loadData(options.autoFocus);
}
}
class DisplaySettings {
class DisplaySettings {
constructor(options) {
this.options = options;
embed(options, this);
@ -249,7 +247,6 @@ import template from './displaySettings.template.html';
destroy() {
this.options = null;
}
}
}
/* eslint-enable indent */
export default DisplaySettings;

View file

@ -9,25 +9,23 @@ import { getParameterByName } from '../utils/url.ts';
import '../styles/scrollstyles.scss';
import '../elements/emby-itemscontainer/emby-itemscontainer';
/* eslint-disable indent */
function enableScrollX() {
function enableScrollX() {
return !layoutManager.desktop;
}
}
function getThumbShape() {
function getThumbShape() {
return enableScrollX() ? 'overflowBackdrop' : 'backdrop';
}
}
function getPosterShape() {
function getPosterShape() {
return enableScrollX() ? 'overflowPortrait' : 'portrait';
}
}
function getSquareShape() {
function getSquareShape() {
return enableScrollX() ? 'overflowSquare' : 'square';
}
}
function getSections() {
function getSections() {
return [{
name: 'Movies',
types: 'Movie',
@ -101,9 +99,9 @@ import '../elements/emby-itemscontainer/emby-itemscontainer';
action: 'instantmix',
coverImage: true
}];
}
}
function loadSection(elem, userId, topParentId, section, isSingleSection) {
function loadSection(elem, userId, topParentId, section, isSingleSection) {
const screenWidth = dom.getWindowSize().innerWidth;
const options = {
SortBy: 'SortName',
@ -193,9 +191,9 @@ import '../elements/emby-itemscontainer/emby-itemscontainer';
elem.innerHTML = html;
imageLoader.lazyChildren(elem);
});
}
}
export function loadSections(page, userId, topParentId, types) {
export function loadSections(page, userId, topParentId, types) {
loading.show();
let sections = getSections();
const sectionid = getParameterByName('sectionid');
@ -235,10 +233,8 @@ import '../elements/emby-itemscontainer/emby-itemscontainer';
Promise.all(promises).then(function () {
loading.hide();
});
}
}
export default {
render: loadSections
};
/* eslint-enable indent */

View file

@ -1,5 +1,4 @@
/* eslint-disable indent */
export function getFetchPromise(request) {
export function getFetchPromise(request) {
const headers = request.headers || {};
if (request.dataType === 'json') {
@ -42,9 +41,9 @@
}
return fetchWithTimeout(url, fetchRequest, request.timeout);
}
}
function fetchWithTimeout(url, options, timeoutMs) {
function fetchWithTimeout(url, options, timeoutMs) {
console.debug(`fetchWithTimeout: timeoutMs: ${timeoutMs}, url: ${url}`);
return new Promise(function (resolve, reject) {
@ -67,20 +66,20 @@
reject(error);
});
});
}
}
/**
/**
* @param params {Record<string, string | number | boolean>}
* @returns {string} Query string
*/
function paramsToString(params) {
function paramsToString(params) {
return Object.entries(params)
.filter(([, v]) => v !== null && v !== undefined && v !== '')
.map(([k, v]) => `${encodeURIComponent(k)}=${encodeURIComponent(v)}`)
.join('&');
}
}
export function ajax(request) {
export function ajax(request) {
if (!request) {
throw new Error('Request cannot be null');
}
@ -106,5 +105,4 @@
console.error(`request failed to url: ${request.url}`);
throw err;
});
}
/* eslint-enable indent */
}

View file

@ -8,8 +8,7 @@ import './style.scss';
import ServerConnections from '../ServerConnections';
import template from './filterdialog.template.html';
/* eslint-disable indent */
function renderOptions(context, selector, cssClass, items, isCheckedFn) {
function renderOptions(context, selector, cssClass, items, isCheckedFn) {
const elem = context.querySelector(selector);
if (items.length) {
elem.classList.remove('hide');
@ -29,9 +28,9 @@ import template from './filterdialog.template.html';
}).join('');
html += '</div>';
elem.querySelector('.filterOptions').innerHTML = html;
}
}
function renderFilters(context, result, query) {
function renderFilters(context, result, query) {
renderOptions(context, '.genreFilters', 'chkGenreFilter', result.Genres, function (i) {
const delimeter = '|';
return (delimeter + (query.Genres || '') + delimeter).includes(delimeter + i + delimeter);
@ -48,9 +47,9 @@ import template from './filterdialog.template.html';
const delimeter = ',';
return (delimeter + (query.Years || '') + delimeter).includes(delimeter + i + delimeter);
});
}
}
function loadDynamicFilters(context, apiClient, userId, itemQuery) {
function loadDynamicFilters(context, apiClient, userId, itemQuery) {
return apiClient.getJSON(apiClient.getUrl('Items/Filters', {
UserId: userId,
ParentId: itemQuery.ParentId,
@ -58,13 +57,13 @@ import template from './filterdialog.template.html';
})).then(function (result) {
renderFilters(context, result, itemQuery);
});
}
}
/**
/**
* @param context {HTMLDivElement} Dialog
* @param options {any} Options
*/
function updateFilterControls(context, options) {
function updateFilterControls(context, options) {
const query = options.query;
if (options.mode === 'livetvchannels') {
@ -99,16 +98,16 @@ import template from './filterdialog.template.html';
const filterName = elem.getAttribute('data-filter');
elem.checked = filters.includes(`,${filterName}`);
}
}
}
/**
/**
* @param instance {FilterDialog} An instance of FilterDialog
*/
function triggerChange(instance) {
function triggerChange(instance) {
Events.trigger(instance, 'filterchange');
}
}
function setVisibility(context, options) {
function setVisibility(context, options) {
if (options.mode === 'livetvchannels' || options.mode === 'albums' || options.mode === 'artists' || options.mode === 'albumartists' || options.mode === 'songs') {
hideByClass(context, 'videoStandard');
}
@ -135,25 +134,25 @@ import template from './filterdialog.template.html';
if (options.mode === 'episodes') {
showByClass(context, 'episodeFilter');
}
}
}
function showByClass(context, className) {
function showByClass(context, className) {
for (const elem of context.querySelectorAll(`.${className}`)) {
elem.classList.remove('hide');
}
}
}
function hideByClass(context, className) {
function hideByClass(context, className) {
for (const elem of context.querySelectorAll(`.${className}`)) {
elem.classList.add('hide');
}
}
}
function enableDynamicFilters(mode) {
function enableDynamicFilters(mode) {
return mode === 'movies' || mode === 'series' || mode === 'albums' || mode === 'albumartists' || mode === 'artists' || mode === 'songs' || mode === 'episodes';
}
}
class FilterDialog {
class FilterDialog {
constructor(options) {
/**
* @private
@ -417,8 +416,6 @@ import template from './filterdialog.template.html';
}
});
}
}
/* eslint-enable indent */
}
export default FilterDialog;

View file

@ -1,20 +1,18 @@
/* eslint-disable indent */
import dom from '../scripts/dom';
import scrollManager from './scrollManager';
const scopes = [];
function pushScope(elem) {
const scopes = [];
function pushScope(elem) {
scopes.push(elem);
}
}
function popScope() {
function popScope() {
if (scopes.length) {
scopes.length -= 1;
}
}
}
function autoFocus(view, defaultToFirst, findAutoFocusElement) {
function autoFocus(view, defaultToFirst, findAutoFocusElement) {
let element;
if (findAutoFocusElement !== false) {
element = view.querySelector('*[autofocus]');
@ -34,9 +32,9 @@ import scrollManager from './scrollManager';
}
return null;
}
}
function focus(element) {
function focus(element) {
try {
element.focus({
preventScroll: scrollManager.isEnabled()
@ -44,23 +42,23 @@ import scrollManager from './scrollManager';
} catch (err) {
console.error('Error in focusManager.autoFocus: ' + err);
}
}
}
const focusableTagNames = ['INPUT', 'TEXTAREA', 'SELECT', 'BUTTON', 'A'];
const focusableContainerTagNames = ['BODY', 'DIALOG'];
const focusableQuery = focusableTagNames.map(function (t) {
const focusableTagNames = ['INPUT', 'TEXTAREA', 'SELECT', 'BUTTON', 'A'];
const focusableContainerTagNames = ['BODY', 'DIALOG'];
const focusableQuery = focusableTagNames.map(function (t) {
if (t === 'INPUT') {
t += ':not([type="range"]):not([type="file"])';
}
return t + ':not([tabindex="-1"]):not(:disabled)';
}).join(',') + ',.focusable';
}).join(',') + ',.focusable';
function isFocusable(elem) {
function isFocusable(elem) {
return focusableTagNames.indexOf(elem.tagName) !== -1
|| (elem.classList?.contains('focusable'));
}
}
function normalizeFocusable(elem, originalElement) {
function normalizeFocusable(elem, originalElement) {
if (elem) {
const tagName = elem.tagName;
if (!tagName || tagName === 'HTML' || tagName === 'BODY') {
@ -69,9 +67,9 @@ import scrollManager from './scrollManager';
}
return elem;
}
}
function focusableParent(elem) {
function focusableParent(elem) {
const originalElement = elem;
while (!isFocusable(elem)) {
@ -85,16 +83,16 @@ import scrollManager from './scrollManager';
}
return normalizeFocusable(elem, originalElement);
}
}
// Determines if a focusable element can be focused at a given point in time
function isCurrentlyFocusableInternal(elem) {
// Determines if a focusable element can be focused at a given point in time
function isCurrentlyFocusableInternal(elem) {
// http://stackoverflow.com/questions/19669786/check-if-element-is-visible-in-dom
return elem.offsetParent !== null;
}
}
// Determines if a focusable element can be focused at a given point in time
function isCurrentlyFocusable(elem) {
// Determines if a focusable element can be focused at a given point in time
function isCurrentlyFocusable(elem) {
if (elem.disabled) {
return false;
}
@ -114,13 +112,13 @@ import scrollManager from './scrollManager';
}
return isCurrentlyFocusableInternal(elem);
}
}
function getDefaultScope() {
function getDefaultScope() {
return scopes[0] || document.body;
}
}
function getFocusableElements(parent, limit, excludeClass) {
function getFocusableElements(parent, limit, excludeClass) {
const elems = (parent || getDefaultScope()).querySelectorAll(focusableQuery);
const focusableElements = [];
@ -141,9 +139,9 @@ import scrollManager from './scrollManager';
}
return focusableElements;
}
}
function isFocusContainer(elem, direction) {
function isFocusContainer(elem, direction) {
if (focusableContainerTagNames.indexOf(elem.tagName) !== -1) {
return true;
}
@ -182,9 +180,9 @@ import scrollManager from './scrollManager';
}
return false;
}
}
function getFocusContainer(elem, direction) {
function getFocusContainer(elem, direction) {
while (!isFocusContainer(elem, direction)) {
elem = elem.parentNode;
@ -194,9 +192,9 @@ import scrollManager from './scrollManager';
}
return elem;
}
}
function getOffset(elem) {
function getOffset(elem) {
let box;
// Support: BlackBerry 5, iOS 3 (original iPhone)
@ -228,9 +226,9 @@ import scrollManager from './scrollManager';
}
return box;
}
}
function nav(activeElement, direction, container, focusableElements) {
function nav(activeElement, direction, container, focusableElements) {
activeElement = activeElement || document.activeElement;
if (activeElement) {
@ -382,23 +380,23 @@ import scrollManager from './scrollManager';
}
focus(nearestElement);
}
}
}
function intersectsInternal(a1, a2, b1, b2) {
function intersectsInternal(a1, a2, b1, b2) {
return (b1 >= a1 && b1 <= a2) || (b2 >= a1 && b2 <= a2);
}
}
function intersects(a1, a2, b1, b2) {
function intersects(a1, a2, b1, b2) {
return intersectsInternal(a1, a2, b1, b2) || intersectsInternal(b1, b2, a1, a2);
}
}
function sendText(text) {
function sendText(text) {
const elem = document.activeElement;
elem.value = text;
}
}
function focusFirst(container, focusableSelector) {
function focusFirst(container, focusableSelector) {
const elems = container.querySelectorAll(focusableSelector);
for (let i = 0, length = elems.length; i < length; i++) {
@ -409,9 +407,9 @@ import scrollManager from './scrollManager';
break;
}
}
}
}
function focusLast(container, focusableSelector) {
function focusLast(container, focusableSelector) {
const elems = [].slice.call(container.querySelectorAll(focusableSelector), 0).reverse();
for (let i = 0, length = elems.length; i < length; i++) {
@ -422,9 +420,9 @@ import scrollManager from './scrollManager';
break;
}
}
}
}
function moveFocus(sourceElement, container, focusableSelector, offset) {
function moveFocus(sourceElement, container, focusableSelector, offset) {
const elems = container.querySelectorAll(focusableSelector);
const list = [];
let i;
@ -462,9 +460,7 @@ import scrollManager from './scrollManager';
if (newElem) {
focus(newElem);
}
}
/* eslint-enable indent */
}
export default {
autoFocus: autoFocus,

View file

@ -1,11 +1,9 @@
/* eslint-disable indent */
import dom from '../scripts/dom';
import { appRouter } from './appRouter';
import Dashboard from '../utils/dashboard';
import ServerConnections from './ServerConnections';
function onGroupedCardClick(e, card) {
function onGroupedCardClick(e, card) {
const itemId = card.getAttribute('data-id');
const serverId = card.getAttribute('data-serverid');
const apiClient = ServerConnections.getApiClient(serverId);
@ -34,14 +32,12 @@ import ServerConnections from './ServerConnections';
e.preventDefault();
return false;
}
}
}
export default function onItemsContainerClick(e) {
export default function onItemsContainerClick(e) {
const groupedCard = dom.parentWithClass(e.target, 'groupedCard');
if (groupedCard) {
onGroupedCardClick(e, groupedCard);
}
}
/* eslint-enable indent */
}

View file

@ -14,11 +14,9 @@ import ServerConnections from '../ServerConnections';
import toast from '../toast/toast';
import template from './homeScreenSettings.template.html';
/* eslint-disable indent */
const numConfigurableSections = 7;
const numConfigurableSections = 7;
function renderViews(page, user, result) {
function renderViews(page, user, result) {
let folderHtml = '';
folderHtml += '<div class="checkboxList">';
@ -42,9 +40,9 @@ import template from './homeScreenSettings.template.html';
folderHtml += '</div>';
page.querySelector('.folderGroupList').innerHTML = folderHtml;
}
}
function getLandingScreenOptions(type) {
function getLandingScreenOptions(type) {
const list = [];
if (type === 'movies') {
@ -158,9 +156,9 @@ import template from './homeScreenSettings.template.html';
}
return list;
}
}
function getLandingScreenOptionsHtml(type, userValue) {
function getLandingScreenOptionsHtml(type, userValue) {
return getLandingScreenOptions(type).map(o => {
const selected = userValue === o.value || (o.isDefault && !userValue);
const selectedHtml = selected ? ' selected' : '';
@ -168,9 +166,9 @@ import template from './homeScreenSettings.template.html';
return `<option value="${optionValue}"${selectedHtml}>${escapeHtml(o.name)}</option>`;
}).join('');
}
}
function renderViewOrder(context, user, result) {
function renderViewOrder(context, user, result) {
let html = '';
html += result.Items.map((view) => {
@ -197,9 +195,9 @@ import template from './homeScreenSettings.template.html';
}).join('');
context.querySelector('.viewOrderList').innerHTML = html;
}
}
function updateHomeSectionValues(context, userSettings) {
function updateHomeSectionValues(context, userSettings) {
for (let i = 1; i <= 7; i++) {
const select = context.querySelector(`#selectHomeSection${i}`);
const defaultValue = homeSections.getDefaultSection(i - 1);
@ -218,9 +216,9 @@ import template from './homeScreenSettings.template.html';
}
context.querySelector('.selectTVHomeScreen').value = userSettings.get('tvhome') || '';
}
}
function getPerLibrarySettingsHtml(item, user, userSettings) {
function getPerLibrarySettingsHtml(item, user, userSettings) {
let html = '';
let isChecked;
@ -274,9 +272,9 @@ import template from './homeScreenSettings.template.html';
}
return html;
}
}
function renderPerLibrarySettings(context, user, userViews, userSettings) {
function renderPerLibrarySettings(context, user, userViews, userSettings) {
const elem = context.querySelector('.perLibrarySettings');
let html = '';
@ -285,9 +283,9 @@ import template from './homeScreenSettings.template.html';
}
elem.innerHTML = html;
}
}
function loadForm(context, user, userSettings, apiClient) {
function loadForm(context, user, userSettings, apiClient) {
context.querySelector('.chkHidePlayedFromLatest').checked = user.Configuration.HidePlayedInLatest || false;
updateHomeSectionValues(context, userSettings);
@ -304,9 +302,9 @@ import template from './homeScreenSettings.template.html';
loading.hide();
});
}
}
function onSectionOrderListClick(e) {
function onSectionOrderListClick(e) {
const target = dom.parentWithClass(e.target, 'btnViewItemMove');
if (target) {
@ -332,9 +330,9 @@ import template from './homeScreenSettings.template.html';
}
}
}
}
}
function getCheckboxItems(selector, context, isChecked) {
function getCheckboxItems(selector, context, isChecked) {
const inputs = context.querySelectorAll(selector);
const list = [];
@ -345,9 +343,9 @@ import template from './homeScreenSettings.template.html';
}
return list;
}
}
function saveUser(context, user, userSettingsInstance, apiClient) {
function saveUser(context, user, userSettingsInstance, apiClient) {
user.Configuration.HidePlayedInLatest = context.querySelector('.chkHidePlayedFromLatest').checked;
user.Configuration.LatestItemsExcludes = getCheckboxItems('.chkIncludeInLatest', context, false).map(i => {
@ -389,9 +387,9 @@ import template from './homeScreenSettings.template.html';
}
return apiClient.updateUserConfiguration(user.Id, user.Configuration);
}
}
function save(instance, context, userId, userSettings, apiClient, enableSaveConfirmation) {
function save(instance, context, userId, userSettings, apiClient, enableSaveConfirmation) {
loading.show();
apiClient.getUser(userId).then(user => {
@ -406,9 +404,9 @@ import template from './homeScreenSettings.template.html';
loading.hide();
});
});
}
}
function onSubmit(e) {
function onSubmit(e) {
const self = this;
const apiClient = ServerConnections.getApiClient(self.options.serverId);
const userId = self.options.userId;
@ -424,9 +422,9 @@ import template from './homeScreenSettings.template.html';
e.preventDefault();
}
return false;
}
}
function onChange(e) {
function onChange(e) {
const chkIncludeInMyMedia = dom.parentWithClass(e.target, 'chkIncludeInMyMedia');
if (!chkIncludeInMyMedia) {
return;
@ -441,9 +439,9 @@ import template from './homeScreenSettings.template.html';
fldIncludeInLatest.classList.add('hide');
}
}
}
}
function embed(options, self) {
function embed(options, self) {
let workingTemplate = template;
for (let i = 1; i <= numConfigurableSections; i++) {
workingTemplate = workingTemplate.replace(`{section${i}label}`, globalize.translate('LabelHomeScreenSectionValue', i));
@ -466,9 +464,9 @@ import template from './homeScreenSettings.template.html';
}
self.loadData(options.autoFocus);
}
}
class HomeScreenSettings {
class HomeScreenSettings {
constructor(options) {
this.options = options;
embed(options, this);
@ -504,8 +502,6 @@ import template from './homeScreenSettings.template.html';
destroy() {
this.options = null;
}
}
/* eslint-enable indent */
}
export default HomeScreenSettings;

View file

@ -13,9 +13,7 @@ import './homesections.scss';
import Dashboard from '../../utils/dashboard';
import ServerConnections from '../ServerConnections';
/* eslint-disable indent */
export function getDefaultSection(index) {
export function getDefaultSection(index) {
switch (index) {
case 0:
return 'smalllibrarytiles';
@ -36,9 +34,9 @@ import ServerConnections from '../ServerConnections';
default:
return '';
}
}
}
function getAllSectionsToShow(userSettings, sectionCount) {
function getAllSectionsToShow(userSettings, sectionCount) {
const sections = [];
for (let i = 0, length = sectionCount; i < length; i++) {
let section = userSettings.get('homesection' + i) || getDefaultSection(i);
@ -50,9 +48,9 @@ import ServerConnections from '../ServerConnections';
}
return sections;
}
}
export function loadSections(elem, apiClient, user, userSettings) {
export function loadSections(elem, apiClient, user, userSettings) {
return getUserViews(apiClient, user.Id).then(function (userViews) {
let html = '';
@ -98,9 +96,9 @@ import ServerConnections from '../ServerConnections';
}
}
});
}
}
export function destroySections(elem) {
export function destroySections(elem) {
const elems = elem.querySelectorAll('.itemsContainer');
for (let i = 0; i < elems.length; i++) {
elems[i].fetchData = null;
@ -109,16 +107,16 @@ import ServerConnections from '../ServerConnections';
}
elem.innerHTML = '';
}
}
export function pause(elem) {
export function pause(elem) {
const elems = elem.querySelectorAll('.itemsContainer');
for (let i = 0; i < elems.length; i++) {
elems[i].pause();
}
}
}
export function resume(elem, options) {
export function resume(elem, options) {
const elems = elem.querySelectorAll('.itemsContainer');
const promises = [];
@ -127,9 +125,9 @@ import ServerConnections from '../ServerConnections';
}
return Promise.all(promises);
}
}
function loadSection(page, apiClient, user, userSettings, userViews, allSections, index) {
function loadSection(page, apiClient, user, userSettings, userViews, allSections, index) {
const section = allSections[index];
const elem = page.querySelector('.section' + index);
@ -156,31 +154,31 @@ import ServerConnections from '../ServerConnections';
return Promise.resolve();
}
return Promise.resolve();
}
}
function getUserViews(apiClient, userId) {
function getUserViews(apiClient, userId) {
return apiClient.getUserViews({}, userId || apiClient.getCurrentUserId()).then(function (result) {
return result.Items;
});
}
}
function enableScrollX() {
function enableScrollX() {
return true;
}
}
function getSquareShape() {
function getSquareShape() {
return enableScrollX() ? 'overflowSquare' : 'square';
}
}
function getThumbShape() {
function getThumbShape() {
return enableScrollX() ? 'overflowBackdrop' : 'backdrop';
}
}
function getPortraitShape() {
function getPortraitShape() {
return enableScrollX() ? 'overflowPortrait' : 'portrait';
}
}
function getLibraryButtonsHtml(items) {
function getLibraryButtonsHtml(items) {
let html = '';
html += '<div class="verticalSection verticalSection-extrabottompadding">';
@ -199,17 +197,17 @@ import ServerConnections from '../ServerConnections';
html += '</div>';
return html;
}
}
function loadlibraryButtons(elem, apiClient, user, userSettings, userViews) {
function loadlibraryButtons(elem, apiClient, user, userSettings, userViews) {
elem.classList.remove('verticalSection');
const html = getLibraryButtonsHtml(userViews);
elem.innerHTML = html;
imageLoader.lazyChildren(elem);
}
}
function getFetchLatestItemsFn(serverId, parentId, collectionType) {
function getFetchLatestItemsFn(serverId, parentId, collectionType) {
return function () {
const apiClient = ServerConnections.getApiClient(serverId);
let limit = 16;
@ -238,9 +236,9 @@ import ServerConnections from '../ServerConnections';
return apiClient.getLatestItems(options);
};
}
}
function getLatestItemsHtmlFn(itemType, viewType) {
function getLatestItemsHtmlFn(itemType, viewType) {
return function (items) {
const cardLayout = false;
let shape;
@ -270,9 +268,9 @@ import ServerConnections from '../ServerConnections';
lines: 2
});
};
}
}
function renderLatestSection(elem, apiClient, user, parent) {
function renderLatestSection(elem, apiClient, user, parent) {
let html = '';
html += '<div class="sectionTitleContainer sectionTitleContainer-cards padded-left">';
@ -308,9 +306,9 @@ import ServerConnections from '../ServerConnections';
itemsContainer.fetchData = getFetchLatestItemsFn(apiClient.serverId(), parent.Id, parent.CollectionType);
itemsContainer.getItemsHtml = getLatestItemsHtmlFn(parent.Type, parent.CollectionType);
itemsContainer.parentContainer = elem;
}
}
function loadRecentlyAdded(elem, apiClient, user, userViews) {
function loadRecentlyAdded(elem, apiClient, user, userViews) {
elem.classList.remove('verticalSection');
const excludeViewTypes = ['playlists', 'livetv', 'boxsets', 'channels'];
@ -331,9 +329,9 @@ import ServerConnections from '../ServerConnections';
renderLatestSection(frag, apiClient, user, item);
}
}
}
export function loadLibraryTiles(elem, apiClient, user, userSettings, shape, userViews) {
export function loadLibraryTiles(elem, apiClient, user, userSettings, shape, userViews) {
let html = '';
if (userViews.length) {
html += '<h2 class="sectionTitle sectionTitle-cards padded-left">' + globalize.translate('HeaderMyMedia') + '</h2>';
@ -363,14 +361,14 @@ import ServerConnections from '../ServerConnections';
elem.innerHTML = html;
imageLoader.lazyChildren(elem);
}
}
const dataMonitorHints = {
const dataMonitorHints = {
'Audio': 'audioplayback,markplayed',
'Video': 'videoplayback,markplayed'
};
};
function loadResume(elem, apiClient, headerText, mediaType, userSettings) {
function loadResume(elem, apiClient, headerText, mediaType, userSettings) {
let html = '';
const dataMonitor = dataMonitorHints[mediaType] || 'markplayed';
@ -395,9 +393,9 @@ import ServerConnections from '../ServerConnections';
itemsContainer.fetchData = getItemsToResumeFn(mediaType, apiClient.serverId());
itemsContainer.getItemsHtml = getItemsToResumeHtmlFn(userSettings.useEpisodeImagesInNextUpAndResume(), mediaType);
itemsContainer.parentContainer = elem;
}
}
function getItemsToResumeFn(mediaType, serverId) {
function getItemsToResumeFn(mediaType, serverId) {
return function () {
const apiClient = ServerConnections.getApiClient(serverId);
@ -415,9 +413,9 @@ import ServerConnections from '../ServerConnections';
return apiClient.getResumableItems(apiClient.getCurrentUserId(), options);
};
}
}
function getItemsToResumeHtmlFn(useEpisodeImages, mediaType) {
function getItemsToResumeHtmlFn(useEpisodeImages, mediaType) {
return function (items) {
const cardLayout = false;
return cardBuilder.getCardsHtml({
@ -439,9 +437,9 @@ import ServerConnections from '../ServerConnections';
lines: 2
});
};
}
}
function getOnNowFetchFn(serverId) {
function getOnNowFetchFn(serverId) {
return function () {
const apiClient = ServerConnections.getApiClient(serverId);
return apiClient.getLiveTvRecommendedPrograms({
@ -454,9 +452,9 @@ import ServerConnections from '../ServerConnections';
Fields: 'ChannelInfo,PrimaryImageAspectRatio'
});
};
}
}
function getOnNowItemsHtml(items) {
function getOnNowItemsHtml(items) {
return cardBuilder.getCardsHtml({
items: items,
preferThumb: 'auto',
@ -476,9 +474,9 @@ import ServerConnections from '../ServerConnections';
lines: 3,
overlayPlayButton: true
});
}
}
function loadOnNow(elem, apiClient, user) {
function loadOnNow(elem, apiClient, user) {
if (!user.Policy.EnableLiveTvAccess) {
return Promise.resolve();
}
@ -587,9 +585,9 @@ import ServerConnections from '../ServerConnections';
itemsContainer.getItemsHtml = getOnNowItemsHtml;
}
});
}
}
function getNextUpFetchFn(serverId, userSettings) {
function getNextUpFetchFn(serverId, userSettings) {
return function () {
const apiClient = ServerConnections.getApiClient(serverId);
const oldestDateForNextUp = new Date();
@ -606,9 +604,9 @@ import ServerConnections from '../ServerConnections';
EnableRewatching: userSettings.enableRewatchingInNextUp()
});
};
}
}
function getNextUpItemsHtmlFn(useEpisodeImages) {
function getNextUpItemsHtmlFn(useEpisodeImages) {
return function (items) {
const cardLayout = false;
return cardBuilder.getCardsHtml({
@ -627,9 +625,9 @@ import ServerConnections from '../ServerConnections';
cardLayout: cardLayout
});
};
}
}
function loadNextUp(elem, apiClient, userSettings) {
function loadNextUp(elem, apiClient, userSettings) {
let html = '';
html += '<div class="sectionTitleContainer sectionTitleContainer-cards padded-left">';
@ -668,9 +666,9 @@ import ServerConnections from '../ServerConnections';
itemsContainer.fetchData = getNextUpFetchFn(apiClient.serverId(), userSettings);
itemsContainer.getItemsHtml = getNextUpItemsHtmlFn(userSettings.useEpisodeImagesInNextUpAndResume());
itemsContainer.parentContainer = elem;
}
}
function getLatestRecordingsFetchFn(serverId, activeRecordingsOnly) {
function getLatestRecordingsFetchFn(serverId, activeRecordingsOnly) {
return function () {
const apiClient = ServerConnections.getApiClient(serverId);
return apiClient.getLiveTvRecordings({
@ -682,9 +680,9 @@ import ServerConnections from '../ServerConnections';
IsInProgress: activeRecordingsOnly ? true : null
});
};
}
}
function getLatestRecordingItemsHtml(activeRecordingsOnly) {
function getLatestRecordingItemsHtml(activeRecordingsOnly) {
return function (items) {
return cardBuilder.getCardsHtml({
items: items,
@ -707,9 +705,9 @@ import ServerConnections from '../ServerConnections';
centerPlayButton: activeRecordingsOnly
});
};
}
}
function loadLatestLiveTvRecordings(elem, activeRecordingsOnly, apiClient) {
function loadLatestLiveTvRecordings(elem, activeRecordingsOnly, apiClient) {
const title = activeRecordingsOnly ?
globalize.translate('HeaderActiveRecordings') :
globalize.translate('HeaderLatestRecordings');
@ -739,7 +737,7 @@ import ServerConnections from '../ServerConnections';
itemsContainer.fetchData = getLatestRecordingsFetchFn(apiClient.serverId(), activeRecordingsOnly);
itemsContainer.getItemsHtml = getLatestRecordingItemsHtml(activeRecordingsOnly);
itemsContainer.parentContainer = elem;
}
}
export default {
loadLibraryTiles: loadLibraryTiles,
@ -750,4 +748,3 @@ export default {
resume: resume
};
/* eslint-enable indent */

View file

@ -1,36 +1,33 @@
/* eslint-disable indent */
import appSettings from '../scripts/settings/appSettings' ;
import browser from '../scripts/browser';
import Events from '../utils/events.ts';
export function getSavedVolume() {
export function getSavedVolume() {
return appSettings.get('volume') || 1;
}
}
export function saveVolume(value) {
export function saveVolume(value) {
if (value) {
appSettings.set('volume', value);
}
}
}
export function getCrossOriginValue(mediaSource) {
export function getCrossOriginValue(mediaSource) {
if (mediaSource.IsRemote) {
return null;
}
return 'anonymous';
}
}
function canPlayNativeHls() {
function canPlayNativeHls() {
const media = document.createElement('video');
return !!(media.canPlayType('application/x-mpegURL').replace(/no/, '')
|| media.canPlayType('application/vnd.apple.mpegURL').replace(/no/, ''));
}
}
export function enableHlsJsPlayer(runTimeTicks, mediaType) {
export function enableHlsJsPlayer(runTimeTicks, mediaType) {
if (window.MediaSource == null) {
return false;
}
@ -58,11 +55,11 @@ import Events from '../utils/events.ts';
}
return true;
}
}
let recoverDecodingErrorDate;
let recoverSwapAudioCodecDate;
export function handleHlsJsMediaError(instance, reject) {
let recoverDecodingErrorDate;
let recoverSwapAudioCodecDate;
export function handleHlsJsMediaError(instance, reject) {
const hlsPlayer = instance._hlsPlayer;
if (!hlsPlayer) {
@ -95,9 +92,9 @@ import Events from '../utils/events.ts';
}
}
}
}
}
export function onErrorInternal(instance, type) {
export function onErrorInternal(instance, type) {
// Needed for video
if (instance.destroyCustomTrack) {
instance.destroyCustomTrack(instance._mediaElement);
@ -108,23 +105,23 @@ import Events from '../utils/events.ts';
type: type
}
]);
}
}
export function isValidDuration(duration) {
export function isValidDuration(duration) {
return duration
&& !isNaN(duration)
&& duration !== Number.POSITIVE_INFINITY
&& duration !== Number.NEGATIVE_INFINITY;
}
}
function setCurrentTimeIfNeeded(element, seconds) {
function setCurrentTimeIfNeeded(element, seconds) {
// If it's worth skipping (1 sec or less of a difference)
if (Math.abs((element.currentTime || 0) - seconds) >= 1) {
element.currentTime = seconds;
}
}
}
export function seekOnPlaybackStart(instance, element, ticks, onMediaReady) {
export function seekOnPlaybackStart(instance, element, ticks, onMediaReady) {
const seconds = (ticks || 0) / 10000000;
if (seconds) {
@ -157,9 +154,9 @@ import Events from '../utils/events.ts';
});
}
}
}
}
export function applySrc(elem, src, options) {
export function applySrc(elem, src, options) {
if (window.Windows && options.mediaSource && options.mediaSource.IsLocal) {
return Windows.Storage.StorageFile.getFileFromPathAsync(options.url).then(function (file) {
const playlist = new Windows.Media.Playback.MediaPlaybackList();
@ -175,19 +172,19 @@ import Events from '../utils/events.ts';
}
return Promise.resolve();
}
}
export function resetSrc(elem) {
export function resetSrc(elem) {
elem.src = '';
elem.innerHTML = '';
elem.removeAttribute('src');
}
}
function onSuccessfulPlay(elem, onErrorFn) {
function onSuccessfulPlay(elem, onErrorFn) {
elem.addEventListener('error', onErrorFn);
}
}
export function playWithPromise(elem, onErrorFn) {
export function playWithPromise(elem, onErrorFn) {
try {
return elem.play()
.catch((e) => {
@ -208,9 +205,9 @@ import Events from '../utils/events.ts';
console.error('error calling video.play: ' + err);
return Promise.reject();
}
}
}
export function destroyCastPlayer(instance) {
export function destroyCastPlayer(instance) {
const player = instance._castPlayer;
if (player) {
try {
@ -221,9 +218,9 @@ import Events from '../utils/events.ts';
instance._castPlayer = null;
}
}
}
export function destroyHlsPlayer(instance) {
export function destroyHlsPlayer(instance) {
const player = instance._hlsPlayer;
if (player) {
try {
@ -234,9 +231,9 @@ import Events from '../utils/events.ts';
instance._hlsPlayer = null;
}
}
}
export function destroyFlvPlayer(instance) {
export function destroyFlvPlayer(instance) {
const player = instance._flvPlayer;
if (player) {
try {
@ -249,9 +246,9 @@ import Events from '../utils/events.ts';
instance._flvPlayer = null;
}
}
}
export function bindEventsToHlsPlayer(instance, hls, elem, onErrorFn, resolve, reject) {
export function bindEventsToHlsPlayer(instance, hls, elem, onErrorFn, resolve, reject) {
hls.on(Hls.Events.MANIFEST_PARSED, function () {
playWithPromise(elem, onErrorFn).then(resolve, function () {
if (reject) {
@ -329,9 +326,9 @@ import Events from '../utils/events.ts';
}
}
});
}
}
export function onEndedInternal(instance, elem, onErrorFn) {
export function onEndedInternal(instance, elem, onErrorFn) {
elem.removeEventListener('error', onErrorFn);
resetSrc(elem);
@ -349,9 +346,9 @@ import Events from '../utils/events.ts';
instance._currentTime = null;
instance._currentSrc = null;
instance._currentPlayOptions = null;
}
}
export function getBufferedRanges(instance, elem) {
export function getBufferedRanges(instance, elem) {
const ranges = [];
const seekable = elem.buffered || [];
@ -382,6 +379,4 @@ import Events from '../utils/events.ts';
}
return ranges;
}
/* eslint-enable indent */
}

View file

@ -15,25 +15,23 @@ import '../cardbuilder/card.scss';
import ServerConnections from '../ServerConnections';
import template from './imageDownloader.template.html';
/* eslint-disable indent */
const enableFocusTransform = !browser.slow && !browser.edge;
const enableFocusTransform = !browser.slow && !browser.edge;
let currentItemId;
let currentItemType;
let currentResolve;
let currentReject;
let hasChanges = false;
let currentItemId;
let currentItemType;
let currentResolve;
let currentReject;
let hasChanges = false;
// These images can be large and we're seeing memory problems in safari
const browsableImagePageSize = browser.slow ? 6 : 30;
// These images can be large and we're seeing memory problems in safari
const browsableImagePageSize = browser.slow ? 6 : 30;
let browsableImageStartIndex = 0;
let browsableImageType = 'Primary';
let selectedProvider;
let browsableParentId;
let browsableImageStartIndex = 0;
let browsableImageType = 'Primary';
let selectedProvider;
let browsableParentId;
function getBaseRemoteOptions(page, forceCurrentItemId = false) {
function getBaseRemoteOptions(page, forceCurrentItemId = false) {
const options = {};
if (!forceCurrentItemId && page.querySelector('#chkShowParentImages').checked && browsableParentId) {
@ -43,9 +41,9 @@ import template from './imageDownloader.template.html';
}
return options;
}
}
function reloadBrowsableImages(page, apiClient) {
function reloadBrowsableImages(page, apiClient) {
loading.show();
const options = getBaseRemoteOptions(page);
@ -76,9 +74,9 @@ import template from './imageDownloader.template.html';
loading.hide();
});
}
}
function renderRemoteImages(page, apiClient, imagesResult, imageType, startIndex, limit) {
function renderRemoteImages(page, apiClient, imagesResult, imageType, startIndex, limit) {
page.querySelector('.availableImagesPaging').innerHTML = getPagingHtml(startIndex, limit, imagesResult.TotalRecordCount);
let html = '';
@ -107,9 +105,9 @@ import template from './imageDownloader.template.html';
reloadBrowsableImages(page, apiClient);
});
}
}
}
function getPagingHtml(startIndex, limit, totalRecordCount) {
function getPagingHtml(startIndex, limit, totalRecordCount) {
let html = '';
const recordsEnd = Math.min(startIndex + limit, totalRecordCount);
@ -137,9 +135,9 @@ import template from './imageDownloader.template.html';
html += '</div>';
return html;
}
}
function downloadRemoteImage(page, apiClient, url, type, provider) {
function downloadRemoteImage(page, apiClient, url, type, provider) {
const options = getBaseRemoteOptions(page, true);
options.Type = type;
@ -153,9 +151,9 @@ import template from './imageDownloader.template.html';
const dlg = dom.parentWithClass(page, 'dialog');
dialogHelper.close(dlg);
});
}
}
function getRemoteImageHtml(image, imageType) {
function getRemoteImageHtml(image, imageType) {
const tagName = layoutManager.tv ? 'button' : 'div';
const enableFooterButtons = !layoutManager.tv;
@ -276,14 +274,14 @@ import template from './imageDownloader.template.html';
html += '</' + tagName + '>';
return html;
}
}
function reloadBrowsableImagesFirstPage(page, apiClient) {
function reloadBrowsableImagesFirstPage(page, apiClient) {
browsableImageStartIndex = 0;
reloadBrowsableImages(page, apiClient);
}
}
function initEditor(page, apiClient) {
function initEditor(page, apiClient) {
page.querySelector('#selectBrowsableImageType').addEventListener('change', function () {
browsableImageType = this.value;
selectedProvider = null;
@ -318,9 +316,9 @@ import template from './imageDownloader.template.html';
downloadRemoteImage(page, apiClient, btnImageCard.getAttribute('data-imageurl'), btnImageCard.getAttribute('data-imagetype'), btnImageCard.getAttribute('data-imageprovider'));
}
});
}
}
function showEditor(itemId, serverId, itemType) {
function showEditor(itemId, serverId, itemType) {
loading.show();
const apiClient = ServerConnections.getApiClient(serverId);
@ -363,9 +361,9 @@ import template from './imageDownloader.template.html';
});
reloadBrowsableImages(editorContent, apiClient);
}
}
function onDialogClosed() {
function onDialogClosed() {
const dlg = this;
if (layoutManager.tv) {
@ -378,7 +376,7 @@ import template from './imageDownloader.template.html';
} else {
currentReject();
}
}
}
export function show(itemId, serverId, itemType, imageType, parentId) {
return new Promise(function (resolve, reject) {
@ -397,4 +395,3 @@ export default {
show: show
};
/* eslint-enable indent */

View file

@ -1,4 +1,3 @@
/* eslint-disable indent */
/**
* Module for image Options Editor.
@ -13,25 +12,25 @@ import '../../elements/emby-select/emby-select';
import '../../elements/emby-input/emby-input';
import template from './imageOptionsEditor.template.html';
function getDefaultImageConfig(itemType, type) {
function getDefaultImageConfig(itemType, type) {
return {
Type: type,
MinWidth: 0,
Limit: type === 'Primary' ? 1 : 0
};
}
}
function findImageOptions(imageOptions, type) {
function findImageOptions(imageOptions, type) {
return imageOptions.filter(i => {
return i.Type == type;
})[0];
}
}
function getImageConfig(options, availableOptions, imageType, itemType) {
function getImageConfig(options, availableOptions, imageType, itemType) {
return findImageOptions(options.ImageOptions || [], imageType) || findImageOptions(availableOptions.DefaultImageOptions || [], imageType) || getDefaultImageConfig(itemType, imageType);
}
}
function setVisibilityOfBackdrops(elem, visible) {
function setVisibilityOfBackdrops(elem, visible) {
if (visible) {
elem.classList.remove('hide');
elem.querySelector('input').setAttribute('required', 'required');
@ -40,9 +39,9 @@ import template from './imageOptionsEditor.template.html';
elem.querySelector('input').setAttribute('required', '');
elem.querySelector('input').removeAttribute('required');
}
}
}
function loadValues(context, itemType, options, availableOptions) {
function loadValues(context, itemType, options, availableOptions) {
const supportedImageTypes = availableOptions.SupportedImageTypes || [];
setVisibilityOfBackdrops(context.querySelector('.backdropFields'), supportedImageTypes.includes('Backdrop'));
Array.prototype.forEach.call(context.querySelectorAll('.imageType'), i => {
@ -64,9 +63,9 @@ import template from './imageOptionsEditor.template.html';
const backdropConfig = getImageConfig(options, availableOptions, 'Backdrop', itemType);
context.querySelector('#txtMaxBackdrops').value = backdropConfig.Limit;
context.querySelector('#txtMinBackdropDownloadWidth').value = backdropConfig.MinWidth;
}
}
function saveValues(context, options) {
function saveValues(context, options) {
options.ImageOptions = Array.prototype.map.call(context.querySelectorAll('.imageType:not(.hide)'), c => {
return {
Type: c.getAttribute('data-imagetype'),
@ -79,9 +78,9 @@ import template from './imageOptionsEditor.template.html';
Limit: context.querySelector('#txtMaxBackdrops').value,
MinWidth: context.querySelector('#txtMinBackdropDownloadWidth').value
});
}
}
function showEditor(itemType, options, availableOptions) {
function showEditor(itemType, options, availableOptions) {
const dlg = dialogHelper.createDialog({
size: 'small',
removeOnClose: true,
@ -101,7 +100,7 @@ import template from './imageOptionsEditor.template.html';
dlg.querySelector('.btnCancel').addEventListener('click', function () {
dialogHelper.close(dlg);
});
}
}
export class editor {
constructor() {
@ -109,5 +108,4 @@ export class editor {
}
}
/* eslint-enable indent */
export default editor;

View file

@ -1,4 +1,3 @@
/* eslint-disable indent */
/**
* Module for imageUploader.
@ -19,12 +18,12 @@ import ServerConnections from '../ServerConnections';
import toast from '../toast/toast';
import template from './imageUploader.template.html';
let currentItemId;
let currentServerId;
let currentFile;
let hasChanges = false;
let currentItemId;
let currentServerId;
let currentFile;
let hasChanges = false;
function onFileReaderError(evt) {
function onFileReaderError(evt) {
loading.hide();
switch (evt.target.error.code) {
@ -37,9 +36,9 @@ import template from './imageUploader.template.html';
toast(globalize.translate('MessageFileReadError'));
break;
}
}
}
function setFiles(page, files) {
function setFiles(page, files) {
const file = files[0];
if (!file || !file.type.match('image.*')) {
@ -76,9 +75,9 @@ import template from './imageUploader.template.html';
// Read in the image file as a data URL.
reader.readAsDataURL(file);
}
}
function onSubmit(e) {
function onSubmit(e) {
const file = currentFile;
if (!file) {
@ -112,9 +111,9 @@ import template from './imageUploader.template.html';
e.preventDefault();
return false;
}
}
function initEditor(page) {
function initEditor(page) {
page.querySelector('form').addEventListener('submit', onSubmit);
page.querySelector('#uploadImage').addEventListener('change', function () {
@ -124,9 +123,9 @@ import template from './imageUploader.template.html';
page.querySelector('.btnBrowse').addEventListener('click', () => {
page.querySelector('#uploadImage').click();
});
}
}
function showEditor(options, resolve) {
function showEditor(options, resolve) {
options = options || {};
currentItemId = options.itemId;
@ -171,17 +170,16 @@ import template from './imageUploader.template.html';
dlg.querySelector('.btnCancel').addEventListener('click', () => {
dialogHelper.close(dlg);
});
}
}
export function show(options) {
export function show(options) {
return new Promise(resolve => {
hasChanges = false;
showEditor(options, resolve);
});
}
}
/* eslint-enable indent */
export default {
show: show
};

View file

@ -18,18 +18,16 @@ import alert from '../alert';
import confirm from '../confirm/confirm';
import template from './imageeditor.template.html';
/* eslint-disable indent */
const enableFocusTransform = !browser.slow && !browser.edge;
const enableFocusTransform = !browser.slow && !browser.edge;
let currentItem;
let hasChanges = false;
let currentItem;
let hasChanges = false;
function getBaseRemoteOptions() {
function getBaseRemoteOptions() {
return { itemId: currentItem.Id };
}
}
function reload(page, item, focusContext) {
function reload(page, item, focusContext) {
loading.show();
let apiClient;
@ -43,18 +41,18 @@ import template from './imageeditor.template.html';
reloadItem(page, itemToReload, apiClient, focusContext);
});
}
}
}
function addListeners(container, className, eventName, fn) {
function addListeners(container, className, eventName, fn) {
container.addEventListener(eventName, function (e) {
const elem = dom.parentWithClass(e.target, className);
if (elem) {
fn.call(elem, e);
}
});
}
}
function reloadItem(page, item, apiClient, focusContext) {
function reloadItem(page, item, apiClient, focusContext) {
currentItem = item;
apiClient.getRemoteImageProviders(getBaseRemoteOptions()).then(function (providers) {
@ -77,9 +75,9 @@ import template from './imageeditor.template.html';
}
});
});
}
}
function getImageUrl(item, apiClient, type, index, options) {
function getImageUrl(item, apiClient, type, index, options) {
options = options || {};
options.type = type;
options.index = index;
@ -94,9 +92,9 @@ import template from './imageeditor.template.html';
// For search hints
return apiClient.getScaledImageUrl(item.Id || item.ItemId, options);
}
}
function getCardHtml(image, apiClient, options) {
function getCardHtml(image, apiClient, options) {
// TODO move card creation code to Card component
let html = '';
@ -181,9 +179,9 @@ import template from './imageeditor.template.html';
html += '</' + options.tagName + '>';
return html;
}
}
function deleteImage(context, itemId, type, index, apiClient, enableConfirmation) {
function deleteImage(context, itemId, type, index, apiClient, enableConfirmation) {
const afterConfirm = function () {
apiClient.deleteItemImage(itemId, type, index).then(function () {
hasChanges = true;
@ -201,18 +199,18 @@ import template from './imageeditor.template.html';
confirmText: globalize.translate('Delete'),
primary: 'delete'
}).then(afterConfirm);
}
}
function moveImage(context, apiClient, itemId, type, index, newIndex, focusContext) {
function moveImage(context, apiClient, itemId, type, index, newIndex, focusContext) {
apiClient.updateItemImageIndex(itemId, type, index, newIndex).then(function () {
hasChanges = true;
reload(context, null, focusContext);
}, function () {
alert(globalize.translate('ErrorDefault'));
});
}
}
function renderImages(page, item, apiClient, images, imageProviders, elem) {
function renderImages(page, item, apiClient, images, imageProviders, elem) {
let html = '';
let imageSize = 300;
@ -232,17 +230,17 @@ import template from './imageeditor.template.html';
elem.innerHTML = html;
imageLoader.lazyChildren(elem);
}
}
function renderStandardImages(page, apiClient, item, imageInfos, imageProviders) {
function renderStandardImages(page, apiClient, item, imageInfos, imageProviders) {
const images = imageInfos.filter(function (i) {
return i.ImageType !== 'Backdrop' && i.ImageType !== 'Chapter';
});
renderImages(page, item, apiClient, images, imageProviders, page.querySelector('#images'));
}
}
function renderBackdrops(page, apiClient, item, imageInfos, imageProviders) {
function renderBackdrops(page, apiClient, item, imageInfos, imageProviders) {
const images = imageInfos.filter(function (i) {
return i.ImageType === 'Backdrop';
}).sort(function (a, b) {
@ -255,9 +253,9 @@ import template from './imageeditor.template.html';
} else {
page.querySelector('#backdropsContainer', page).classList.add('hide');
}
}
}
function showImageDownloader(page, imageType) {
function showImageDownloader(page, imageType) {
import('../imageDownloader/imageDownloader').then((ImageDownloader) => {
ImageDownloader.show(
currentItem.Id,
@ -270,9 +268,9 @@ import template from './imageeditor.template.html';
reload(page);
});
});
}
}
function showActionSheet(context, imageCard) {
function showActionSheet(context, imageCard) {
const itemId = imageCard.getAttribute('data-id');
const serverId = imageCard.getAttribute('data-serverid');
const apiClient = ServerConnections.getApiClient(serverId);
@ -337,9 +335,9 @@ import template from './imageeditor.template.html';
}
});
});
}
}
function initEditor(context, options) {
function initEditor(context, options) {
const uploadButtons = context.querySelectorAll('.btnOpenUploadMenu');
const isFileInputSupported = appHost.supports('fileinput');
for (let i = 0, length = uploadButtons.length; i < length; i++) {
@ -397,9 +395,9 @@ import template from './imageeditor.template.html';
const apiClient = ServerConnections.getApiClient(currentItem.ServerId);
moveImage(context, apiClient, currentItem.Id, type, index, newIndex, dom.parentWithClass(this, 'itemsContainer'));
});
}
}
function showEditor(options, resolve, reject) {
function showEditor(options, resolve, reject) {
const itemId = options.itemId;
const serverId = options.serverId;
@ -452,7 +450,7 @@ import template from './imageeditor.template.html';
dialogHelper.close(dlg);
});
});
}
}
export function show (options) {
return new Promise(function (resolve, reject) {
@ -465,4 +463,3 @@ export default {
show
};
/* eslint-enable indent */

View file

@ -17,17 +17,16 @@ worker.addEventListener(
}
}
);
/* eslint-disable indent */
export function lazyImage(elem, source = elem.getAttribute('data-src')) {
export function lazyImage(elem, source = elem.getAttribute('data-src')) {
if (!source) {
return;
}
fillImageElement(elem, source);
}
}
function drawBlurhash(target, pixels, width, height) {
function drawBlurhash(target, pixels, width, height) {
const canvas = document.createElement('canvas');
canvas.setAttribute('aria-hidden', 'true');
canvas.width = width;
@ -46,9 +45,9 @@ worker.addEventListener(
target.classList.add('blurhashed');
target.removeAttribute('data-blurhash');
});
}
}
function itemBlurhashing(target, hash) {
function itemBlurhashing(target, hash) {
try {
// Although the default values recommended by Blurhash developers is 32x32, a size of 20x20 seems to be the sweet spot for us,
// improving the performance and reducing the memory usage, while retaining almost full blur quality.
@ -68,9 +67,9 @@ worker.addEventListener(
target.classList.add('non-blurhashable');
return;
}
}
}
export function fillImage(entry) {
export function fillImage(entry) {
if (!entry) {
throw new Error('entry cannot be null');
}
@ -90,9 +89,9 @@ worker.addEventListener(
} else if (!source) {
emptyImageElement(target);
}
}
}
function onAnimationEnd(event) {
function onAnimationEnd(event) {
const elem = event.target;
requestAnimationFrame(() => {
const canvas = elem.previousSibling;
@ -104,9 +103,9 @@ worker.addEventListener(
elem.parentNode?.querySelector('.cardPadder')?.classList.add('lazy-hidden-children');
});
elem.removeEventListener('animationend', onAnimationEnd);
}
}
function fillImageElement(elem, url) {
function fillImageElement(elem, url) {
if (url === undefined) {
throw new TypeError('url cannot be undefined');
}
@ -134,9 +133,9 @@ worker.addEventListener(
elem.classList.remove('lazy-hidden');
});
});
}
}
function emptyImageElement(elem) {
function emptyImageElement(elem) {
elem.removeEventListener('animationend', onAnimationEnd);
const canvas = elem.previousSibling;
if (canvas?.tagName === 'CANVAS') {
@ -159,9 +158,9 @@ worker.addEventListener(
elem.classList.remove('lazy-image-fadein-fast', 'lazy-image-fadein');
elem.classList.add('lazy-hidden');
}
}
export function lazyChildren(elem) {
export function lazyChildren(elem) {
if (userSettings.enableBlurhash()) {
for (const lazyElem of elem.querySelectorAll('.lazy')) {
const blurhashstr = lazyElem.getAttribute('data-blurhash');
@ -174,9 +173,9 @@ worker.addEventListener(
}
lazyLoader.lazyChildren(elem, fillImage);
}
}
export function getPrimaryImageAspectRatio(items) {
export function getPrimaryImageAspectRatio(items) {
const values = [];
for (let i = 0, length = items.length; i < length; i++) {
@ -232,22 +231,21 @@ worker.addEventListener(
}
return result;
}
}
export function fillImages(elems) {
export function fillImages(elems) {
for (let i = 0, length = elems.length; i < length; i++) {
const elem = elems[0];
fillImage(elem);
}
}
}
export function setLazyImage(element, url) {
export function setLazyImage(element, url) {
element.classList.add('lazy');
element.setAttribute('data-src', url);
lazyImage(element);
}
}
/* eslint-enable indent */
export default {
setLazyImage: setLazyImage,
fillImages: fillImages,

View file

@ -9,8 +9,7 @@ import { playbackManager } from './playback/playbackmanager';
import ServerConnections from './ServerConnections';
import toast from './toast/toast';
/* eslint-disable indent */
export function getCommands(options) {
export function getCommands(options) {
const item = options.item;
const user = options.user;
@ -305,9 +304,9 @@ import toast from './toast/toast';
}
return commands;
}
}
function getResolveFunction(resolve, id, changed, deleted) {
function getResolveFunction(resolve, id, changed, deleted) {
return function () {
resolve({
command: id,
@ -315,9 +314,9 @@ import toast from './toast/toast';
deleted: deleted
});
};
}
}
function executeCommand(item, id, options) {
function executeCommand(item, id, options) {
const itemId = item.Id;
const serverId = item.ServerId;
const apiClient = ServerConnections.getApiClient(serverId);
@ -532,26 +531,26 @@ import toast from './toast/toast';
break;
}
});
}
}
function deleteTimer(apiClient, item, resolve, command) {
function deleteTimer(apiClient, item, resolve, command) {
import('./recordingcreator/recordinghelper').then(({ default: recordingHelper }) => {
const timerId = item.TimerId || item.Id;
recordingHelper.cancelTimerWithConfirmation(timerId, item.ServerId).then(function () {
getResolveFunction(resolve, command, true)();
});
});
}
}
function deleteSeriesTimer(apiClient, item, resolve, command) {
function deleteSeriesTimer(apiClient, item, resolve, command) {
import('./recordingcreator/recordinghelper').then(({ default: recordingHelper }) => {
recordingHelper.cancelSeriesTimerWithConfirmation(item.Id, item.ServerId).then(function () {
getResolveFunction(resolve, command, true)();
});
});
}
}
function play(item, resume, queue, queueNext) {
function play(item, resume, queue, queueNext) {
let method = 'play';
if (queue) {
if (queueNext) {
@ -578,9 +577,9 @@ import toast from './toast/toast';
startPositionTicks: startPosition
});
}
}
}
function editItem(apiClient, item) {
function editItem(apiClient, item) {
return new Promise(function (resolve, reject) {
const serverId = apiClient.serverInfo().Id;
@ -598,9 +597,9 @@ import toast from './toast/toast';
});
}
});
}
}
function deleteItem(apiClient, item) {
function deleteItem(apiClient, item) {
return new Promise(function (resolve, reject) {
import('../scripts/deleteHelper').then((deleteHelper) => {
deleteHelper.deleteItem({
@ -611,9 +610,9 @@ import toast from './toast/toast';
}, reject);
});
});
}
}
function refresh(apiClient, item) {
function refresh(apiClient, item) {
import('./refreshdialog/refreshdialog').then(({ default: refreshDialog }) => {
new refreshDialog({
itemIds: [item.Id],
@ -621,9 +620,9 @@ import toast from './toast/toast';
mode: item.Type === 'CollectionFolder' ? 'scan' : null
}).show();
});
}
}
export function show(options) {
export function show(options) {
const commands = getCommands(options);
if (!commands.length) {
return Promise.reject();
@ -636,9 +635,7 @@ import toast from './toast/toast';
}).then(function (id) {
return executeCommand(options.item, id, options);
});
}
/* eslint-enable indent */
}
export default {
getCommands: getCommands,

View file

@ -1,4 +1,3 @@
/* eslint-disable indent */
/**
* Module for display media info.
@ -30,7 +29,7 @@ const copyButtonHtml = layoutManager.tv ? '' :
><span class="material-icons content_copy" aria-hidden="true"></span></button>`;
const attributeDelimiterHtml = layoutManager.tv ? '' : '<span class="hide">: </span>';
function setMediaInfo(user, page, item) {
function setMediaInfo(user, page, item) {
let html = item.MediaSources.map(version => {
return getMediaSourceHtml(user, item, version);
}).join('<div style="border-top:1px solid #444;margin: 1em 0;"></div>');
@ -52,9 +51,9 @@ const attributeDelimiterHtml = layoutManager.tv ? '' : '<span class="hide">: </s
});
});
}
}
}
function getMediaSourceHtml(user, item, version) {
function getMediaSourceHtml(user, item, version) {
let html = '<div class="mediaInfoSource">';
if (version.Name) {
html += `<div><h2 class="mediaInfoStreamType">${escapeHtml(version.Name)}${copyButtonHtml}</h2></div>\n`;
@ -210,14 +209,14 @@ const attributeDelimiterHtml = layoutManager.tv ? '' : '<span class="hide">: </s
}
html += '</div>';
return html;
}
}
// File Paths should be always ltr. The isLtr parameter allows this.
function createAttribute(label, value, isLtr) {
// File Paths should be always ltr. The isLtr parameter allows this.
function createAttribute(label, value, isLtr) {
return `<span class="mediaInfoLabel">${label}</span>${attributeDelimiterHtml}<span class="mediaInfoAttribute" ${isLtr && 'dir="ltr"'}>${escapeHtml(value)}</span>\n`;
}
}
function loadMediaInfo(itemId, serverId) {
function loadMediaInfo(itemId, serverId) {
const apiClient = ServerConnections.getApiClient(serverId);
return apiClient.getItem(apiClient.getCurrentUserId(), itemId).then(item => {
const dialogOptions = {
@ -245,14 +244,13 @@ const attributeDelimiterHtml = layoutManager.tv ? '' : '<span class="hide">: </s
});
loading.hide();
});
}
}
export function show(itemId, serverId) {
export function show(itemId, serverId) {
loading.show();
return loadMediaInfo(itemId, serverId);
}
}
/* eslint-enable indent */
export default {
show: show
};

View file

@ -1,4 +1,3 @@
/* eslint-disable indent */
/**
* Module for itemidentifier media item.
@ -24,21 +23,21 @@ import toast from '../toast/toast';
import template from './itemidentifier.template.html';
import datetime from '../../scripts/datetime';
const enableFocusTransform = !browser.slow && !browser.edge;
const enableFocusTransform = !browser.slow && !browser.edge;
let currentItem;
let currentItemType;
let currentServerId;
let currentResolve;
let currentReject;
let hasChanges = false;
let currentSearchResult;
let currentItem;
let currentItemType;
let currentServerId;
let currentResolve;
let currentReject;
let hasChanges = false;
let currentSearchResult;
function getApiClient() {
function getApiClient() {
return ServerConnections.getApiClient(currentServerId);
}
}
function searchForIdentificationResults(page) {
function searchForIdentificationResults(page) {
let lookupInfo = {
ProviderIds: {}
};
@ -101,9 +100,9 @@ import datetime from '../../scripts/datetime';
loading.hide();
showIdentificationSearchResults(page, results);
});
}
}
function showIdentificationSearchResults(page, results) {
function showIdentificationSearchResults(page, results) {
const identificationSearchResults = page.querySelector('.identificationSearchResults');
page.querySelector('.popupIdentifyForm').classList.add('hide');
@ -142,17 +141,17 @@ import datetime from '../../scripts/datetime';
if (layoutManager.tv) {
focusManager.autoFocus(identificationSearchResults);
}
}
}
function finishFindNewDialog(dlg, identifyResult) {
function finishFindNewDialog(dlg, identifyResult) {
currentSearchResult = identifyResult;
hasChanges = true;
loading.hide();
dialogHelper.close(dlg);
}
}
function showIdentifyOptions(page, identifyResult) {
function showIdentifyOptions(page, identifyResult) {
const identifyOptionsForm = page.querySelector('.identifyOptionsForm');
page.querySelector('.popupIdentifyForm').classList.add('hide');
@ -179,9 +178,9 @@ import datetime from '../../scripts/datetime';
page.querySelector('.selectedSearchResult').innerHTML = resultHtml;
focusManager.focus(identifyOptionsForm.querySelector('.btnSubmit'));
}
}
function getSearchResultHtml(result, index) {
function getSearchResultHtml(result, index) {
// TODO move card creation code to Card component
let html = '';
@ -254,9 +253,9 @@ import datetime from '../../scripts/datetime';
html += '</div>';
html += '</button>';
return html;
}
}
function submitIdentficationResult(page) {
function submitIdentficationResult(page) {
loading.show();
const options = {
@ -281,9 +280,9 @@ import datetime from '../../scripts/datetime';
dialogHelper.close(page);
});
}
}
function showIdentificationForm(page, item) {
function showIdentificationForm(page, item) {
const apiClient = getApiClient();
apiClient.getJSON(apiClient.getUrl(`Items/${item.Id}/ExternalIdInfos`)).then(idList => {
@ -322,9 +321,9 @@ import datetime from '../../scripts/datetime';
page.querySelector('.formDialogHeaderTitle').innerHTML = globalize.translate('Identify');
});
}
}
function showEditor(itemId) {
function showEditor(itemId) {
loading.show();
const apiClient = getApiClient();
@ -391,19 +390,19 @@ import datetime from '../../scripts/datetime';
showIdentificationForm(dlg, item);
loading.hide();
});
}
}
function onDialogClosed() {
function onDialogClosed() {
loading.hide();
if (hasChanges) {
currentResolve();
} else {
currentReject();
}
}
}
// TODO investigate where this was used
function showEditorFindNew(itemName, itemYear, itemType, resolveFunc) {
// TODO investigate where this was used
function showEditorFindNew(itemName, itemYear, itemType, resolveFunc) {
currentItem = null;
currentItemType = itemType;
@ -453,9 +452,9 @@ import datetime from '../../scripts/datetime';
dlg.classList.add('identifyDialog');
showIdentificationFormFindNew(dlg, itemName, itemYear, itemType);
}
}
function showIdentificationFormFindNew(dlg, itemName, itemYear, itemType) {
function showIdentificationFormFindNew(dlg, itemName, itemYear, itemType) {
dlg.querySelector('#txtLookupName').value = itemName;
if (itemType === 'Person' || itemType === 'BoxSet') {
@ -467,9 +466,9 @@ import datetime from '../../scripts/datetime';
}
dlg.querySelector('.formDialogHeaderTitle').innerHTML = globalize.translate('Search');
}
}
export function show(itemId, serverId) {
export function show(itemId, serverId) {
return new Promise((resolve, reject) => {
currentResolve = resolve;
currentReject = reject;
@ -478,18 +477,17 @@ import datetime from '../../scripts/datetime';
showEditor(itemId);
});
}
}
export function showFindNew(itemName, itemYear, itemType, serverId) {
export function showFindNew(itemName, itemYear, itemType, serverId) {
return new Promise((resolve) => {
currentServerId = serverId;
hasChanges = false;
showEditorFindNew(itemName, itemYear, itemType, resolve);
});
}
}
/* eslint-enable indent */
export default {
show: show,
showFindNew: showFindNew

View file

@ -1,5 +1,5 @@
/* eslint-disable indent */
export class LazyLoader {
export class LazyLoader {
constructor(options) {
this.options = options;
}
@ -47,9 +47,9 @@
this.destroyObserver();
this.options = null;
}
}
}
function unveilElements(elements, root, callback) {
function unveilElements(elements, root, callback) {
if (!elements.length) {
return;
}
@ -57,13 +57,12 @@
callback: callback
});
lazyLoader.addElements(elements);
}
}
export function lazyChildren(elem, callback) {
export function lazyChildren(elem, callback) {
unveilElements(elem.getElementsByClassName('lazy'), elem, callback);
}
}
/* eslint-enable indent */
export default {
LazyLoader: LazyLoader,
lazyChildren: lazyChildren

View file

@ -1,4 +1,3 @@
/* eslint-disable indent */
/**
* Module for library options editor.
@ -14,14 +13,14 @@ import '../../elements/emby-input/emby-input';
import './style.scss';
import template from './libraryoptionseditor.template.html';
function populateLanguages(parent) {
function populateLanguages(parent) {
return ApiClient.getCultures().then(languages => {
populateLanguagesIntoSelect(parent.querySelector('#selectLanguage'), languages);
populateLanguagesIntoList(parent.querySelector('.subtitleDownloadLanguages'), languages);
});
}
}
function populateLanguagesIntoSelect(select, languages) {
function populateLanguagesIntoSelect(select, languages) {
let html = '';
html += "<option value=''></option>";
for (let i = 0; i < languages.length; i++) {
@ -29,18 +28,18 @@ import template from './libraryoptionseditor.template.html';
html += `<option value='${culture.TwoLetterISOLanguageName}'>${culture.DisplayName}</option>`;
}
select.innerHTML = html;
}
}
function populateLanguagesIntoList(element, languages) {
function populateLanguagesIntoList(element, languages) {
let html = '';
for (let i = 0; i < languages.length; i++) {
const culture = languages[i];
html += `<label><input type="checkbox" is="emby-checkbox" class="chkSubtitleLanguage" data-lang="${culture.ThreeLetterISOLanguageName.toLowerCase()}" /><span>${culture.DisplayName}</span></label>`;
}
element.innerHTML = html;
}
}
function populateCountries(select) {
function populateCountries(select) {
return ApiClient.getCountries().then(allCountries => {
let html = '';
html += "<option value=''></option>";
@ -50,18 +49,18 @@ import template from './libraryoptionseditor.template.html';
}
select.innerHTML = html;
});
}
}
function populateRefreshInterval(select) {
function populateRefreshInterval(select) {
let html = '';
html += `<option value='0'>${globalize.translate('Never')}</option>`;
html += [30, 60, 90].map(val => {
return `<option value='${val}'>${globalize.translate('EveryNDays', val)}</option>`;
}).join('');
select.innerHTML = html;
}
}
function renderMetadataReaders(page, plugins) {
function renderMetadataReaders(page, plugins) {
let html = '';
const elem = page.querySelector('.metadataReaders');
@ -98,9 +97,9 @@ import template from './libraryoptionseditor.template.html';
}
elem.innerHTML = html;
return true;
}
}
function renderMetadataSavers(page, metadataSavers) {
function renderMetadataSavers(page, metadataSavers) {
let html = '';
const elem = page.querySelector('.metadataSavers');
if (!metadataSavers.length) {
@ -119,9 +118,9 @@ import template from './libraryoptionseditor.template.html';
elem.innerHTML = html;
elem.classList.remove('hide');
return true;
}
}
function getMetadataFetchersForTypeHtml(availableTypeOptions, libraryOptionsForType) {
function getMetadataFetchersForTypeHtml(availableTypeOptions, libraryOptionsForType) {
let html = '';
let plugins = availableTypeOptions.MetadataFetchers;
@ -154,18 +153,18 @@ import template from './libraryoptionseditor.template.html';
html += '<div class="fieldDescription">' + globalize.translate('LabelMetadataDownloadersHelp') + '</div>';
html += '</div>';
return html;
}
}
function getTypeOptions(allOptions, type) {
function getTypeOptions(allOptions, type) {
const allTypeOptions = allOptions.TypeOptions || [];
for (let i = 0; i < allTypeOptions.length; i++) {
const typeOptions = allTypeOptions[i];
if (typeOptions.Type === type) return typeOptions;
}
return null;
}
}
function renderMetadataFetchers(page, availableOptions, libraryOptions) {
function renderMetadataFetchers(page, availableOptions, libraryOptions) {
let html = '';
const elem = page.querySelector('.metadataFetchers');
for (let i = 0; i < availableOptions.TypeOptions.length; i++) {
@ -185,9 +184,9 @@ import template from './libraryoptionseditor.template.html';
page.querySelector('.fldMetadataCountry').classList.add('hide');
}
return true;
}
}
function renderSubtitleFetchers(page, availableOptions, libraryOptions) {
function renderSubtitleFetchers(page, availableOptions, libraryOptions) {
let html = '';
const elem = page.querySelector('.subtitleFetchers');
@ -218,9 +217,9 @@ import template from './libraryoptionseditor.template.html';
html += '</div>';
html += `<div class="fieldDescription">${globalize.translate('SubtitleDownloadersHelp')}</div>`;
elem.innerHTML = html;
}
}
function getImageFetchersForTypeHtml(availableTypeOptions, libraryOptionsForType) {
function getImageFetchersForTypeHtml(availableTypeOptions, libraryOptionsForType) {
let html = '';
let plugins = availableTypeOptions.ImageFetchers;
@ -258,9 +257,9 @@ import template from './libraryoptionseditor.template.html';
html += '<div class="fieldDescription">' + globalize.translate('LabelImageFetchersHelp') + '</div>';
html += '</div>';
return html;
}
}
function renderImageFetchers(page, availableOptions, libraryOptions) {
function renderImageFetchers(page, availableOptions, libraryOptions) {
let html = '';
const elem = page.querySelector('.imageFetchers');
for (let i = 0; i < availableOptions.TypeOptions.length; i++) {
@ -276,9 +275,9 @@ import template from './libraryoptionseditor.template.html';
page.querySelector('.chkSaveLocalContainer').classList.add('hide');
}
return true;
}
}
function populateMetadataSettings(parent, contentType) {
function populateMetadataSettings(parent, contentType) {
const isNewLibrary = parent.classList.contains('newlibrary');
return ApiClient.getJSON(ApiClient.getUrl('Libraries/AvailableOptions', {
LibraryContentType: contentType,
@ -295,9 +294,9 @@ import template from './libraryoptionseditor.template.html';
}).catch(() => {
return Promise.resolve();
});
}
}
function adjustSortableListElement(elem) {
function adjustSortableListElement(elem) {
const btnSortable = elem.querySelector('.btnSortable');
const inner = btnSortable.querySelector('.material-icons');
if (elem.previousSibling) {
@ -313,9 +312,9 @@ import template from './libraryoptionseditor.template.html';
inner.classList.remove('keyboard_arrow_up');
inner.classList.add('keyboard_arrow_down');
}
}
}
function showImageOptionsForType(type) {
function showImageOptionsForType(type) {
import('../imageOptionsEditor/imageOptionsEditor').then(({ default: ImageOptionsEditor }) => {
let typeOptions = getTypeOptions(currentLibraryOptions, type);
if (!typeOptions) {
@ -328,18 +327,18 @@ import template from './libraryoptionseditor.template.html';
const imageOptionsEditor = new ImageOptionsEditor();
imageOptionsEditor.show(type, typeOptions, availableOptions);
});
}
}
function onImageFetchersContainerClick(e) {
function onImageFetchersContainerClick(e) {
const btnImageOptionsForType = dom.parentWithClass(e.target, 'btnImageOptionsForType');
if (btnImageOptionsForType) {
showImageOptionsForType(dom.parentWithClass(btnImageOptionsForType, 'imageFetcher').getAttribute('data-type'));
return;
}
onSortableContainerClick.call(this, e);
}
}
function onSortableContainerClick(e) {
function onSortableContainerClick(e) {
const btnSortable = dom.parentWithClass(e.target, 'btnSortable');
if (btnSortable) {
const li = dom.parentWithClass(btnSortable, 'sortableOption');
@ -359,9 +358,9 @@ import template from './libraryoptionseditor.template.html';
}
Array.prototype.forEach.call(list.querySelectorAll('.sortableOption'), adjustSortableListElement);
}
}
}
function bindEvents(parent) {
function bindEvents(parent) {
parent.querySelector('.metadataReaders').addEventListener('click', onSortableContainerClick);
parent.querySelector('.subtitleFetchers').addEventListener('click', onSortableContainerClick);
parent.querySelector('.metadataFetchers').addEventListener('click', onSortableContainerClick);
@ -370,9 +369,9 @@ import template from './libraryoptionseditor.template.html';
parent.querySelector('#chkEnableEmbeddedTitles').addEventListener('change', (e) => {
parent.querySelector('.chkEnableEmbeddedExtrasTitlesContainer').classList.toggle('hide', !e.currentTarget.checked);
});
}
}
export async function embed(parent, contentType, libraryOptions) {
export async function embed(parent, contentType, libraryOptions) {
currentLibraryOptions = {
TypeOptions: []
};
@ -389,9 +388,9 @@ import template from './libraryoptionseditor.template.html';
bindEvents(parent);
});
});
}
}
export function setContentType(parent, contentType) {
export function setContentType(parent, contentType) {
if (contentType === 'homevideos' || contentType === 'photos') {
parent.querySelector('.chkEnablePhotosContainer').classList.remove('hide');
} else {
@ -439,9 +438,9 @@ import template from './libraryoptionseditor.template.html';
parent.querySelector('.chkAutomaticallyAddToCollectionContainer').classList.toggle('hide', contentType !== 'movies' && contentType !== 'mixed');
return populateMetadataSettings(parent, contentType);
}
}
function setSubtitleFetchersIntoOptions(parent, options) {
function setSubtitleFetchersIntoOptions(parent, options) {
options.DisabledSubtitleFetchers = Array.prototype.map.call(Array.prototype.filter.call(parent.querySelectorAll('.chkSubtitleFetcher'), elem => {
return !elem.checked;
}), elem => {
@ -451,9 +450,9 @@ import template from './libraryoptionseditor.template.html';
options.SubtitleFetcherOrder = Array.prototype.map.call(parent.querySelectorAll('.subtitleFetcherItem'), elem => {
return elem.getAttribute('data-pluginname');
});
}
}
function setMetadataFetchersIntoOptions(parent, options) {
function setMetadataFetchersIntoOptions(parent, options) {
const sections = parent.querySelectorAll('.metadataFetcher');
for (let i = 0; i < sections.length; i++) {
const section = sections[i];
@ -475,9 +474,9 @@ import template from './libraryoptionseditor.template.html';
return elem.getAttribute('data-pluginname');
});
}
}
}
function setImageFetchersIntoOptions(parent, options) {
function setImageFetchersIntoOptions(parent, options) {
const sections = parent.querySelectorAll('.imageFetcher');
for (let i = 0; i < sections.length; i++) {
const section = sections[i];
@ -500,9 +499,9 @@ import template from './libraryoptionseditor.template.html';
return elem.getAttribute('data-pluginname');
});
}
}
}
function setImageOptionsIntoOptions(options) {
function setImageOptionsIntoOptions(options) {
const originalTypeOptions = (currentLibraryOptions || {}).TypeOptions || [];
for (let i = 0; i < originalTypeOptions.length; i++) {
const originalTypeOption = originalTypeOptions[i];
@ -516,9 +515,9 @@ import template from './libraryoptionseditor.template.html';
}
originalTypeOption.ImageOptions && (typeOptions.ImageOptions = originalTypeOption.ImageOptions);
}
}
}
export function getLibraryOptions(parent) {
export function getLibraryOptions(parent) {
const options = {
EnableArchiveMediaFiles: false,
EnablePhotos: parent.querySelector('.chkEnablePhotos').checked,
@ -563,9 +562,9 @@ import template from './libraryoptionseditor.template.html';
setImageOptionsIntoOptions(options);
return options;
}
}
function getOrderedPlugins(plugins, configuredOrder) {
function getOrderedPlugins(plugins, configuredOrder) {
plugins = plugins.slice(0);
plugins.sort((a, b) => {
a = configuredOrder.indexOf(a.Name);
@ -573,9 +572,9 @@ import template from './libraryoptionseditor.template.html';
return a - b;
});
return plugins;
}
}
export function setLibraryOptions(parent, options) {
export function setLibraryOptions(parent, options) {
currentLibraryOptions = options;
currentAvailableOptions = parent.availableOptions;
parent.querySelector('#selectLanguage').value = options.PreferredMetadataLanguage || '';
@ -608,12 +607,11 @@ import template from './libraryoptionseditor.template.html';
renderMetadataFetchers(parent, parent.availableOptions, options);
renderImageFetchers(parent, parent.availableOptions, options);
renderSubtitleFetchers(parent, parent.availableOptions, options);
}
}
let currentLibraryOptions;
let currentAvailableOptions;
let currentLibraryOptions;
let currentAvailableOptions;
/* eslint-enable indent */
export default {
embed: embed,
setContentType: setContentType,

View file

@ -1,4 +1,3 @@
/* eslint-disable indent */
/**
* Module for display list view.
@ -18,7 +17,7 @@ import '../../elements/emby-ratingbutton/emby-ratingbutton';
import '../../elements/emby-playstatebutton/emby-playstatebutton';
import ServerConnections from '../ServerConnections';
function getIndex(item, options) {
function getIndex(item, options) {
if (options.index === 'disc') {
return item.ParentIndexNumber == null ? '' : globalize.translate('ValueDiscNumber', item.ParentIndexNumber);
}
@ -75,9 +74,9 @@ import ServerConnections from '../ServerConnections';
return name.toUpperCase();
}
return '';
}
}
function getImageUrl(item, size) {
function getImageUrl(item, size) {
const apiClient = ServerConnections.getApiClient(item.ServerId);
let itemId;
@ -105,9 +104,9 @@ import ServerConnections from '../ServerConnections';
return apiClient.getScaledImageUrl(itemId, options);
}
return null;
}
}
function getChannelImageUrl(item, size) {
function getChannelImageUrl(item, size) {
const apiClient = ServerConnections.getApiClient(item.ServerId);
const options = {
fillWidth: size,
@ -122,9 +121,9 @@ import ServerConnections from '../ServerConnections';
if (item.ChannelId) {
return apiClient.getScaledImageUrl(item.ChannelId, options);
}
}
}
function getTextLinesHtml(textlines, isLargeStyle) {
function getTextLinesHtml(textlines, isLargeStyle) {
let html = '';
const largeTitleTagName = layoutManager.tv ? 'h2' : 'div';
@ -155,9 +154,9 @@ import ServerConnections from '../ServerConnections';
}
return html;
}
}
function getRightButtonsHtml(options) {
function getRightButtonsHtml(options) {
let html = '';
for (let i = 0, length = options.rightButtons.length; i < length; i++) {
@ -167,9 +166,9 @@ import ServerConnections from '../ServerConnections';
}
return html;
}
}
export function getListViewHtml(options) {
export function getListViewHtml(options) {
const items = options.items;
let groupTitle = '';
@ -493,9 +492,8 @@ import ServerConnections from '../ServerConnections';
}
return outerHtml;
}
}
/* eslint-enable indent */
export default {
getListViewHtml: getListViewHtml
};

View file

@ -4,25 +4,23 @@ import Events from '../utils/events.ts';
import '../elements/emby-tabs/emby-tabs';
import '../elements/emby-button/emby-button';
/* eslint-disable indent */
let tabOwnerView;
const queryScope = document.querySelector('.skinHeader');
let headerTabsContainer;
let tabsElem;
let tabOwnerView;
const queryScope = document.querySelector('.skinHeader');
let headerTabsContainer;
let tabsElem;
function ensureElements() {
function ensureElements() {
if (!headerTabsContainer) {
headerTabsContainer = queryScope.querySelector('.headerTabs');
}
}
}
function onViewTabsReady() {
function onViewTabsReady() {
this.selectedIndex(this.readySelectedIndex);
this.readySelectedIndex = null;
}
}
function allowSwipe(target) {
function allowSwipe(target) {
function allowSwipeOn(elem) {
if (dom.parentWithTag(elem, 'input')) {
return false;
@ -45,9 +43,9 @@ import '../elements/emby-button/emby-button';
}
return true;
}
}
function configureSwipeTabs(view, currentElement) {
function configureSwipeTabs(view, currentElement) {
if (!browser.touch) {
return;
}
@ -75,9 +73,9 @@ import '../elements/emby-button/emby-button';
touchHelper.destroy();
});
});
}
}
export function setTabs(view, selectedIndex, getTabsFn, getTabContainersFn, onBeforeTabChange, onTabChange, setSelectedIndex) {
export function setTabs(view, selectedIndex, getTabsFn, getTabContainersFn, onBeforeTabChange, onTabChange, setSelectedIndex) {
ensureElements();
if (!view) {
@ -186,18 +184,16 @@ import '../elements/emby-button/emby-button';
tabs: tabsElem,
replaced: false
};
}
}
export function selectedTabIndex(index) {
export function selectedTabIndex(index) {
if (index != null) {
tabsElem.selectedIndex(index);
} else {
tabsElem.triggerTabChange();
}
}
}
export function getTabsElement() {
export function getTabsElement() {
return document.querySelector('.tabs-viewmenubar');
}
/* eslint-enable indent */
}

View file

@ -1,4 +1,3 @@
/* eslint-disable indent */
/**
* Module for media library creator.
@ -25,7 +24,7 @@ import toast from '../toast/toast';
import alert from '../alert';
import template from './mediaLibraryCreator.template.html';
function onAddLibrary(e) {
function onAddLibrary(e) {
if (isCreating) {
return false;
}
@ -63,15 +62,15 @@ import template from './mediaLibraryCreator.template.html';
loading.hide();
});
e.preventDefault();
}
}
function getCollectionTypeOptionsHtml(collectionTypeOptions) {
function getCollectionTypeOptionsHtml(collectionTypeOptions) {
return collectionTypeOptions.map(i => {
return `<option value="${i.value}">${i.name}</option>`;
}).join('');
}
}
function initEditor(page, collectionTypeOptions) {
function initEditor(page, collectionTypeOptions) {
$('#selectCollectionType', page).html(getCollectionTypeOptionsHtml(collectionTypeOptions)).val('').on('change', function () {
const value = this.value;
const dlg = $(this).parents('.dialog')[0];
@ -98,9 +97,9 @@ import template from './mediaLibraryCreator.template.html';
page.querySelector('.btnAddFolder').addEventListener('click', onAddButtonClick);
page.querySelector('.addLibraryForm').addEventListener('submit', onAddLibrary);
page.querySelector('.folderList').addEventListener('click', onRemoveClick);
}
}
function onAddButtonClick() {
function onAddButtonClick() {
const page = dom.parentWithClass(this, 'dlg-librarycreator');
import('../directorybrowser/directorybrowser').then(({ default: DirectoryBrowser }) => {
@ -116,9 +115,9 @@ import template from './mediaLibraryCreator.template.html';
}
});
});
}
}
function getFolderHtml(pathInfo, index) {
function getFolderHtml(pathInfo, index) {
let html = '';
html += '<div class="listItem listItem-border lnkPath">';
html += `<div class="${pathInfo.NetworkPath ? 'listItemBody two-line' : 'listItemBody'}">`;
@ -132,9 +131,9 @@ import template from './mediaLibraryCreator.template.html';
html += `<button type="button" is="paper-icon-button-light"" class="listItemButton btnRemovePath" data-index="${index}"><span class="material-icons remove_circle" aria-hidden="true"></span></button>`;
html += '</div>';
return html;
}
}
function renderPaths(page) {
function renderPaths(page) {
const foldersHtml = pathInfos.map(getFolderHtml).join('');
const folderList = page.querySelector('.folderList');
folderList.innerHTML = foldersHtml;
@ -144,9 +143,9 @@ import template from './mediaLibraryCreator.template.html';
} else {
folderList.classList.add('hide');
}
}
}
function addMediaLocation(page, path, networkSharePath) {
function addMediaLocation(page, path, networkSharePath) {
const pathLower = path.toLowerCase();
const pathFilter = pathInfos.filter(p => {
return p.Path.toLowerCase() == pathLower;
@ -164,9 +163,9 @@ import template from './mediaLibraryCreator.template.html';
pathInfos.push(pathInfo);
renderPaths(page);
}
}
}
function onRemoveClick(e) {
function onRemoveClick(e) {
const button = dom.parentWithClass(e.target, 'btnRemovePath');
const index = parseInt(button.getAttribute('data-index'), 10);
const location = pathInfos[index].Path;
@ -175,17 +174,17 @@ import template from './mediaLibraryCreator.template.html';
return p.Path.toLowerCase() != locationLower;
});
renderPaths(dom.parentWithClass(button, 'dlg-librarycreator'));
}
}
function onDialogClosed() {
function onDialogClosed() {
currentResolve(hasChanges);
}
}
function initLibraryOptions(dlg) {
function initLibraryOptions(dlg) {
libraryoptionseditor.embed(dlg.querySelector('.libraryOptions')).then(() => {
$('#selectCollectionType', dlg).trigger('change');
});
}
}
export class showEditor {
constructor(options) {
@ -217,11 +216,10 @@ export class showEditor {
}
}
let pathInfos = [];
let currentResolve;
let currentOptions;
let hasChanges = false;
let isCreating = false;
let pathInfos = [];
let currentResolve;
let currentOptions;
let hasChanges = false;
let isCreating = false;
/* eslint-enable indent */
export default showEditor;

View file

@ -1,4 +1,3 @@
/* eslint-disable indent */
/**
* Module for media library editor.
@ -23,7 +22,7 @@ import toast from '../toast/toast';
import confirm from '../confirm/confirm';
import template from './mediaLibraryEditor.template.html';
function onEditLibrary() {
function onEditLibrary() {
if (isCreating) {
return false;
}
@ -43,9 +42,9 @@ import template from './mediaLibraryEditor.template.html';
loading.hide();
});
return false;
}
}
function addMediaLocation(page, path, networkSharePath) {
function addMediaLocation(page, path, networkSharePath) {
const virtualFolder = currentOptions.library;
const refreshAfterChange = currentOptions.refresh;
ApiClient.addMediaPath(virtualFolder.Name, path, networkSharePath, refreshAfterChange).then(() => {
@ -54,9 +53,9 @@ import template from './mediaLibraryEditor.template.html';
}, () => {
toast(globalize.translate('ErrorAddingMediaPathToVirtualFolder'));
});
}
}
function updateMediaLocation(page, path, networkSharePath) {
function updateMediaLocation(page, path, networkSharePath) {
const virtualFolder = currentOptions.library;
ApiClient.updateMediaPath(virtualFolder.Name, {
Path: path,
@ -67,9 +66,9 @@ import template from './mediaLibraryEditor.template.html';
}, () => {
toast(globalize.translate('ErrorAddingMediaPathToVirtualFolder'));
});
}
}
function onRemoveClick(btnRemovePath, location) {
function onRemoveClick(btnRemovePath, location) {
const button = btnRemovePath;
const virtualFolder = currentOptions.library;
@ -87,9 +86,9 @@ import template from './mediaLibraryEditor.template.html';
toast(globalize.translate('ErrorDefault'));
});
});
}
}
function onListItemClick(e) {
function onListItemClick(e) {
const listItem = dom.parentWithClass(e.target, 'listItem');
if (listItem) {
@ -106,9 +105,9 @@ import template from './mediaLibraryEditor.template.html';
showDirectoryBrowser(dom.parentWithClass(listItem, 'dlg-libraryeditor'), originalPath, pathInfo.NetworkPath);
}
}
}
function getFolderHtml(pathInfo, index) {
function getFolderHtml(pathInfo, index) {
let html = '';
html += `<div class="listItem listItem-border lnkPath" data-index="${index}">`;
html += `<div class="${pathInfo.NetworkPath ? 'listItemBody two-line' : 'listItemBody'}">`;
@ -124,9 +123,9 @@ import template from './mediaLibraryEditor.template.html';
html += `<button type="button" is="paper-icon-button-light" class="listItemButton btnRemovePath" data-index="${index}"><span class="material-icons remove_circle" aria-hidden="true"></span></button>`;
html += '</div>';
return html;
}
}
function refreshLibraryFromServer(page) {
function refreshLibraryFromServer(page) {
ApiClient.getVirtualFolders().then(result => {
const library = result.filter(f => {
return f.Name === currentOptions.library.Name;
@ -137,9 +136,9 @@ import template from './mediaLibraryEditor.template.html';
renderLibrary(page, currentOptions);
}
});
}
}
function renderLibrary(page, options) {
function renderLibrary(page, options) {
let pathInfos = (options.library.LibraryOptions || {}).PathInfos || [];
if (!pathInfos.length) {
@ -157,13 +156,13 @@ import template from './mediaLibraryEditor.template.html';
}
page.querySelector('.folderList').innerHTML = pathInfos.map(getFolderHtml).join('');
}
}
function onAddButtonClick() {
function onAddButtonClick() {
showDirectoryBrowser(dom.parentWithClass(this, 'dlg-libraryeditor'));
}
}
function showDirectoryBrowser(context, originalPath, networkPath) {
function showDirectoryBrowser(context, originalPath, networkPath) {
import('../directorybrowser/directorybrowser').then(({ default: DirectoryBrowser }) => {
const picker = new DirectoryBrowser();
picker.show({
@ -184,19 +183,19 @@ import template from './mediaLibraryEditor.template.html';
}
});
});
}
}
function initEditor(dlg, options) {
function initEditor(dlg, options) {
renderLibrary(dlg, options);
dlg.querySelector('.btnAddFolder').addEventListener('click', onAddButtonClick);
dlg.querySelector('.folderList').addEventListener('click', onListItemClick);
dlg.querySelector('.btnSubmit').addEventListener('click', onEditLibrary);
libraryoptionseditor.embed(dlg.querySelector('.libraryOptions'), options.library.CollectionType, options.library.LibraryOptions);
}
}
function onDialogClosed() {
function onDialogClosed() {
currentDeferred.resolveWith(null, [hasChanges]);
}
}
export class showEditor {
constructor(options) {
@ -227,10 +226,9 @@ export class showEditor {
}
}
let currentDeferred;
let currentOptions;
let hasChanges = false;
let isCreating = false;
let currentDeferred;
let currentOptions;
let hasChanges = false;
let isCreating = false;
/* eslint-enable indent */
export default showEditor;

View file

@ -10,8 +10,7 @@ import '../guide/programs.scss';
import '../../elements/emby-button/emby-button';
import * as userSettings from '../../scripts/settings/userSettings';
/* eslint-disable indent */
function getTimerIndicator(item) {
function getTimerIndicator(item) {
let status;
if (item.Type === 'SeriesTimer') {
@ -33,9 +32,9 @@ import * as userSettings from '../../scripts/settings/userSettings';
}
return '<span class="material-icons mediaInfoItem mediaInfoIconItem mediaInfoTimerIcon fiber_manual_record" aria-hidden="true"></span>';
}
}
function getProgramInfoHtml(item, options) {
function getProgramInfoHtml(item, options) {
let html = '';
const miscInfo = [];
@ -100,9 +99,9 @@ import * as userSettings from '../../scripts/settings/userSettings';
}).join('');
return html;
}
}
export function getMediaInfoHtml(item, options = {}) {
export function getMediaInfoHtml(item, options = {}) {
let html = '';
const miscInfo = [];
@ -318,9 +317,9 @@ import * as userSettings from '../../scripts/settings/userSettings';
html += indicators.getMissingIndicator(item);
return html;
}
}
export function getEndsAt(item) {
export function getEndsAt(item) {
if (item.MediaType === 'Video' && item.RunTimeTicks && !item.StartDate) {
let endDate = new Date().getTime() + (item.RunTimeTicks / 10000);
endDate = new Date(endDate);
@ -330,9 +329,9 @@ import * as userSettings from '../../scripts/settings/userSettings';
}
return null;
}
}
export function getEndsAtFromPosition(runtimeTicks, positionTicks, playbackRate, includeText) {
export function getEndsAtFromPosition(runtimeTicks, positionTicks, playbackRate, includeText) {
let endDate = new Date().getTime() + (1 / playbackRate) * ((runtimeTicks - (positionTicks || 0)) / 10000);
endDate = new Date(endDate);
@ -342,9 +341,9 @@ import * as userSettings from '../../scripts/settings/userSettings';
return displayTime;
}
return globalize.translate('EndsAtValue', displayTime);
}
}
function getMediaInfoItem(m, cssClass) {
function getMediaInfoItem(m, cssClass) {
cssClass = cssClass ? (`${cssClass} mediaInfoItem`) : 'mediaInfoItem';
let mediaInfoText = m;
@ -356,9 +355,9 @@ import * as userSettings from '../../scripts/settings/userSettings';
cssClass += ` ${m.cssClass}`;
}
return `<div class="${cssClass}">${mediaInfoText}</div>`;
}
}
function getStarIconsHtml(item) {
function getStarIconsHtml(item) {
let html = '';
if (item.CommunityRating) {
@ -370,9 +369,9 @@ import * as userSettings from '../../scripts/settings/userSettings';
}
return html;
}
}
function dynamicEndTime(elem, item) {
function dynamicEndTime(elem, item) {
const interval = setInterval(() => {
if (!document.body.contains(elem)) {
clearInterval(interval);
@ -381,23 +380,23 @@ import * as userSettings from '../../scripts/settings/userSettings';
elem.innerHTML = getEndsAt(item);
}, 60000);
}
}
export function fillPrimaryMediaInfo(elem, item, options) {
export function fillPrimaryMediaInfo(elem, item, options) {
const html = getPrimaryMediaInfoHtml(item, options);
elem.innerHTML = html;
afterFill(elem, item, options);
}
}
export function fillSecondaryMediaInfo(elem, item, options) {
export function fillSecondaryMediaInfo(elem, item, options) {
const html = getSecondaryMediaInfoHtml(item, options);
elem.innerHTML = html;
afterFill(elem, item, options);
}
}
function afterFill(elem, item, options) {
function afterFill(elem, item, options) {
if (options.endsAt !== false) {
const endsAtElem = elem.querySelector('.endsAt');
if (endsAtElem) {
@ -409,9 +408,9 @@ import * as userSettings from '../../scripts/settings/userSettings';
if (lnkChannel) {
lnkChannel.addEventListener('click', onChannelLinkClick);
}
}
}
function onChannelLinkClick(e) {
function onChannelLinkClick(e) {
const channelId = this.getAttribute('data-id');
const serverId = this.getAttribute('data-serverid');
@ -419,17 +418,17 @@ import * as userSettings from '../../scripts/settings/userSettings';
e.preventDefault();
return false;
}
}
export function getPrimaryMediaInfoHtml(item, options = {}) {
export function getPrimaryMediaInfoHtml(item, options = {}) {
if (options.interactive === undefined) {
options.interactive = false;
}
return getMediaInfoHtml(item, options);
}
}
export function getSecondaryMediaInfoHtml(item, options) {
export function getSecondaryMediaInfoHtml(item, options) {
options = options || {};
if (options.interactive == null) {
options.interactive = false;
@ -439,9 +438,9 @@ import * as userSettings from '../../scripts/settings/userSettings';
}
return '';
}
}
export function getResolutionText(i) {
export function getResolutionText(i) {
const width = i.Width;
const height = i.Height;
@ -475,9 +474,9 @@ import * as userSettings from '../../scripts/settings/userSettings';
}
}
return null;
}
}
function getAudioStreamForDisplay(item) {
function getAudioStreamForDisplay(item) {
if (!item.MediaSources) {
return null;
}
@ -490,9 +489,9 @@ import * as userSettings from '../../scripts/settings/userSettings';
return (mediaSource.MediaStreams || []).filter(i => {
return i.Type === 'Audio' && (i.Index === mediaSource.DefaultAudioStreamIndex || mediaSource.DefaultAudioStreamIndex == null);
})[0];
}
}
export function getMediaInfoStats(item) {
export function getMediaInfoStats(item) {
const list = [];
const mediaSource = (item.MediaSources || [])[0] || {};
@ -575,9 +574,7 @@ import * as userSettings from '../../scripts/settings/userSettings';
}
return list;
}
/* eslint-enable indent */
}
export default {
getMediaInfoHtml: getPrimaryMediaInfoHtml,

View file

@ -23,23 +23,21 @@ import toast from '../toast/toast';
import { appRouter } from '../appRouter';
import template from './metadataEditor.template.html';
/* eslint-disable indent */
let currentContext;
let metadataEditorInfo;
let currentItem;
let currentContext;
let metadataEditorInfo;
let currentItem;
function isDialog() {
function isDialog() {
return currentContext.classList.contains('dialog');
}
}
function closeDialog() {
function closeDialog() {
if (isDialog()) {
dialogHelper.close(currentContext);
}
}
}
function submitUpdatedItem(form, item) {
function submitUpdatedItem(form, item) {
function afterContentTypeUpdated() {
toast(globalize.translate('MessageItemSaved'));
@ -68,16 +66,16 @@ import template from './metadataEditor.template.html';
afterContentTypeUpdated();
}
});
}
}
function getSelectedAirDays(form) {
function getSelectedAirDays(form) {
const checkedItems = form.querySelectorAll('.chkAirDay:checked') || [];
return Array.prototype.map.call(checkedItems, function (c) {
return c.getAttribute('data-day');
});
}
}
function getAlbumArtists(form) {
function getAlbumArtists(form) {
return form.querySelector('#txtAlbumArtist').value.trim().split(';').filter(function (s) {
return s.length > 0;
}).map(function (a) {
@ -85,9 +83,9 @@ import template from './metadataEditor.template.html';
Name: a
};
});
}
}
function getArtists(form) {
function getArtists(form) {
return form.querySelector('#txtArtist').value.trim().split(';').filter(function (s) {
return s.length > 0;
}).map(function (a) {
@ -95,9 +93,9 @@ import template from './metadataEditor.template.html';
Name: a
};
});
}
}
function getDateValue(form, element, property) {
function getDateValue(form, element, property) {
let val = form.querySelector(element).value;
if (!val) {
@ -118,9 +116,9 @@ import template from './metadataEditor.template.html';
}
return val;
}
}
function onSubmit(e) {
function onSubmit(e) {
loading.show();
const form = this;
@ -202,15 +200,15 @@ import template from './metadataEditor.template.html';
// Disable default form submission
return false;
}
}
function getListValues(list) {
function getListValues(list) {
return Array.prototype.map.call(list.querySelectorAll('.textValue'), function (el) {
return el.textContent;
});
}
}
function addElementToList(source, sortCallback) {
function addElementToList(source, sortCallback) {
import('../prompt/prompt').then(({ default: prompt }) => {
prompt({
label: 'Value:'
@ -221,14 +219,14 @@ import template from './metadataEditor.template.html';
populateListView(list, items, sortCallback);
});
});
}
}
function removeElementFromList(source) {
function removeElementFromList(source) {
const el = dom.parentWithClass(source, 'listItem');
el.parentNode.removeChild(el);
}
}
function editPerson(context, person, index) {
function editPerson(context, person, index) {
import('./personEditor').then(({ default: personEditor }) => {
personEditor.show(person).then(function (updatedPerson) {
const isNew = index === -1;
@ -240,9 +238,9 @@ import template from './metadataEditor.template.html';
populatePeople(context, currentItem.People);
});
});
}
}
function afterDeleted(context, item) {
function afterDeleted(context, item) {
const parentId = item.ParentId || item.SeasonId || item.SeriesId;
if (parentId) {
@ -250,9 +248,9 @@ import template from './metadataEditor.template.html';
} else {
appRouter.goHome();
}
}
}
function showMoreMenu(context, button, user) {
function showMoreMenu(context, button, user) {
import('../itemContextMenu').then(({ default: itemContextMenu }) => {
const item = currentItem;
@ -275,9 +273,9 @@ import template from './metadataEditor.template.html';
}
});
});
}
}
function onEditorClick(e) {
function onEditorClick(e) {
const btnRemoveFromEditorList = dom.parentWithClass(e.target, 'btnRemoveFromEditorList');
if (btnRemoveFromEditorList) {
removeElementFromList(btnRemoveFromEditorList);
@ -288,19 +286,19 @@ import template from './metadataEditor.template.html';
if (btnAddTextItem) {
addElementToList(btnAddTextItem);
}
}
}
function getApiClient() {
function getApiClient() {
return ServerConnections.getApiClient(currentItem.ServerId);
}
}
function bindAll(elems, eventName, fn) {
function bindAll(elems, eventName, fn) {
for (let i = 0, length = elems.length; i < length; i++) {
elems[i].addEventListener(eventName, fn);
}
}
}
function init(context) {
function init(context) {
context.querySelector('.externalIds').addEventListener('click', function (e) {
const btnOpenExternalId = dom.parentWithClass(e.target, 'btnOpenExternalId');
if (btnOpenExternalId) {
@ -368,9 +366,9 @@ import template from './metadataEditor.template.html';
editPerson(context, currentItem.People[index], index);
}
});
}
}
function getItem(itemId, serverId) {
function getItem(itemId, serverId) {
const apiClient = ServerConnections.getApiClient(serverId);
if (itemId) {
@ -378,9 +376,9 @@ import template from './metadataEditor.template.html';
}
return apiClient.getRootFolder(apiClient.getCurrentUserId());
}
}
function getEditorConfig(itemId, serverId) {
function getEditorConfig(itemId, serverId) {
const apiClient = ServerConnections.getApiClient(serverId);
if (itemId) {
@ -388,9 +386,9 @@ import template from './metadataEditor.template.html';
}
return Promise.resolve({});
}
}
function populateCountries(select, allCountries) {
function populateCountries(select, allCountries) {
let html = '';
html += "<option value=''></option>";
@ -402,9 +400,9 @@ import template from './metadataEditor.template.html';
}
select.innerHTML = html;
}
}
function populateLanguages(select, languages) {
function populateLanguages(select, languages) {
let html = '';
html += "<option value=''></option>";
@ -416,9 +414,9 @@ import template from './metadataEditor.template.html';
}
select.innerHTML = html;
}
}
function renderContentTypeOptions(context, metadataInfo) {
function renderContentTypeOptions(context, metadataInfo) {
if (!metadataInfo.ContentTypeOptions.length) {
hideElement('#fldContentType', context);
} else {
@ -432,9 +430,9 @@ import template from './metadataEditor.template.html';
const selectEl = context.querySelector('#selectContentType');
selectEl.innerHTML = html;
selectEl.value = metadataInfo.ContentType || '';
}
}
function loadExternalIds(context, item, externalIds) {
function loadExternalIds(context, item, externalIds) {
let html = '';
const providerIds = item.ProviderIds || {};
@ -477,12 +475,12 @@ import template from './metadataEditor.template.html';
} else {
context.querySelector('.externalIdsSection').classList.add('hide');
}
}
}
// Function to hide the element by selector or raw element
// Selector can be an element or a selector string
// Context is optional and restricts the querySelector to the context
function hideElement(selector, context, multiple) {
// Function to hide the element by selector or raw element
// Selector can be an element or a selector string
// Context is optional and restricts the querySelector to the context
function hideElement(selector, context, multiple) {
context = context || document;
if (typeof selector === 'string') {
const elements = multiple ? context.querySelectorAll(selector) : [context.querySelector(selector)];
@ -495,12 +493,12 @@ import template from './metadataEditor.template.html';
} else {
selector.classList.add('hide');
}
}
}
// Function to show the element by selector or raw element
// Selector can be an element or a selector string
// Context is optional and restricts the querySelector to the context
function showElement(selector, context, multiple) {
// Function to show the element by selector or raw element
// Selector can be an element or a selector string
// Context is optional and restricts the querySelector to the context
function showElement(selector, context, multiple) {
context = context || document;
if (typeof selector === 'string') {
const elements = multiple ? context.querySelectorAll(selector) : [context.querySelector(selector)];
@ -513,9 +511,9 @@ import template from './metadataEditor.template.html';
} else {
selector.classList.remove('hide');
}
}
}
function setFieldVisibilities(context, item) {
function setFieldVisibilities(context, item) {
if (item.Path && item.EnableMediaSourceDisplay !== false) {
showElement('#fldPath', context);
} else {
@ -713,9 +711,9 @@ import template from './metadataEditor.template.html';
context.querySelector('#selectDisplayOrder').innerHTML = '';
hideElement('#fldDisplayOrder', context);
}
}
}
function fillItemInfo(context, item, parentalRatingOptions) {
function fillItemInfo(context, item, parentalRatingOptions) {
let select = context.querySelector('#selectOfficialRating');
populateRatings(parentalRatingOptions, select, item.OfficialRating);
@ -843,9 +841,9 @@ import template from './metadataEditor.template.html';
} else {
context.querySelector('#txtSeriesRuntime', context).value = '';
}
}
}
function populateRatings(allParentalRatings, select, currentValue) {
function populateRatings(allParentalRatings, select, currentValue) {
let html = '';
html += "<option value=''></option>";
@ -876,18 +874,18 @@ import template from './metadataEditor.template.html';
}
select.innerHTML = html;
}
}
function populateStatus(select) {
function populateStatus(select) {
let html = '';
html += "<option value=''></option>";
html += "<option value='Continuing'>" + globalize.translate('Continuing') + '</option>';
html += "<option value='Ended'>" + globalize.translate('Ended') + '</option>';
select.innerHTML = html;
}
}
function populateListView(list, items, sortCallback) {
function populateListView(list, items, sortCallback) {
items = items || [];
if (typeof (sortCallback) === 'undefined') {
items.sort(function (a, b) {
@ -916,9 +914,9 @@ import template from './metadataEditor.template.html';
}
list.innerHTML = html;
}
}
function populatePeople(context, people) {
function populatePeople(context, people) {
const lastType = '';
let html = '';
@ -953,9 +951,9 @@ import template from './metadataEditor.template.html';
}
elem.innerHTML = html;
}
}
function getLockedFieldsHtml(fields, currentFields) {
function getLockedFieldsHtml(fields, currentFields) {
let html = '';
for (let i = 0; i < fields.length; i++) {
const field = fields[i];
@ -968,9 +966,9 @@ import template from './metadataEditor.template.html';
html += '</label>';
}
return html;
}
}
function fillMetadataSettings(context, item, lockedFields) {
function fillMetadataSettings(context, item, lockedFields) {
const container = context.querySelector('.providerSettingsContainer');
lockedFields = lockedFields || [];
@ -1001,9 +999,9 @@ import template from './metadataEditor.template.html';
html += '<p>' + globalize.translate('HeaderEnabledFieldsHelp') + '</p>';
html += getLockedFieldsHtml(lockedFieldsList, lockedFields);
container.innerHTML = html;
}
}
function reload(context, itemId, serverId) {
function reload(context, itemId, serverId) {
loading.show();
Promise.all([getItem(itemId, serverId), getEditorConfig(itemId, serverId)]).then(function (responses) {
@ -1033,16 +1031,16 @@ import template from './metadataEditor.template.html';
loading.hide();
});
}
}
function centerFocus(elem, horiz, on) {
function centerFocus(elem, horiz, on) {
import('../../scripts/scrollHelper').then((scrollHelper) => {
const fn = on ? 'on' : 'off';
scrollHelper.centerFocus[fn](elem, horiz);
});
}
}
function show(itemId, serverId, resolve) {
function show(itemId, serverId, resolve) {
loading.show();
const dialogOptions = {
@ -1085,9 +1083,9 @@ import template from './metadataEditor.template.html';
init(dlg);
reload(dlg, itemId, serverId);
}
}
export default {
export default {
show: function (itemId, serverId) {
return new Promise(resolve => show(itemId, serverId, resolve));
},
@ -1111,6 +1109,5 @@ import template from './metadataEditor.template.html';
focusManager.autoFocus(elem);
});
}
};
};
/* eslint-enable indent */

View file

@ -8,16 +8,14 @@ import '../../elements/emby-select/emby-select';
import '../formdialog.scss';
import template from './personEditor.template.html';
/* eslint-disable indent */
function centerFocus(elem, horiz, on) {
function centerFocus(elem, horiz, on) {
import('../../scripts/scrollHelper').then((scrollHelper) => {
const fn = on ? 'on' : 'off';
scrollHelper.centerFocus[fn](elem, horiz);
});
}
}
function show(person) {
function show(person) {
return new Promise(function (resolve, reject) {
const dialogOptions = {
removeOnClose: true,
@ -92,10 +90,9 @@ import template from './personEditor.template.html';
bubbles: true
}));
});
}
}
export default {
show: show
};
/* eslint-enable indent */

View file

@ -11,13 +11,11 @@ import confirm from '../confirm/confirm';
import itemHelper from '../itemHelper';
import datetime from '../../scripts/datetime';
/* eslint-disable indent */
let selectedItems = [];
let selectedElements = [];
let currentSelectionCommandsPanel;
let selectedItems = [];
let selectedElements = [];
let currentSelectionCommandsPanel;
function hideSelections() {
function hideSelections() {
const selectionCommandsPanel = currentSelectionCommandsPanel;
if (selectionCommandsPanel) {
selectionCommandsPanel.parentNode.removeChild(selectionCommandsPanel);
@ -32,9 +30,9 @@ import datetime from '../../scripts/datetime';
parent.classList.remove('withMultiSelect');
}
}
}
}
function onItemSelectionPanelClick(e, itemSelectionPanel) {
function onItemSelectionPanelClick(e, itemSelectionPanel) {
// toggle the checkbox, if it wasn't clicked on
if (!dom.parentWithClass(e.target, 'chkItemSelect')) {
const chkItemSelect = itemSelectionPanel.querySelector('.chkItemSelect');
@ -53,9 +51,9 @@ import datetime from '../../scripts/datetime';
e.preventDefault();
e.stopPropagation();
return false;
}
}
function updateItemSelection(chkItemSelect, selected) {
function updateItemSelection(chkItemSelect, selected) {
const id = dom.parentWithAttribute(chkItemSelect, 'data-id').getAttribute('data-id');
if (selected) {
@ -84,13 +82,13 @@ import datetime from '../../scripts/datetime';
} else {
hideSelections();
}
}
}
function onSelectionChange() {
function onSelectionChange() {
updateItemSelection(this, this.checked);
}
}
function showSelection(item, isChecked) {
function showSelection(item, isChecked) {
let itemSelectionPanel = item.querySelector('.itemSelectionPanel');
if (!itemSelectionPanel) {
@ -112,9 +110,9 @@ import datetime from '../../scripts/datetime';
const chkItemSelect = itemSelectionPanel.querySelector('.chkItemSelect');
chkItemSelect.addEventListener('change', onSelectionChange);
}
}
}
function showSelectionCommands() {
function showSelectionCommands() {
let selectionCommandsPanel = currentSelectionCommandsPanel;
if (!selectionCommandsPanel) {
@ -140,15 +138,15 @@ import datetime from '../../scripts/datetime';
dom.addEventListener(btnSelectionPanelOptions, 'click', showMenuForSelectedItems, { passive: true });
}
}
}
function alertText(options) {
function alertText(options) {
return new Promise((resolve) => {
alert(options).then(resolve, resolve);
});
}
}
function deleteItems(apiClient, itemIds) {
function deleteItems(apiClient, itemIds) {
return new Promise((resolve, reject) => {
let msg = globalize.translate('ConfirmDeleteItem');
let title = globalize.translate('HeaderDeleteItem');
@ -166,9 +164,9 @@ import datetime from '../../scripts/datetime';
});
}, reject);
});
}
}
function showMenuForSelectedItems(e) {
function showMenuForSelectedItems(e) {
const apiClient = ServerConnections.currentApiClient();
apiClient.getCurrentUser().then(user => {
@ -318,9 +316,9 @@ import datetime from '../../scripts/datetime';
});
});
});
}
}
function dispatchNeedsRefresh() {
function dispatchNeedsRefresh() {
const elems = [];
[].forEach.call(selectedElements, i => {
@ -334,9 +332,9 @@ import datetime from '../../scripts/datetime';
for (let i = 0, length = elems.length; i < length; i++) {
elems[i].notifyRefreshNeeded(true);
}
}
}
function combineVersions(apiClient, selection) {
function combineVersions(apiClient, selection) {
if (selection.length < 2) {
alert({
text: globalize.translate('PleaseSelectTwoItems')
@ -357,9 +355,9 @@ import datetime from '../../scripts/datetime';
hideSelections();
dispatchNeedsRefresh();
});
}
}
function showSelections(initialCard) {
function showSelections(initialCard) {
import('../../elements/emby-checkbox/emby-checkbox').then(() => {
const cards = document.querySelectorAll('.card');
for (let i = 0, length = cards.length; i < length; i++) {
@ -369,9 +367,9 @@ import datetime from '../../scripts/datetime';
showSelectionCommands();
updateItemSelection(initialCard, true);
});
}
}
function onContainerClick(e) {
function onContainerClick(e) {
const target = e.target;
if (selectedItems.length) {
@ -387,11 +385,11 @@ import datetime from '../../scripts/datetime';
e.stopPropagation();
return false;
}
}
}
document.addEventListener('viewbeforehide', hideSelections);
document.addEventListener('viewbeforehide', hideSelections);
export default function (options) {
export default function (options) {
const self = this;
const container = options.container;
@ -564,6 +562,5 @@ import datetime from '../../scripts/datetime';
passive: true
});
};
}
}
/* eslint-enable indent */

View file

@ -17,32 +17,30 @@ import './nowPlayingBar.scss';
import '../../elements/emby-slider/emby-slider';
import { appRouter } from '../appRouter';
/* eslint-disable indent */
let currentPlayer;
let currentPlayerSupportedCommands = [];
let currentPlayer;
let currentPlayerSupportedCommands = [];
let currentTimeElement;
let nowPlayingImageElement;
let nowPlayingImageUrl;
let nowPlayingTextElement;
let nowPlayingUserData;
let muteButton;
let volumeSlider;
let volumeSliderContainer;
let playPauseButtons;
let positionSlider;
let toggleRepeatButton;
let toggleRepeatButtonIcon;
let currentTimeElement;
let nowPlayingImageElement;
let nowPlayingImageUrl;
let nowPlayingTextElement;
let nowPlayingUserData;
let muteButton;
let volumeSlider;
let volumeSliderContainer;
let playPauseButtons;
let positionSlider;
let toggleRepeatButton;
let toggleRepeatButtonIcon;
let lastUpdateTime = 0;
let lastPlayerState = {};
let isEnabled;
let currentRuntimeTicks = 0;
let lastUpdateTime = 0;
let lastPlayerState = {};
let isEnabled;
let currentRuntimeTicks = 0;
let isVisibilityAllowed = true;
let isVisibilityAllowed = true;
function getNowPlayingBarHtml() {
function getNowPlayingBarHtml() {
let html = '';
html += '<div class="nowPlayingBar hide nowPlayingBar-hidden">';
@ -99,13 +97,13 @@ import { appRouter } from '../appRouter';
html += '</div>';
return html;
}
}
function onSlideDownComplete() {
function onSlideDownComplete() {
this.classList.add('hide');
}
}
function slideDown(elem) {
function slideDown(elem) {
// trigger reflow
void elem.offsetWidth;
@ -114,9 +112,9 @@ import { appRouter } from '../appRouter';
dom.addEventListener(elem, dom.whichTransitionEvent(), onSlideDownComplete, {
once: true
});
}
}
function slideUp(elem) {
function slideUp(elem) {
dom.removeEventListener(elem, dom.whichTransitionEvent(), onSlideDownComplete, {
once: true
});
@ -127,13 +125,13 @@ import { appRouter } from '../appRouter';
void elem.offsetWidth;
elem.classList.remove('nowPlayingBar-hidden');
}
}
function onPlayPauseClick() {
function onPlayPauseClick() {
playbackManager.playPause(currentPlayer);
}
}
function bindEvents(elem) {
function bindEvents(elem) {
currentTimeElement = elem.querySelector('.nowPlayingBarCurrentTime');
nowPlayingImageElement = elem.querySelector('.nowPlayingImage');
nowPlayingTextElement = elem.querySelector('.nowPlayingBarText');
@ -251,14 +249,14 @@ import { appRouter } from '../appRouter';
showRemoteControl();
}
});
}
}
function showRemoteControl() {
function showRemoteControl() {
appRouter.showNowPlaying();
}
}
let nowPlayingBarElement;
function getNowPlayingBar() {
let nowPlayingBarElement;
function getNowPlayingBar() {
if (nowPlayingBarElement) {
return nowPlayingBarElement;
}
@ -290,17 +288,17 @@ import { appRouter } from '../appRouter';
bindEvents(nowPlayingBarElement);
return nowPlayingBarElement;
}
}
function showButton(button) {
function showButton(button) {
button.classList.remove('hide');
}
}
function hideButton(button) {
function hideButton(button) {
button.classList.add('hide');
}
}
function updatePlayPauseState(isPaused) {
function updatePlayPauseState(isPaused) {
if (playPauseButtons) {
playPauseButtons.forEach((button) => {
const icon = button.querySelector('.material-icons');
@ -308,9 +306,9 @@ import { appRouter } from '../appRouter';
icon.classList.add(isPaused ? 'play_arrow' : 'pause');
});
}
}
}
function updatePlayerStateInternal(event, state, player) {
function updatePlayerStateInternal(event, state, player) {
showNowPlayingBar();
lastPlayerState = state;
@ -347,9 +345,9 @@ import { appRouter } from '../appRouter';
updateTimeDisplay(playState.PositionTicks, nowPlayingItem.RunTimeTicks, playbackManager.getBufferedRanges(player));
updateNowPlayingInfo(state);
}
}
function updateRepeatModeDisplay(repeatMode) {
function updateRepeatModeDisplay(repeatMode) {
toggleRepeatButtonIcon.classList.remove('repeat', 'repeat_one');
const cssClass = 'buttonActive';
@ -368,9 +366,9 @@ import { appRouter } from '../appRouter';
toggleRepeatButton.classList.remove(cssClass);
break;
}
}
}
function updateTimeDisplay(positionTicks, runtimeTicks, bufferedRanges) {
function updateTimeDisplay(positionTicks, runtimeTicks, bufferedRanges) {
// See bindEvents for why this is necessary
if (positionSlider && !positionSlider.dragging) {
if (runtimeTicks) {
@ -395,9 +393,9 @@ import { appRouter } from '../appRouter';
currentTimeElement.innerHTML = timeText;
}
}
}
function updatePlayerVolumeState(isMuted, volumeLevel) {
function updatePlayerVolumeState(isMuted, volumeLevel) {
const supportedCommands = currentPlayerSupportedCommands;
let showMuteButton = true;
@ -434,9 +432,9 @@ import { appRouter } from '../appRouter';
volumeSlider.value = volumeLevel || 0;
}
}
}
}
function seriesImageUrl(item, options) {
function seriesImageUrl(item, options) {
if (!item) {
throw new Error('item cannot be null!');
}
@ -468,9 +466,9 @@ import { appRouter } from '../appRouter';
}
return null;
}
}
function imageUrl(item, options) {
function imageUrl(item, options) {
if (!item) {
throw new Error('item cannot be null!');
}
@ -489,9 +487,9 @@ import { appRouter } from '../appRouter';
}
return null;
}
}
function updateNowPlayingInfo(state) {
function updateNowPlayingInfo(state) {
const nowPlayingItem = state.NowPlayingItem;
const textLines = nowPlayingItem ? nowPlayingHelper.getNowPlayingNames(nowPlayingItem) : [];
@ -572,23 +570,23 @@ import { appRouter } from '../appRouter';
} else {
nowPlayingUserData.innerHTML = '';
}
}
}
function onPlaybackStart(e, state) {
function onPlaybackStart(e, state) {
console.debug('nowplaying event: ' + e.type);
const player = this;
onStateChanged.call(player, e, state);
}
}
function onRepeatModeChange() {
function onRepeatModeChange() {
if (!isEnabled) {
return;
}
updateRepeatModeDisplay(playbackManager.getRepeatMode());
}
}
function onQueueShuffleModeChange() {
function onQueueShuffleModeChange() {
if (!isEnabled) {
return;
}
@ -606,18 +604,18 @@ import { appRouter } from '../appRouter';
toggleShuffleButton.classList.remove(cssClass);
break;
}
}
}
function showNowPlayingBar() {
function showNowPlayingBar() {
if (!isVisibilityAllowed) {
hideNowPlayingBar();
return;
}
slideUp(getNowPlayingBar());
}
}
function hideNowPlayingBar() {
function hideNowPlayingBar() {
isEnabled = false;
// Use a timeout to prevent the bar from hiding and showing quickly
@ -628,9 +626,9 @@ import { appRouter } from '../appRouter';
if (elem) {
slideDown(elem);
}
}
}
function onPlaybackStopped(e, state) {
function onPlaybackStopped(e, state) {
console.debug('nowplaying event: ' + e.type);
const player = this;
@ -643,18 +641,18 @@ import { appRouter } from '../appRouter';
hideNowPlayingBar();
}
}
}
}
function onPlayPauseStateChanged() {
function onPlayPauseStateChanged() {
if (!isEnabled) {
return;
}
const player = this;
updatePlayPauseState(player.paused());
}
}
function onStateChanged(event, state) {
function onStateChanged(event, state) {
if (event.type === 'init') {
// skip non-ready state
return;
@ -682,9 +680,9 @@ import { appRouter } from '../appRouter';
getNowPlayingBar();
updatePlayerStateInternal(event, state, player);
}
}
function onTimeUpdate() {
function onTimeUpdate() {
if (!isEnabled) {
return;
}
@ -699,9 +697,9 @@ import { appRouter } from '../appRouter';
const player = this;
currentRuntimeTicks = playbackManager.duration(player);
updateTimeDisplay(playbackManager.currentTime(player) * 10000, currentRuntimeTicks, playbackManager.getBufferedRanges(player));
}
}
function releaseCurrentPlayer() {
function releaseCurrentPlayer() {
const player = currentPlayer;
if (player) {
@ -718,9 +716,9 @@ import { appRouter } from '../appRouter';
currentPlayer = null;
hideNowPlayingBar();
}
}
}
function onVolumeChanged() {
function onVolumeChanged() {
if (!isEnabled) {
return;
}
@ -728,15 +726,15 @@ import { appRouter } from '../appRouter';
const player = this;
updatePlayerVolumeState(player.isMuted(), player.getVolume());
}
}
function refreshFromPlayer(player, type) {
function refreshFromPlayer(player, type) {
const state = playbackManager.getPlayerState(player);
onStateChanged.call(player, { type }, state);
}
}
function bindToPlayer(player) {
function bindToPlayer(player) {
if (player === currentPlayer) {
return;
}
@ -760,15 +758,15 @@ import { appRouter } from '../appRouter';
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());
});
});
bindToPlayer(playbackManager.getCurrentPlayer());
bindToPlayer(playbackManager.getCurrentPlayer());
document.addEventListener('viewbeforeshow', function (e) {
document.addEventListener('viewbeforeshow', function (e) {
if (!e.detail.options.enableMediaControl) {
if (isVisibilityAllowed) {
isVisibilityAllowed = false;
@ -782,6 +780,5 @@ import { appRouter } from '../appRouter';
hideNowPlayingBar();
}
}
});
});
/* eslint-enable indent */

View file

@ -1,8 +1,7 @@
import appSettings from '../scripts/settings/appSettings';
import { pluginManager } from './pluginManager';
/* eslint-disable indent */
class PackageManager {
class PackageManager {
#packagesList = [];
#settingsKey = 'installedpackages1';
@ -133,8 +132,6 @@ import { pluginManager } from './pluginManager';
xhr.send();
});
}
}
/* eslint-enable indent */
}
export default new PackageManager();

View file

@ -4,13 +4,11 @@ import Events from '../../utils/events.ts';
import ServerConnections from '../ServerConnections';
import shell from '../../scripts/shell';
/* eslint-disable indent */
// Reports media playback to the device for lock screen control
// Reports media playback to the device for lock screen control
let currentPlayer;
let currentPlayer;
function seriesImageUrl(item, options = {}) {
function seriesImageUrl(item, options = {}) {
options.type = options.type || 'Primary';
if (item.Type !== 'Episode') {
@ -32,9 +30,9 @@ import shell from '../../scripts/shell';
}
return null;
}
}
function imageUrl(item, options = {}) {
function imageUrl(item, options = {}) {
options.type = options.type || 'Primary';
if (item.ImageTags && item.ImageTags[options.type]) {
@ -48,9 +46,9 @@ import shell from '../../scripts/shell';
}
return null;
}
}
function getImageUrl(item, imageOptions = {}) {
function getImageUrl(item, imageOptions = {}) {
const url = seriesImageUrl(item, imageOptions) || imageUrl(item, imageOptions);
if (url) {
@ -63,9 +61,9 @@ import shell from '../../scripts/shell';
} else {
return null;
}
}
}
function getImageUrls(item, imageSizes = [96, 128, 192, 256, 384, 512]) {
function getImageUrls(item, imageSizes = [96, 128, 192, 256, 384, 512]) {
const list = [];
imageSizes.forEach((size) => {
@ -76,9 +74,9 @@ import shell from '../../scripts/shell';
});
return list;
}
}
function updatePlayerState(player, state, eventName) {
function updatePlayerState(player, state, eventName) {
// Don't go crazy reporting position changes
if (eventName === 'timeupdate') {
// Only report if this item hasn't been reported yet, or if there's an actual playback change.
@ -144,27 +142,27 @@ import shell from '../../scripts/shell';
isPaused: isPaused
});
}
}
}
function onGeneralEvent(e) {
function onGeneralEvent(e) {
const state = playbackManager.getPlayerState(this);
updatePlayerState(this, state, e.type);
}
}
function onStateChanged(e, state) {
function onStateChanged(e, state) {
updatePlayerState(this, state, 'statechange');
}
}
function onPlaybackStart(e, state) {
function onPlaybackStart(e, state) {
updatePlayerState(this, state, e.type);
}
}
function onPlaybackStopped() {
function onPlaybackStopped() {
hideMediaControls();
}
}
function releaseCurrentPlayer() {
function releaseCurrentPlayer() {
if (currentPlayer) {
Events.off(currentPlayer, 'playbackstart', onPlaybackStart);
Events.off(currentPlayer, 'playbackstop', onPlaybackStopped);
@ -177,18 +175,18 @@ import shell from '../../scripts/shell';
hideMediaControls();
}
}
}
function hideMediaControls() {
function hideMediaControls() {
if ('mediaSession' in navigator) {
/* eslint-disable-next-line compat/compat */
navigator.mediaSession.metadata = null;
} else {
shell.hideMediaSession();
}
}
}
function bindToPlayer(player) {
function bindToPlayer(player) {
releaseCurrentPlayer();
if (!player) {
@ -206,13 +204,13 @@ import shell from '../../scripts/shell';
Events.on(currentPlayer, 'pause', onGeneralEvent);
Events.on(currentPlayer, 'statechange', onStateChanged);
Events.on(currentPlayer, 'timeupdate', onGeneralEvent);
}
}
function execute(name) {
function execute(name) {
playbackManager[name](currentPlayer);
}
}
if ('mediaSession' in navigator) {
if ('mediaSession' in navigator) {
/* eslint-disable-next-line compat/compat */
navigator.mediaSession.setActionHandler('previoustrack', function () {
execute('previousTrack');
@ -251,12 +249,11 @@ import shell from '../../scripts/shell';
const wantedTime = object.seekTime * 1000;
playbackManager.seekPercent(wantedTime / duration * 100, currentPlayer);
});
}
}
Events.on(playbackManager, 'playerchange', function () {
Events.on(playbackManager, 'playerchange', function () {
bindToPlayer(playbackManager.getCurrentPlayer());
});
});
bindToPlayer(playbackManager.getCurrentPlayer());
bindToPlayer(playbackManager.getCurrentPlayer());
/* eslint-enable indent */

View file

@ -12,9 +12,7 @@ import ServerConnections from '../ServerConnections';
import toast from '../toast/toast';
import template from './playbackSettings.template.html';
/* eslint-disable indent */
function fillSkipLengths(select) {
function fillSkipLengths(select) {
const options = [5, 10, 15, 20, 25, 30];
select.innerHTML = options.map(option => {
@ -25,9 +23,9 @@ import template from './playbackSettings.template.html';
}).map(o => {
return `<option value="${o.value}">${o.name}</option>`;
}).join('');
}
}
function populateLanguages(select, languages) {
function populateLanguages(select, languages) {
let html = '';
html += `<option value=''>${globalize.translate('AnyLanguage')}</option>`;
@ -39,9 +37,9 @@ import template from './playbackSettings.template.html';
}
select.innerHTML = html;
}
}
function fillQuality(select, isInNetwork, mediatype, maxVideoWidth) {
function fillQuality(select, isInNetwork, mediatype, maxVideoWidth) {
const options = mediatype === 'Audio' ? qualityoptions.getAudioQualityOptions({
currentMaxBitrate: appSettings.maxStreamingBitrate(isInNetwork, mediatype),
@ -61,9 +59,9 @@ import template from './playbackSettings.template.html';
// render empty string instead of 0 for the auto option
return `<option value="${i.bitrate || ''}">${i.name}</option>`;
}).join('');
}
}
function setMaxBitrateIntoField(select, isInNetwork, mediatype) {
function setMaxBitrateIntoField(select, isInNetwork, mediatype) {
fillQuality(select, isInNetwork, mediatype);
if (appSettings.enableAutomaticBitrateDetection(isInNetwork, mediatype)) {
@ -71,9 +69,9 @@ import template from './playbackSettings.template.html';
} else {
select.value = appSettings.maxStreamingBitrate(isInNetwork, mediatype);
}
}
}
function fillChromecastQuality(select, maxVideoWidth) {
function fillChromecastQuality(select, maxVideoWidth) {
const options = qualityoptions.getVideoQualityOptions({
currentMaxBitrate: appSettings.maxChromecastBitrate(),
@ -88,18 +86,18 @@ import template from './playbackSettings.template.html';
}).join('');
select.value = appSettings.maxChromecastBitrate() || '';
}
}
function setMaxBitrateFromField(select, isInNetwork, mediatype) {
function setMaxBitrateFromField(select, isInNetwork, mediatype) {
if (select.value) {
appSettings.maxStreamingBitrate(isInNetwork, mediatype, select.value);
appSettings.enableAutomaticBitrateDetection(isInNetwork, mediatype, false);
} else {
appSettings.enableAutomaticBitrateDetection(isInNetwork, mediatype, true);
}
}
}
function showHideQualityFields(context, user, apiClient) {
function showHideQualityFields(context, user, apiClient) {
if (user.Policy.EnableVideoPlaybackTranscoding) {
context.querySelector('.videoQualitySection').classList.remove('hide');
} else {
@ -137,18 +135,18 @@ import template from './playbackSettings.template.html';
}
}
});
}
}
function showOrHideEpisodesField(context) {
function showOrHideEpisodesField(context) {
if (browser.tizen || browser.web0s) {
context.querySelector('.fldEpisodeAutoPlay').classList.add('hide');
return;
}
context.querySelector('.fldEpisodeAutoPlay').classList.remove('hide');
}
}
function loadForm(context, user, userSettings, apiClient) {
function loadForm(context, user, userSettings, apiClient) {
const loggedInUserId = apiClient.getCurrentUserId();
const userId = user.Id;
@ -213,9 +211,9 @@ import template from './playbackSettings.template.html';
showOrHideEpisodesField(context);
loading.hide();
}
}
function saveUser(context, user, userSettingsInstance, apiClient) {
function saveUser(context, user, userSettingsInstance, apiClient) {
appSettings.enableSystemExternalPlayers(context.querySelector('.chkExternalVideoPlayer').checked);
appSettings.maxChromecastBitrate(context.querySelector('.selectChromecastVideoQuality').value);
@ -240,9 +238,9 @@ import template from './playbackSettings.template.html';
userSettingsInstance.skipBackLength(context.querySelector('.selectSkipBackLength').value);
return apiClient.updateUserConfiguration(user.Id, user.Configuration);
}
}
function save(instance, context, userId, userSettings, apiClient, enableSaveConfirmation) {
function save(instance, context, userId, userSettings, apiClient, enableSaveConfirmation) {
loading.show();
apiClient.getUser(userId).then(user => {
@ -257,17 +255,17 @@ import template from './playbackSettings.template.html';
loading.hide();
});
});
}
}
function setSelectValue(select, value, defaultValue) {
function setSelectValue(select, value, defaultValue) {
select.value = value;
if (select.selectedIndex < 0) {
select.value = defaultValue;
}
}
}
function onMaxVideoWidthChange(e) {
function onMaxVideoWidthChange(e) {
const context = this.options.element;
const selectVideoInNetworkQuality = context.querySelector('.selectVideoInNetworkQuality');
@ -287,9 +285,9 @@ import template from './playbackSettings.template.html';
setSelectValue(selectVideoInNetworkQuality, selectVideoInNetworkQualityValue, '');
setSelectValue(selectVideoInternetQuality, selectVideoInternetQualityValue, '');
setSelectValue(selectChromecastVideoQuality, selectChromecastVideoQualityValue, '');
}
}
function onSubmit(e) {
function onSubmit(e) {
const self = this;
const apiClient = ServerConnections.getApiClient(self.options.serverId);
const userId = self.options.userId;
@ -305,9 +303,9 @@ import template from './playbackSettings.template.html';
e.preventDefault();
}
return false;
}
}
function embed(options, self) {
function embed(options, self) {
options.element.innerHTML = globalize.translateHtml(template, 'core');
options.element.querySelector('form').addEventListener('submit', onSubmit.bind(self));
@ -323,9 +321,9 @@ import template from './playbackSettings.template.html';
if (options.autoFocus) {
focusManager.autoFocus(options.element);
}
}
}
class PlaybackSettings {
class PlaybackSettings {
constructor(options) {
this.options = options;
embed(options, this);
@ -357,7 +355,6 @@ import template from './playbackSettings.template.html';
destroy() {
this.options = null;
}
}
}
/* eslint-enable indent */
export default PlaybackSettings;

View file

@ -9,9 +9,7 @@ import { PluginType } from '../../types/plugin.ts';
import './playerstats.scss';
import ServerConnections from '../ServerConnections';
/* eslint-disable indent */
function init(instance) {
function init(instance) {
const parent = document.createElement('div');
parent.classList.add('playerStats');
@ -43,13 +41,13 @@ import ServerConnections from '../ServerConnections';
document.body.appendChild(parent);
instance.element = parent;
}
}
function onCloseButtonClick() {
function onCloseButtonClick() {
this.enabled(false);
}
}
function renderStats(elem, categories) {
function renderStats(elem, categories) {
elem.querySelector('.playerStats-stats').innerHTML = categories.map(function (category) {
let categoryHtml = '';
@ -87,9 +85,9 @@ import ServerConnections from '../ServerConnections';
return categoryHtml;
}).join('');
}
}
function getSession(instance, player) {
function getSession(instance, player) {
const now = new Date().getTime();
if ((now - (instance.lastSessionTime || 0)) < 10000) {
@ -108,13 +106,13 @@ import ServerConnections from '../ServerConnections';
}, function () {
return Promise.resolve({});
});
}
}
function translateReason(reason) {
function translateReason(reason) {
return globalize.translate('' + reason);
}
}
function getTranscodingStats(session, player, displayPlayMethod) {
function getTranscodingStats(session, player, displayPlayMethod) {
const sessionStats = [];
let videoCodec;
@ -183,17 +181,17 @@ import ServerConnections from '../ServerConnections';
}
return sessionStats;
}
}
function getDisplayBitrate(bitrate) {
function getDisplayBitrate(bitrate) {
if (bitrate > 1000000) {
return (bitrate / 1000000).toFixed(1) + ' Mbps';
} else {
return Math.floor(bitrate / 1000) + ' kbps';
}
}
}
function getReadableSize(size) {
function getReadableSize(size) {
if (size >= 1073741824) {
return parseFloat((size / 1073741824).toFixed(1)) + ' GiB';
} else if (size >= 1048576) {
@ -201,9 +199,9 @@ import ServerConnections from '../ServerConnections';
} else {
return Math.floor(size / 1024) + ' KiB';
}
}
}
function getMediaSourceStats(session, player) {
function getMediaSourceStats(session, player) {
const sessionStats = [];
const mediaSource = playbackManager.currentMediaSource(player) || {};
@ -323,9 +321,9 @@ import ServerConnections from '../ServerConnections';
}
return sessionStats;
}
}
function getSyncPlayStats() {
function getSyncPlayStats() {
const SyncPlay = pluginManager.firstOfType(PluginType.SyncPlay)?.instance;
if (!SyncPlay?.Manager.isSyncPlayEnabled()) {
@ -357,9 +355,9 @@ import ServerConnections from '../ServerConnections';
});
return syncStats;
}
}
function getStats(instance, player) {
function getStats(instance, player) {
const statsPromise = player.getStats ? player.getStats() : Promise.resolve({});
const sessionPromise = getSession(instance, player);
@ -439,9 +437,9 @@ import ServerConnections from '../ServerConnections';
return Promise.resolve(categories);
});
}
}
function renderPlayerStats(instance, player) {
function renderPlayerStats(instance, player) {
const now = new Date().getTime();
if ((now - (instance.lastRender || 0)) < 700) {
@ -458,24 +456,24 @@ import ServerConnections from '../ServerConnections';
renderStats(elem, stats);
});
}
}
function bindEvents(instance, player) {
function bindEvents(instance, player) {
const localOnTimeUpdate = function () {
renderPlayerStats(instance, player);
};
instance.onTimeUpdate = localOnTimeUpdate;
Events.on(player, 'timeupdate', localOnTimeUpdate);
}
}
function unbindEvents(instance, player) {
function unbindEvents(instance, player) {
const localOnTimeUpdate = instance.onTimeUpdate;
if (localOnTimeUpdate) {
Events.off(player, 'timeupdate', localOnTimeUpdate);
}
}
}
class PlayerStats {
constructor(options) {
@ -527,6 +525,4 @@ class PlayerStats {
}
}
/* eslint-enable indent */
export default PlayerStats;

View file

@ -18,11 +18,9 @@ import 'material-design-icons-iconfont';
import '../formdialog.scss';
import ServerConnections from '../ServerConnections';
/* eslint-disable indent */
let currentServerId;
let currentServerId;
function onSubmit(e) {
function onSubmit(e) {
const panel = dom.parentWithClass(this, 'dialog');
const playlistId = panel.querySelector('#selectPlaylistToAddTo').value;
@ -37,9 +35,9 @@ import ServerConnections from '../ServerConnections';
e.preventDefault();
return false;
}
}
function createPlaylist(apiClient, dlg) {
function createPlaylist(apiClient, dlg) {
loading.show();
const url = apiClient.getUrl('Playlists', {
@ -62,13 +60,13 @@ import ServerConnections from '../ServerConnections';
dialogHelper.close(dlg);
redirectToPlaylist(apiClient, id);
});
}
}
function redirectToPlaylist(apiClient, id) {
function redirectToPlaylist(apiClient, id) {
appRouter.showItem(id, apiClient.serverId());
}
}
function addToPlaylist(apiClient, dlg, id) {
function addToPlaylist(apiClient, dlg, id) {
const itemIds = dlg.querySelector('.fldSelectedItemIds').value || '';
if (id === 'queue') {
@ -98,13 +96,13 @@ import ServerConnections from '../ServerConnections';
dlg.submitted = true;
dialogHelper.close(dlg);
});
}
}
function triggerChange(select) {
function triggerChange(select) {
select.dispatchEvent(new CustomEvent('change', {}));
}
}
function populatePlaylists(editorOptions, panel) {
function populatePlaylists(editorOptions, panel) {
const select = panel.querySelector('#selectPlaylistToAddTo');
loading.hide();
@ -151,9 +149,9 @@ import ServerConnections from '../ServerConnections';
loading.hide();
});
}
}
function getEditorHtml(items) {
function getEditorHtml(items) {
let html = '';
html += '<div class="formDialogContent smoothScrollY" style="padding-top:2em;">';
@ -186,9 +184,9 @@ import ServerConnections from '../ServerConnections';
html += '</div>';
return html;
}
}
function initEditor(content, options, items) {
function initEditor(content, options, items) {
content.querySelector('#selectPlaylistToAddTo').addEventListener('change', function () {
if (this.value) {
content.querySelector('.newPlaylistInfo').classList.add('hide');
@ -214,16 +212,16 @@ import ServerConnections from '../ServerConnections';
selectPlaylistToAddTo.value = '';
triggerChange(selectPlaylistToAddTo);
}
}
}
function centerFocus(elem, horiz, on) {
function centerFocus(elem, horiz, on) {
import('../../scripts/scrollHelper').then((scrollHelper) => {
const fn = on ? 'on' : 'off';
scrollHelper.centerFocus[fn](elem, horiz);
});
}
}
export class showEditor {
export class showEditor {
constructor(options) {
const items = options.items || {};
currentServerId = options.serverId;
@ -280,7 +278,6 @@ import ServerConnections from '../ServerConnections';
return Promise.reject();
});
}
}
}
/* eslint-enable indent */
export default showEditor;

View file

@ -1,5 +1,3 @@
/* eslint-disable indent */
/**
* Module for controlling scroll behavior.
* @module components/scrollManager
@ -9,35 +7,35 @@ import dom from '../scripts/dom';
import browser from '../scripts/browser';
import layoutManager from './layoutManager';
/**
/**
* Scroll time in ms.
*/
const ScrollTime = 270;
const ScrollTime = 270;
/**
/**
* Epsilon for comparing values.
*/
const Epsilon = 1e-6;
const Epsilon = 1e-6;
// FIXME: Need to scroll to top of page to fully show the top menu. This can be solved by some marker of top most elements or their containers
/**
// FIXME: Need to scroll to top of page to fully show the top menu. This can be solved by some marker of top most elements or their containers
/**
* Returns minimum vertical scroll.
* Scroll less than that value will be zeroed.
*
* @return {number} Minimum vertical scroll.
*/
function minimumScrollY() {
function minimumScrollY() {
const topMenu = document.querySelector('.headerTop');
if (topMenu) {
return topMenu.clientHeight;
}
return 0;
}
}
const supportsSmoothScroll = 'scrollBehavior' in document.documentElement.style;
const supportsSmoothScroll = 'scrollBehavior' in document.documentElement.style;
let supportsScrollToOptions = false;
try {
let supportsScrollToOptions = false;
try {
const elem = document.createElement('div');
const opts = Object.defineProperty({}, 'behavior', {
@ -48,11 +46,11 @@ import layoutManager from './layoutManager';
});
elem.scrollTo(opts);
} catch (e) {
} catch (e) {
console.error('error checking ScrollToOptions support');
}
}
/**
/**
* Returns value clamped by range [min, max].
*
* @param {number} value - Clamped value.
@ -60,16 +58,16 @@ import layoutManager from './layoutManager';
* @param {number} max - Ending of range.
* @return {number} Clamped value.
*/
function clamp(value, min, max) {
function clamp(value, min, max) {
if (value <= min) {
return min;
} else if (value >= max) {
return max;
}
return value;
}
}
/**
/**
* Returns the required delta to fit range 1 into range 2.
* In case of range 1 is bigger than range 2 returns delta to fit most out of range part.
*
@ -79,7 +77,7 @@ import layoutManager from './layoutManager';
* @param {number} end2 - Ending of range 2.
* @return {number} Delta: <0 move range1 to the left, >0 - to the right.
*/
function fitRange(begin1, end1, begin2, end2) {
function fitRange(begin1, end1, begin2, end2) {
const delta1 = begin1 - begin2;
const delta2 = end2 - end1;
if (delta1 < 0 && delta1 < delta2) {
@ -88,19 +86,19 @@ import layoutManager from './layoutManager';
return delta2;
}
return 0;
}
}
/**
/**
* Ease value.
*
* @param {number} t - Value in range [0, 1].
* @return {number} Eased value in range [0, 1].
*/
function ease(t) {
function ease(t) {
return t * (2 - t); // easeOutQuad === ease-out
}
}
/**
/**
* @typedef {Object} Rect
* @property {number} left - X coordinate of top-left corner.
* @property {number} top - Y coordinate of top-left corner.
@ -108,7 +106,7 @@ import layoutManager from './layoutManager';
* @property {number} height - Height.
*/
/**
/**
* Document scroll wrapper helps to unify scrolling and fix issues of some browsers.
*
* webOS 2 Browser: scrolls documentElement (and window), but body has a scroll size
@ -121,7 +119,7 @@ import layoutManager from './layoutManager';
*
* Tizen 5 Browser/Native: scrolls documentElement (and window); has a document.scrollingElement
*/
class DocumentScroller {
class DocumentScroller {
/**
* Horizontal scroll position.
* @type {number}
@ -208,14 +206,14 @@ import layoutManager from './layoutManager';
scrollTo() {
window.scrollTo.apply(window, arguments);
}
}
}
/**
/**
* Default (document) scroller.
*/
const documentScroller = new DocumentScroller();
const documentScroller = new DocumentScroller();
const scrollerHints = {
const scrollerHints = {
x: {
nameScroll: 'scrollWidth',
nameClient: 'clientWidth',
@ -228,16 +226,16 @@ import layoutManager from './layoutManager';
nameStyle: 'overflowY',
nameScrollMode: 'data-scroll-mode-y'
}
};
};
/**
/**
* Returns parent element that can be scrolled. If no such, returns document scroller.
*
* @param {HTMLElement} element - Element for which parent is being searched.
* @param {boolean} vertical - Search for vertical scrollable parent.
* @param {HTMLElement|DocumentScroller} Parent element that can be scrolled or document scroller.
*/
function getScrollableParent(element, vertical) {
function getScrollableParent(element, vertical) {
if (element) {
const scrollerHint = vertical ? scrollerHints.y : scrollerHints.x;
@ -269,9 +267,9 @@ import layoutManager from './layoutManager';
}
return documentScroller;
}
}
/**
/**
* @typedef {Object} ScrollerData
* @property {number} scrollPos - Current scroll position.
* @property {number} scrollSize - Scroll size.
@ -280,14 +278,14 @@ import layoutManager from './layoutManager';
* @property {boolean} custom - Custom scrolling mode.
*/
/**
/**
* Returns scroller data for specified orientation.
*
* @param {HTMLElement} scroller - Scroller.
* @param {boolean} vertical - Vertical scroller data.
* @return {ScrollerData} Scroller data.
*/
function getScrollerData(scroller, vertical) {
function getScrollerData(scroller, vertical) {
const data = {};
if (!vertical) {
@ -305,9 +303,9 @@ import layoutManager from './layoutManager';
data.custom = data.mode === 'custom';
return data;
}
}
/**
/**
* Returns position of child of scroller for specified orientation.
*
* @param {HTMLElement} scroller - Scroller.
@ -315,7 +313,7 @@ import layoutManager from './layoutManager';
* @param {boolean} vertical - Vertical scroll.
* @return {number} Child position.
*/
function getScrollerChildPos(scroller, element, vertical) {
function getScrollerChildPos(scroller, element, vertical) {
const elementRect = element.getBoundingClientRect();
const scrollerRect = scroller.getBoundingClientRect();
@ -324,9 +322,9 @@ import layoutManager from './layoutManager';
} else {
return scroller.scrollTop + elementRect.top - scrollerRect.top;
}
}
}
/**
/**
* Returns scroll position for element.
*
* @param {ScrollerData} scrollerData - Scroller data.
@ -335,7 +333,7 @@ import layoutManager from './layoutManager';
* @param {boolean} centered - Scroll to center.
* @return {number} Scroll position.
*/
function calcScroll(scrollerData, elementPos, elementSize, centered) {
function calcScroll(scrollerData, elementPos, elementSize, centered) {
const maxScroll = scrollerData.scrollSize - scrollerData.clientSize;
let scroll;
@ -348,15 +346,15 @@ import layoutManager from './layoutManager';
}
return clamp(Math.round(scroll), 0, maxScroll);
}
}
/**
/**
* Calls scrollTo function in proper way.
*
* @param {HTMLElement} scroller - Scroller.
* @param {ScrollToOptions} options - Scroll options.
*/
function scrollToHelper(scroller, options) {
function scrollToHelper(scroller, options) {
if ('scrollTo' in scroller) {
if (!supportsScrollToOptions) {
const scrollX = (options.left !== undefined ? options.left : scroller.scrollLeft);
@ -373,9 +371,9 @@ import layoutManager from './layoutManager';
scroller.scrollTop = options.top;
}
}
}
}
/**
/**
* Performs built-in scroll.
*
* @param {HTMLElement} xScroller - Horizontal scroller.
@ -384,7 +382,7 @@ import layoutManager from './layoutManager';
* @param {number} scrollY - Vertical coordinate.
* @param {boolean} smooth - Smooth scrolling.
*/
function builtinScroll(xScroller, scrollX, yScroller, scrollY, smooth) {
function builtinScroll(xScroller, scrollX, yScroller, scrollY, smooth) {
const scrollBehavior = smooth ? 'smooth' : 'instant';
if (xScroller !== yScroller) {
@ -397,22 +395,22 @@ import layoutManager from './layoutManager';
} else if (xScroller) {
scrollToHelper(xScroller, { left: scrollX, top: scrollY, behavior: scrollBehavior });
}
}
}
/**
/**
* Requested frame for animated scroll.
*/
let scrollTimer;
let scrollTimer;
/**
/**
* Resets scroll timer to stop scrolling.
*/
function resetScrollTimer() {
function resetScrollTimer() {
cancelAnimationFrame(scrollTimer);
scrollTimer = undefined;
}
}
/**
/**
* Performs animated scroll.
*
* @param {HTMLElement} xScroller - Horizontal scroller.
@ -420,7 +418,7 @@ import layoutManager from './layoutManager';
* @param {HTMLElement} yScroller - Vertical scroller.
* @param {number} scrollY - Vertical coordinate.
*/
function animateScroll(xScroller, scrollX, yScroller, scrollY) {
function animateScroll(xScroller, scrollX, yScroller, scrollY) {
const ox = xScroller ? xScroller.scrollLeft : scrollX;
const oy = yScroller ? yScroller.scrollTop : scrollY;
const dx = scrollX - ox;
@ -454,9 +452,9 @@ import layoutManager from './layoutManager';
}
scrollTimer = requestAnimationFrame(scrollAnim);
}
}
/**
/**
* Performs scroll.
*
* @param {HTMLElement} xScroller - Horizontal scroller.
@ -465,7 +463,7 @@ import layoutManager from './layoutManager';
* @param {number} scrollY - Vertical coordinate.
* @param {boolean} smooth - Smooth scrolling.
*/
function doScroll(xScroller, scrollX, yScroller, scrollY, smooth) {
function doScroll(xScroller, scrollX, yScroller, scrollY, smooth) {
resetScrollTimer();
if (smooth && useAnimatedScroll()) {
@ -473,39 +471,39 @@ import layoutManager from './layoutManager';
} else {
builtinScroll(xScroller, scrollX, yScroller, scrollY, smooth);
}
}
}
/**
/**
* Returns true if smooth scroll must be used.
*/
function useSmoothScroll() {
function useSmoothScroll() {
return !!browser.tizen;
}
}
/**
/**
* Returns true if animated implementation of smooth scroll must be used.
*/
function useAnimatedScroll() {
function useAnimatedScroll() {
// Add block to force using (or not) of animated implementation
return !supportsSmoothScroll;
}
}
/**
/**
* Returns true if scroll manager is enabled.
*/
export function isEnabled() {
export function isEnabled() {
return layoutManager.tv;
}
}
/**
/**
* Scrolls the document to a given position.
*
* @param {number} scrollX - Horizontal coordinate.
* @param {number} scrollY - Vertical coordinate.
* @param {boolean} [smooth=false] - Smooth scrolling.
*/
export function scrollTo(scrollX, scrollY, smooth) {
export function scrollTo(scrollX, scrollY, smooth) {
smooth = !!smooth;
// Scroller is document itself by default
@ -518,15 +516,15 @@ import layoutManager from './layoutManager';
scrollY = clamp(Math.round(scrollY), 0, yScrollerData.scrollSize - yScrollerData.clientSize);
doScroll(scroller, scrollX, scroller, scrollY, smooth);
}
}
/**
/**
* Scrolls the document to a given element.
*
* @param {HTMLElement} element - Target element of scroll task.
* @param {boolean} [smooth=false] - Smooth scrolling.
*/
export function scrollToElement(element, smooth) {
export function scrollToElement(element, smooth) {
smooth = !!smooth;
let scrollCenterX = true;
@ -590,17 +588,15 @@ import layoutManager from './layoutManager';
}
doScroll(xScroller, scrollX, yScroller, scrollY, smooth);
}
}
if (isEnabled()) {
if (isEnabled()) {
dom.addEventListener(window, 'focusin', function(e) {
setTimeout(function() {
scrollToElement(e.target, useSmoothScroll());
}, 0);
}, { capture: true });
}
/* eslint-enable indent */
}
export default {
isEnabled: isEnabled,

View file

@ -1,5 +1,3 @@
/* eslint-disable indent */
/**
* Module shortcuts.
* @module components/shortcuts
@ -14,7 +12,7 @@ import recordingHelper from './recordingcreator/recordinghelper';
import ServerConnections from './ServerConnections';
import toast from './toast/toast';
function playAllFromHere(card, serverId, queue) {
function playAllFromHere(card, serverId, queue) {
const parent = card.parentNode;
const className = card.classList.length ? (`.${card.classList[0]}`) : '';
const cards = parent.querySelectorAll(`${className}[data-id]`);
@ -68,15 +66,15 @@ import toast from './toast/toast';
startIndex: startIndex
});
}
}
}
function showProgramDialog(item) {
function showProgramDialog(item) {
import('./recordingcreator/recordingcreator').then(({ default:recordingCreator }) => {
recordingCreator.show(item.Id, item.ServerId);
});
}
}
function getItem(button) {
function getItem(button) {
button = dom.parentWithAttribute(button, 'data-id');
const serverId = button.getAttribute('data-serverid');
const id = button.getAttribute('data-id');
@ -91,17 +89,17 @@ import toast from './toast/toast';
return apiClient.getLiveTvSeriesTimer(id);
}
return apiClient.getItem(apiClient.getCurrentUserId(), id);
}
}
function notifyRefreshNeeded(childElement, itemsContainer) {
function notifyRefreshNeeded(childElement, itemsContainer) {
itemsContainer = itemsContainer || dom.parentWithAttribute(childElement, 'is', 'emby-itemscontainer');
if (itemsContainer) {
itemsContainer.notifyRefreshNeeded(true);
}
}
}
function showContextMenu(card, options) {
function showContextMenu(card, options) {
getItem(card).then(item => {
const playlistId = card.getAttribute('data-playlistid');
const collectionId = card.getAttribute('data-collectionid');
@ -133,9 +131,9 @@ import toast from './toast/toast';
});
});
});
}
}
function getItemInfoFromCard(card) {
function getItemInfoFromCard(card) {
return {
Type: card.getAttribute('data-type'),
Id: card.getAttribute('data-id'),
@ -153,9 +151,9 @@ import toast from './toast/toast';
PlaybackPositionTicks: parseInt(card.getAttribute('data-positionticks') || '0', 10)
}
};
}
}
function showPlayMenu(card, target) {
function showPlayMenu(card, target) {
const item = getItemInfoFromCard(card);
import('./playmenu').then((playMenu) => {
@ -165,9 +163,9 @@ import toast from './toast/toast';
positionTo: target
});
});
}
}
function executeAction(card, target, action) {
function executeAction(card, target, action) {
target = target || card;
let id = card.getAttribute('data-id');
@ -269,9 +267,9 @@ import toast from './toast/toast';
bubbles: true
}));
}
}
}
function addToPlaylist(item) {
function addToPlaylist(item) {
import('./playlisteditor/playlisteditor').then(({ default: playlistEditor }) => {
new playlistEditor().show({
items: [item.Id],
@ -279,17 +277,17 @@ import toast from './toast/toast';
});
});
}
}
function playTrailer(item) {
function playTrailer(item) {
const apiClient = ServerConnections.getApiClient(item.ServerId);
apiClient.getLocalTrailers(apiClient.getCurrentUserId(), item.Id).then(trailers => {
playbackManager.play({ items: trailers });
});
}
}
function editItem(item, serverId) {
function editItem(item, serverId) {
const apiClient = ServerConnections.getApiClient(serverId);
return new Promise((resolve, reject) => {
@ -311,16 +309,16 @@ import toast from './toast/toast';
});
}
});
}
}
function onRecordCommand(serverId, id, type, timerId, seriesTimerId) {
function onRecordCommand(serverId, id, type, timerId, seriesTimerId) {
if (type === 'Program' || timerId || seriesTimerId) {
const programId = type === 'Program' ? id : null;
recordingHelper.toggleRecording(serverId, programId, timerId, seriesTimerId);
}
}
}
export function onClick(e) {
export function onClick(e) {
const card = dom.parentWithClass(e.target, 'itemAction');
if (card) {
@ -342,9 +340,9 @@ import toast from './toast/toast';
return false;
}
}
}
}
function onCommand(e) {
function onCommand(e) {
const cmd = e.detail.command;
if (cmd === 'play' || cmd === 'resume' || cmd === 'record' || cmd === 'menu' || cmd === 'info') {
@ -357,9 +355,9 @@ import toast from './toast/toast';
executeAction(card, card, cmd);
}
}
}
}
export function on(context, options) {
export function on(context, options) {
options = options || {};
if (options.click !== false) {
@ -369,9 +367,9 @@ import toast from './toast/toast';
if (options.command !== false) {
inputManager.on(context, onCommand);
}
}
}
export function off(context, options) {
export function off(context, options) {
options = options || {};
context.removeEventListener('click', onClick);
@ -379,9 +377,9 @@ import toast from './toast/toast';
if (options.command !== false) {
inputManager.off(context, onCommand);
}
}
}
export function getShortcutAttributesHtml(item, serverId) {
export function getShortcutAttributesHtml(item, serverId) {
let html = `data-id="${item.Id}" data-serverid="${serverId || item.ServerId}" data-type="${item.Type}" data-mediatype="${item.MediaType}" data-channelid="${item.ChannelId}" data-isfolder="${item.IsFolder}"`;
const collectionType = item.CollectionType;
@ -390,9 +388,7 @@ import toast from './toast/toast';
}
return html;
}
/* eslint-enable indent */
}
export default {
on: on,

View file

@ -10,11 +10,9 @@ import './upnextdialog.scss';
import '../../elements/emby-button/emby-button';
import '../../styles/flexstyles.scss';
/* eslint-disable indent */
const transitionEndEventName = dom.whichTransitionEvent();
const transitionEndEventName = dom.whichTransitionEvent();
function getHtml() {
function getHtml() {
let html = '';
html += '<div class="flex flex-direction-column flex-grow">';
@ -43,9 +41,9 @@ import '../../styles/flexstyles.scss';
html += '</div>';
return html;
}
}
function setNextVideoText() {
function setNextVideoText() {
const instance = this;
const elem = instance.options.parent;
@ -61,9 +59,9 @@ import '../../styles/flexstyles.scss';
globalize.translate('HeaderNextVideoPlayingInValue', timeText);
elem.querySelector('.upNextDialog-nextVideoText').innerHTML = nextVideoText;
}
}
function fillItem(item) {
function fillItem(item) {
const instance = this;
const elem = instance.options.parent;
@ -85,16 +83,16 @@ import '../../styles/flexstyles.scss';
instance.itemType = item.Type;
instance.show();
}
}
function clearCountdownTextTimeout(instance) {
function clearCountdownTextTimeout(instance) {
if (instance._countdownTextTimeout) {
clearInterval(instance._countdownTextTimeout);
instance._countdownTextTimeout = null;
}
}
}
async function onStartNowClick() {
async function onStartNowClick() {
const options = this.options;
if (options) {
@ -104,9 +102,9 @@ import '../../styles/flexstyles.scss';
playbackManager.nextTrack(player);
}
}
}
function init(instance, options) {
function init(instance, options) {
options.parent.innerHTML = getHtml();
options.parent.classList.add('hide');
@ -117,9 +115,9 @@ import '../../styles/flexstyles.scss';
options.parent.querySelector('.btnHide').addEventListener('click', instance.hide.bind(instance));
options.parent.querySelector('.btnStartNow').addEventListener('click', onStartNowClick.bind(instance));
}
}
function clearHideAnimationEventListeners(instance, elem) {
function clearHideAnimationEventListeners(instance, elem) {
const fn = instance._onHideAnimationComplete;
if (fn) {
@ -127,9 +125,9 @@ import '../../styles/flexstyles.scss';
once: true
});
}
}
}
function onHideAnimationComplete(e) {
function onHideAnimationComplete(e) {
const instance = this;
const elem = e.target;
@ -137,9 +135,9 @@ import '../../styles/flexstyles.scss';
clearHideAnimationEventListeners(instance, elem);
Events.trigger(instance, 'hide');
}
}
async function hideComingUpNext() {
async function hideComingUpNext() {
const instance = this;
clearCountdownTextTimeout(this);
@ -174,9 +172,9 @@ import '../../styles/flexstyles.scss';
});
instance._onHideAnimationComplete(transitionEvent);
}
}
function getTimeRemainingMs(instance) {
function getTimeRemainingMs(instance) {
const options = instance.options;
if (options) {
const runtimeTicks = playbackManager.duration(options.player);
@ -189,9 +187,9 @@ import '../../styles/flexstyles.scss';
}
return 0;
}
}
function startComingUpNextHideTimer(instance) {
function startComingUpNextHideTimer(instance) {
const timeRemainingMs = getTimeRemainingMs(instance);
if (timeRemainingMs <= 0) {
@ -202,7 +200,7 @@ import '../../styles/flexstyles.scss';
clearCountdownTextTimeout(instance);
instance._countdownTextTimeout = setInterval(setNextVideoText.bind(instance), 400);
}
}
class UpNextDialog {
constructor(options) {
@ -243,4 +241,3 @@ class UpNextDialog {
export default UpNextDialog;
/* eslint-enable indent */

View file

@ -10,9 +10,7 @@ const getMainAnimatedPages = () => {
return mainAnimatedPages;
};
/* eslint-disable indent */
function setControllerClass(view, options) {
function setControllerClass(view, options) {
if (options.controllerFactory) {
return Promise.resolve();
}
@ -32,9 +30,9 @@ const getMainAnimatedPages = () => {
}
return Promise.resolve();
}
}
export function loadView(options) {
export function loadView(options) {
if (!options.cancel) {
const selected = selectedPageIndex;
const previousAnimatable = selected === -1 ? null : allPages[selected];
@ -123,9 +121,9 @@ const getMainAnimatedPages = () => {
return view;
});
}
}
}
function parseHtml(html, hasScript) {
function parseHtml(html, hasScript) {
if (hasScript) {
html = html
.replaceAll('\x3c!--<script', '<script')
@ -135,9 +133,9 @@ const getMainAnimatedPages = () => {
const wrapper = document.createElement('div');
wrapper.innerHTML = html;
return wrapper.querySelector('div[data-role="page"]');
}
}
function normalizeNewView(options, isPluginpage) {
function normalizeNewView(options, isPluginpage) {
const viewHtml = options.view;
if (viewHtml.indexOf('data-role="page"') === -1) {
@ -168,29 +166,29 @@ const getMainAnimatedPages = () => {
hasjQueryChecked: hasjQueryChecked,
hasjQuery: hasjQuery
};
}
}
function beforeAnimate(allPages, newPageIndex, oldPageIndex) {
function beforeAnimate(allPages, newPageIndex, oldPageIndex) {
for (let index = 0, length = allPages.length; index < length; index++) {
if (newPageIndex !== index && oldPageIndex !== index) {
allPages[index].classList.add('hide');
}
}
}
}
function afterAnimate(allPages, newPageIndex) {
function afterAnimate(allPages, newPageIndex) {
for (let index = 0, length = allPages.length; index < length; index++) {
if (newPageIndex !== index) {
allPages[index].classList.add('hide');
}
}
}
}
export function setOnBeforeChange(fn) {
export function setOnBeforeChange(fn) {
onBeforeChange = fn;
}
}
export function tryRestoreView(options) {
export function tryRestoreView(options) {
const url = options.url;
const index = currentUrls.indexOf(url);
@ -229,29 +227,27 @@ const getMainAnimatedPages = () => {
}
return Promise.reject();
}
}
function triggerDestroy(view) {
function triggerDestroy(view) {
view.dispatchEvent(new CustomEvent('viewdestroy', {}));
}
}
export function reset() {
export function reset() {
allPages = [];
currentUrls = [];
if (mainAnimatedPages) mainAnimatedPages.innerHTML = '';
selectedPageIndex = -1;
}
}
let onBeforeChange;
let mainAnimatedPages;
let allPages = [];
let currentUrls = [];
const pageContainerCount = 3;
let selectedPageIndex = -1;
reset();
getMainAnimatedPages()?.classList.remove('hide');
/* eslint-enable indent */
let onBeforeChange;
let mainAnimatedPages;
let allPages = [];
let currentUrls = [];
const pageContainerCount = 3;
let selectedPageIndex = -1;
reset();
getMainAnimatedPages()?.classList.remove('hide');
export default {
loadView: loadView,

View file

@ -6,9 +6,7 @@ import '../../elements/emby-button/emby-button';
import confirm from '../../components/confirm/confirm';
import { pageIdOn } from '../../utils/dashboard';
/* eslint-disable indent */
function revoke(page, key) {
function revoke(page, key) {
confirm(globalize.translate('MessageConfirmRevokeApiKey'), globalize.translate('HeaderConfirmRevokeApiKey')).then(function () {
loading.show();
ApiClient.ajax({
@ -18,9 +16,9 @@ import { pageIdOn } from '../../utils/dashboard';
loadData(page);
});
});
}
}
function renderKeys(page, keys) {
function renderKeys(page, keys) {
const rows = keys.map(function (item) {
let html = '';
html += '<tr class="detailTableBodyRow detailTableBodyRow-shaded">';
@ -42,16 +40,16 @@ import { pageIdOn } from '../../utils/dashboard';
}).join('');
page.querySelector('.resultBody').innerHTML = rows;
loading.hide();
}
}
function loadData(page) {
function loadData(page) {
loading.show();
ApiClient.getJSON(ApiClient.getUrl('Auth/Keys')).then(function (result) {
renderKeys(page, result.Items);
});
}
}
function showNewKeyPrompt(page) {
function showNewKeyPrompt(page) {
import('../../components/prompt/prompt').then(({ default: prompt }) => {
prompt({
title: globalize.translate('HeaderNewApiKey'),
@ -68,9 +66,9 @@ import { pageIdOn } from '../../utils/dashboard';
});
});
});
}
}
pageIdOn('pageinit', 'apiKeysPage', function () {
pageIdOn('pageinit', 'apiKeysPage', function () {
const page = this;
page.querySelector('.btnNewKey').addEventListener('click', function () {
showNewKeyPrompt(page);
@ -82,9 +80,8 @@ import { pageIdOn } from '../../utils/dashboard';
revoke(page, btnRevoke.getAttribute('data-token'));
}
});
});
pageIdOn('pagebeforeshow', 'apiKeysPage', function () {
});
pageIdOn('pagebeforeshow', 'apiKeysPage', function () {
loadData(this);
});
});
/* eslint-enable indent */

View file

@ -24,9 +24,7 @@ import ServerConnections from '../../components/ServerConnections';
import alert from '../../components/alert';
import confirm from '../../components/confirm/confirm';
/* eslint-disable indent */
function showPlaybackInfo(btn, session) {
function showPlaybackInfo(btn, session) {
let title;
const text = [];
const displayPlayMethod = playMethodHelper.getDisplayPlayMethod(session);
@ -62,9 +60,9 @@ import confirm from '../../components/confirm/confirm';
text: text.join('<br/>'),
title: title
});
}
}
function showSendMessageForm(btn, session) {
function showSendMessageForm(btn, session) {
import('../../components/prompt/prompt').then(({ default: prompt }) => {
prompt({
title: globalize.translate('HeaderSendMessage'),
@ -79,9 +77,9 @@ import confirm from '../../components/confirm/confirm';
}
});
});
}
}
function showOptionsMenu(btn, session) {
function showOptionsMenu(btn, session) {
import('../../components/actionSheet/actionSheet').then(({ default: actionsheet }) => {
const menuItems = [];
@ -113,9 +111,9 @@ import confirm from '../../components/confirm/confirm';
}
});
});
}
}
function onActiveDevicesClick(evt) {
function onActiveDevicesClick(evt) {
const btn = dom.parentWithClass(evt.target, 'sessionCardButton');
if (btn) {
@ -142,9 +140,9 @@ import confirm from '../../components/confirm/confirm';
}
}
}
}
}
function filterSessions(sessions) {
function filterSessions(sessions) {
const list = [];
const minActiveDate = new Date().getTime() - 9e5;
@ -161,9 +159,9 @@ import confirm from '../../components/confirm/confirm';
}
return list;
}
}
function refreshActiveRecordings(view, apiClient) {
function refreshActiveRecordings(view, apiClient) {
apiClient.getLiveTvRecordings({
UserId: Dashboard.getCurrentUserId(),
IsInProgress: true,
@ -197,9 +195,9 @@ import confirm from '../../components/confirm/confirm';
});
imageLoader.lazyChildren(itemsContainer);
});
}
}
function reloadSystemInfo(view, apiClient) {
function reloadSystemInfo(view, apiClient) {
apiClient.getSystemInfo().then(function (systemInfo) {
view.querySelector('#serverName').innerText = globalize.translate('DashboardServerName', systemInfo.ServerName);
view.querySelector('#versionNumber').innerText = globalize.translate('DashboardVersionNumber', systemInfo.Version);
@ -216,15 +214,15 @@ import confirm from '../../components/confirm/confirm';
view.querySelector('#metadataPath').innerText = systemInfo.InternalMetadataPath;
view.querySelector('#webPath').innerText = systemInfo.WebPath;
});
}
}
function renderInfo(view, sessions) {
function renderInfo(view, sessions) {
sessions = filterSessions(sessions);
renderActiveConnections(view, sessions);
loading.hide();
}
}
function pollForInfo(view, apiClient) {
function pollForInfo(view, apiClient) {
apiClient.getSessions({
ActiveWithinSeconds: 960
}).then(function (sessions) {
@ -233,9 +231,9 @@ import confirm from '../../components/confirm/confirm';
apiClient.getScheduledTasks().then(function (tasks) {
renderRunningTasks(view, tasks);
});
}
}
function renderActiveConnections(view, sessions) {
function renderActiveConnections(view, sessions) {
let html = '';
DashboardPage.sessionsList = sessions;
const parentElement = view.querySelector('.activeDevices');
@ -343,9 +341,9 @@ import confirm from '../../components/confirm/confirm';
if (deadSessionElem) {
deadSessionElem.parentNode.removeChild(deadSessionElem);
}
}
}
function renderRunningTasks(view, tasks) {
function renderRunningTasks(view, tasks) {
let html = '';
tasks = tasks.filter(function (task) {
if (task.State != 'Idle') {
@ -381,9 +379,9 @@ import confirm from '../../components/confirm/confirm';
}
view.querySelector('#divRunningTasks').innerHTML = html;
}
}
window.DashboardPage = {
window.DashboardPage = {
startInterval: function (apiClient) {
apiClient.sendMessage('SessionsStart', '0,1500');
apiClient.sendMessage('ScheduledTasksInfoStart', '0,1000');
@ -731,8 +729,8 @@ import confirm from '../../components/confirm/confirm';
ApiClient.shutdownServer();
});
}
};
export default function (view) {
};
export default function (view) {
function onRestartRequired(evt, apiClient) {
console.debug('onRestartRequired not implemented', evt, apiClient);
}
@ -844,6 +842,5 @@ import confirm from '../../components/confirm/confirm';
serverActivityLog.destroy();
}
});
}
}
/* eslint-enable indent */

View file

@ -5,14 +5,12 @@ import '../../../elements/emby-button/emby-button';
import Dashboard from '../../../utils/dashboard';
import { getParameterByName } from '../../../utils/url.ts';
/* eslint-disable indent */
function load(page, device, deviceOptions) {
function load(page, device, deviceOptions) {
page.querySelector('#txtCustomName', page).value = deviceOptions.CustomName || '';
page.querySelector('.reportedName', page).innerText = device.Name || '';
}
}
function loadData() {
function loadData() {
const page = this;
loading.show();
const id = getParameterByName('id');
@ -26,9 +24,9 @@ import { getParameterByName } from '../../../utils/url.ts';
load(page, responses[0], responses[1]);
loading.hide();
});
}
}
function save(page) {
function save(page) {
const id = getParameterByName('id');
ApiClient.ajax({
url: ApiClient.getUrl('Devices/Options', {
@ -40,18 +38,17 @@ import { getParameterByName } from '../../../utils/url.ts';
}),
contentType: 'application/json'
}).then(Dashboard.processServerConfigurationUpdateResult);
}
}
function onSubmit(e) {
function onSubmit(e) {
const form = this;
save(dom.parentWithClass(form, 'page'));
e.preventDefault();
return false;
}
}
export default function (view) {
export default function (view) {
view.querySelector('form').addEventListener('submit', onSubmit);
view.addEventListener('viewshow', loadData);
}
}
/* eslint-enable indent */

View file

@ -12,16 +12,14 @@ import '../../../components/cardbuilder/card.scss';
import Dashboard from '../../../utils/dashboard';
import confirm from '../../../components/confirm/confirm';
/* eslint-disable indent */
// Local cache of loaded
let deviceIds = [];
// Local cache of loaded
let deviceIds = [];
function canDelete(deviceId) {
function canDelete(deviceId) {
return deviceId !== ApiClient.deviceId();
}
}
function deleteAllDevices(page) {
function deleteAllDevices(page) {
const msg = globalize.translate('DeleteDevicesConfirmation');
confirm({
@ -36,9 +34,9 @@ import confirm from '../../../components/confirm/confirm';
);
loadData(page);
});
}
}
function deleteDevice(page, id) {
function deleteDevice(page, id) {
const msg = globalize.translate('DeleteDeviceConfirmation');
confirm({
@ -51,9 +49,9 @@ import confirm from '../../../components/confirm/confirm';
await ApiClient.deleteDevice(id);
loadData(page);
});
}
}
function showDeviceMenu(view, btn, deviceId) {
function showDeviceMenu(view, btn, deviceId) {
const menuItems = [{
name: globalize.translate('Edit'),
id: 'open',
@ -84,9 +82,9 @@ import confirm from '../../../components/confirm/confirm';
}
});
});
}
}
function load(page, devices) {
function load(page, devices) {
const localeWithSuffix = getLocaleWithSuffix();
let html = '';
@ -140,18 +138,18 @@ import confirm from '../../../components/confirm/confirm';
return deviceHtml;
}).join('');
page.querySelector('.devicesList').innerHTML = html;
}
}
function loadData(page) {
function loadData(page) {
loading.show();
ApiClient.getJSON(ApiClient.getUrl('Devices')).then(function (result) {
load(page, result.Items);
deviceIds = result.Items.map((device) => device.Id);
loading.hide();
});
}
}
export default function (view) {
export default function (view) {
view.querySelector('.devicesList').addEventListener('click', function (e) {
const btnDeviceMenu = dom.parentWithClass(e.target, 'btnDeviceMenu');
@ -166,5 +164,5 @@ import confirm from '../../../components/confirm/confirm';
view.querySelector('#deviceDeleteAll').addEventListener('click', function() {
deleteAllDevices(view);
});
}
/* eslint-enable indent */
}

View file

@ -11,9 +11,7 @@ import Dashboard from '../../../utils/dashboard';
import toast from '../../../components/toast/toast';
import { getParameterByName } from '../../../utils/url.ts';
/* eslint-disable indent */
function loadProfile(page) {
function loadProfile(page) {
loading.show();
const promise1 = getProfile();
const promise2 = ApiClient.getUsers();
@ -22,15 +20,15 @@ import { getParameterByName } from '../../../utils/url.ts';
renderProfile(page, currentProfile, responses[1]);
loading.hide();
});
}
}
function getProfile() {
function getProfile() {
const id = getParameterByName('id');
const url = id ? 'Dlna/Profiles/' + id : 'Dlna/Profiles/Default';
return ApiClient.getJSON(ApiClient.getUrl(url));
}
}
function renderProfile(page, profile, users) {
function renderProfile(page, profile, users) {
$('#txtName', page).val(profile.Name);
$('.chkMediaType', page).each(function () {
this.checked = (profile.SupportedMediaTypes || '').split(',').indexOf(this.getAttribute('data-value')) != -1;
@ -82,9 +80,9 @@ import { getParameterByName } from '../../../utils/url.ts';
}).join('');
$('#selectUser', page).html(usersHtml).val(profile.UserId || '');
renderSubProfiles(page, profile);
}
}
function renderIdentificationHeaders(page, headers) {
function renderIdentificationHeaders(page, headers) {
let index = 0;
const html = '<div class="paperList">' + headers.map(function (h) {
let li = '<div class="listItem">';
@ -104,17 +102,17 @@ import { getParameterByName } from '../../../utils/url.ts';
currentProfile.Identification.Headers.splice(itemIndex, 1);
renderIdentificationHeaders(page, currentProfile.Identification.Headers);
});
}
}
function openPopup(elem) {
function openPopup(elem) {
elem.classList.remove('hide');
}
}
function closePopup(elem) {
function closePopup(elem) {
elem.classList.add('hide');
}
}
function editIdentificationHeader(page, header) {
function editIdentificationHeader(page, header) {
isSubProfileNew = header == null;
header = header || {};
currentSubProfile = header;
@ -123,9 +121,9 @@ import { getParameterByName } from '../../../utils/url.ts';
$('#txtIdentificationHeaderValue', popup).val(header.Value || '');
$('#selectMatchType', popup).val(header.Match || 'Equals');
openPopup(popup[0]);
}
}
function saveIdentificationHeader(page) {
function saveIdentificationHeader(page) {
currentSubProfile.Name = $('#txtIdentificationHeaderName', page).val();
currentSubProfile.Value = $('#txtIdentificationHeaderValue', page).val();
currentSubProfile.Match = $('#selectMatchType', page).val();
@ -139,9 +137,9 @@ import { getParameterByName } from '../../../utils/url.ts';
renderIdentificationHeaders(page, currentProfile.Identification.Headers);
currentSubProfile = null;
closePopup($('#identificationHeaderPopup', page)[0]);
}
}
function renderXmlDocumentAttributes(page, attribute) {
function renderXmlDocumentAttributes(page, attribute) {
const html = '<div class="paperList">' + attribute.map(function (h) {
let li = '<div class="listItem">';
li += '<span class="material-icons listItemIcon info" aria-hidden="true"></span>';
@ -158,9 +156,9 @@ import { getParameterByName } from '../../../utils/url.ts';
currentProfile.XmlRootAttributes.splice(itemIndex, 1);
renderXmlDocumentAttributes(page, currentProfile.XmlRootAttributes);
});
}
}
function editXmlDocumentAttribute(page, attribute) {
function editXmlDocumentAttribute(page, attribute) {
isSubProfileNew = attribute == null;
attribute = attribute || {};
currentSubProfile = attribute;
@ -168,9 +166,9 @@ import { getParameterByName } from '../../../utils/url.ts';
$('#txtXmlAttributeName', popup).val(attribute.Name || '');
$('#txtXmlAttributeValue', popup).val(attribute.Value || '');
openPopup(popup[0]);
}
}
function saveXmlDocumentAttribute(page) {
function saveXmlDocumentAttribute(page) {
currentSubProfile.Name = $('#txtXmlAttributeName', page).val();
currentSubProfile.Value = $('#txtXmlAttributeValue', page).val();
@ -181,9 +179,9 @@ import { getParameterByName } from '../../../utils/url.ts';
renderXmlDocumentAttributes(page, currentProfile.XmlRootAttributes);
currentSubProfile = null;
closePopup($('#xmlAttributePopup', page)[0]);
}
}
function renderSubtitleProfiles(page, profiles) {
function renderSubtitleProfiles(page, profiles) {
let index = 0;
const html = '<div class="paperList">' + profiles.map(function (h) {
let li = '<div class="listItem lnkEditSubProfile" data-index="' + index + '">';
@ -206,9 +204,9 @@ import { getParameterByName } from '../../../utils/url.ts';
const itemIndex = parseInt(this.getAttribute('data-index'), 10);
editSubtitleProfile(page, currentProfile.SubtitleProfiles[itemIndex]);
});
}
}
function editSubtitleProfile(page, profile) {
function editSubtitleProfile(page, profile) {
isSubProfileNew = profile == null;
profile = profile || {};
currentSubProfile = profile;
@ -217,9 +215,9 @@ import { getParameterByName } from '../../../utils/url.ts';
$('#selectSubtitleProfileMethod', popup).val(profile.Method || '');
$('#selectSubtitleProfileDidlMode', popup).val(profile.DidlMode || '');
openPopup(popup[0]);
}
}
function saveSubtitleProfile(page) {
function saveSubtitleProfile(page) {
currentSubProfile.Format = $('#txtSubtitleProfileFormat', page).val();
currentSubProfile.Method = $('#selectSubtitleProfileMethod', page).val();
currentSubProfile.DidlMode = $('#selectSubtitleProfileDidlMode', page).val();
@ -231,17 +229,17 @@ import { getParameterByName } from '../../../utils/url.ts';
renderSubtitleProfiles(page, currentProfile.SubtitleProfiles);
currentSubProfile = null;
closePopup($('#subtitleProfilePopup', page)[0]);
}
}
function renderSubProfiles(page, profile) {
function renderSubProfiles(page, profile) {
renderDirectPlayProfiles(page, profile.DirectPlayProfiles);
renderTranscodingProfiles(page, profile.TranscodingProfiles);
renderContainerProfiles(page, profile.ContainerProfiles);
renderCodecProfiles(page, profile.CodecProfiles);
renderResponseProfiles(page, profile.ResponseProfiles);
}
}
function saveDirectPlayProfile(page) {
function saveDirectPlayProfile(page) {
currentSubProfile.Type = $('#selectDirectPlayProfileType', page).val();
currentSubProfile.Container = $('#txtDirectPlayContainer', page).val();
currentSubProfile.AudioCodec = $('#txtDirectPlayAudioCodec', page).val();
@ -254,9 +252,9 @@ import { getParameterByName } from '../../../utils/url.ts';
renderSubProfiles(page, currentProfile);
currentSubProfile = null;
closePopup($('#popupEditDirectPlayProfile', page)[0]);
}
}
function renderDirectPlayProfiles(page, profiles) {
function renderDirectPlayProfiles(page, profiles) {
let html = '';
html += '<ul data-role="listview" data-inset="true" data-split-icon="delete">';
let currentType;
@ -295,14 +293,14 @@ import { getParameterByName } from '../../../utils/url.ts';
const index = parseInt(this.getAttribute('data-profileindex'), 10);
editDirectPlayProfile(page, currentProfile.DirectPlayProfiles[index]);
});
}
}
function deleteDirectPlayProfile(page, index) {
function deleteDirectPlayProfile(page, index) {
currentProfile.DirectPlayProfiles.splice(index, 1);
renderDirectPlayProfiles(page, currentProfile.DirectPlayProfiles);
}
}
function editDirectPlayProfile(page, directPlayProfile) {
function editDirectPlayProfile(page, directPlayProfile) {
isSubProfileNew = directPlayProfile == null;
directPlayProfile = directPlayProfile || {};
currentSubProfile = directPlayProfile;
@ -312,9 +310,9 @@ import { getParameterByName } from '../../../utils/url.ts';
$('#txtDirectPlayAudioCodec', popup).val(directPlayProfile.AudioCodec || '');
$('#txtDirectPlayVideoCodec', popup).val(directPlayProfile.VideoCodec || '');
openPopup(popup[0]);
}
}
function renderTranscodingProfiles(page, profiles) {
function renderTranscodingProfiles(page, profiles) {
let html = '';
html += '<ul data-role="listview" data-inset="true" data-split-icon="delete">';
let currentType;
@ -356,9 +354,9 @@ import { getParameterByName } from '../../../utils/url.ts';
const index = parseInt(this.getAttribute('data-profileindex'), 10);
editTranscodingProfile(page, currentProfile.TranscodingProfiles[index]);
});
}
}
function editTranscodingProfile(page, transcodingProfile) {
function editTranscodingProfile(page, transcodingProfile) {
isSubProfileNew = transcodingProfile == null;
transcodingProfile = transcodingProfile || {};
currentSubProfile = transcodingProfile;
@ -373,14 +371,14 @@ import { getParameterByName } from '../../../utils/url.ts';
$('#chkReportByteRangeRequests', popup).prop('checked', transcodingProfile.TranscodeSeekInfo == 'Bytes');
$('.radioTabButton:first', popup).trigger('click');
openPopup(popup[0]);
}
}
function deleteTranscodingProfile(page, index) {
function deleteTranscodingProfile(page, index) {
currentProfile.TranscodingProfiles.splice(index, 1);
renderTranscodingProfiles(page, currentProfile.TranscodingProfiles);
}
}
function saveTranscodingProfile(page) {
function saveTranscodingProfile(page) {
currentSubProfile.Type = $('#selectTranscodingProfileType', page).val();
currentSubProfile.Container = $('#txtTranscodingContainer', page).val();
currentSubProfile.AudioCodec = $('#txtTranscodingAudioCodec', page).val();
@ -398,9 +396,9 @@ import { getParameterByName } from '../../../utils/url.ts';
renderSubProfiles(page, currentProfile);
currentSubProfile = null;
closePopup($('#transcodingProfilePopup', page)[0]);
}
}
function renderContainerProfiles(page, profiles) {
function renderContainerProfiles(page, profiles) {
let html = '';
html += '<ul data-role="listview" data-inset="true" data-split-icon="delete">';
let currentType;
@ -440,14 +438,14 @@ import { getParameterByName } from '../../../utils/url.ts';
const index = parseInt(this.getAttribute('data-profileindex'), 10);
editContainerProfile(page, currentProfile.ContainerProfiles[index]);
});
}
}
function deleteContainerProfile(page, index) {
function deleteContainerProfile(page, index) {
currentProfile.ContainerProfiles.splice(index, 1);
renderContainerProfiles(page, currentProfile.ContainerProfiles);
}
}
function editContainerProfile(page, containerProfile) {
function editContainerProfile(page, containerProfile) {
isSubProfileNew = containerProfile == null;
containerProfile = containerProfile || {};
currentSubProfile = containerProfile;
@ -456,9 +454,9 @@ import { getParameterByName } from '../../../utils/url.ts';
$('#txtContainerProfileContainer', popup).val(containerProfile.Container || '');
$('.radioTabButton:first', popup).trigger('click');
openPopup(popup[0]);
}
}
function saveContainerProfile(page) {
function saveContainerProfile(page) {
currentSubProfile.Type = $('#selectContainerProfileType', page).val();
currentSubProfile.Container = $('#txtContainerProfileContainer', page).val();
@ -469,9 +467,9 @@ import { getParameterByName } from '../../../utils/url.ts';
renderSubProfiles(page, currentProfile);
currentSubProfile = null;
closePopup($('#containerProfilePopup', page)[0]);
}
}
function renderCodecProfiles(page, profiles) {
function renderCodecProfiles(page, profiles) {
let html = '';
html += '<ul data-role="listview" data-inset="true" data-split-icon="delete">';
let currentType;
@ -512,14 +510,14 @@ import { getParameterByName } from '../../../utils/url.ts';
const index = parseInt(this.getAttribute('data-profileindex'), 10);
editCodecProfile(page, currentProfile.CodecProfiles[index]);
});
}
}
function deleteCodecProfile(page, index) {
function deleteCodecProfile(page, index) {
currentProfile.CodecProfiles.splice(index, 1);
renderCodecProfiles(page, currentProfile.CodecProfiles);
}
}
function editCodecProfile(page, codecProfile) {
function editCodecProfile(page, codecProfile) {
isSubProfileNew = codecProfile == null;
codecProfile = codecProfile || {};
currentSubProfile = codecProfile;
@ -528,9 +526,9 @@ import { getParameterByName } from '../../../utils/url.ts';
$('#txtCodecProfileCodec', popup).val(codecProfile.Codec || '');
$('.radioTabButton:first', popup).trigger('click');
openPopup(popup[0]);
}
}
function saveCodecProfile(page) {
function saveCodecProfile(page) {
currentSubProfile.Type = $('#selectCodecProfileType', page).val();
currentSubProfile.Codec = $('#txtCodecProfileCodec', page).val();
@ -541,9 +539,9 @@ import { getParameterByName } from '../../../utils/url.ts';
renderSubProfiles(page, currentProfile);
currentSubProfile = null;
closePopup($('#codecProfilePopup', page)[0]);
}
}
function renderResponseProfiles(page, profiles) {
function renderResponseProfiles(page, profiles) {
let html = '';
html += '<ul data-role="listview" data-inset="true" data-split-icon="delete">';
let currentType;
@ -592,14 +590,14 @@ import { getParameterByName } from '../../../utils/url.ts';
const index = parseInt(this.getAttribute('data-profileindex'), 10);
editResponseProfile(page, currentProfile.ResponseProfiles[index]);
});
}
}
function deleteResponseProfile(page, index) {
function deleteResponseProfile(page, index) {
currentProfile.ResponseProfiles.splice(index, 1);
renderResponseProfiles(page, currentProfile.ResponseProfiles);
}
}
function editResponseProfile(page, responseProfile) {
function editResponseProfile(page, responseProfile) {
isSubProfileNew = responseProfile == null;
responseProfile = responseProfile || {};
currentSubProfile = responseProfile;
@ -610,9 +608,9 @@ import { getParameterByName } from '../../../utils/url.ts';
$('#txtResponseProfileVideoCodec', popup).val(responseProfile.VideoCodec || '');
$('.radioTabButton:first', popup).trigger('click');
openPopup(popup[0]);
}
}
function saveResponseProfile(page) {
function saveResponseProfile(page) {
currentSubProfile.Type = $('#selectResponseProfileType', page).val();
currentSubProfile.Container = $('#txtResponseProfileContainer', page).val();
currentSubProfile.AudioCodec = $('#txtResponseProfileAudioCodec', page).val();
@ -625,9 +623,9 @@ import { getParameterByName } from '../../../utils/url.ts';
renderSubProfiles(page, currentProfile);
currentSubProfile = null;
closePopup($('#responseProfilePopup', page)[0]);
}
}
function saveProfile(page, profile) {
function saveProfile(page, profile) {
updateProfile(page, profile);
const id = getParameterByName('id');
@ -652,9 +650,9 @@ import { getParameterByName } from '../../../utils/url.ts';
}
loading.hide();
}
}
function updateProfile(page, profile) {
function updateProfile(page, profile) {
profile.Name = $('#txtName', page).val();
profile.EnableAlbumArtInDidl = $('#chkEnableAlbumArtInDidl', page).is(':checked');
profile.EnableSingleAlbumArtLimit = $('#chkEnableSingleImageLimit', page).is(':checked');
@ -694,14 +692,14 @@ import { getParameterByName } from '../../../utils/url.ts';
profile.XDlnaDoc = $('#txtXDlnaDoc', page).val();
profile.SonyAggregationFlags = $('#txtSonyAggregationFlags', page).val();
profile.UserId = $('#selectUser', page).val();
}
}
let currentProfile;
let currentSubProfile;
let isSubProfileNew;
const allText = globalize.translate('All');
let currentProfile;
let currentSubProfile;
let isSubProfileNew;
const allText = globalize.translate('All');
$(document).on('pageinit', '#dlnaProfilePage', function () {
$(document).on('pageinit', '#dlnaProfilePage', function () {
const page = this;
$('.radioTabButton', page).on('click', function () {
$(this).siblings().removeClass('ui-btn-active');
@ -791,12 +789,12 @@ import { getParameterByName } from '../../../utils/url.ts';
$('.identificationHeaderForm').off('submit', DlnaProfilePage.onIdentificationHeaderFormSubmit).on('submit', DlnaProfilePage.onIdentificationHeaderFormSubmit);
$('.xmlAttributeForm').off('submit', DlnaProfilePage.onXmlAttributeFormSubmit).on('submit', DlnaProfilePage.onXmlAttributeFormSubmit);
$('.subtitleProfileForm').off('submit', DlnaProfilePage.onSubtitleProfileFormSubmit).on('submit', DlnaProfilePage.onSubtitleProfileFormSubmit);
}).on('pageshow', '#dlnaProfilePage', function () {
}).on('pageshow', '#dlnaProfilePage', function () {
const page = this;
$('#radioInfo', page).trigger('click');
loadProfile(page);
});
window.DlnaProfilePage = {
});
window.DlnaProfilePage = {
onSubmit: function () {
loading.show();
saveProfile($(this).parents('.page'), currentProfile);
@ -834,6 +832,5 @@ import { getParameterByName } from '../../../utils/url.ts';
saveSubtitleProfile($(this).parents('.page'));
return false;
}
};
};
/* eslint-enable indent */

View file

@ -7,30 +7,28 @@ import '../../../components/listview/listview.scss';
import '../../../elements/emby-button/emby-button';
import confirm from '../../../components/confirm/confirm';
/* eslint-disable indent */
function loadProfiles(page) {
function loadProfiles(page) {
loading.show();
ApiClient.getJSON(ApiClient.getUrl('Dlna/ProfileInfos')).then(function (result) {
renderUserProfiles(page, result);
renderSystemProfiles(page, result);
loading.hide();
});
}
}
function renderUserProfiles(page, profiles) {
function renderUserProfiles(page, profiles) {
renderProfiles(page, page.querySelector('.customProfiles'), profiles.filter(function (p) {
return p.Type == 'User';
}));
}
}
function renderSystemProfiles(page, profiles) {
function renderSystemProfiles(page, profiles) {
renderProfiles(page, page.querySelector('.systemProfiles'), profiles.filter(function (p) {
return p.Type == 'System';
}));
}
}
function renderProfiles(page, element, profiles) {
function renderProfiles(page, element, profiles) {
let html = '';
if (profiles.length) {
@ -63,9 +61,9 @@ import confirm from '../../../components/confirm/confirm';
const id = this.getAttribute('data-profileid');
deleteProfile(page, id);
});
}
}
function deleteProfile(page, id) {
function deleteProfile(page, id) {
confirm(globalize.translate('MessageConfirmProfileDeletion'), globalize.translate('HeaderConfirmProfileDeletion')).then(function () {
loading.show();
ApiClient.ajax({
@ -76,9 +74,9 @@ import confirm from '../../../components/confirm/confirm';
loadProfiles(page);
});
});
}
}
function getTabs() {
function getTabs() {
return [{
href: '#/dlnasettings.html',
name: globalize.translate('Settings')
@ -86,11 +84,10 @@ import confirm from '../../../components/confirm/confirm';
href: '#/dlnaprofiles.html',
name: globalize.translate('TabProfiles')
}];
}
}
$(document).on('pageshow', '#dlnaProfilesPage', function () {
$(document).on('pageshow', '#dlnaProfilesPage', function () {
libraryMenu.setTabs('dlna', 1, getTabs);
loadProfiles(this);
});
});
/* eslint-enable indent */

View file

@ -5,9 +5,7 @@ import libraryMenu from '../../../scripts/libraryMenu';
import globalize from '../../../scripts/globalize';
import Dashboard from '../../../utils/dashboard';
/* eslint-disable indent */
function loadPage(page, config, users) {
function loadPage(page, config, users) {
page.querySelector('#chkEnablePlayTo').checked = config.EnablePlayTo;
page.querySelector('#chkEnableDlnaDebugLogging').checked = config.EnableDebugLog;
$('#txtClientDiscoveryInterval', page).val(config.ClientDiscoveryIntervalSeconds);
@ -19,9 +17,9 @@ import Dashboard from '../../../utils/dashboard';
}).join('');
$('#selectUser', page).html(usersHtml).val(config.DefaultUserId || '');
loading.hide();
}
}
function onSubmit() {
function onSubmit() {
loading.show();
const form = this;
ApiClient.getNamedConfiguration('dlna').then(function (config) {
@ -35,9 +33,9 @@ import Dashboard from '../../../utils/dashboard';
ApiClient.updateNamedConfiguration('dlna', config).then(Dashboard.processServerConfigurationUpdateResult);
});
return false;
}
}
function getTabs() {
function getTabs() {
return [{
href: '#/dlnasettings.html',
name: globalize.translate('Settings')
@ -45,11 +43,11 @@ import Dashboard from '../../../utils/dashboard';
href: '#/dlnaprofiles.html',
name: globalize.translate('TabProfiles')
}];
}
}
$(document).on('pageinit', '#dlnaSettingsPage', function () {
$(document).on('pageinit', '#dlnaSettingsPage', function () {
$('.dlnaSettingsForm').off('submit', onSubmit).on('submit', onSubmit);
}).on('pageshow', '#dlnaSettingsPage', function () {
}).on('pageshow', '#dlnaSettingsPage', function () {
libraryMenu.setTabs('dlna', 0, getTabs);
loading.show();
const page = this;
@ -58,6 +56,5 @@ import Dashboard from '../../../utils/dashboard';
Promise.all([promise1, promise2]).then(function (responses) {
loadPage(page, responses[0], responses[1]);
});
});
});
/* eslint-enable indent */

View file

@ -6,9 +6,7 @@ import libraryMenu from '../../scripts/libraryMenu';
import Dashboard from '../../utils/dashboard';
import alert from '../../components/alert';
/* eslint-disable indent */
function loadPage(page, config, systemInfo) {
function loadPage(page, config, systemInfo) {
Array.prototype.forEach.call(page.querySelectorAll('.chkDecodeCodec'), function (c) {
c.checked = (config.HardwareDecodingCodecs || []).indexOf(c.getAttribute('data-codec')) !== -1;
});
@ -52,14 +50,14 @@ import alert from '../../components/alert';
bubbles: true
}));
loading.hide();
}
}
function onSaveEncodingPathFailure() {
function onSaveEncodingPathFailure() {
loading.hide();
alert(globalize.translate('FFmpegSavePathNotFound'));
}
}
function updateEncoder(form) {
function updateEncoder(form) {
return ApiClient.getSystemInfo().then(function () {
return ApiClient.ajax({
url: ApiClient.getUrl('System/MediaEncoder/Path'),
@ -71,9 +69,9 @@ import alert from '../../components/alert';
contentType: 'application/json'
}).then(Dashboard.processServerConfigurationUpdateResult, onSaveEncodingPathFailure);
});
}
}
function onSubmit() {
function onSubmit() {
const form = this;
const onDecoderConfirmed = function () {
@ -138,9 +136,9 @@ import alert from '../../components/alert';
}
return false;
}
}
function setDecodingCodecsVisible(context, value) {
function setDecodingCodecsVisible(context, value) {
value = value || '';
let any;
Array.prototype.forEach.call(context.querySelectorAll('.chkDecodeCodec'), function (c) {
@ -157,9 +155,9 @@ import alert from '../../components/alert';
} else {
context.querySelector('.decodingCodecsList').classList.add('hide');
}
}
}
function getTabs() {
function getTabs() {
return [{
href: '#/encodingsettings.html',
name: globalize.translate('Transcoding')
@ -170,19 +168,19 @@ import alert from '../../components/alert';
href: '#/streamingsettings.html',
name: globalize.translate('TabStreaming')
}];
}
}
let systemInfo;
function getSystemInfo() {
let systemInfo;
function getSystemInfo() {
return systemInfo ? Promise.resolve(systemInfo) : ApiClient.getPublicSystemInfo().then(
info => {
systemInfo = info;
return info;
}
);
}
}
$(document).on('pageinit', '#encodingSettingsPage', function () {
$(document).on('pageinit', '#encodingSettingsPage', function () {
const page = this;
getSystemInfo();
page.querySelector('#selectVideoDecoder').addEventListener('change', function () {
@ -288,7 +286,7 @@ import alert from '../../components/alert';
});
});
$('.encodingSettingsForm').off('submit', onSubmit).on('submit', onSubmit);
}).on('pageshow', '#encodingSettingsPage', function () {
}).on('pageshow', '#encodingSettingsPage', function () {
loading.show();
libraryMenu.setTabs('playback', 0, getTabs);
const page = this;
@ -297,6 +295,5 @@ import alert from '../../components/alert';
loadPage(page, config, fetchedSystemInfo);
});
});
});
});
/* eslint-enable indent */

View file

@ -10,9 +10,7 @@ import '../../elements/emby-button/emby-button';
import Dashboard from '../../utils/dashboard';
import alert from '../../components/alert';
/* eslint-disable indent */
function loadPage(page, config, languageOptions, systemInfo) {
function loadPage(page, config, languageOptions, systemInfo) {
page.querySelector('#txtServerName').value = systemInfo.ServerName;
page.querySelector('#txtCachePath').value = systemInfo.CachePath || '';
page.querySelector('#chkQuickConnectAvailable').checked = config.QuickConnectAvailable === true;
@ -24,9 +22,9 @@ import alert from '../../components/alert';
page.querySelector('#txtParallelImageEncodingLimit').value = config.ParallelImageEncodingLimit || '';
loading.hide();
}
}
function onSubmit() {
function onSubmit() {
loading.show();
const form = this;
$(form).parents('.page');
@ -55,10 +53,10 @@ import alert from '../../components/alert';
});
});
return false;
}
}
const brandingConfigKey = 'branding';
export default function (view) {
const brandingConfigKey = 'branding';
export default function (view) {
$('#btnSelectCachePath', view).on('click.selectDirectory', function () {
import('../../components/directorybrowser/directorybrowser').then(({ default: DirectoryBrowser }) => {
const picker = new DirectoryBrowser();
@ -114,6 +112,5 @@ import alert from '../../components/alert';
view.querySelector('#chkSplashScreenAvailable').checked = config.SplashscreenEnabled === true;
});
});
}
}
/* eslint-enable indent */

View file

@ -12,9 +12,7 @@ import Dashboard, { pageClassOn, pageIdOn } from '../../utils/dashboard';
import confirm from '../../components/confirm/confirm';
import cardBuilder from '../../components/cardbuilder/cardBuilder';
/* eslint-disable indent */
function addVirtualFolder(page) {
function addVirtualFolder(page) {
import('../../components/mediaLibraryCreator/mediaLibraryCreator').then(({ default: medialibrarycreator }) => {
new medialibrarycreator({
collectionTypeOptions: getCollectionTypeOptions().filter(function (f) {
@ -27,9 +25,9 @@ import cardBuilder from '../../components/cardbuilder/cardBuilder';
}
});
});
}
}
function editVirtualFolder(page, virtualFolder) {
function editVirtualFolder(page, virtualFolder) {
import('../../components/mediaLibraryEditor/mediaLibraryEditor').then(({ default: medialibraryeditor }) => {
new medialibraryeditor({
refresh: shouldRefreshLibraryAfterChanges(page),
@ -40,9 +38,9 @@ import cardBuilder from '../../components/cardbuilder/cardBuilder';
}
});
});
}
}
function deleteVirtualFolder(page, virtualFolder) {
function deleteVirtualFolder(page, virtualFolder) {
let msg = globalize.translate('MessageAreYouSureYouWishToRemoveMediaFolder');
if (virtualFolder.Locations.length) {
@ -61,9 +59,9 @@ import cardBuilder from '../../components/cardbuilder/cardBuilder';
reloadLibrary(page);
});
});
}
}
function refreshVirtualFolder(page, virtualFolder) {
function refreshVirtualFolder(page, virtualFolder) {
import('../../components/refreshdialog/refreshdialog').then(({ default: refreshDialog }) => {
new refreshDialog({
itemIds: [virtualFolder.ItemId],
@ -71,9 +69,9 @@ import cardBuilder from '../../components/cardbuilder/cardBuilder';
mode: 'scan'
}).show();
});
}
}
function renameVirtualFolder(page, virtualFolder) {
function renameVirtualFolder(page, virtualFolder) {
import('../../components/prompt/prompt').then(({ default: prompt }) => {
prompt({
label: globalize.translate('LabelNewName'),
@ -88,9 +86,9 @@ import cardBuilder from '../../components/cardbuilder/cardBuilder';
}
});
});
}
}
function showCardMenu(page, elem, virtualFolders) {
function showCardMenu(page, elem, virtualFolders) {
const card = dom.parentWithClass(elem, 'card');
const index = parseInt(card.getAttribute('data-index'), 10);
const virtualFolder = virtualFolders[index];
@ -149,20 +147,20 @@ import cardBuilder from '../../components/cardbuilder/cardBuilder';
}
});
});
}
}
function reloadLibrary(page) {
function reloadLibrary(page) {
loading.show();
ApiClient.getVirtualFolders().then(function (result) {
reloadVirtualFolders(page, result);
});
}
}
function shouldRefreshLibraryAfterChanges(page) {
function shouldRefreshLibraryAfterChanges(page) {
return page.id === 'mediaLibraryPage';
}
}
function reloadVirtualFolders(page, virtualFolders) {
function reloadVirtualFolders(page, virtualFolders) {
let html = '';
virtualFolders.push({
Name: globalize.translate('ButtonAddMediaLibrary'),
@ -200,9 +198,9 @@ import cardBuilder from '../../components/cardbuilder/cardBuilder';
}
});
loading.hide();
}
}
function editImages(page, virtualFolder) {
function editImages(page, virtualFolder) {
import('../../components/imageeditor/imageeditor').then((imageEditor) => {
imageEditor.show({
itemId: virtualFolder.ItemId,
@ -211,13 +209,13 @@ import cardBuilder from '../../components/cardbuilder/cardBuilder';
reloadLibrary(page);
});
});
}
}
function getLink(text, url) {
function getLink(text, url) {
return globalize.translate(text, '<a is="emby-linkbutton" class="button-link" href="' + url + '" target="_blank" data-autohide="true">', '</a>');
}
}
function getCollectionTypeOptions() {
function getCollectionTypeOptions() {
return [{
name: '',
value: ''
@ -248,9 +246,9 @@ import cardBuilder from '../../components/cardbuilder/cardBuilder';
value: 'mixed',
message: globalize.translate('MessageUnsetContentHelp')
}];
}
}
function getVirtualFolderHtml(page, virtualFolder, index) {
function getVirtualFolderHtml(page, virtualFolder, index) {
let html = '';
let style = '';
@ -360,9 +358,9 @@ import cardBuilder from '../../components/cardbuilder/cardBuilder';
html += '</div>';
html += '</div>';
return html;
}
}
function getTabs() {
function getTabs() {
return [{
href: '#/library.html',
name: globalize.translate('HeaderLibraries')
@ -376,17 +374,17 @@ import cardBuilder from '../../components/cardbuilder/cardBuilder';
href: '#/metadatanfo.html',
name: globalize.translate('TabNfoSettings')
}];
}
}
window.WizardLibraryPage = {
window.WizardLibraryPage = {
next: function () {
Dashboard.navigate('wizardsettings.html');
}
};
pageClassOn('pageshow', 'mediaLibraryPage', function () {
};
pageClassOn('pageshow', 'mediaLibraryPage', function () {
reloadLibrary(this);
});
pageIdOn('pageshow', 'mediaLibraryPage', function () {
});
pageIdOn('pageshow', 'mediaLibraryPage', function () {
libraryMenu.setTabs('librarysetup', 0, getTabs);
const page = this;
@ -396,8 +394,8 @@ import cardBuilder from '../../components/cardbuilder/cardBuilder';
taskKey: 'RefreshLibrary',
button: page.querySelector('.btnRefresh')
});
});
pageIdOn('pagebeforehide', 'mediaLibraryPage', function () {
});
pageIdOn('pagebeforehide', 'mediaLibraryPage', function () {
const page = this;
taskButton({
mode: 'off',
@ -405,6 +403,5 @@ import cardBuilder from '../../components/cardbuilder/cardBuilder';
taskKey: 'RefreshLibrary',
button: page.querySelector('.btnRefresh')
});
});
});
/* eslint-enable indent */

View file

@ -5,9 +5,7 @@ import '../../elements/emby-checkbox/emby-checkbox';
import '../../elements/emby-button/emby-button';
import Dashboard from '../../utils/dashboard';
/* eslint-disable indent */
function getTabs() {
function getTabs() {
return [{
href: '#/library.html',
name: globalize.translate('HeaderLibraries')
@ -21,9 +19,9 @@ import Dashboard from '../../utils/dashboard';
href: '#/metadatanfo.html',
name: globalize.translate('TabNfoSettings')
}];
}
}
export default function(view) {
export default function(view) {
function loadData() {
ApiClient.getServerConfiguration().then(function(config) {
view.querySelector('.chkFolderView').checked = config.EnableFolderView;
@ -69,6 +67,5 @@ import Dashboard from '../../utils/dashboard';
}
});
});
}
}
/* eslint-enable indent */

View file

@ -7,9 +7,7 @@ import '../../styles/flexstyles.scss';
import Dashboard from '../../utils/dashboard';
import alert from '../../components/alert';
/* eslint-disable indent */
function onSubmit(event) {
function onSubmit(event) {
event.preventDefault();
loading.show();
const form = this;
@ -24,9 +22,9 @@ import alert from '../../components/alert';
});
});
return false;
}
}
export default function(view) {
export default function(view) {
view.querySelector('.logsForm').addEventListener('submit', onSubmit);
view.addEventListener('viewbeforeshow', function() {
loading.show();
@ -62,6 +60,4 @@ import alert from '../../components/alert';
loading.hide();
});
}
/* eslint-enable indent */
}

View file

@ -30,9 +30,7 @@ function populateImageResolutionOptions(select) {
select.innerHTML = html;
}
/* eslint-disable indent */
function populateLanguages(select) {
function populateLanguages(select) {
return ApiClient.getCultures().then(function(languages) {
let html = '';
html += "<option value=''></option>";
@ -42,9 +40,9 @@ function populateImageResolutionOptions(select) {
}
select.innerHTML = html;
});
}
}
function populateCountries(select) {
function populateCountries(select) {
return ApiClient.getCountries().then(function(allCountries) {
let html = '';
html += "<option value=''></option>";
@ -54,9 +52,9 @@ function populateImageResolutionOptions(select) {
}
select.innerHTML = html;
});
}
}
function loadPage(page) {
function loadPage(page) {
const promises = [
ApiClient.getServerConfiguration(),
populateLanguages(page.querySelector('#selectLanguage')),
@ -74,9 +72,9 @@ function populateImageResolutionOptions(select) {
page.querySelector('#txtChapterImageResolution').value = config.ChapterImageResolution || '';
loading.hide();
});
}
}
function onSubmit() {
function onSubmit() {
const form = this;
loading.show();
ApiClient.getServerConfiguration().then(function(config) {
@ -88,9 +86,9 @@ function populateImageResolutionOptions(select) {
ApiClient.updateServerConfiguration(config).then(Dashboard.processServerConfigurationUpdateResult);
});
return false;
}
}
function getTabs() {
function getTabs() {
return [{
href: '#/library.html',
name: globalize.translate('HeaderLibraries')
@ -104,14 +102,13 @@ function populateImageResolutionOptions(select) {
href: '#/metadatanfo.html',
name: globalize.translate('TabNfoSettings')
}];
}
}
$(document).on('pageinit', '#metadataImagesConfigurationPage', function() {
$(document).on('pageinit', '#metadataImagesConfigurationPage', function() {
$('.metadataImagesConfigurationForm').off('submit', onSubmit).on('submit', onSubmit);
}).on('pageshow', '#metadataImagesConfigurationPage', function() {
}).on('pageshow', '#metadataImagesConfigurationPage', function() {
libraryMenu.setTabs('metadata', 2, getTabs);
loading.show();
loadPage(this);
});
});
/* eslint-enable indent */

View file

@ -6,9 +6,7 @@ import globalize from '../../scripts/globalize';
import Dashboard from '../../utils/dashboard';
import alert from '../../components/alert';
/* eslint-disable indent */
function loadPage(page, config, users) {
function loadPage(page, config, users) {
let html = '<option value="" selected="selected">' + globalize.translate('None') + '</option>';
html += users.map(function (user) {
return '<option value="' + user.Id + '">' + escapeHtml(user.Name) + '</option>';
@ -19,9 +17,9 @@ import alert from '../../components/alert';
page.querySelector('#chkEnablePathSubstitution').checked = config.EnablePathSubstitution;
page.querySelector('#chkEnableExtraThumbs').checked = config.EnableExtraThumbsDuplication;
loading.hide();
}
}
function onSubmit() {
function onSubmit() {
loading.show();
const form = this;
ApiClient.getNamedConfiguration(metadataKey).then(function (config) {
@ -36,17 +34,17 @@ import alert from '../../components/alert';
});
});
return false;
}
}
function showConfirmMessage() {
function showConfirmMessage() {
const msg = [];
msg.push(globalize.translate('MetadataSettingChangeHelp'));
alert({
text: msg.join('<br/><br/>')
});
}
}
function getTabs() {
function getTabs() {
return [{
href: '#/library.html',
name: globalize.translate('HeaderLibraries')
@ -60,12 +58,12 @@ import alert from '../../components/alert';
href: '#/metadatanfo.html',
name: globalize.translate('TabNfoSettings')
}];
}
}
const metadataKey = 'xbmcmetadata';
$(document).on('pageinit', '#metadataNfoPage', function () {
const metadataKey = 'xbmcmetadata';
$(document).on('pageinit', '#metadataNfoPage', function () {
$('.metadataNfoForm').off('submit', onSubmit).on('submit', onSubmit);
}).on('pageshow', '#metadataNfoPage', function () {
}).on('pageshow', '#metadataNfoPage', function () {
libraryMenu.setTabs('metadata', 3, getTabs);
loading.show();
const page = this;
@ -74,6 +72,5 @@ import alert from '../../components/alert';
Promise.all([promise1, promise2]).then(function (responses) {
loadPage(page, responses[1], responses[0]);
});
});
});
/* eslint-enable indent */

View file

@ -5,9 +5,7 @@ import '../../elements/emby-select/emby-select';
import Dashboard from '../../utils/dashboard';
import alert from '../../components/alert';
/* eslint-disable indent */
function onSubmit(e) {
function onSubmit(e) {
const form = this;
const localAddress = form.querySelector('#txtLocalAddress').value;
const enableUpnp = form.querySelector('#chkEnableUpnp').checked;
@ -76,15 +74,15 @@ import alert from '../../components/alert';
});
});
e.preventDefault();
}
}
function triggerChange(select) {
function triggerChange(select) {
const evt = document.createEvent('HTMLEvents');
evt.initEvent('change', false, true);
select.dispatchEvent(evt);
}
}
function getValidationAlert(form) {
function getValidationAlert(form) {
if (form.querySelector('#txtPublicPort').value === form.querySelector('#txtPublicHttpsPort').value) {
return 'The public http and https ports must be different.';
}
@ -98,9 +96,9 @@ import alert from '../../components/alert';
}
return null;
}
}
function validateHttps(form) {
function validateHttps(form) {
const certPath = form.querySelector('#txtCertificatePath').value || null;
const httpsEnabled = form.querySelector('#chkEnableHttps').checked;
@ -112,15 +110,15 @@ import alert from '../../components/alert';
}
return Promise.resolve();
}
}
function showAlertText(options) {
function showAlertText(options) {
return new Promise(function (resolve, reject) {
alert(options).then(resolve, reject);
});
}
}
function confirmSelections(localAddress, enableUpnp, callback) {
function confirmSelections(localAddress, enableUpnp, callback) {
if (localAddress || !enableUpnp) {
showAlertText({
title: globalize.translate('TitleHostingSettings'),
@ -129,9 +127,9 @@ import alert from '../../components/alert';
} else {
callback();
}
}
}
export default function (view) {
export default function (view) {
function loadPage(page, config) {
page.querySelector('#txtPortNumber').value = config.HttpServerPortNumber;
page.querySelector('#txtPublicPort').value = config.PublicPort;
@ -204,6 +202,5 @@ import alert from '../../components/alert';
loadPage(view, config);
});
});
}
}
/* eslint-enable indent */

View file

@ -4,18 +4,16 @@ import libraryMenu from '../../scripts/libraryMenu';
import globalize from '../../scripts/globalize';
import Dashboard from '../../utils/dashboard';
/* eslint-disable indent */
function loadPage(page, config) {
function loadPage(page, config) {
$('#txtMinResumePct', page).val(config.MinResumePct);
$('#txtMaxResumePct', page).val(config.MaxResumePct);
$('#txtMinAudiobookResume', page).val(config.MinAudiobookResume);
$('#txtMaxAudiobookResume', page).val(config.MaxAudiobookResume);
$('#txtMinResumeDuration', page).val(config.MinResumeDurationSeconds);
loading.hide();
}
}
function onSubmit() {
function onSubmit() {
loading.show();
const form = this;
ApiClient.getServerConfiguration().then(function (config) {
@ -29,9 +27,9 @@ import Dashboard from '../../utils/dashboard';
});
return false;
}
}
function getTabs() {
function getTabs() {
return [{
href: '#/encodingsettings.html',
name: globalize.translate('Transcoding')
@ -42,17 +40,16 @@ import Dashboard from '../../utils/dashboard';
href: '#/streamingsettings.html',
name: globalize.translate('TabStreaming')
}];
}
}
$(document).on('pageinit', '#playbackConfigurationPage', function () {
$(document).on('pageinit', '#playbackConfigurationPage', function () {
$('.playbackConfigurationForm').off('submit', onSubmit).on('submit', onSubmit);
}).on('pageshow', '#playbackConfigurationPage', function () {
}).on('pageshow', '#playbackConfigurationPage', function () {
loading.show();
libraryMenu.setTabs('playback', 1, getTabs);
const page = this;
ApiClient.getServerConfiguration().then(function (config) {
loadPage(page, config);
});
});
});
/* eslint-enable indent */

View file

@ -9,9 +9,7 @@ import '../../../elements/emby-select/emby-select';
import confirm from '../../../components/confirm/confirm';
import { getParameterByName } from '../../../utils/url.ts';
/* eslint-disable indent */
function fillTimeOfDay(select) {
function fillTimeOfDay(select) {
const options = [];
for (let i = 0; i < 86400000; i += 900000) {
@ -24,15 +22,15 @@ import { getParameterByName } from '../../../utils/url.ts';
select.innerHTML = options.map(function (o) {
return '<option value="' + o.value + '">' + o.name + '</option>';
}).join('');
}
}
Array.prototype.remove = function (from, to) {
Array.prototype.remove = function (from, to) {
const rest = this.slice((to || from) + 1 || this.length);
this.length = from < 0 ? this.length + from : from;
return this.push.apply(this, rest);
};
};
const ScheduledTaskPage = {
const ScheduledTaskPage = {
refreshScheduledTask: function (view) {
loading.show();
const id = getParameterByName('id');
@ -207,8 +205,8 @@ import { getParameterByName } from '../../../utils/url.ts';
return trigger;
}
};
export default function (view) {
};
export default function (view) {
function onSubmit(e) {
loading.show();
const id = getParameterByName('id');
@ -241,6 +239,5 @@ import { getParameterByName } from '../../../utils/url.ts';
view.addEventListener('viewshow', function () {
ScheduledTaskPage.refreshScheduledTask(view);
});
}
}
/* eslint-enable indent */

View file

@ -9,18 +9,16 @@ import Events from '../../../utils/events.ts';
import '../../../components/listview/listview.scss';
import '../../../elements/emby-button/emby-button';
/* eslint-disable indent */
function reloadList(page) {
function reloadList(page) {
ApiClient.getScheduledTasks({
isHidden: false
}).then(function(tasks) {
populateList(page, tasks);
loading.hide();
});
}
}
function populateList(page, tasks) {
function populateList(page, tasks) {
tasks = tasks.sort(function(a, b) {
a = a.Category + ' ' + a.Name;
b = b.Category + ' ' + b.Name;
@ -79,9 +77,9 @@ import '../../../elements/emby-button/emby-button';
html += '</div>';
}
page.querySelector('.divScheduledTasks').innerHTML = html;
}
}
function getTaskProgressHtml(task) {
function getTaskProgressHtml(task) {
let html = '';
if (task.State === 'Idle') {
if (task.LastExecutionResult) {
@ -110,15 +108,15 @@ import '../../../elements/emby-button/emby-button';
html += "<span style='color:#FF0000;'>" + globalize.translate('LabelStopping') + '</span>';
}
return html;
}
}
function setTaskButtonIcon(button, icon) {
function setTaskButtonIcon(button, icon) {
const inner = button.querySelector('.material-icons');
inner.classList.remove('stop', 'play_arrow');
inner.classList.add(icon);
}
}
function updateTaskButton(elem, state) {
function updateTaskButton(elem, state) {
if (state === 'Running') {
elem.classList.remove('btnStartTask');
elem.classList.add('btnStopTask');
@ -131,9 +129,9 @@ import '../../../elements/emby-button/emby-button';
elem.title = globalize.translate('ButtonStart');
}
$(elem).parents('.listItem')[0].setAttribute('data-status', state);
}
}
export default function(view) {
export default function(view) {
function updateTasks(tasks) {
for (let i = 0; i < tasks.length; i++) {
const task = tasks[i];
@ -197,6 +195,5 @@ import '../../../elements/emby-button/emby-button';
reloadList(view);
Events.on(serverNotifications, 'ScheduledTasksInfo', onScheduledTasksUpdate);
});
}
}
/* eslint-enable indent */

View file

@ -2,9 +2,7 @@ import ActivityLog from '../../components/activitylog';
import globalize from '../../scripts/globalize';
import { toBoolean } from '../../utils/string.ts';
/* eslint-disable indent */
export default function (view, params) {
export default function (view, params) {
let activityLog;
if (toBoolean(params.useractivity, true)) {
@ -30,6 +28,5 @@ import { toBoolean } from '../../utils/string.ts';
activityLog = null;
});
}
}
/* eslint-enable indent */

View file

@ -4,14 +4,12 @@ import loading from '../../components/loading/loading';
import globalize from '../../scripts/globalize';
import Dashboard from '../../utils/dashboard';
/* eslint-disable indent */
function loadPage(page, config) {
function loadPage(page, config) {
$('#txtRemoteClientBitrateLimit', page).val(config.RemoteClientBitrateLimit / 1e6 || '');
loading.hide();
}
}
function onSubmit() {
function onSubmit() {
loading.show();
const form = this;
ApiClient.getServerConfiguration().then(function (config) {
@ -20,9 +18,9 @@ import Dashboard from '../../utils/dashboard';
});
return false;
}
}
function getTabs() {
function getTabs() {
return [{
href: '#/encodingsettings.html',
name: globalize.translate('Transcoding')
@ -33,17 +31,16 @@ import Dashboard from '../../utils/dashboard';
href: '#/streamingsettings.html',
name: globalize.translate('TabStreaming')
}];
}
}
$(document).on('pageinit', '#streamingSettingsPage', function () {
$(document).on('pageinit', '#streamingSettingsPage', function () {
$('.streamingSettingsForm').off('submit', onSubmit).on('submit', onSubmit);
}).on('pageshow', '#streamingSettingsPage', function () {
}).on('pageshow', '#streamingSettingsPage', function () {
loading.show();
libraryMenu.setTabs('playback', 2, getTabs);
const page = this;
ApiClient.getServerConfiguration().then(function (config) {
loadPage(page, config);
});
});
});
/* eslint-enable indent */

View file

@ -9,25 +9,23 @@ import '../elements/emby-itemscontainer/emby-itemscontainer';
import '../elements/emby-scroller/emby-scroller';
import ServerConnections from '../components/ServerConnections';
/* eslint-disable indent */
function enableScrollX() {
function enableScrollX() {
return true;
}
}
function getThumbShape() {
function getThumbShape() {
return enableScrollX() ? 'overflowBackdrop' : 'backdrop';
}
}
function getPosterShape() {
function getPosterShape() {
return enableScrollX() ? 'overflowPortrait' : 'portrait';
}
}
function getSquareShape() {
function getSquareShape() {
return enableScrollX() ? 'overflowSquare' : 'square';
}
}
function getSections() {
function getSections() {
return [{
name: 'Movies',
types: 'Movie',
@ -139,9 +137,9 @@ import ServerConnections from '../components/ServerConnections';
overlayText: false,
centerText: true
}];
}
}
function getFetchDataFn(section) {
function getFetchDataFn(section) {
return function () {
const apiClient = this.apiClient;
const options = {
@ -168,17 +166,17 @@ import ServerConnections from '../components/ServerConnections';
options.IncludeItemTypes = section.types;
return apiClient.getItems(userId, options);
};
}
}
function getRouteUrl(section, serverId) {
function getRouteUrl(section, serverId) {
return appRouter.getRouteUrl('list', {
serverId: serverId,
itemTypes: section.types,
isFavorite: true
});
}
}
function getItemsHtmlFn(section) {
function getItemsHtmlFn(section) {
return function (items) {
let cardLayout = appHost.preferVisualCards && section.autoCardLayout && section.showTitle;
cardLayout = false;
@ -223,9 +221,9 @@ import ServerConnections from '../components/ServerConnections';
lines: lines
});
};
}
}
function createSections(instance, elem, apiClient) {
function createSections(instance, elem, apiClient) {
const sections = getSections();
let html = '';
@ -266,7 +264,7 @@ import ServerConnections from '../components/ServerConnections';
itemsContainer.getItemsHtml = getItemsHtmlFn(sections[i]).bind(instance);
itemsContainer.parentContainer = dom.parentWithClass(itemsContainer, 'verticalSection');
}
}
}
class FavoritesTab {
constructor(view, params) {
@ -318,4 +316,3 @@ class FavoritesTab {
export default FavoritesTab;
/* eslint-enable indent */

View file

@ -13,9 +13,7 @@ import '../elements/emby-scroller/emby-scroller';
import ServerConnections from '../components/ServerConnections';
import LibraryMenu from '../scripts/libraryMenu';
/* eslint-disable indent */
function getInitialLiveTvQuery(instance, params, startIndex = 0, limit = 300) {
function getInitialLiveTvQuery(instance, params, startIndex = 0, limit = 300) {
const query = {
UserId: ServerConnections.getApiClient(params.serverId).getCurrentUserId(),
StartIndex: startIndex,
@ -70,9 +68,9 @@ import LibraryMenu from '../scripts/libraryMenu';
}
return modifyQueryWithFilters(instance, query);
}
}
function modifyQueryWithFilters(instance, query) {
function modifyQueryWithFilters(instance, query) {
const sortValues = instance.getSortValues();
if (!query.SortBy) {
@ -176,15 +174,15 @@ import LibraryMenu from '../scripts/libraryMenu';
}
return query;
}
}
function setSortButtonIcon(btnSortIcon, icon) {
function setSortButtonIcon(btnSortIcon, icon) {
btnSortIcon.classList.remove('arrow_downward');
btnSortIcon.classList.remove('arrow_upward');
btnSortIcon.classList.add(icon);
}
}
function updateSortText(instance) {
function updateSortText(instance) {
const btnSortText = instance.btnSortText;
if (btnSortText) {
@ -205,9 +203,9 @@ import LibraryMenu from '../scripts/libraryMenu';
setSortButtonIcon(btnSortIcon, values.sortOrder === 'Descending' ? 'arrow_downward' : 'arrow_upward');
}
}
}
}
function updateItemsContainerForViewType(instance) {
function updateItemsContainerForViewType(instance) {
if (instance.getViewSettings().imageType === 'list') {
instance.itemsContainer.classList.remove('vertical-wrap');
instance.itemsContainer.classList.add('vertical-list');
@ -215,9 +213,9 @@ import LibraryMenu from '../scripts/libraryMenu';
instance.itemsContainer.classList.add('vertical-wrap');
instance.itemsContainer.classList.remove('vertical-list');
}
}
}
function updateAlphaPickerState(instance) {
function updateAlphaPickerState(instance) {
if (instance.alphaPicker) {
const alphaPicker = instance.alphaPickerElement;
@ -233,9 +231,9 @@ import LibraryMenu from '../scripts/libraryMenu';
}
}
}
}
}
function getItems(instance, params, item, sortBy, startIndex, limit) {
function getItems(instance, params, item, sortBy, startIndex, limit) {
const apiClient = ServerConnections.getApiClient(params.serverId);
instance.queryRecursive = false;
@ -329,9 +327,9 @@ import LibraryMenu from '../scripts/libraryMenu';
ParentId: item.Id,
SortBy: sortBy
}));
}
}
function getItem(params) {
function getItem(params) {
if (params.type === 'Recordings' || params.type === 'Programs' || params.type === 'nextup') {
return Promise.resolve(null);
}
@ -344,9 +342,9 @@ import LibraryMenu from '../scripts/libraryMenu';
}
return Promise.resolve(null);
}
}
function showViewSettingsMenu() {
function showViewSettingsMenu() {
const instance = this;
import('../components/viewSettings/viewSettings').then(({ default: ViewSettings }) => {
@ -359,9 +357,9 @@ import LibraryMenu from '../scripts/libraryMenu';
instance.itemsContainer.refreshItems();
});
});
}
}
function showFilterMenu() {
function showFilterMenu() {
const instance = this;
import('../components/filtermenu/filtermenu').then(({ default: FilterMenu }) => {
@ -378,9 +376,9 @@ import LibraryMenu from '../scripts/libraryMenu';
instance.itemsContainer.refreshItems();
});
});
}
}
function showSortMenu() {
function showSortMenu() {
const instance = this;
import('../components/sortmenu/sortmenu').then(({ default: SortMenu }) => {
@ -396,9 +394,9 @@ import LibraryMenu from '../scripts/libraryMenu';
instance.itemsContainer.refreshItems();
});
});
}
}
function onNewItemClick() {
function onNewItemClick() {
const instance = this;
import('../components/playlisteditor/playlisteditor').then(({ default: playlistEditor }) => {
@ -407,9 +405,9 @@ import LibraryMenu from '../scripts/libraryMenu';
serverId: instance.params.serverId
});
});
}
}
function hideOrShowAll(elems, hide) {
function hideOrShowAll(elems, hide) {
for (const elem of elems) {
if (hide) {
elem.classList.add('hide');
@ -417,13 +415,13 @@ import LibraryMenu from '../scripts/libraryMenu';
elem.classList.remove('hide');
}
}
}
}
function bindAll(elems, eventName, fn) {
function bindAll(elems, eventName, fn) {
for (const elem of elems) {
elem.addEventListener(eventName, fn);
}
}
}
class ItemsView {
constructor(view, params) {
@ -1295,4 +1293,3 @@ class ItemsView {
export default ItemsView;
/* eslint-enable indent */

View file

@ -11,9 +11,7 @@ import Events from '../../utils/events.ts';
import '../../elements/emby-itemscontainer/emby-itemscontainer';
/* eslint-disable indent */
export default function (view, params, tabContent) {
export default function (view, params, tabContent) {
function playAll() {
ApiClient.getItem(ApiClient.getCurrentUserId(), params.topParentId).then(function (item) {
playbackManager.play({
@ -299,6 +297,5 @@ import '../../elements/emby-itemscontainer/emby-itemscontainer';
reloadItems();
this.alphaPicker?.updateControls(getQuery());
};
}
}
/* eslint-enable indent */

View file

@ -9,9 +9,7 @@ import Events from '../../utils/events.ts';
import '../../elements/emby-itemscontainer/emby-itemscontainer';
/* eslint-disable indent */
export default function (view, params, tabContent) {
export default function (view, params, tabContent) {
function getPageData(context) {
const key = getSavedQueryKey(context);
let pageData = data[key];
@ -240,6 +238,5 @@ import '../../elements/emby-itemscontainer/emby-itemscontainer';
reloadItems(tabContent);
this.alphaPicker?.updateControls(getQuery(tabContent));
};
}
}
/* eslint-enable indent */

View file

@ -3,9 +3,7 @@ import cardBuilder from '../../components/cardbuilder/cardBuilder';
import imageLoader from '../../components/images/imageLoader';
import loading from '../../components/loading/loading';
/* eslint-disable indent */
export default function (view, params, tabContent) {
export default function (view, params, tabContent) {
function getPageData() {
const key = getSavedQueryKey();
let pageData = data[key];
@ -129,6 +127,5 @@ import loading from '../../components/loading/loading';
this.renderTab = function () {
reloadItems(tabContent, promise);
};
}
}
/* eslint-enable indent */

View file

@ -3,9 +3,7 @@ import cardBuilder from '../../components/cardbuilder/cardBuilder';
import imageLoader from '../../components/images/imageLoader';
import loading from '../../components/loading/loading';
/* eslint-disable indent */
export default function (view, params, tabContent) {
export default function (view, params, tabContent) {
function getPageData() {
const key = getSavedQueryKey();
let pageData = data[key];
@ -84,6 +82,5 @@ import loading from '../../components/loading/loading';
this.renderTab = function () {
reloadItems(tabContent, promise);
};
}
}
/* eslint-enable indent */

View file

@ -16,9 +16,7 @@ import '../../elements/emby-button/emby-button';
import '../../styles/flexstyles.scss';
import Dashboard from '../../utils/dashboard';
/* eslint-disable indent */
function itemsPerRow() {
function itemsPerRow() {
const screenWidth = dom.getWindowSize().innerWidth;
if (screenWidth >= 1920) {
@ -34,17 +32,17 @@ import Dashboard from '../../utils/dashboard';
}
return 8;
}
}
function enableScrollX() {
function enableScrollX() {
return !layoutManager.desktop;
}
}
function getSquareShape() {
function getSquareShape() {
return enableScrollX() ? 'overflowSquare' : 'square';
}
}
function loadLatest(page, parentId) {
function loadLatest(page, parentId) {
loading.show();
const userId = ApiClient.getCurrentUserId();
const options = {
@ -79,9 +77,9 @@ import Dashboard from '../../utils/dashboard';
autoFocuser.autoFocus(page);
});
});
}
}
function loadRecentlyPlayed(page, parentId) {
function loadRecentlyPlayed(page, parentId) {
const options = {
SortBy: 'DatePlayed',
SortOrder: 'Descending',
@ -121,9 +119,9 @@ import Dashboard from '../../utils/dashboard';
});
imageLoader.lazyChildren(itemsContainer);
});
}
}
function loadFrequentlyPlayed(page, parentId) {
function loadFrequentlyPlayed(page, parentId) {
const options = {
SortBy: 'PlayCount',
SortOrder: 'Descending',
@ -163,9 +161,9 @@ import Dashboard from '../../utils/dashboard';
});
imageLoader.lazyChildren(itemsContainer);
});
}
}
function loadSuggestionsTab(page, tabContent, parentId) {
function loadSuggestionsTab(page, tabContent, parentId) {
console.debug('loadSuggestionsTab');
loadLatest(tabContent, parentId);
loadRecentlyPlayed(tabContent, parentId);
@ -174,9 +172,9 @@ import Dashboard from '../../utils/dashboard';
import('../../components/favoriteitems').then(({ default: favoriteItems }) => {
favoriteItems.render(tabContent, ApiClient.getCurrentUserId(), parentId, ['favoriteArtists', 'favoriteAlbums', 'favoriteSongs']);
});
}
}
function getTabs() {
function getTabs() {
return [{
name: globalize.translate('Albums')
}, {
@ -192,9 +190,9 @@ import Dashboard from '../../utils/dashboard';
}, {
name: globalize.translate('Genres')
}];
}
}
function getDefaultTabIndex(folderId) {
function getDefaultTabIndex(folderId) {
switch (userSettings.get('landing-' + folderId)) {
case 'suggestions':
return 1;
@ -217,9 +215,9 @@ import Dashboard from '../../utils/dashboard';
default:
return 0;
}
}
}
export default function (view, params) {
export default function (view, params) {
function reload() {
loading.show();
const tabContent = view.querySelector(".pageTabContent[data-index='" + suggestionsTabIndex + "']");
@ -396,6 +394,5 @@ import Dashboard from '../../utils/dashboard';
}
});
});
}
}
/* eslint-enable indent */

View file

@ -27,15 +27,14 @@ import { setBackdropTransparency, TRANSPARENCY_LEVEL } from '../../../components
import { pluginManager } from '../../../components/pluginManager';
import { PluginType } from '../../../types/plugin.ts';
/* eslint-disable indent */
const TICKS_PER_MINUTE = 600000000;
const TICKS_PER_SECOND = 10000000;
const TICKS_PER_MINUTE = 600000000;
const TICKS_PER_SECOND = 10000000;
function getOpenedDialog() {
function getOpenedDialog() {
return document.querySelector('.dialogContainer .dialog.opened');
}
}
export default function (view) {
export default function (view) {
function getDisplayItem(item) {
if (item.Type === 'TvChannel') {
const apiClient = ServerConnections.getApiClient(item.ServerId);
@ -1832,6 +1831,5 @@ import { PluginType } from '../../../types/plugin.ts';
}
});
}
}
}
/* eslint-enable indent */

View file

@ -6,9 +6,7 @@ import Dashboard from '../../../utils/dashboard';
import ServerConnections from '../../../components/ServerConnections';
import { ConnectionState } from '../../../utils/jellyfin-apiclient/ConnectionState.ts';
/* eslint-disable indent */
function handleConnectionResult(page, result) {
function handleConnectionResult(page, result) {
loading.hide();
switch (result.State) {
case ConnectionState.SignedIn: {
@ -34,9 +32,9 @@ import { ConnectionState } from '../../../utils/jellyfin-apiclient/ConnectionSta
title: globalize.translate('HeaderConnectionFailure')
});
}
}
}
function submitServer(page) {
function submitServer(page) {
loading.show();
const host = page.querySelector('#txtServerHost').value;
ServerConnections.connectToAddress(host, {
@ -48,9 +46,9 @@ import { ConnectionState } from '../../../utils/jellyfin-apiclient/ConnectionSta
State: ConnectionState.Unavailable
});
});
}
}
export default function(view) {
export default function(view) {
view.querySelector('.addServerForm').addEventListener('submit', onServerSubmit);
view.querySelector('.btnCancel').addEventListener('click', goBack);
@ -69,6 +67,5 @@ import { ConnectionState } from '../../../utils/jellyfin-apiclient/ConnectionSta
appRouter.back();
});
}
}
}
/* eslint-enable indent */

View file

@ -1,9 +1,7 @@
import globalize from '../../../scripts/globalize';
import Dashboard from '../../../utils/dashboard';
/* eslint-disable indent */
function processForgotPasswordResult(result) {
function processForgotPasswordResult(result) {
if (result.Action == 'ContactAdmin') {
Dashboard.alert({
message: globalize.translate('MessageContactAdminToResetPassword'),
@ -36,9 +34,9 @@ import Dashboard from '../../../utils/dashboard';
}
});
}
}
}
export default function (view) {
export default function (view) {
function onSubmit(e) {
ApiClient.ajax({
type: 'POST',
@ -54,6 +52,5 @@ import Dashboard from '../../../utils/dashboard';
}
view.querySelector('form').addEventListener('submit', onSubmit);
}
}
/* eslint-enable indent */

View file

@ -18,11 +18,9 @@ import baseAlert from '../../../components/alert';
import cardBuilder from '../../../components/cardbuilder/cardBuilder';
import './login.scss';
/* eslint-disable indent */
const enableFocusTransform = !browser.slow && !browser.edge;
const enableFocusTransform = !browser.slow && !browser.edge;
function authenticateUserByName(page, apiClient, username, password) {
function authenticateUserByName(page, apiClient, username, password) {
loading.show();
apiClient.authenticateUserByName(username, password).then(function (result) {
const user = result.User;
@ -44,9 +42,9 @@ import './login.scss';
});
}
});
}
}
function authenticateQuickConnect(apiClient) {
function authenticateQuickConnect(apiClient) {
const url = apiClient.getUrl('/QuickConnect/Initiate');
apiClient.ajax({ type: 'POST', url }, true).then(res => res.json()).then(function (json) {
if (!json.Secret || !json.Code) {
@ -108,14 +106,14 @@ import './login.scss';
console.error('Quick connect error: ', e);
return false;
});
}
}
function onLoginSuccessful(id, accessToken, apiClient) {
function onLoginSuccessful(id, accessToken, apiClient) {
Dashboard.onServerChanged(id, accessToken, apiClient);
Dashboard.navigate('home.html');
}
}
function showManualForm(context, showCancel, focusPassword) {
function showManualForm(context, showCancel, focusPassword) {
context.querySelector('.chkRememberLogin').checked = appSettings.enableAutoLogin();
context.querySelector('.manualLoginForm').classList.remove('hide');
context.querySelector('.visualLoginForm').classList.add('hide');
@ -132,9 +130,9 @@ import './login.scss';
} else {
context.querySelector('.btnCancel').classList.add('hide');
}
}
}
function loadUserList(context, apiClient, users) {
function loadUserList(context, apiClient, users) {
let html = '';
for (let i = 0; i < users.length; i++) {
@ -183,9 +181,9 @@ import './login.scss';
}
context.querySelector('#divUsers').innerHTML = html;
}
}
export default function (view, params) {
export default function (view, params) {
function getApiClient() {
const serverId = params.serverid;
@ -304,6 +302,5 @@ import './login.scss';
view.addEventListener('viewhide', function () {
libraryMenu.setTransparentMenu(false);
});
}
}
/* eslint-enable indent */

View file

@ -1,9 +1,7 @@
import globalize from '../../../scripts/globalize';
import Dashboard from '../../../utils/dashboard';
/* eslint-disable indent */
function processForgotPasswordResult(result) {
function processForgotPasswordResult(result) {
if (result.Success) {
let msg = globalize.translate('MessagePasswordResetForUsers');
msg += '<br/>';
@ -23,9 +21,9 @@ import Dashboard from '../../../utils/dashboard';
message: globalize.translate('MessageInvalidForgotPasswordPin'),
title: globalize.translate('HeaderPasswordReset')
});
}
}
export default function (view) {
export default function (view) {
function onSubmit(e) {
ApiClient.ajax({
type: 'POST',
@ -41,6 +39,5 @@ import Dashboard from '../../../utils/dashboard';
}
view.querySelector('form').addEventListener('submit', onSubmit);
}
}
/* eslint-enable indent */

View file

@ -21,11 +21,9 @@ import alert from '../../../components/alert';
import cardBuilder from '../../../components/cardbuilder/cardBuilder';
import { ConnectionState } from '../../../utils/jellyfin-apiclient/ConnectionState.ts';
/* eslint-disable indent */
const enableFocusTransform = !browser.slow && !browser.edge;
const enableFocusTransform = !browser.slow && !browser.edge;
function renderSelectServerItems(view, servers) {
function renderSelectServerItems(view, servers) {
const items = servers.map(function (server) {
return {
name: server.Name,
@ -76,9 +74,9 @@ import { ConnectionState } from '../../../utils/jellyfin-apiclient/ConnectionSta
itemsContainer.innerHTML = html;
loading.hide();
}
}
function updatePageStyle(view, params) {
function updatePageStyle(view, params) {
if (params.showuser == '1') {
view.classList.add('libraryPage');
view.classList.remove('standalonePage');
@ -88,23 +86,23 @@ import { ConnectionState } from '../../../utils/jellyfin-apiclient/ConnectionSta
view.classList.remove('libraryPage');
view.classList.remove('noSecondaryNavPage');
}
}
}
function alertText(text) {
function alertText(text) {
alertTextWithOptions({
text: text
});
}
}
function alertTextWithOptions(options) {
function alertTextWithOptions(options) {
alert(options);
}
}
function showServerConnectionFailure() {
function showServerConnectionFailure() {
alertText(globalize.translate('MessageUnableToConnectToServer'));
}
}
export default function (view, params) {
export default function (view, params) {
function connectToServer(server) {
loading.show();
ServerConnections.connectToServer(server, {
@ -211,6 +209,5 @@ import { ConnectionState } from '../../../utils/jellyfin-apiclient/ConnectionSta
}
}
});
}
}
/* eslint-enable indent */

View file

@ -10,9 +10,7 @@ import Events from '../../utils/events.ts';
import '../../elements/emby-itemscontainer/emby-itemscontainer';
/* eslint-disable indent */
export default function (view, params, tabContent) {
export default function (view, params, tabContent) {
function getPageData(context) {
const key = getSavedQueryKey(context);
let pageData = data[key];
@ -247,6 +245,5 @@ import '../../elements/emby-itemscontainer/emby-itemscontainer';
self.renderTab = function () {
reloadItems(tabContent);
};
}
}
/* eslint-enable indent */

View file

@ -8,9 +8,7 @@ import globalize from '../../scripts/globalize';
import { appRouter } from '../../components/appRouter';
import '../../elements/emby-button/emby-button';
/* eslint-disable indent */
export default function (view, params, tabContent) {
export default function (view, params, tabContent) {
function getPageData() {
const key = getSavedQueryKey();
let pageData = data[key];
@ -215,6 +213,5 @@ import '../../elements/emby-button/emby-button';
self.renderTab = function () {
reloadItems(tabContent, promise);
};
}
}
/* eslint-enable indent */

View file

@ -16,9 +16,7 @@ import Dashboard from '../../utils/dashboard';
import Events from '../../utils/events.ts';
import autoFocuser from '../../components/autoFocuser';
/* eslint-disable indent */
function getTabs() {
function getTabs() {
return [{
name: globalize.translate('Shows')
}, {
@ -32,9 +30,9 @@ import autoFocuser from '../../components/autoFocuser';
}, {
name: globalize.translate('Episodes')
}];
}
}
function getDefaultTabIndex(folderId) {
function getDefaultTabIndex(folderId) {
switch (userSettings.get('landing-' + folderId)) {
case 'suggestions':
return 1;
@ -54,9 +52,9 @@ import autoFocuser from '../../components/autoFocuser';
default:
return 0;
}
}
}
function setScrollClasses(elem, scrollX) {
function setScrollClasses(elem, scrollX) {
if (scrollX) {
elem.classList.add('hiddenScrollX');
@ -72,26 +70,26 @@ import autoFocuser from '../../components/autoFocuser';
elem.classList.remove('scrollX');
elem.classList.add('vertical-wrap');
}
}
}
function initSuggestedTab(page, tabContent) {
function initSuggestedTab(page, tabContent) {
const containers = tabContent.querySelectorAll('.itemsContainer');
for (let i = 0, length = containers.length; i < length; i++) {
setScrollClasses(containers[i], enableScrollX());
}
}
}
function loadSuggestionsTab(view, params, tabContent) {
function loadSuggestionsTab(view, params, tabContent) {
const parentId = params.topParentId;
const userId = ApiClient.getCurrentUserId();
console.debug('loadSuggestionsTab');
loadResume(tabContent, userId, parentId);
loadLatest(tabContent, userId, parentId);
loadNextUp(tabContent, userId, parentId);
}
}
function loadResume(view, userId, parentId) {
function loadResume(view, userId, parentId) {
const screenWidth = dom.getWindowSize().innerWidth;
const options = {
SortBy: 'DatePlayed',
@ -133,9 +131,9 @@ import autoFocuser from '../../components/autoFocuser';
autoFocuser.autoFocus(view);
});
}
}
function loadLatest(view, userId, parentId) {
function loadLatest(view, userId, parentId) {
const options = {
userId: userId,
IncludeItemTypes: 'Episode',
@ -172,9 +170,9 @@ import autoFocuser from '../../components/autoFocuser';
autoFocuser.autoFocus(view);
});
}
}
function loadNextUp(view, userId, parentId) {
function loadNextUp(view, userId, parentId) {
const query = {
userId: userId,
Limit: 24,
@ -212,17 +210,17 @@ import autoFocuser from '../../components/autoFocuser';
autoFocuser.autoFocus(view);
});
}
}
function enableScrollX() {
function enableScrollX() {
return !layoutManager.desktop;
}
}
function getThumbShape() {
function getThumbShape() {
return enableScrollX() ? 'overflowBackdrop' : 'backdrop';
}
}
export default function (view, params) {
export default function (view, params) {
function onBeforeTabChange(e) {
preLoadTab(view, parseInt(e.detail.selectedTabIndex, 10));
}
@ -387,6 +385,5 @@ import autoFocuser from '../../components/autoFocuser';
}
});
});
}
}
/* eslint-enable indent */

View file

@ -10,9 +10,7 @@ import Events from '../../utils/events.ts';
import '../../elements/emby-itemscontainer/emby-itemscontainer';
/* eslint-disable indent */
export default function (view, params, tabContent) {
export default function (view, params, tabContent) {
function getPageData(context) {
const key = getSavedQueryKey(context);
let pageData = data[key];
@ -304,6 +302,5 @@ import '../../elements/emby-itemscontainer/emby-itemscontainer';
reloadItems(tabContent);
this.alphaPicker?.updateControls(getQuery(tabContent));
};
}
}
/* eslint-enable indent */

View file

@ -2,9 +2,7 @@ import loading from '../../components/loading/loading';
import libraryBrowser from '../../scripts/libraryBrowser';
import cardBuilder from '../../components/cardbuilder/cardBuilder';
/* eslint-disable indent */
function getQuery(params) {
function getQuery(params) {
const key = getSavedQueryKey();
let pageData = data[key];
@ -23,19 +21,19 @@ import cardBuilder from '../../components/cardbuilder/cardBuilder';
}
return pageData.query;
}
}
function getSavedQueryKey() {
function getSavedQueryKey() {
return libraryBrowser.getSavedQueryKey('studios');
}
}
function getPromise(context, params) {
function getPromise(context, params) {
const query = getQuery(params);
loading.show();
return ApiClient.getStudios(ApiClient.getCurrentUserId(), query);
}
}
function reloadItems(context, params, promise) {
function reloadItems(context, params, promise) {
promise.then(function (result) {
const elem = context.querySelector('#items');
cardBuilder.buildCards(result.Items, {
@ -54,11 +52,11 @@ import cardBuilder from '../../components/cardbuilder/cardBuilder';
autoFocuser.autoFocus(context);
});
});
}
}
const data = {};
const data = {};
export default function (view, params, tabContent) {
export default function (view, params, tabContent) {
let promise;
const self = this;
@ -69,6 +67,5 @@ import cardBuilder from '../../components/cardbuilder/cardBuilder';
self.renderTab = function () {
reloadItems(tabContent, params, promise);
};
}
}
/* eslint-enable indent */

View file

@ -7,9 +7,7 @@ import globalize from '../../scripts/globalize';
import '../../styles/scrollstyles.scss';
import '../../elements/emby-itemscontainer/emby-itemscontainer';
/* eslint-disable indent */
function getUpcomingPromise(context, params) {
function getUpcomingPromise(context, params) {
loading.show();
const query = {
Limit: 48,
@ -21,9 +19,9 @@ import '../../elements/emby-itemscontainer/emby-itemscontainer';
};
query.ParentId = params.topParentId;
return ApiClient.getJSON(ApiClient.getUrl('Shows/Upcoming', query));
}
}
function loadUpcoming(context, params, promise) {
function loadUpcoming(context, params, promise) {
promise.then(function (result) {
const items = result.Items;
@ -36,17 +34,17 @@ import '../../elements/emby-itemscontainer/emby-itemscontainer';
renderUpcoming(context.querySelector('#upcomingItems'), items);
loading.hide();
});
}
}
function enableScrollX() {
function enableScrollX() {
return !layoutManager.desktop;
}
}
function getThumbShape() {
function getThumbShape() {
return enableScrollX() ? 'overflowBackdrop' : 'backdrop';
}
}
function renderUpcoming(elem, items) {
function renderUpcoming(elem, items) {
const groups = [];
let currentGroupName = '';
let currentGroup = [];
@ -126,9 +124,9 @@ import '../../elements/emby-itemscontainer/emby-itemscontainer';
elem.innerHTML = html;
imageLoader.lazyChildren(elem);
}
}
export default function (view, params, tabContent) {
export default function (view, params, tabContent) {
let upcomingPromise;
const self = this;
@ -139,6 +137,5 @@ import '../../elements/emby-itemscontainer/emby-itemscontainer';
self.renderTab = function () {
loadUpcoming(tabContent, params, upcomingPromise);
};
}
}
/* eslint-enable indent */

View file

@ -2,12 +2,10 @@ import DisplaySettings from '../../../components/displaySettings/displaySettings
import * as userSettings from '../../../scripts/settings/userSettings';
import autoFocuser from '../../../components/autoFocuser';
/* eslint-disable indent */
// Shortcuts
const UserSettings = userSettings.UserSettings;
// Shortcuts
const UserSettings = userSettings.UserSettings;
export default function (view, params) {
export default function (view, params) {
let settingsInstance;
const userId = params.userId || ApiClient.getCurrentUserId();
@ -35,6 +33,5 @@ import autoFocuser from '../../../components/autoFocuser';
settingsInstance = null;
}
});
}
}
/* eslint-enable indent */

View file

@ -3,12 +3,10 @@ import * as userSettings from '../../../scripts/settings/userSettings';
import autoFocuser from '../../../components/autoFocuser';
import '../../../components/listview/listview.scss';
/* eslint-disable indent */
// Shortcuts
const UserSettings = userSettings.UserSettings;
// Shortcuts
const UserSettings = userSettings.UserSettings;
export default function (view, params) {
export default function (view, params) {
let homescreenSettingsInstance;
const userId = params.userId || ApiClient.getCurrentUserId();
@ -36,6 +34,5 @@ import '../../../components/listview/listview.scss';
homescreenSettingsInstance = null;
}
});
}
}
/* eslint-enable indent */

View file

@ -4,12 +4,10 @@ import * as userSettings from '../../../scripts/settings/userSettings';
import autoFocuser from '../../../components/autoFocuser';
import '../../../components/listview/listview.scss';
/* eslint-disable indent */
// Shortcuts
const UserSettings = userSettings.UserSettings;
// Shortcuts
const UserSettings = userSettings.UserSettings;
export default function (view, params) {
export default function (view, params) {
let settingsInstance;
const userId = params.userId || ApiClient.getCurrentUserId();
@ -37,6 +35,5 @@ import '../../../components/listview/listview.scss';
settingsInstance = null;
}
});
}
}
/* eslint-enable indent */

View file

@ -2,12 +2,10 @@ import SubtitleSettings from '../../../components/subtitlesettings/subtitlesetti
import * as userSettings from '../../../scripts/settings/userSettings';
import autoFocuser from '../../../components/autoFocuser';
/* eslint-disable indent */
// Shortcuts
const UserSettings = userSettings.UserSettings;
// Shortcuts
const UserSettings = userSettings.UserSettings;
export default function (view, params) {
export default function (view, params) {
let subtitleSettingsInstance;
const userId = params.userId || ApiClient.getCurrentUserId();
@ -35,6 +33,5 @@ import autoFocuser from '../../../components/autoFocuser';
subtitleSettingsInstance = null;
}
});
}
}
/* eslint-enable indent */

View file

@ -3,11 +3,9 @@ import dom from '../../scripts/dom';
import './emby-checkbox.scss';
import 'webcomponents.js/webcomponents-lite';
/* eslint-disable indent */
const EmbyCheckboxPrototype = Object.create(HTMLInputElement.prototype);
const EmbyCheckboxPrototype = Object.create(HTMLInputElement.prototype);
function onKeyDown(e) {
function onKeyDown(e) {
// Don't submit form on enter
// Real (non-emulator) Tizen does nothing on Space
if (e.keyCode === 13 || (e.keyCode === 32 && browser.tizen)) {
@ -21,11 +19,11 @@ import 'webcomponents.js/webcomponents-lite';
return false;
}
}
}
const enableRefreshHack = browser.tizen || browser.orsay || browser.operaTv || browser.web0s ? true : false;
const enableRefreshHack = browser.tizen || browser.orsay || browser.operaTv || browser.web0s ? true : false;
function forceRefresh(loading) {
function forceRefresh(loading) {
const elem = this.parentNode;
elem.style.webkitAnimationName = 'repaintChrome';
@ -36,9 +34,9 @@ import 'webcomponents.js/webcomponents-lite';
setTimeout(function () {
elem.style.webkitAnimationName = '';
}, (loading === true ? 520 : 20));
}
}
EmbyCheckboxPrototype.attachedCallback = function () {
EmbyCheckboxPrototype.attachedCallback = function () {
if (this.getAttribute('data-embycheckbox') === 'true') {
return;
}
@ -84,9 +82,9 @@ import 'webcomponents.js/webcomponents-lite';
passive: true
});
}
};
};
EmbyCheckboxPrototype.detachedCallback = function () {
EmbyCheckboxPrototype.detachedCallback = function () {
this.removeEventListener('keydown', onKeyDown);
dom.removeEventListener(this, 'click', forceRefresh, {
@ -101,11 +99,10 @@ import 'webcomponents.js/webcomponents-lite';
dom.removeEventListener(this, 'change', forceRefresh, {
passive: true
});
};
};
document.registerElement('emby-checkbox', {
document.registerElement('emby-checkbox', {
prototype: EmbyCheckboxPrototype,
extends: 'input'
});
});
/* eslint-enable indent */

View file

@ -2,11 +2,9 @@ import './emby-collapse.scss';
import 'webcomponents.js/webcomponents-lite';
import '../emby-button/emby-button';
/* eslint-disable indent */
const EmbyButtonPrototype = Object.create(HTMLDivElement.prototype);
const EmbyButtonPrototype = Object.create(HTMLDivElement.prototype);
function slideDownToShow(button, elem) {
function slideDownToShow(button, elem) {
requestAnimationFrame(() => {
elem.classList.remove('hide');
elem.classList.add('expanded');
@ -30,9 +28,9 @@ import '../emby-button/emby-button';
const icon = button.querySelector('.material-icons');
icon.classList.add('emby-collapse-expandIconExpanded');
});
}
}
function slideUpToHide(button, elem) {
function slideUpToHide(button, elem) {
requestAnimationFrame(() => {
elem.style.height = elem.offsetHeight + 'px';
// trigger reflow
@ -52,9 +50,9 @@ import '../emby-button/emby-button';
const icon = button.querySelector('.material-icons');
icon.classList.remove('emby-collapse-expandIconExpanded');
});
}
}
function onButtonClick() {
function onButtonClick() {
const button = this;
const collapseContent = button.parentNode.querySelector('.collapseContent');
@ -65,9 +63,9 @@ import '../emby-button/emby-button';
collapseContent.expanded = true;
slideDownToShow(button, collapseContent);
}
}
}
EmbyButtonPrototype.attachedCallback = function () {
EmbyButtonPrototype.attachedCallback = function () {
if (this.classList.contains('emby-collapse')) {
return;
}
@ -92,11 +90,10 @@ import '../emby-button/emby-button';
if (this.getAttribute('data-expanded') === 'true') {
onButtonClick.call(button);
}
};
};
document.registerElement('emby-collapse', {
document.registerElement('emby-collapse', {
prototype: EmbyButtonPrototype,
extends: 'div'
});
});
/* eslint-enable indent */

View file

@ -3,14 +3,12 @@ import dom from '../../scripts/dom';
import './emby-input.scss';
import 'webcomponents.js/webcomponents-lite';
/* eslint-disable indent */
const EmbyInputPrototype = Object.create(HTMLInputElement.prototype);
const EmbyInputPrototype = Object.create(HTMLInputElement.prototype);
let inputId = 0;
let supportsFloatingLabel = false;
let inputId = 0;
let supportsFloatingLabel = false;
if (Object.getOwnPropertyDescriptor && Object.defineProperty) {
if (Object.getOwnPropertyDescriptor && Object.defineProperty) {
const descriptor = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value');
// descriptor returning null in webos
@ -28,9 +26,9 @@ import 'webcomponents.js/webcomponents-lite';
Object.defineProperty(HTMLInputElement.prototype, 'value', descriptor);
supportsFloatingLabel = true;
}
}
}
EmbyInputPrototype.createdCallback = function () {
EmbyInputPrototype.createdCallback = function () {
if (!this.id) {
this.id = 'embyinput' + inputId;
inputId++;
@ -89,9 +87,9 @@ import 'webcomponents.js/webcomponents-lite';
if (browser.orsay && this === document.activeElement && document.attachIME) {
document.attachIME(this);
}
};
};
function onChange() {
function onChange() {
const label = this.labelElement;
if (this.value) {
label.classList.remove('inputLabel-float');
@ -102,20 +100,19 @@ import 'webcomponents.js/webcomponents-lite';
label.classList.add('inputLabel-float');
}
}
}
}
EmbyInputPrototype.attachedCallback = function () {
EmbyInputPrototype.attachedCallback = function () {
this.labelElement.htmlFor = this.id;
onChange.call(this);
};
};
EmbyInputPrototype.label = function (text) {
EmbyInputPrototype.label = function (text) {
this.labelElement.innerText = text;
};
};
document.registerElement('emby-input', {
document.registerElement('emby-input', {
prototype: EmbyInputPrototype,
extends: 'input'
});
});
/* eslint-enable indent */

View file

@ -5,23 +5,21 @@ import Events from '../../utils/events.ts';
import 'webcomponents.js/webcomponents-lite';
/* eslint-disable indent */
function addNotificationEvent(instance, name, handler) {
function addNotificationEvent(instance, name, handler) {
const localHandler = handler.bind(instance);
Events.on(serverNotifications, name, localHandler);
instance[name] = localHandler;
}
}
function removeNotificationEvent(instance, name) {
function removeNotificationEvent(instance, name) {
const handler = instance[name];
if (handler) {
Events.off(serverNotifications, name, handler);
instance[name] = null;
}
}
}
function onRefreshProgress(e, apiClient, info) {
function onRefreshProgress(e, apiClient, info) {
const indicator = this;
if (!indicator.itemId) {
@ -39,27 +37,27 @@ import 'webcomponents.js/webcomponents-lite';
this.setAttribute('data-progress', progress);
}
}
}
const EmbyItemRefreshIndicatorPrototype = Object.create(EmbyProgressRing);
const EmbyItemRefreshIndicatorPrototype = Object.create(EmbyProgressRing);
EmbyItemRefreshIndicatorPrototype.createdCallback = function () {
EmbyItemRefreshIndicatorPrototype.createdCallback = function () {
// base method
if (EmbyProgressRing.createdCallback) {
EmbyProgressRing.createdCallback.call(this);
}
addNotificationEvent(this, 'RefreshProgress', onRefreshProgress);
};
};
EmbyItemRefreshIndicatorPrototype.attachedCallback = function () {
EmbyItemRefreshIndicatorPrototype.attachedCallback = function () {
// base method
if (EmbyProgressRing.attachedCallback) {
EmbyProgressRing.attachedCallback.call(this);
}
};
};
EmbyItemRefreshIndicatorPrototype.detachedCallback = function () {
EmbyItemRefreshIndicatorPrototype.detachedCallback = function () {
// base method
if (EmbyProgressRing.detachedCallback) {
EmbyProgressRing.detachedCallback.call(this);
@ -67,11 +65,10 @@ import 'webcomponents.js/webcomponents-lite';
removeNotificationEvent(this, 'RefreshProgress');
this.itemId = null;
};
};
document.registerElement('emby-itemrefreshindicator', {
document.registerElement('emby-itemrefreshindicator', {
prototype: EmbyItemRefreshIndicatorPrototype,
extends: 'div'
});
});
/* eslint-enable indent */

View file

@ -13,11 +13,9 @@ import 'webcomponents.js/webcomponents-lite';
import ServerConnections from '../../components/ServerConnections';
import Sortable from 'sortablejs';
/* eslint-disable indent */
const ItemsContainerPrototype = Object.create(HTMLDivElement.prototype);
const ItemsContainerPrototype = Object.create(HTMLDivElement.prototype);
function onClick(e) {
function onClick(e) {
const itemsContainer = this;
const multiSelect = itemsContainer.multiSelect;
@ -26,15 +24,15 @@ import Sortable from 'sortablejs';
}
itemShortcuts.onClick.call(itemsContainer, e);
}
}
function disableEvent(e) {
function disableEvent(e) {
e.preventDefault();
e.stopPropagation();
return false;
}
}
function onContextMenu(e) {
function onContextMenu(e) {
const target = e.target;
const card = dom.parentWithAttribute(target, 'data-id');
@ -48,15 +46,15 @@ import Sortable from 'sortablejs';
e.stopPropagation();
return false;
}
}
}
function getShortcutOptions() {
function getShortcutOptions() {
return {
click: false
};
}
}
ItemsContainerPrototype.enableMultiSelect = function (enabled) {
ItemsContainerPrototype.enableMultiSelect = function (enabled) {
const current = this.multiSelect;
if (!enabled) {
@ -78,9 +76,9 @@ import Sortable from 'sortablejs';
bindOnClick: false
});
});
};
};
function onDrop(evt, itemsContainer) {
function onDrop(evt, itemsContainer) {
const el = evt.item;
const newIndex = evt.newIndex;
@ -115,9 +113,9 @@ import Sortable from 'sortablejs';
loading.hide();
itemsContainer.refreshItems();
});
}
}
ItemsContainerPrototype.enableDragReordering = function (enabled) {
ItemsContainerPrototype.enableDragReordering = function (enabled) {
const current = this.sortable;
if (!enabled) {
if (current) {
@ -141,9 +139,9 @@ import Sortable from 'sortablejs';
return onDrop(evt, self);
}
});
};
};
function onUserDataChanged(e, apiClient, userData) {
function onUserDataChanged(e, apiClient, userData) {
const itemsContainer = this;
import('../../components/cardbuilder/cardBuilder').then((cardBuilder) => {
@ -158,18 +156,18 @@ import Sortable from 'sortablejs';
) {
itemsContainer.notifyRefreshNeeded();
}
}
}
function getEventsToMonitor(itemsContainer) {
function getEventsToMonitor(itemsContainer) {
const monitor = itemsContainer.getAttribute('data-monitor');
if (monitor) {
return monitor.split(',');
}
return [];
}
}
function onTimerCreated(e, apiClient, data) {
function onTimerCreated(e, apiClient, data) {
const itemsContainer = this;
if (getEventsToMonitor(itemsContainer).indexOf('timers') !== -1) {
@ -184,16 +182,16 @@ import Sortable from 'sortablejs';
import('../../components/cardbuilder/cardBuilder').then((cardBuilder) => {
cardBuilder.onTimerCreated(programId, newTimerId, itemsContainer);
});
}
}
function onSeriesTimerCreated() {
function onSeriesTimerCreated() {
const itemsContainer = this;
if (getEventsToMonitor(itemsContainer).indexOf('seriestimers') !== -1) {
itemsContainer.notifyRefreshNeeded();
}
}
}
function onTimerCancelled(e, apiClient, data) {
function onTimerCancelled(e, apiClient, data) {
const itemsContainer = this;
if (getEventsToMonitor(itemsContainer).indexOf('timers') !== -1) {
itemsContainer.notifyRefreshNeeded();
@ -203,9 +201,9 @@ import Sortable from 'sortablejs';
import('../../components/cardbuilder/cardBuilder').then((cardBuilder) => {
cardBuilder.onTimerCancelled(data.Id, itemsContainer);
});
}
}
function onSeriesTimerCancelled(e, apiClient, data) {
function onSeriesTimerCancelled(e, apiClient, data) {
const itemsContainer = this;
if (getEventsToMonitor(itemsContainer).indexOf('seriestimers') !== -1) {
itemsContainer.notifyRefreshNeeded();
@ -215,9 +213,9 @@ import Sortable from 'sortablejs';
import('../../components/cardbuilder/cardBuilder').then((cardBuilder) => {
cardBuilder.onSeriesTimerCancelled(data.Id, itemsContainer);
});
}
}
function onLibraryChanged(e, apiClient, data) {
function onLibraryChanged(e, apiClient, data) {
const itemsContainer = this;
const eventsToMonitor = getEventsToMonitor(itemsContainer);
@ -244,9 +242,9 @@ import Sortable from 'sortablejs';
}
itemsContainer.notifyRefreshNeeded();
}
}
function onPlaybackStopped(e, stopInfo) {
function onPlaybackStopped(e, stopInfo) {
const itemsContainer = this;
const state = stopInfo.state;
@ -260,29 +258,29 @@ import Sortable from 'sortablejs';
itemsContainer.notifyRefreshNeeded(true);
return;
}
}
}
function addNotificationEvent(instance, name, handler, owner) {
function addNotificationEvent(instance, name, handler, owner) {
const localHandler = handler.bind(instance);
owner = owner || serverNotifications;
Events.on(owner, name, localHandler);
instance['event_' + name] = localHandler;
}
}
function removeNotificationEvent(instance, name, owner) {
function removeNotificationEvent(instance, name, owner) {
const handler = instance['event_' + name];
if (handler) {
owner = owner || serverNotifications;
Events.off(owner, name, handler);
instance['event_' + name] = null;
}
}
}
ItemsContainerPrototype.createdCallback = function () {
ItemsContainerPrototype.createdCallback = function () {
this.classList.add('itemsContainer');
};
};
ItemsContainerPrototype.attachedCallback = function () {
ItemsContainerPrototype.attachedCallback = function () {
this.addEventListener('click', onClick);
if (browser.touch) {
@ -314,9 +312,9 @@ import Sortable from 'sortablejs';
if (this.getAttribute('data-dragreorder') === 'true') {
this.enableDragReordering(true);
}
};
};
ItemsContainerPrototype.detachedCallback = function () {
ItemsContainerPrototype.detachedCallback = function () {
clearRefreshInterval(this);
this.enableMultiSelect(false);
@ -338,14 +336,14 @@ import Sortable from 'sortablejs';
this.fetchData = null;
this.getItemsHtml = null;
this.parentContainer = null;
};
};
ItemsContainerPrototype.pause = function () {
ItemsContainerPrototype.pause = function () {
clearRefreshInterval(this, true);
this.paused = true;
};
};
ItemsContainerPrototype.resume = function (options) {
ItemsContainerPrototype.resume = function (options) {
this.paused = false;
const refreshIntervalEndTime = this.refreshIntervalEndTime;
@ -364,9 +362,9 @@ import Sortable from 'sortablejs';
}
return Promise.resolve();
};
};
ItemsContainerPrototype.refreshItems = function () {
ItemsContainerPrototype.refreshItems = function () {
if (!this.fetchData) {
return Promise.resolve();
}
@ -379,9 +377,9 @@ import Sortable from 'sortablejs';
this.needsRefresh = false;
return this.fetchData().then(onDataFetched.bind(this));
};
};
ItemsContainerPrototype.notifyRefreshNeeded = function (isInForeground) {
ItemsContainerPrototype.notifyRefreshNeeded = function (isInForeground) {
if (this.paused) {
this.needsRefresh = true;
return;
@ -397,9 +395,9 @@ import Sortable from 'sortablejs';
} else {
this.refreshTimeout = setTimeout(this.refreshItems.bind(this), 10000);
}
};
};
function clearRefreshInterval(itemsContainer, isPausing) {
function clearRefreshInterval(itemsContainer, isPausing) {
if (itemsContainer.refreshInterval) {
clearInterval(itemsContainer.refreshInterval);
itemsContainer.refreshInterval = null;
@ -408,9 +406,9 @@ import Sortable from 'sortablejs';
itemsContainer.refreshIntervalEndTime = null;
}
}
}
}
function resetRefreshInterval(itemsContainer, intervalMs) {
function resetRefreshInterval(itemsContainer, intervalMs) {
clearRefreshInterval(itemsContainer);
if (!intervalMs) {
@ -421,9 +419,9 @@ import Sortable from 'sortablejs';
itemsContainer.refreshInterval = setInterval(itemsContainer.notifyRefreshNeeded.bind(itemsContainer), intervalMs);
itemsContainer.refreshIntervalEndTime = new Date().getTime() + intervalMs;
}
}
}
function onDataFetched(result) {
function onDataFetched(result) {
const items = result.Items || result;
const parentContainer = this.parentContainer;
@ -457,9 +455,9 @@ import Sortable from 'sortablejs';
if (this.afterRefresh) {
this.afterRefresh(result);
}
}
}
function setFocus(itemsContainer, focusId) {
function setFocus(itemsContainer, focusId) {
if (focusId) {
const newElement = itemsContainer.querySelector('[data-id="' + focusId + '"]');
if (newElement) {
@ -473,11 +471,10 @@ import Sortable from 'sortablejs';
}
focusManager.autoFocus(itemsContainer);
}
}
document.registerElement('emby-itemscontainer', {
document.registerElement('emby-itemscontainer', {
prototype: ItemsContainerPrototype,
extends: 'div'
});
});
/* eslint-enable indent */

View file

@ -4,23 +4,21 @@ import Events from '../../utils/events.ts';
import EmbyButtonPrototype from '../../elements/emby-button/emby-button';
import ServerConnections from '../../components/ServerConnections';
/* eslint-disable indent */
function addNotificationEvent(instance, name, handler) {
function addNotificationEvent(instance, name, handler) {
const localHandler = handler.bind(instance);
Events.on(serverNotifications, name, localHandler);
instance[name] = localHandler;
}
}
function removeNotificationEvent(instance, name) {
function removeNotificationEvent(instance, name) {
const handler = instance[name];
if (handler) {
Events.off(serverNotifications, name, handler);
instance[name] = null;
}
}
}
function onClick() {
function onClick() {
const button = this;
const id = button.getAttribute('data-id');
const serverId = button.getAttribute('data-serverid');
@ -33,16 +31,16 @@ import ServerConnections from '../../components/ServerConnections';
apiClient.markUnplayed(apiClient.getCurrentUserId(), id, new Date());
setState(button, false);
}
}
}
function onUserDataChanged(e, apiClient, userData) {
function onUserDataChanged(e, apiClient, userData) {
const button = this;
if (userData.ItemId === button.getAttribute('data-id')) {
setState(button, userData.Played);
}
}
}
function setState(button, played, updateAttribute) {
function setState(button, played, updateAttribute) {
let icon = button.iconElement;
if (!icon) {
button.iconElement = button.querySelector('.material-icons');
@ -68,9 +66,9 @@ import ServerConnections from '../../components/ServerConnections';
}
setTitle(button, button.getAttribute('data-type'), played);
}
}
function setTitle(button, itemType, played) {
function setTitle(button, itemType, played) {
if (itemType !== 'AudioBook' && itemType !== 'AudioPodcast') {
button.title = played ? globalize.translate('Watched') : globalize.translate('MarkPlayed');
} else {
@ -81,30 +79,30 @@ import ServerConnections from '../../components/ServerConnections';
if (text) {
text.innerText = button.title;
}
}
}
function clearEvents(button) {
function clearEvents(button) {
button.removeEventListener('click', onClick);
removeNotificationEvent(button, 'UserDataChanged');
}
}
function bindEvents(button) {
function bindEvents(button) {
clearEvents(button);
button.addEventListener('click', onClick);
addNotificationEvent(button, 'UserDataChanged', onUserDataChanged);
}
}
const EmbyPlaystateButtonPrototype = Object.create(EmbyButtonPrototype);
const EmbyPlaystateButtonPrototype = Object.create(EmbyButtonPrototype);
EmbyPlaystateButtonPrototype.createdCallback = function () {
EmbyPlaystateButtonPrototype.createdCallback = function () {
// base method
if (EmbyButtonPrototype.createdCallback) {
EmbyButtonPrototype.createdCallback.call(this);
}
};
};
EmbyPlaystateButtonPrototype.attachedCallback = function () {
EmbyPlaystateButtonPrototype.attachedCallback = function () {
// base method
if (EmbyButtonPrototype.attachedCallback) {
EmbyButtonPrototype.attachedCallback.call(this);
@ -116,9 +114,9 @@ import ServerConnections from '../../components/ServerConnections';
setState(this, this.getAttribute('data-played') === 'true', false);
bindEvents(this);
}
};
};
EmbyPlaystateButtonPrototype.detachedCallback = function () {
EmbyPlaystateButtonPrototype.detachedCallback = function () {
// base method
if (EmbyButtonPrototype.detachedCallback) {
EmbyButtonPrototype.detachedCallback.call(this);
@ -126,9 +124,9 @@ import ServerConnections from '../../components/ServerConnections';
clearEvents(this);
this.iconElement = null;
};
};
EmbyPlaystateButtonPrototype.setItem = function (item) {
EmbyPlaystateButtonPrototype.setItem = function (item) {
if (item) {
this.setAttribute('data-id', item.Id);
this.setAttribute('data-serverid', item.ServerId);
@ -144,11 +142,10 @@ import ServerConnections from '../../components/ServerConnections';
this.removeAttribute('data-played');
clearEvents(this);
}
};
};
document.registerElement('emby-playstatebutton', {
document.registerElement('emby-playstatebutton', {
prototype: EmbyPlaystateButtonPrototype,
extends: 'button'
});
});
/* eslint-enable indent */

View file

@ -1,8 +1,7 @@
/* eslint-disable indent */
const ProgressBarPrototype = Object.create(HTMLDivElement.prototype);
const ProgressBarPrototype = Object.create(HTMLDivElement.prototype);
function onAutoTimeProgress() {
function onAutoTimeProgress() {
const start = parseInt(this.getAttribute('data-starttime'), 10);
const end = parseInt(this.getAttribute('data-endtime'), 10);
@ -15,9 +14,9 @@
const itemProgressBarForeground = this.querySelector('.itemProgressBarForeground');
itemProgressBarForeground.style.width = pct + '%';
}
}
ProgressBarPrototype.attachedCallback = function () {
ProgressBarPrototype.attachedCallback = function () {
if (this.timeInterval) {
clearInterval(this.timeInterval);
}
@ -25,18 +24,17 @@
if (this.getAttribute('data-automode') === 'time') {
this.timeInterval = setInterval(onAutoTimeProgress.bind(this), 60000);
}
};
};
ProgressBarPrototype.detachedCallback = function () {
ProgressBarPrototype.detachedCallback = function () {
if (this.timeInterval) {
clearInterval(this.timeInterval);
this.timeInterval = null;
}
};
};
document.registerElement('emby-progressbar', {
document.registerElement('emby-progressbar', {
prototype: ProgressBarPrototype,
extends: 'div'
});
});
/* eslint-enable indent */

View file

@ -4,11 +4,9 @@ import template from './emby-progressring.template.html';
import { getCurrentDateTimeLocale } from '../../scripts/globalize';
import { toPercent } from '../../utils/number.ts';
/* eslint-disable indent */
const EmbyProgressRing = Object.create(HTMLDivElement.prototype);
const EmbyProgressRing = Object.create(HTMLDivElement.prototype);
EmbyProgressRing.createdCallback = function () {
EmbyProgressRing.createdCallback = function () {
this.classList.add('progressring');
this.setAttribute('dir', 'ltr');
const instance = this;
@ -33,9 +31,9 @@ import { toPercent } from '../../utils/number.ts';
}
instance.setProgress(parseFloat(instance.getAttribute('data-progress') || '0'));
};
};
EmbyProgressRing.setProgress = function (progress) {
EmbyProgressRing.setProgress = function (progress) {
progress = Math.floor(progress);
let angle;
@ -74,13 +72,13 @@ import { toPercent } from '../../utils/number.ts';
}
this.querySelector('.progressring-text').innerHTML = toPercent(progress / 100, getCurrentDateTimeLocale());
};
};
EmbyProgressRing.attachedCallback = function () {
EmbyProgressRing.attachedCallback = function () {
// no-op
};
};
EmbyProgressRing.detachedCallback = function () {
EmbyProgressRing.detachedCallback = function () {
const observer = this.observer;
if (observer) {
@ -89,13 +87,12 @@ import { toPercent } from '../../utils/number.ts';
this.observer = null;
}
};
};
document.registerElement('emby-progressring', {
document.registerElement('emby-progressring', {
prototype: EmbyProgressRing,
extends: 'div'
});
});
export default EmbyProgressRing;
export default EmbyProgressRing;
/* eslint-enable indent */

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