mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Migration imageOptionsEditor and libraryoptionseditor to es6
This commit is contained in:
parent
336c7bc5f9
commit
eff468dc82
3 changed files with 196 additions and 179 deletions
|
@ -93,8 +93,10 @@
|
||||||
"src/components/actionSheet/actionSheet.js",
|
"src/components/actionSheet/actionSheet.js",
|
||||||
"src/components/autoFocuser.js",
|
"src/components/autoFocuser.js",
|
||||||
"src/components/cardbuilder/cardBuilder.js",
|
"src/components/cardbuilder/cardBuilder.js",
|
||||||
|
"src/components/imageOptionsEditor/imageOptionsEditor.js",
|
||||||
"src/components/images/imageLoader.js",
|
"src/components/images/imageLoader.js",
|
||||||
"src/components/indicators/indicators.js",
|
"src/components/indicators/indicators.js",
|
||||||
|
"src/components/libraryoptionseditor/libraryoptionseditor.js",
|
||||||
"src/components/lazyLoader/lazyLoaderIntersectionObserver.js",
|
"src/components/lazyLoader/lazyLoaderIntersectionObserver.js",
|
||||||
"src/components/playback/brightnessosd.js",
|
"src/components/playback/brightnessosd.js",
|
||||||
"src/components/playback/mediasession.js",
|
"src/components/playback/mediasession.js",
|
||||||
|
|
|
@ -1,5 +1,16 @@
|
||||||
define(['globalize', 'dom', 'dialogHelper', 'emby-checkbox', 'emby-select', 'emby-input'], function (globalize, dom, dialogHelper) {
|
/* eslint-disable indent */
|
||||||
'use strict';
|
|
||||||
|
/**
|
||||||
|
* Module for image Options Editor.
|
||||||
|
* @module components/imageOptionsEditor/imageOptionsEditor
|
||||||
|
*/
|
||||||
|
|
||||||
|
import globalize from 'globalize';
|
||||||
|
import dom from 'dom';
|
||||||
|
import dialogHelper from 'dialogHelper';
|
||||||
|
import 'emby-checkbox';
|
||||||
|
import 'emby-select';
|
||||||
|
import 'emby-input';
|
||||||
|
|
||||||
function getDefaultImageConfig(itemType, type) {
|
function getDefaultImageConfig(itemType, type) {
|
||||||
return {
|
return {
|
||||||
|
@ -10,7 +21,7 @@ define(['globalize', 'dom', 'dialogHelper', 'emby-checkbox', 'emby-select', 'emb
|
||||||
}
|
}
|
||||||
|
|
||||||
function findImageOptions(imageOptions, type) {
|
function findImageOptions(imageOptions, type) {
|
||||||
return imageOptions.filter(function (i) {
|
return imageOptions.filter(i => {
|
||||||
return i.Type == type;
|
return i.Type == type;
|
||||||
})[0];
|
})[0];
|
||||||
}
|
}
|
||||||
|
@ -31,14 +42,14 @@ define(['globalize', 'dom', 'dialogHelper', 'emby-checkbox', 'emby-select', 'emb
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadValues(context, itemType, options, availableOptions) {
|
function loadValues(context, itemType, options, availableOptions) {
|
||||||
var supportedImageTypes = availableOptions.SupportedImageTypes || [];
|
const supportedImageTypes = availableOptions.SupportedImageTypes || [];
|
||||||
setVisibilityOfBackdrops(context.querySelector('.backdropFields'), -1 != supportedImageTypes.indexOf('Backdrop'));
|
setVisibilityOfBackdrops(context.querySelector('.backdropFields'), supportedImageTypes.includes('Backdrop'));
|
||||||
setVisibilityOfBackdrops(context.querySelector('.screenshotFields'), -1 != supportedImageTypes.indexOf('Screenshot'));
|
setVisibilityOfBackdrops(context.querySelector('.screenshotFields'), supportedImageTypes.includes('Screenshot'));
|
||||||
Array.prototype.forEach.call(context.querySelectorAll('.imageType'), function (i) {
|
Array.prototype.forEach.call(context.querySelectorAll('.imageType'), i => {
|
||||||
var imageType = i.getAttribute('data-imagetype');
|
const imageType = i.getAttribute('data-imagetype');
|
||||||
var container = dom.parentWithTag(i, 'LABEL');
|
const container = dom.parentWithTag(i, 'LABEL');
|
||||||
|
|
||||||
if (-1 == supportedImageTypes.indexOf(imageType)) {
|
if (!supportedImageTypes.includes(imageType)) {
|
||||||
container.classList.add('hide');
|
container.classList.add('hide');
|
||||||
} else {
|
} else {
|
||||||
container.classList.remove('hide');
|
container.classList.remove('hide');
|
||||||
|
@ -50,16 +61,16 @@ define(['globalize', 'dom', 'dialogHelper', 'emby-checkbox', 'emby-select', 'emb
|
||||||
i.checked = false;
|
i.checked = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
var backdropConfig = getImageConfig(options, availableOptions, 'Backdrop', itemType);
|
const backdropConfig = getImageConfig(options, availableOptions, 'Backdrop', itemType);
|
||||||
context.querySelector('#txtMaxBackdrops').value = backdropConfig.Limit;
|
context.querySelector('#txtMaxBackdrops').value = backdropConfig.Limit;
|
||||||
context.querySelector('#txtMinBackdropDownloadWidth').value = backdropConfig.MinWidth;
|
context.querySelector('#txtMinBackdropDownloadWidth').value = backdropConfig.MinWidth;
|
||||||
var screenshotConfig = getImageConfig(options, availableOptions, 'Screenshot', itemType);
|
const screenshotConfig = getImageConfig(options, availableOptions, 'Screenshot', itemType);
|
||||||
context.querySelector('#txtMaxScreenshots').value = screenshotConfig.Limit;
|
context.querySelector('#txtMaxScreenshots').value = screenshotConfig.Limit;
|
||||||
context.querySelector('#txtMinScreenshotDownloadWidth').value = screenshotConfig.MinWidth;
|
context.querySelector('#txtMinScreenshotDownloadWidth').value = screenshotConfig.MinWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
function saveValues(context, options) {
|
function saveValues(context, options) {
|
||||||
options.ImageOptions = Array.prototype.map.call(context.querySelectorAll('.imageType:not(.hide)'), function (c) {
|
options.ImageOptions = Array.prototype.map.call(context.querySelectorAll('.imageType:not(.hide)'), c => {
|
||||||
return {
|
return {
|
||||||
Type: c.getAttribute('data-imagetype'),
|
Type: c.getAttribute('data-imagetype'),
|
||||||
Limit: c.checked ? 1 : 0,
|
Limit: c.checked ? 1 : 0,
|
||||||
|
@ -78,35 +89,32 @@ define(['globalize', 'dom', 'dialogHelper', 'emby-checkbox', 'emby-select', 'emb
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function editor() {
|
export class editor {
|
||||||
this.show = function (itemType, options, availableOptions) {
|
constructor() {
|
||||||
return new Promise(function (resolve, reject) {
|
this.show = (itemType, options, availableOptions) => {
|
||||||
var xhr = new XMLHttpRequest();
|
return new Promise((resolve) => {
|
||||||
xhr.open('GET', 'components/imageOptionsEditor/imageOptionsEditor.template.html', true);
|
//TODO: remove require
|
||||||
|
require(['text!./components/imageOptionsEditor/imageOptionsEditor.template.html'], template => {
|
||||||
xhr.onload = function (e) {
|
const dlg = dialogHelper.createDialog({
|
||||||
var template = this.response;
|
|
||||||
var dlg = dialogHelper.createDialog({
|
|
||||||
size: 'small',
|
size: 'small',
|
||||||
removeOnClose: true,
|
removeOnClose: true,
|
||||||
scrollY: false
|
scrollY: false
|
||||||
});
|
});
|
||||||
dlg.classList.add('formDialog');
|
dlg.classList.add('formDialog');
|
||||||
dlg.innerHTML = globalize.translateDocument(template);
|
dlg.innerHTML = globalize.translateDocument(template);
|
||||||
dlg.addEventListener('close', function () {
|
dlg.addEventListener('close', () => {
|
||||||
saveValues(dlg, options);
|
saveValues(dlg, options);
|
||||||
});
|
});
|
||||||
loadValues(dlg, itemType, options, availableOptions);
|
loadValues(dlg, itemType, options, availableOptions);
|
||||||
dialogHelper.open(dlg).then(resolve, resolve);
|
dialogHelper.open(dlg).then(resolve, resolve);
|
||||||
dlg.querySelector('.btnCancel').addEventListener('click', function () {
|
dlg.querySelector('.btnCancel').addEventListener('click', () => {
|
||||||
dialogHelper.close(dlg);
|
dialogHelper.close(dlg);
|
||||||
});
|
});
|
||||||
};
|
});
|
||||||
|
|
||||||
xhr.send();
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return editor;
|
/* eslint-enable indent */
|
||||||
});
|
export default editor;
|
||||||
|
|
|
@ -1,63 +1,73 @@
|
||||||
define(['globalize', 'dom', 'emby-checkbox', 'emby-select', 'emby-input'], function(globalize, dom) {
|
/* eslint-disable indent */
|
||||||
'use strict';
|
|
||||||
|
/**
|
||||||
|
* Module for library options editor.
|
||||||
|
* @module components/libraryoptionseditor/libraryoptionseditor
|
||||||
|
*/
|
||||||
|
|
||||||
|
import globalize from 'globalize';
|
||||||
|
import dom from 'dom';
|
||||||
|
import 'emby-checkbox';
|
||||||
|
import 'emby-select';
|
||||||
|
import 'emby-input';
|
||||||
|
|
||||||
function populateLanguages(parent) {
|
function populateLanguages(parent) {
|
||||||
return ApiClient.getCultures().then(function(languages) {
|
return ApiClient.getCultures().then(languages => {
|
||||||
populateLanguagesIntoSelect(parent.querySelector('#selectLanguage'), languages);
|
populateLanguagesIntoSelect(parent.querySelector('#selectLanguage'), languages);
|
||||||
populateLanguagesIntoList(parent.querySelector('.subtitleDownloadLanguages'), languages);
|
populateLanguagesIntoList(parent.querySelector('.subtitleDownloadLanguages'), languages);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function populateLanguagesIntoSelect(select, languages) {
|
function populateLanguagesIntoSelect(select, languages) {
|
||||||
var html = '';
|
let html = '';
|
||||||
html += "<option value=''></option>";
|
html += "<option value=''></option>";
|
||||||
for (var i = 0; i < languages.length; i++) {
|
for (let i = 0; i < languages.length; i++) {
|
||||||
var culture = languages[i];
|
const culture = languages[i];
|
||||||
html += "<option value='" + culture.TwoLetterISOLanguageName + "'>" + culture.DisplayName + '</option>';
|
html += `<option value='${culture.TwoLetterISOLanguageName}'>${culture.DisplayName}</option>`;
|
||||||
}
|
}
|
||||||
select.innerHTML = html;
|
select.innerHTML = html;
|
||||||
}
|
}
|
||||||
|
|
||||||
function populateLanguagesIntoList(element, languages) {
|
function populateLanguagesIntoList(element, languages) {
|
||||||
var html = '';
|
let html = '';
|
||||||
for (var i = 0; i < languages.length; i++) {
|
for (let i = 0; i < languages.length; i++) {
|
||||||
var culture = languages[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>';
|
html += `<label><input type="checkbox" is="emby-checkbox" class="chkSubtitleLanguage" data-lang="${culture.ThreeLetterISOLanguageName.toLowerCase()}" /><span>${culture.DisplayName}</span></label>`;
|
||||||
}
|
}
|
||||||
element.innerHTML = html;
|
element.innerHTML = html;
|
||||||
}
|
}
|
||||||
|
|
||||||
function populateCountries(select) {
|
function populateCountries(select) {
|
||||||
return ApiClient.getCountries().then(function(allCountries) {
|
return ApiClient.getCountries().then(allCountries => {
|
||||||
var html = '';
|
let html = '';
|
||||||
html += "<option value=''></option>";
|
html += "<option value=''></option>";
|
||||||
for (var i = 0; i < allCountries.length; i++) {
|
for (let i = 0; i < allCountries.length; i++) {
|
||||||
var culture = allCountries[i];
|
const culture = allCountries[i];
|
||||||
html += "<option value='" + culture.TwoLetterISORegionName + "'>" + culture.DisplayName + '</option>';
|
html += `<option value='${culture.TwoLetterISORegionName}'>${culture.DisplayName}</option>`;
|
||||||
}
|
}
|
||||||
select.innerHTML = html;
|
select.innerHTML = html;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function populateRefreshInterval(select) {
|
function populateRefreshInterval(select) {
|
||||||
var html = '';
|
let html = '';
|
||||||
html += "<option value='0'>" + globalize.translate('Never') + '</option>';
|
html += `<option value='0'>${globalize.translate('Never')}</option>`;
|
||||||
html += [30, 60, 90].map(function(val) {
|
html += [30, 60, 90].map(val => {
|
||||||
return "<option value='" + val + "'>" + globalize.translate('EveryNDays', val) + '</option>';
|
return `<option value='${val}'>${globalize.translate('EveryNDays', val)}</option>`;
|
||||||
}).join('');
|
}).join('');
|
||||||
select.innerHTML = html;
|
select.innerHTML = html;
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderMetadataReaders(page, plugins) {
|
function renderMetadataReaders(page, plugins) {
|
||||||
var html = '';
|
let html = '';
|
||||||
var elem = page.querySelector('.metadataReaders');
|
const elem = page.querySelector('.metadataReaders');
|
||||||
|
|
||||||
if (plugins.length < 1) return elem.innerHTML = '', elem.classList.add('hide'), !1;
|
if (plugins.length < 1) return elem.innerHTML = '', elem.classList.add('hide'), !1;
|
||||||
html += '<h3 class="checkboxListLabel">' + globalize.translate('LabelMetadataReaders') + '</h3>';
|
html += `<h3 class="checkboxListLabel">${globalize.translate('LabelMetadataReaders')}</h3>`;
|
||||||
html += '<div class="checkboxList paperList checkboxList-paperList">';
|
html += '<div class="checkboxList paperList checkboxList-paperList">';
|
||||||
for (var i = 0; i < plugins.length; i++) {
|
for (let i = 0; i < plugins.length; i++) {
|
||||||
var plugin = plugins[i];
|
const plugin = plugins[i];
|
||||||
html += '<div class="listItem localReaderOption sortableOption" data-pluginname="' + plugin.Name + '">';
|
html += `<div class="listItem localReaderOption sortableOption" data-pluginname="${plugin.Name}">`;
|
||||||
html += '<span class="listItemIcon material-icons live_tv"></span>';
|
html += '<span class="listItemIcon material-icons live_tv"></span>';
|
||||||
html += '<div class="listItemBody">';
|
html += '<div class="listItemBody">';
|
||||||
html += '<h3 class="listItemBodyText">';
|
html += '<h3 class="listItemBodyText">';
|
||||||
|
@ -65,14 +75,14 @@ define(['globalize', 'dom', 'emby-checkbox', 'emby-select', 'emby-input'], funct
|
||||||
html += '</h3>';
|
html += '</h3>';
|
||||||
html += '</div>';
|
html += '</div>';
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
html += '<button type="button" is="paper-icon-button-light" title="' + globalize.translate('ButtonUp') + '" class="btnSortableMoveUp btnSortable" data-pluginindex="' + i + '"><span class="material-icons keyboard_arrow_up"></span></button>';
|
html += `<button type="button" is="paper-icon-button-light" title="${globalize.translate('ButtonUp')}" class="btnSortableMoveUp btnSortable" data-pluginindex="${i}"><span class="material-icons keyboard_arrow_up"></span></button>`;
|
||||||
} else if (plugins.length > 1) {
|
} else if (plugins.length > 1) {
|
||||||
html += '<button type="button" is="paper-icon-button-light" title="' + globalize.translate('ButtonDown') + '" class="btnSortableMoveDown btnSortable" data-pluginindex="' + i + '"><span class="material-icons keyboard_arrow_down"></span></button>';
|
html += `<button type="button" is="paper-icon-button-light" title="${globalize.translate('ButtonDown')}" class="btnSortableMoveDown btnSortable" data-pluginindex="${i}"><span class="material-icons keyboard_arrow_down"></span></button>`;
|
||||||
}
|
}
|
||||||
html += '</div>';
|
html += '</div>';
|
||||||
}
|
}
|
||||||
html += '</div>';
|
html += '</div>';
|
||||||
html += '<div class="fieldDescription">' + globalize.translate('LabelMetadataReadersHelp') + '</div>';
|
html += `<div class="fieldDescription">${globalize.translate('LabelMetadataReadersHelp')}</div>`;
|
||||||
if (plugins.length < 2) {
|
if (plugins.length < 2) {
|
||||||
elem.classList.add('hide');
|
elem.classList.add('hide');
|
||||||
} else {
|
} else {
|
||||||
|
@ -83,25 +93,25 @@ define(['globalize', 'dom', 'emby-checkbox', 'emby-select', 'emby-input'], funct
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderMetadataSavers(page, metadataSavers) {
|
function renderMetadataSavers(page, metadataSavers) {
|
||||||
var html = '';
|
let html = '';
|
||||||
var elem = page.querySelector('.metadataSavers');
|
const elem = page.querySelector('.metadataSavers');
|
||||||
if (!metadataSavers.length) return elem.innerHTML = '', elem.classList.add('hide'), false;
|
if (!metadataSavers.length) return elem.innerHTML = '', elem.classList.add('hide'), false;
|
||||||
html += '<h3 class="checkboxListLabel">' + globalize.translate('LabelMetadataSavers') + '</h3>';
|
html += `<h3 class="checkboxListLabel">${globalize.translate('LabelMetadataSavers')}</h3>`;
|
||||||
html += '<div class="checkboxList paperList checkboxList-paperList">';
|
html += '<div class="checkboxList paperList checkboxList-paperList">';
|
||||||
for (var i = 0; i < metadataSavers.length; i++) {
|
for (let i = 0; i < metadataSavers.length; i++) {
|
||||||
var plugin = metadataSavers[i];
|
const plugin = metadataSavers[i];
|
||||||
html += '<label><input type="checkbox" data-defaultenabled="' + plugin.DefaultEnabled + '" is="emby-checkbox" class="chkMetadataSaver" data-pluginname="' + plugin.Name + '" ' + false + '><span>' + plugin.Name + '</span></label>';
|
html += `<label><input type="checkbox" data-defaultenabled="${plugin.DefaultEnabled}" is="emby-checkbox" class="chkMetadataSaver" data-pluginname="${plugin.Name}" ${false}><span>${plugin.Name}</span></label>`;
|
||||||
}
|
}
|
||||||
html += '</div>';
|
html += '</div>';
|
||||||
html += '<div class="fieldDescription" style="margin-top:.25em;">' + globalize.translate('LabelMetadataSaversHelp') + '</div>';
|
html += `<div class="fieldDescription" style="margin-top:.25em;">${globalize.translate('LabelMetadataSaversHelp')}</div>`;
|
||||||
elem.innerHTML = html;
|
elem.innerHTML = html;
|
||||||
elem.classList.remove('hide');
|
elem.classList.remove('hide');
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getMetadataFetchersForTypeHtml(availableTypeOptions, libraryOptionsForType) {
|
function getMetadataFetchersForTypeHtml(availableTypeOptions, libraryOptionsForType) {
|
||||||
var html = '';
|
let html = '';
|
||||||
var plugins = availableTypeOptions.MetadataFetchers;
|
let plugins = availableTypeOptions.MetadataFetchers;
|
||||||
|
|
||||||
plugins = getOrderedPlugins(plugins, libraryOptionsForType.MetadataFetcherOrder || []);
|
plugins = getOrderedPlugins(plugins, libraryOptionsForType.MetadataFetcherOrder || []);
|
||||||
if (!plugins.length) return html;
|
if (!plugins.length) return html;
|
||||||
|
@ -112,8 +122,8 @@ define(['globalize', 'dom', 'emby-checkbox', 'emby-select', 'emby-input'], funct
|
||||||
|
|
||||||
plugins.forEach((plugin, index) => {
|
plugins.forEach((plugin, index) => {
|
||||||
html += '<div class="listItem metadataFetcherItem sortableOption" data-pluginname="' + plugin.Name + '">';
|
html += '<div class="listItem metadataFetcherItem sortableOption" data-pluginname="' + plugin.Name + '">';
|
||||||
var isChecked = libraryOptionsForType.MetadataFetchers ? -1 !== libraryOptionsForType.MetadataFetchers.indexOf(plugin.Name) : plugin.DefaultEnabled;
|
const isChecked = libraryOptionsForType.MetadataFetchers ? libraryOptionsForType.MetadataFetchers.includes(plugin.Name) : plugin.DefaultEnabled;
|
||||||
var checkedHtml = isChecked ? ' checked="checked"' : '';
|
const checkedHtml = isChecked ? ' checked="checked"' : '';
|
||||||
html += '<label class="listItemCheckboxContainer"><input type="checkbox" is="emby-checkbox" class="chkMetadataFetcher" data-pluginname="' + plugin.Name + '" ' + checkedHtml + '><span></span></label>';
|
html += '<label class="listItemCheckboxContainer"><input type="checkbox" is="emby-checkbox" class="chkMetadataFetcher" data-pluginname="' + plugin.Name + '" ' + checkedHtml + '><span></span></label>';
|
||||||
html += '<div class="listItemBody">';
|
html += '<div class="listItemBody">';
|
||||||
html += '<h3 class="listItemBodyText">';
|
html += '<h3 class="listItemBodyText">';
|
||||||
|
@ -135,19 +145,19 @@ define(['globalize', 'dom', 'emby-checkbox', 'emby-select', 'emby-input'], funct
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTypeOptions(allOptions, type) {
|
function getTypeOptions(allOptions, type) {
|
||||||
var allTypeOptions = allOptions.TypeOptions || [];
|
const allTypeOptions = allOptions.TypeOptions || [];
|
||||||
for (var i = 0; i < allTypeOptions.length; i++) {
|
for (let i = 0; i < allTypeOptions.length; i++) {
|
||||||
var typeOptions = allTypeOptions[i];
|
const typeOptions = allTypeOptions[i];
|
||||||
if (typeOptions.Type === type) return typeOptions;
|
if (typeOptions.Type === type) return typeOptions;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderMetadataFetchers(page, availableOptions, libraryOptions) {
|
function renderMetadataFetchers(page, availableOptions, libraryOptions) {
|
||||||
var html = '';
|
let html = '';
|
||||||
var elem = page.querySelector('.metadataFetchers');
|
const elem = page.querySelector('.metadataFetchers');
|
||||||
for (var i = 0; i < availableOptions.TypeOptions.length; i++) {
|
for (let i = 0; i < availableOptions.TypeOptions.length; i++) {
|
||||||
var availableTypeOptions = availableOptions.TypeOptions[i];
|
const availableTypeOptions = availableOptions.TypeOptions[i];
|
||||||
html += getMetadataFetchersForTypeHtml(availableTypeOptions, getTypeOptions(libraryOptions, availableTypeOptions.Type) || {});
|
html += getMetadataFetchersForTypeHtml(availableTypeOptions, getTypeOptions(libraryOptions, availableTypeOptions.Type) || {});
|
||||||
}
|
}
|
||||||
elem.innerHTML = html;
|
elem.innerHTML = html;
|
||||||
|
@ -166,41 +176,41 @@ define(['globalize', 'dom', 'emby-checkbox', 'emby-select', 'emby-input'], funct
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderSubtitleFetchers(page, availableOptions, libraryOptions) {
|
function renderSubtitleFetchers(page, availableOptions, libraryOptions) {
|
||||||
var html = '';
|
let html = '';
|
||||||
var elem = page.querySelector('.subtitleFetchers');
|
const elem = page.querySelector('.subtitleFetchers');
|
||||||
|
|
||||||
var plugins = availableOptions.SubtitleFetchers;
|
let plugins = availableOptions.SubtitleFetchers;
|
||||||
plugins = getOrderedPlugins(plugins, libraryOptions.SubtitleFetcherOrder || []);
|
plugins = getOrderedPlugins(plugins, libraryOptions.SubtitleFetcherOrder || []);
|
||||||
if (!plugins.length) return html;
|
if (!plugins.length) return html;
|
||||||
|
|
||||||
html += '<h3 class="checkboxListLabel">' + globalize.translate('LabelSubtitleDownloaders') + '</h3>';
|
html += `<h3 class="checkboxListLabel">${globalize.translate('LabelSubtitleDownloaders')}</h3>`;
|
||||||
html += '<div class="checkboxList paperList checkboxList-paperList">';
|
html += '<div class="checkboxList paperList checkboxList-paperList">';
|
||||||
for (var i = 0; i < plugins.length; i++) {
|
for (let i = 0; i < plugins.length; i++) {
|
||||||
var plugin = plugins[i];
|
const plugin = plugins[i];
|
||||||
html += '<div class="listItem subtitleFetcherItem sortableOption" data-pluginname="' + plugin.Name + '">';
|
html += `<div class="listItem subtitleFetcherItem sortableOption" data-pluginname="${plugin.Name}">`;
|
||||||
var isChecked = libraryOptions.DisabledSubtitleFetchers ? -1 === libraryOptions.DisabledSubtitleFetchers.indexOf(plugin.Name) : plugin.DefaultEnabled;
|
const isChecked = libraryOptions.DisabledSubtitleFetchers ? !libraryOptions.DisabledSubtitleFetchers.includes(plugin.Name) : plugin.DefaultEnabled;
|
||||||
var checkedHtml = isChecked ? ' checked="checked"' : '';
|
const checkedHtml = isChecked ? ' checked="checked"' : '';
|
||||||
html += '<label class="listItemCheckboxContainer"><input type="checkbox" is="emby-checkbox" class="chkSubtitleFetcher" data-pluginname="' + plugin.Name + '" ' + checkedHtml + '><span></span></label>';
|
html += `<label class="listItemCheckboxContainer"><input type="checkbox" is="emby-checkbox" class="chkSubtitleFetcher" data-pluginname="${plugin.Name}" ${checkedHtml}><span></span></label>`;
|
||||||
html += '<div class="listItemBody">';
|
html += '<div class="listItemBody">';
|
||||||
html += '<h3 class="listItemBodyText">';
|
html += '<h3 class="listItemBodyText">';
|
||||||
html += plugin.Name;
|
html += plugin.Name;
|
||||||
html += '</h3>';
|
html += '</h3>';
|
||||||
html += '</div>';
|
html += '</div>';
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
html += '<button type="button" is="paper-icon-button-light" title="' + globalize.translate('ButtonUp') + '" class="btnSortableMoveUp btnSortable" data-pluginindex="' + i + '"><span class="material-icons keyboard_arrow_up"></span></button>';
|
html += `<button type="button" is="paper-icon-button-light" title="${globalize.translate('ButtonUp')}" class="btnSortableMoveUp btnSortable" data-pluginindex="${i}"><span class="material-icons keyboard_arrow_up"></span></button>`;
|
||||||
} else if (plugins.length > 1) {
|
} else if (plugins.length > 1) {
|
||||||
html += '<button type="button" is="paper-icon-button-light" title="' + globalize.translate('ButtonDown') + '" class="btnSortableMoveDown btnSortable" data-pluginindex="' + i + '"><span class="material-icons keyboard_arrow_down"></span></button>';
|
html += `<button type="button" is="paper-icon-button-light" title="${globalize.translate('ButtonDown')}" class="btnSortableMoveDown btnSortable" data-pluginindex="${i}"><span class="material-icons keyboard_arrow_down"></span></button>`;
|
||||||
}
|
}
|
||||||
html += '</div>';
|
html += '</div>';
|
||||||
}
|
}
|
||||||
html += '</div>';
|
html += '</div>';
|
||||||
html += '<div class="fieldDescription">' + globalize.translate('SubtitleDownloadersHelp') + '</div>';
|
html += `<div class="fieldDescription">${globalize.translate('SubtitleDownloadersHelp')}</div>`;
|
||||||
elem.innerHTML = html;
|
elem.innerHTML = html;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getImageFetchersForTypeHtml(availableTypeOptions, libraryOptionsForType) {
|
function getImageFetchersForTypeHtml(availableTypeOptions, libraryOptionsForType) {
|
||||||
var html = '';
|
let html = '';
|
||||||
var plugins = availableTypeOptions.ImageFetchers;
|
let plugins = availableTypeOptions.ImageFetchers;
|
||||||
|
|
||||||
plugins = getOrderedPlugins(plugins, libraryOptionsForType.ImageFetcherOrder || []);
|
plugins = getOrderedPlugins(plugins, libraryOptionsForType.ImageFetcherOrder || []);
|
||||||
if (!plugins.length) return html;
|
if (!plugins.length) return html;
|
||||||
|
@ -208,17 +218,17 @@ define(['globalize', 'dom', 'emby-checkbox', 'emby-select', 'emby-input'], funct
|
||||||
html += '<div class="imageFetcher" data-type="' + availableTypeOptions.Type + '">';
|
html += '<div class="imageFetcher" data-type="' + availableTypeOptions.Type + '">';
|
||||||
html += '<div class="flex align-items-center" style="margin:1.5em 0 .5em;">';
|
html += '<div class="flex align-items-center" style="margin:1.5em 0 .5em;">';
|
||||||
html += '<h3 class="checkboxListLabel" style="margin:0;">' + globalize.translate('HeaderTypeImageFetchers', availableTypeOptions.Type) + '</h3>';
|
html += '<h3 class="checkboxListLabel" style="margin:0;">' + globalize.translate('HeaderTypeImageFetchers', availableTypeOptions.Type) + '</h3>';
|
||||||
var supportedImageTypes = availableTypeOptions.SupportedImageTypes || [];
|
const supportedImageTypes = availableTypeOptions.SupportedImageTypes || [];
|
||||||
if (supportedImageTypes.length > 1 || 1 === supportedImageTypes.length && 'Primary' !== supportedImageTypes[0]) {
|
if (supportedImageTypes.length > 1 || 1 === supportedImageTypes.length && 'Primary' !== supportedImageTypes[0]) {
|
||||||
html += '<button is="emby-button" class="raised btnImageOptionsForType" type="button" style="margin-left:1.5em;font-size:90%;"><span>' + globalize.translate('HeaderFetcherSettings') + '</span></button>';
|
html += '<button is="emby-button" class="raised btnImageOptionsForType" type="button" style="margin-left:1.5em;font-size:90%;"><span>' + globalize.translate('HeaderFetcherSettings') + '</span></button>';
|
||||||
}
|
}
|
||||||
html += '</div>';
|
html += '</div>';
|
||||||
html += '<div class="checkboxList paperList checkboxList-paperList">';
|
html += '<div class="checkboxList paperList checkboxList-paperList">';
|
||||||
for (var i = 0; i < plugins.length; i++) {
|
for (let i = 0; i < plugins.length; i++) {
|
||||||
var plugin = plugins[i];
|
const plugin = plugins[i];
|
||||||
html += '<div class="listItem imageFetcherItem sortableOption" data-pluginname="' + plugin.Name + '">';
|
html += '<div class="listItem imageFetcherItem sortableOption" data-pluginname="' + plugin.Name + '">';
|
||||||
var isChecked = libraryOptionsForType.ImageFetchers ? -1 !== libraryOptionsForType.ImageFetchers.indexOf(plugin.Name) : plugin.DefaultEnabled;
|
const isChecked = libraryOptionsForType.ImageFetchers ? libraryOptionsForType.ImageFetchers.includes(plugin.Name) : plugin.DefaultEnabled;
|
||||||
var checkedHtml = isChecked ? ' checked="checked"' : '';
|
const checkedHtml = isChecked ? ' checked="checked"' : '';
|
||||||
html += '<label class="listItemCheckboxContainer"><input type="checkbox" is="emby-checkbox" class="chkImageFetcher" data-pluginname="' + plugin.Name + '" ' + checkedHtml + '><span></span></label>';
|
html += '<label class="listItemCheckboxContainer"><input type="checkbox" is="emby-checkbox" class="chkImageFetcher" data-pluginname="' + plugin.Name + '" ' + checkedHtml + '><span></span></label>';
|
||||||
html += '<div class="listItemBody">';
|
html += '<div class="listItemBody">';
|
||||||
html += '<h3 class="listItemBodyText">';
|
html += '<h3 class="listItemBodyText">';
|
||||||
|
@ -239,10 +249,10 @@ define(['globalize', 'dom', 'emby-checkbox', 'emby-select', 'emby-input'], funct
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderImageFetchers(page, availableOptions, libraryOptions) {
|
function renderImageFetchers(page, availableOptions, libraryOptions) {
|
||||||
var html = '';
|
let html = '';
|
||||||
var elem = page.querySelector('.imageFetchers');
|
const elem = page.querySelector('.imageFetchers');
|
||||||
for (var i = 0; i < availableOptions.TypeOptions.length; i++) {
|
for (let i = 0; i < availableOptions.TypeOptions.length; i++) {
|
||||||
var availableTypeOptions = availableOptions.TypeOptions[i];
|
const availableTypeOptions = availableOptions.TypeOptions[i];
|
||||||
html += getImageFetchersForTypeHtml(availableTypeOptions, getTypeOptions(libraryOptions, availableTypeOptions.Type) || {});
|
html += getImageFetchersForTypeHtml(availableTypeOptions, getTypeOptions(libraryOptions, availableTypeOptions.Type) || {});
|
||||||
}
|
}
|
||||||
elem.innerHTML = html;
|
elem.innerHTML = html;
|
||||||
|
@ -259,11 +269,11 @@ define(['globalize', 'dom', 'emby-checkbox', 'emby-select', 'emby-input'], funct
|
||||||
}
|
}
|
||||||
|
|
||||||
function populateMetadataSettings(parent, contentType, isNewLibrary) {
|
function populateMetadataSettings(parent, contentType, isNewLibrary) {
|
||||||
var isNewLibrary = parent.classList.contains('newlibrary');
|
isNewLibrary = parent.classList.contains('newlibrary');
|
||||||
return ApiClient.getJSON(ApiClient.getUrl('Libraries/AvailableOptions', {
|
return ApiClient.getJSON(ApiClient.getUrl('Libraries/AvailableOptions', {
|
||||||
LibraryContentType: contentType,
|
LibraryContentType: contentType,
|
||||||
IsNewLibrary: isNewLibrary
|
IsNewLibrary: isNewLibrary
|
||||||
})).then(function(availableOptions) {
|
})).then(availableOptions => {
|
||||||
currentAvailableOptions = availableOptions;
|
currentAvailableOptions = availableOptions;
|
||||||
parent.availableOptions = availableOptions;
|
parent.availableOptions = availableOptions;
|
||||||
renderMetadataSavers(parent, availableOptions.MetadataSavers);
|
renderMetadataSavers(parent, availableOptions.MetadataSavers);
|
||||||
|
@ -272,14 +282,14 @@ define(['globalize', 'dom', 'emby-checkbox', 'emby-select', 'emby-input'], funct
|
||||||
renderSubtitleFetchers(parent, availableOptions, {});
|
renderSubtitleFetchers(parent, availableOptions, {});
|
||||||
renderImageFetchers(parent, availableOptions, {});
|
renderImageFetchers(parent, availableOptions, {});
|
||||||
availableOptions.SubtitleFetchers.length ? parent.querySelector('.subtitleDownloadSettings').classList.remove('hide') : parent.querySelector('.subtitleDownloadSettings').classList.add('hide');
|
availableOptions.SubtitleFetchers.length ? parent.querySelector('.subtitleDownloadSettings').classList.remove('hide') : parent.querySelector('.subtitleDownloadSettings').classList.add('hide');
|
||||||
}).catch(function() {
|
}).catch(() => {
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function adjustSortableListElement(elem) {
|
function adjustSortableListElement(elem) {
|
||||||
var btnSortable = elem.querySelector('.btnSortable');
|
const btnSortable = elem.querySelector('.btnSortable');
|
||||||
var inner = btnSortable.querySelector('.material-icons');
|
const inner = btnSortable.querySelector('.material-icons');
|
||||||
if (elem.previousSibling) {
|
if (elem.previousSibling) {
|
||||||
btnSortable.title = globalize.translate('ButtonUp');
|
btnSortable.title = globalize.translate('ButtonUp');
|
||||||
btnSortable.classList.add('btnSortableMoveUp');
|
btnSortable.classList.add('btnSortableMoveUp');
|
||||||
|
@ -296,22 +306,22 @@ define(['globalize', 'dom', 'emby-checkbox', 'emby-select', 'emby-input'], funct
|
||||||
}
|
}
|
||||||
|
|
||||||
function showImageOptionsForType(type) {
|
function showImageOptionsForType(type) {
|
||||||
require(['imageoptionseditor'], function(ImageOptionsEditor) {
|
import('imageoptionseditor').then(({default: ImageOptionsEditor}) => {
|
||||||
var typeOptions = getTypeOptions(currentLibraryOptions, type);
|
let typeOptions = getTypeOptions(currentLibraryOptions, type);
|
||||||
if (!typeOptions) {
|
if (!typeOptions) {
|
||||||
typeOptions = {
|
typeOptions = {
|
||||||
Type: type
|
Type: type
|
||||||
};
|
};
|
||||||
currentLibraryOptions.TypeOptions.push(typeOptions);
|
currentLibraryOptions.TypeOptions.push(typeOptions);
|
||||||
}
|
}
|
||||||
var availableOptions = getTypeOptions(currentAvailableOptions || {}, type);
|
const availableOptions = getTypeOptions(currentAvailableOptions || {}, type);
|
||||||
var imageOptionsEditor = new ImageOptionsEditor();
|
const imageOptionsEditor = new ImageOptionsEditor();
|
||||||
imageOptionsEditor.show(type, typeOptions, availableOptions);
|
imageOptionsEditor.show(type, typeOptions, availableOptions);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function onImageFetchersContainerClick(e) {
|
function onImageFetchersContainerClick(e) {
|
||||||
var btnImageOptionsForType = dom.parentWithClass(e.target, 'btnImageOptionsForType');
|
const btnImageOptionsForType = dom.parentWithClass(e.target, 'btnImageOptionsForType');
|
||||||
if (btnImageOptionsForType) {
|
if (btnImageOptionsForType) {
|
||||||
return void showImageOptionsForType(dom.parentWithClass(btnImageOptionsForType, 'imageFetcher').getAttribute('data-type'));
|
return void showImageOptionsForType(dom.parentWithClass(btnImageOptionsForType, 'imageFetcher').getAttribute('data-type'));
|
||||||
}
|
}
|
||||||
|
@ -319,18 +329,18 @@ define(['globalize', 'dom', 'emby-checkbox', 'emby-select', 'emby-input'], funct
|
||||||
}
|
}
|
||||||
|
|
||||||
function onSortableContainerClick(e) {
|
function onSortableContainerClick(e) {
|
||||||
var btnSortable = dom.parentWithClass(e.target, 'btnSortable');
|
const btnSortable = dom.parentWithClass(e.target, 'btnSortable');
|
||||||
if (btnSortable) {
|
if (btnSortable) {
|
||||||
var li = dom.parentWithClass(btnSortable, 'sortableOption');
|
const li = dom.parentWithClass(btnSortable, 'sortableOption');
|
||||||
var list = dom.parentWithClass(li, 'paperList');
|
const list = dom.parentWithClass(li, 'paperList');
|
||||||
if (btnSortable.classList.contains('btnSortableMoveDown')) {
|
if (btnSortable.classList.contains('btnSortableMoveDown')) {
|
||||||
var next = li.nextSibling;
|
const next = li.nextSibling;
|
||||||
if (next) {
|
if (next) {
|
||||||
li.parentNode.removeChild(li);
|
li.parentNode.removeChild(li);
|
||||||
next.parentNode.insertBefore(li, next.nextSibling);
|
next.parentNode.insertBefore(li, next.nextSibling);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
var prev = li.previousSibling;
|
const prev = li.previousSibling;
|
||||||
if (prev) {
|
if (prev) {
|
||||||
li.parentNode.removeChild(li);
|
li.parentNode.removeChild(li);
|
||||||
prev.parentNode.insertBefore(li, prev);
|
prev.parentNode.insertBefore(li, prev);
|
||||||
|
@ -347,41 +357,38 @@ define(['globalize', 'dom', 'emby-checkbox', 'emby-select', 'emby-input'], funct
|
||||||
parent.querySelector('.imageFetchers').addEventListener('click', onImageFetchersContainerClick);
|
parent.querySelector('.imageFetchers').addEventListener('click', onImageFetchersContainerClick);
|
||||||
}
|
}
|
||||||
|
|
||||||
function embed(parent, contentType, libraryOptions) {
|
export function embed(parent, contentType, libraryOptions) {
|
||||||
currentLibraryOptions = {
|
currentLibraryOptions = {
|
||||||
TypeOptions: []
|
TypeOptions: []
|
||||||
};
|
};
|
||||||
currentAvailableOptions = null;
|
currentAvailableOptions = null;
|
||||||
var isNewLibrary = null === libraryOptions;
|
const isNewLibrary = null === libraryOptions;
|
||||||
isNewLibrary && parent.classList.add('newlibrary');
|
isNewLibrary && parent.classList.add('newlibrary');
|
||||||
return new Promise(function(resolve, reject) {
|
return new Promise((resolve) => {
|
||||||
var xhr = new XMLHttpRequest;
|
//TODO: remove require
|
||||||
xhr.open('GET', 'components/libraryoptionseditor/libraryoptionseditor.template.html', true);
|
require(['text!./components/libraryoptionseditor/libraryoptionseditor.template.html'], function (template) {
|
||||||
xhr.onload = function(e) {
|
|
||||||
var template = this.response;
|
|
||||||
parent.innerHTML = globalize.translateDocument(template);
|
parent.innerHTML = globalize.translateDocument(template);
|
||||||
populateRefreshInterval(parent.querySelector('#selectAutoRefreshInterval'));
|
populateRefreshInterval(parent.querySelector('#selectAutoRefreshInterval'));
|
||||||
var promises = [populateLanguages(parent), populateCountries(parent.querySelector('#selectCountry'))];
|
const promises = [populateLanguages(parent), populateCountries(parent.querySelector('#selectCountry'))];
|
||||||
Promise.all(promises).then(function() {
|
Promise.all(promises).then(() => {
|
||||||
return setContentType(parent, contentType).then(function() {
|
return setContentType(parent, contentType).then(() => {
|
||||||
libraryOptions && setLibraryOptions(parent, libraryOptions);
|
libraryOptions && setLibraryOptions(parent, libraryOptions);
|
||||||
bindEvents(parent);
|
bindEvents(parent);
|
||||||
resolve();
|
resolve();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
});
|
||||||
xhr.send();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function setAdvancedVisible(parent, visible) {
|
export function setAdvancedVisible(parent, visible) {
|
||||||
var elems = parent.querySelectorAll('.advanced');
|
const elems = parent.querySelectorAll('.advanced');
|
||||||
for (var i = 0; i < elems.length; i++) {
|
for (let i = 0; i < elems.length; i++) {
|
||||||
visible ? elems[i].classList.remove('advancedHide') : elems[i].classList.add('advancedHide');
|
visible ? elems[i].classList.remove('advancedHide') : elems[i].classList.add('advancedHide');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function setContentType(parent, contentType) {
|
export function setContentType(parent, contentType) {
|
||||||
if (contentType === 'homevideos' || contentType === 'photos') {
|
if (contentType === 'homevideos' || contentType === 'photos') {
|
||||||
parent.querySelector('.chkEnablePhotosContainer').classList.remove('hide');
|
parent.querySelector('.chkEnablePhotosContainer').classList.remove('hide');
|
||||||
} else {
|
} else {
|
||||||
|
@ -422,47 +429,47 @@ define(['globalize', 'dom', 'emby-checkbox', 'emby-select', 'emby-input'], funct
|
||||||
}
|
}
|
||||||
|
|
||||||
function setSubtitleFetchersIntoOptions(parent, options) {
|
function setSubtitleFetchersIntoOptions(parent, options) {
|
||||||
options.DisabledSubtitleFetchers = Array.prototype.map.call(Array.prototype.filter.call(parent.querySelectorAll('.chkSubtitleFetcher'), function(elem) {
|
options.DisabledSubtitleFetchers = Array.prototype.map.call(Array.prototype.filter.call(parent.querySelectorAll('.chkSubtitleFetcher'), elem => {
|
||||||
return !elem.checked;
|
return !elem.checked;
|
||||||
}), function(elem) {
|
}), elem => {
|
||||||
return elem.getAttribute('data-pluginname');
|
return elem.getAttribute('data-pluginname');
|
||||||
});
|
});
|
||||||
|
|
||||||
options.SubtitleFetcherOrder = Array.prototype.map.call(parent.querySelectorAll('.subtitleFetcherItem'), function(elem) {
|
options.SubtitleFetcherOrder = Array.prototype.map.call(parent.querySelectorAll('.subtitleFetcherItem'), elem => {
|
||||||
return elem.getAttribute('data-pluginname');
|
return elem.getAttribute('data-pluginname');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function setMetadataFetchersIntoOptions(parent, options) {
|
function setMetadataFetchersIntoOptions(parent, options) {
|
||||||
var sections = parent.querySelectorAll('.metadataFetcher');
|
const sections = parent.querySelectorAll('.metadataFetcher');
|
||||||
for (var i = 0; i < sections.length; i++) {
|
for (let i = 0; i < sections.length; i++) {
|
||||||
var section = sections[i];
|
const section = sections[i];
|
||||||
var type = section.getAttribute('data-type');
|
const type = section.getAttribute('data-type');
|
||||||
var typeOptions = getTypeOptions(options, type);
|
let typeOptions = getTypeOptions(options, type);
|
||||||
if (!typeOptions) {
|
if (!typeOptions) {
|
||||||
typeOptions = {
|
typeOptions = {
|
||||||
Type: type
|
Type: type
|
||||||
};
|
};
|
||||||
options.TypeOptions.push(typeOptions);
|
options.TypeOptions.push(typeOptions);
|
||||||
}
|
}
|
||||||
typeOptions.MetadataFetchers = Array.prototype.map.call(Array.prototype.filter.call(section.querySelectorAll('.chkMetadataFetcher'), function(elem) {
|
typeOptions.MetadataFetchers = Array.prototype.map.call(Array.prototype.filter.call(section.querySelectorAll('.chkMetadataFetcher'), elem => {
|
||||||
return elem.checked;
|
return elem.checked;
|
||||||
}), function(elem) {
|
}), elem => {
|
||||||
return elem.getAttribute('data-pluginname');
|
return elem.getAttribute('data-pluginname');
|
||||||
});
|
});
|
||||||
|
|
||||||
typeOptions.MetadataFetcherOrder = Array.prototype.map.call(section.querySelectorAll('.metadataFetcherItem'), function(elem) {
|
typeOptions.MetadataFetcherOrder = Array.prototype.map.call(section.querySelectorAll('.metadataFetcherItem'), elem => {
|
||||||
return elem.getAttribute('data-pluginname');
|
return elem.getAttribute('data-pluginname');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function setImageFetchersIntoOptions(parent, options) {
|
function setImageFetchersIntoOptions(parent, options) {
|
||||||
var sections = parent.querySelectorAll('.imageFetcher');
|
const sections = parent.querySelectorAll('.imageFetcher');
|
||||||
for (var i = 0; i < sections.length; i++) {
|
for (let i = 0; i < sections.length; i++) {
|
||||||
var section = sections[i];
|
const section = sections[i];
|
||||||
var type = section.getAttribute('data-type');
|
const type = section.getAttribute('data-type');
|
||||||
var typeOptions = getTypeOptions(options, type);
|
let typeOptions = getTypeOptions(options, type);
|
||||||
if (!typeOptions) {
|
if (!typeOptions) {
|
||||||
typeOptions = {
|
typeOptions = {
|
||||||
Type: type
|
Type: type
|
||||||
|
@ -470,23 +477,23 @@ define(['globalize', 'dom', 'emby-checkbox', 'emby-select', 'emby-input'], funct
|
||||||
options.TypeOptions.push(typeOptions);
|
options.TypeOptions.push(typeOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
typeOptions.ImageFetchers = Array.prototype.map.call(Array.prototype.filter.call(section.querySelectorAll('.chkImageFetcher'), function(elem) {
|
typeOptions.ImageFetchers = Array.prototype.map.call(Array.prototype.filter.call(section.querySelectorAll('.chkImageFetcher'), elem => {
|
||||||
return elem.checked;
|
return elem.checked;
|
||||||
}), function(elem) {
|
}), elem => {
|
||||||
return elem.getAttribute('data-pluginname');
|
return elem.getAttribute('data-pluginname');
|
||||||
});
|
});
|
||||||
|
|
||||||
typeOptions.ImageFetcherOrder = Array.prototype.map.call(section.querySelectorAll('.imageFetcherItem'), function(elem) {
|
typeOptions.ImageFetcherOrder = Array.prototype.map.call(section.querySelectorAll('.imageFetcherItem'), elem => {
|
||||||
return elem.getAttribute('data-pluginname');
|
return elem.getAttribute('data-pluginname');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function setImageOptionsIntoOptions(parent, options) {
|
function setImageOptionsIntoOptions(options) {
|
||||||
var originalTypeOptions = (currentLibraryOptions || {}).TypeOptions || [];
|
const originalTypeOptions = (currentLibraryOptions || {}).TypeOptions || [];
|
||||||
for (var i = 0; i < originalTypeOptions.length; i++) {
|
for (let i = 0; i < originalTypeOptions.length; i++) {
|
||||||
var originalTypeOption = originalTypeOptions[i];
|
const originalTypeOption = originalTypeOptions[i];
|
||||||
var typeOptions = getTypeOptions(options, originalTypeOption.Type);
|
let typeOptions = getTypeOptions(options, originalTypeOption.Type);
|
||||||
|
|
||||||
if (!typeOptions) {
|
if (!typeOptions) {
|
||||||
typeOptions = {
|
typeOptions = {
|
||||||
|
@ -498,8 +505,8 @@ define(['globalize', 'dom', 'emby-checkbox', 'emby-select', 'emby-input'], funct
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getLibraryOptions(parent) {
|
export function getLibraryOptions(parent) {
|
||||||
var options = {
|
const options = {
|
||||||
EnableArchiveMediaFiles: false,
|
EnableArchiveMediaFiles: false,
|
||||||
EnablePhotos: parent.querySelector('.chkEnablePhotos').checked,
|
EnablePhotos: parent.querySelector('.chkEnablePhotos').checked,
|
||||||
EnableRealtimeMonitor: parent.querySelector('.chkEnableRealtimeMonitor').checked,
|
EnableRealtimeMonitor: parent.querySelector('.chkEnableRealtimeMonitor').checked,
|
||||||
|
@ -520,39 +527,39 @@ define(['globalize', 'dom', 'emby-checkbox', 'emby-select', 'emby-input'], funct
|
||||||
SkipSubtitlesIfAudioTrackMatches: parent.querySelector('#chkSkipIfAudioTrackPresent').checked,
|
SkipSubtitlesIfAudioTrackMatches: parent.querySelector('#chkSkipIfAudioTrackPresent').checked,
|
||||||
SaveSubtitlesWithMedia: parent.querySelector('#chkSaveSubtitlesLocally').checked,
|
SaveSubtitlesWithMedia: parent.querySelector('#chkSaveSubtitlesLocally').checked,
|
||||||
RequirePerfectSubtitleMatch: parent.querySelector('#chkRequirePerfectMatch').checked,
|
RequirePerfectSubtitleMatch: parent.querySelector('#chkRequirePerfectMatch').checked,
|
||||||
MetadataSavers: Array.prototype.map.call(Array.prototype.filter.call(parent.querySelectorAll('.chkMetadataSaver'), function(elem) {
|
MetadataSavers: Array.prototype.map.call(Array.prototype.filter.call(parent.querySelectorAll('.chkMetadataSaver'), elem => {
|
||||||
return elem.checked;
|
return elem.checked;
|
||||||
}), function(elem) {
|
}), elem => {
|
||||||
return elem.getAttribute('data-pluginname');
|
return elem.getAttribute('data-pluginname');
|
||||||
}),
|
}),
|
||||||
TypeOptions: []
|
TypeOptions: []
|
||||||
};
|
};
|
||||||
|
|
||||||
options.LocalMetadataReaderOrder = Array.prototype.map.call(parent.querySelectorAll('.localReaderOption'), function(elem) {
|
options.LocalMetadataReaderOrder = Array.prototype.map.call(parent.querySelectorAll('.localReaderOption'), elem => {
|
||||||
return elem.getAttribute('data-pluginname');
|
return elem.getAttribute('data-pluginname');
|
||||||
});
|
});
|
||||||
options.SubtitleDownloadLanguages = Array.prototype.map.call(Array.prototype.filter.call(parent.querySelectorAll('.chkSubtitleLanguage'), function(elem) {
|
options.SubtitleDownloadLanguages = Array.prototype.map.call(Array.prototype.filter.call(parent.querySelectorAll('.chkSubtitleLanguage'), elem => {
|
||||||
return elem.checked;
|
return elem.checked;
|
||||||
}), function(elem) {
|
}), elem => {
|
||||||
return elem.getAttribute('data-lang');
|
return elem.getAttribute('data-lang');
|
||||||
});
|
});
|
||||||
setSubtitleFetchersIntoOptions(parent, options);
|
setSubtitleFetchersIntoOptions(parent, options);
|
||||||
setMetadataFetchersIntoOptions(parent, options);
|
setMetadataFetchersIntoOptions(parent, options);
|
||||||
setImageFetchersIntoOptions(parent, options);
|
setImageFetchersIntoOptions(parent, options);
|
||||||
setImageOptionsIntoOptions(parent, options);
|
setImageOptionsIntoOptions(options);
|
||||||
|
|
||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getOrderedPlugins(plugins, configuredOrder) {
|
function getOrderedPlugins(plugins, configuredOrder) {
|
||||||
plugins = plugins.slice(0);
|
plugins = plugins.slice(0);
|
||||||
plugins.sort(function(a, b) {
|
plugins.sort((a, b) => {
|
||||||
return a = configuredOrder.indexOf(a.Name), b = configuredOrder.indexOf(b.Name), a < b ? -1 : a > b ? 1 : 0;
|
return a = configuredOrder.indexOf(a.Name), b = configuredOrder.indexOf(b.Name), a < b ? -1 : a > b ? 1 : 0;
|
||||||
});
|
});
|
||||||
return plugins;
|
return plugins;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setLibraryOptions(parent, options) {
|
export function setLibraryOptions(parent, options) {
|
||||||
currentLibraryOptions = options;
|
currentLibraryOptions = options;
|
||||||
currentAvailableOptions = parent.availableOptions;
|
currentAvailableOptions = parent.availableOptions;
|
||||||
parent.querySelector('#selectLanguage').value = options.PreferredMetadataLanguage || '';
|
parent.querySelector('#selectLanguage').value = options.PreferredMetadataLanguage || '';
|
||||||
|
@ -573,11 +580,11 @@ define(['globalize', 'dom', 'emby-checkbox', 'emby-select', 'emby-input'], funct
|
||||||
parent.querySelector('#chkSaveSubtitlesLocally').checked = options.SaveSubtitlesWithMedia;
|
parent.querySelector('#chkSaveSubtitlesLocally').checked = options.SaveSubtitlesWithMedia;
|
||||||
parent.querySelector('#chkSkipIfAudioTrackPresent').checked = options.SkipSubtitlesIfAudioTrackMatches;
|
parent.querySelector('#chkSkipIfAudioTrackPresent').checked = options.SkipSubtitlesIfAudioTrackMatches;
|
||||||
parent.querySelector('#chkRequirePerfectMatch').checked = options.RequirePerfectSubtitleMatch;
|
parent.querySelector('#chkRequirePerfectMatch').checked = options.RequirePerfectSubtitleMatch;
|
||||||
Array.prototype.forEach.call(parent.querySelectorAll('.chkMetadataSaver'), function(elem) {
|
Array.prototype.forEach.call(parent.querySelectorAll('.chkMetadataSaver'), elem => {
|
||||||
elem.checked = options.MetadataSavers ? -1 !== options.MetadataSavers.indexOf(elem.getAttribute('data-pluginname')) : 'true' === elem.getAttribute('data-defaultenabled');
|
elem.checked = options.MetadataSavers ? options.MetadataSavers.includes(elem.getAttribute('data-pluginname')) : 'true' === elem.getAttribute('data-defaultenabled');
|
||||||
});
|
});
|
||||||
Array.prototype.forEach.call(parent.querySelectorAll('.chkSubtitleLanguage'), function(elem) {
|
Array.prototype.forEach.call(parent.querySelectorAll('.chkSubtitleLanguage'), elem => {
|
||||||
elem.checked = !!options.SubtitleDownloadLanguages && -1 !== options.SubtitleDownloadLanguages.indexOf(elem.getAttribute('data-lang'));
|
elem.checked = !!options.SubtitleDownloadLanguages && options.SubtitleDownloadLanguages.includes(elem.getAttribute('data-lang'));
|
||||||
});
|
});
|
||||||
renderMetadataReaders(parent, getOrderedPlugins(parent.availableOptions.MetadataReaders, options.LocalMetadataReaderOrder || []));
|
renderMetadataReaders(parent, getOrderedPlugins(parent.availableOptions.MetadataReaders, options.LocalMetadataReaderOrder || []));
|
||||||
renderMetadataFetchers(parent, parent.availableOptions, options);
|
renderMetadataFetchers(parent, parent.availableOptions, options);
|
||||||
|
@ -585,14 +592,14 @@ define(['globalize', 'dom', 'emby-checkbox', 'emby-select', 'emby-input'], funct
|
||||||
renderSubtitleFetchers(parent, parent.availableOptions, options);
|
renderSubtitleFetchers(parent, parent.availableOptions, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
var currentLibraryOptions;
|
let currentLibraryOptions;
|
||||||
var currentAvailableOptions;
|
let currentAvailableOptions;
|
||||||
|
|
||||||
return {
|
/* eslint-enable indent */
|
||||||
|
export default {
|
||||||
embed: embed,
|
embed: embed,
|
||||||
setContentType: setContentType,
|
setContentType: setContentType,
|
||||||
getLibraryOptions: getLibraryOptions,
|
getLibraryOptions: getLibraryOptions,
|
||||||
setLibraryOptions: setLibraryOptions,
|
setLibraryOptions: setLibraryOptions,
|
||||||
setAdvancedVisible: setAdvancedVisible
|
setAdvancedVisible: setAdvancedVisible
|
||||||
};
|
};
|
||||||
});
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue