Merge branch 'es6' into migrate-to-ES6-13

This commit is contained in:
Cameron 2020-07-22 20:40:56 +01:00 committed by GitHub
commit d147184ea9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
24 changed files with 472 additions and 416 deletions

View File

@ -122,6 +122,8 @@
"src/components/maintabsmanager.js",
"src/components/mediaLibraryCreator/mediaLibraryCreator.js",
"src/components/mediaLibraryEditor/mediaLibraryEditor.js",
"src/components/metadataEditor/metadataEditor.js",
"src/components/metadataEditor/personEditor.js",
"src/components/nowPlayingBar/nowPlayingBar.js",
"src/components/listview/listview.js",
"src/components/playback/brightnessosd.js",
@ -133,6 +135,7 @@
"src/components/playback/playmethodhelper.js",
"src/components/playback/remotecontrolautoplay.js",
"src/components/playback/volumeosd.js",
"src/components/playerstats/playerstats.js",
"src/components/prompt/prompt.js",
"src/components/playbackSettings/playbackSettings.js",
"src/components/playlisteditor/playlisteditor.js",
@ -177,6 +180,11 @@
"src/controllers/dashboard/users/userparentalcontrol.js",
"src/controllers/dashboard/users/userpasswordpage.js",
"src/controllers/dashboard/users/userprofilespage.js",
"src/controllers/wizard/finish.js",
"src/controllers/wizard/remoteaccess.js",
"src/controllers/wizard/settings.js",
"src/controllers/wizard/start.js",
"src/controllers/wizard/user.js",
"src/controllers/shows/episodes.js",
"src/controllers/shows/tvgenres.js",
"src/controllers/shows/tvlatest.js",

View File

@ -59,8 +59,7 @@ import 'formDialogStyle';
export function show(options) {
return new Promise((resolve, reject) => {
// TODO: remove require
require(['text!./components/accessSchedule/accessSchedule.template.html'], template => {
import('text!./components/accessSchedule/accessSchedule.template.html').then(({default: template}) => {
const dlg = dialogHelper.createDialog({
removeOnClose: true,
size: 'small'

View File

@ -73,7 +73,7 @@ function getPosition(options, dlg) {
}
function centerFocus(elem, horiz, on) {
require(['scrollHelper'], function (scrollHelper) {
import('scrollHelper').then(({default: scrollHelper}) => {
const fn = on ? 'on' : 'off';
scrollHelper.centerFocus[fn](elem, horiz);
});

View File

@ -1160,10 +1160,10 @@ import 'programStyles';
/**
* Imports the refresh indicator element.
*/
function requireRefreshIndicator() {
function importRefreshIndicator() {
if (!refreshIndicatorLoaded) {
refreshIndicatorLoaded = true;
require(['emby-itemrefreshindicator']);
import('emby-itemrefreshindicator');
}
}
@ -1414,7 +1414,7 @@ import 'programStyles';
if (item.Type === 'CollectionFolder' || item.CollectionType) {
const refreshClass = item.RefreshProgress ? '' : ' class="hide"';
indicatorsHtml += '<div is="emby-itemrefreshindicator"' + refreshClass + ' data-progress="' + (item.RefreshProgress || 0) + '" data-status="' + item.RefreshStatus + '"></div>';
requireRefreshIndicator();
importRefreshIndicator();
}
if (indicatorsHtml) {
@ -1495,7 +1495,7 @@ import 'programStyles';
const userData = item.UserData || {};
if (itemHelper.canMarkPlayed(item)) {
require(['emby-playstatebutton']);
import('emby-playstatebutton');
html += '<button is="emby-playstatebutton" type="button" data-action="none" class="' + btnCssClass + '" data-id="' + item.Id + '" data-serverid="' + item.ServerId + '" data-itemtype="' + item.Type + '" data-played="' + (userData.Played) + '"><span class="material-icons cardOverlayButtonIcon cardOverlayButtonIcon-hover check"></span></button>';
}
@ -1503,7 +1503,7 @@ import 'programStyles';
const likes = userData.Likes == null ? '' : userData.Likes;
require(['emby-ratingbutton']);
import('emby-ratingbutton');
html += '<button is="emby-ratingbutton" type="button" data-action="none" class="' + btnCssClass + '" data-id="' + item.Id + '" data-serverid="' + item.ServerId + '" data-itemtype="' + item.Type + '" data-likes="' + likes + '" data-isfavorite="' + (userData.IsFavorite) + '"><span class="material-icons cardOverlayButtonIcon cardOverlayButtonIcon-hover favorite"></span></button>';
}

View File

@ -157,7 +157,7 @@ import 'emby-button';
}
function alertTextWithOptions(options) {
require(['alert'], alert => {
import('alert').then(({default: alert}) => {
alert(options);
});
}

View File

@ -1,9 +1,30 @@
define(['itemHelper', 'dom', 'layoutManager', 'dialogHelper', 'datetime', 'loading', 'focusManager', 'connectionManager', 'globalize', 'require', 'shell', 'emby-checkbox', 'emby-input', 'emby-select', 'listViewStyle', 'emby-textarea', 'emby-button', 'paper-icon-button-light', 'css!./../formdialog', 'clearButtonStyle', 'flexStyles'], function (itemHelper, dom, layoutManager, dialogHelper, datetime, loading, focusManager, connectionManager, globalize, require, shell) {
'use strict';
import itemHelper from 'itemHelper';
import dom from 'dom';
import layoutManager from 'layoutManager';
import dialogHelper from 'dialogHelper';
import datetime from 'datetime';
import loading from 'loading';
import focusManager from 'focusManager';
import connectionManager from 'connectionManager';
import globalize from 'globalize';
import require from 'require';
import shell from 'shell';
import 'emby-checkbox';
import 'emby-input';
import 'emby-select';
import 'listViewStyle';
import 'emby-textarea';
import 'emby-button';
import 'paper-icon-button-light';
import 'css!./../formdialog';
import 'clearButtonStyle';
import 'flexStyles';
var currentContext;
var metadataEditorInfo;
var currentItem;
/* eslint-disable indent */
let currentContext;
let metadataEditorInfo;
let currentItem;
function isDialog() {
return currentContext.classList.contains('dialog');
@ -28,11 +49,11 @@ define(['itemHelper', 'dom', 'layoutManager', 'dialogHelper', 'datetime', 'loadi
closeDialog(true);
}
var apiClient = getApiClient();
const apiClient = getApiClient();
apiClient.updateItem(item).then(function () {
var newContentType = form.querySelector('#selectContentType').value || '';
const newContentType = form.querySelector('#selectContentType').value || '';
if ((metadataEditorInfo.ContentType || '') !== newContentType) {
@ -56,7 +77,7 @@ define(['itemHelper', 'dom', 'layoutManager', 'dialogHelper', 'datetime', 'loadi
}
function getSelectedAirDays(form) {
var checkedItems = form.querySelectorAll('.chkAirDay:checked') || [];
const checkedItems = form.querySelectorAll('.chkAirDay:checked') || [];
return Array.prototype.map.call(checkedItems, function (c) {
return c.getAttribute('data-day');
});
@ -92,7 +113,7 @@ define(['itemHelper', 'dom', 'layoutManager', 'dialogHelper', 'datetime', 'loadi
function getDateValue(form, element, property) {
var val = form.querySelector(element).value;
let val = form.querySelector(element).value;
if (!val) {
return null;
@ -100,14 +121,14 @@ define(['itemHelper', 'dom', 'layoutManager', 'dialogHelper', 'datetime', 'loadi
if (currentItem[property]) {
var date = datetime.parseISO8601Date(currentItem[property], true);
const date = datetime.parseISO8601Date(currentItem[property], true);
var parts = date.toISOString().split('T');
const parts = date.toISOString().split('T');
// If the date is the same, preserve the time
if (parts[0].indexOf(val) === 0) {
var iso = parts[1];
const iso = parts[1];
val += 'T' + iso;
}
@ -120,9 +141,9 @@ define(['itemHelper', 'dom', 'layoutManager', 'dialogHelper', 'datetime', 'loadi
loading.show();
var form = this;
const form = this;
var item = {
const item = {
Id: currentItem.Id,
Name: form.querySelector('#txtName').value,
OriginalTitle: form.querySelector('#txtOriginalName').value,
@ -168,9 +189,9 @@ define(['itemHelper', 'dom', 'layoutManager', 'dialogHelper', 'datetime', 'loadi
item.ProviderIds = Object.assign({}, currentItem.ProviderIds);
var idElements = form.querySelectorAll('.txtExternalId');
const idElements = form.querySelectorAll('.txtExternalId');
Array.prototype.map.call(idElements, function (idElem) {
var providerKey = idElem.getAttribute('data-providerkey');
const providerKey = idElem.getAttribute('data-providerkey');
item.ProviderIds[providerKey] = idElem.value;
});
@ -179,7 +200,7 @@ define(['itemHelper', 'dom', 'layoutManager', 'dialogHelper', 'datetime', 'loadi
if (currentItem.Type === 'Person') {
var placeOfBirth = form.querySelector('#txtPlaceOfBirth').value;
const placeOfBirth = form.querySelector('#txtPlaceOfBirth').value;
item.ProductionLocations = placeOfBirth ? [placeOfBirth] : [];
}
@ -187,11 +208,11 @@ define(['itemHelper', 'dom', 'layoutManager', 'dialogHelper', 'datetime', 'loadi
if (currentItem.Type === 'Series') {
// 600000000
var seriesRuntime = form.querySelector('#txtSeriesRuntime').value;
const seriesRuntime = form.querySelector('#txtSeriesRuntime').value;
item.RunTimeTicks = seriesRuntime ? (seriesRuntime * 600000000) : null;
}
var tagline = form.querySelector('#txtTagline').value;
const tagline = form.querySelector('#txtTagline').value;
item.Taglines = tagline ? [tagline] : [];
submitUpdatedItem(form, item);
@ -215,8 +236,8 @@ define(['itemHelper', 'dom', 'layoutManager', 'dialogHelper', 'datetime', 'loadi
prompt.default({
label: 'Value:'
}).then(function (text) {
var list = dom.parentWithClass(source, 'editableListviewContainer').querySelector('.paperList');
var items = getListValues(list);
const list = dom.parentWithClass(source, 'editableListviewContainer').querySelector('.paperList');
const items = getListValues(list);
items.push(text);
populateListView(list, items, sortCallback);
});
@ -224,7 +245,7 @@ define(['itemHelper', 'dom', 'layoutManager', 'dialogHelper', 'datetime', 'loadi
}
function removeElementFromList(source) {
var el = dom.parentWithClass(source, 'listItem');
const el = dom.parentWithClass(source, 'listItem');
el.parentNode.removeChild(el);
}
@ -234,7 +255,7 @@ define(['itemHelper', 'dom', 'layoutManager', 'dialogHelper', 'datetime', 'loadi
personEditor.show(person).then(function (updatedPerson) {
var isNew = index === -1;
const isNew = index === -1;
if (isNew) {
currentItem.People.push(updatedPerson);
@ -247,13 +268,13 @@ define(['itemHelper', 'dom', 'layoutManager', 'dialogHelper', 'datetime', 'loadi
function onEditorClick(e) {
var btnRemoveFromEditorList = dom.parentWithClass(e.target, 'btnRemoveFromEditorList');
const btnRemoveFromEditorList = dom.parentWithClass(e.target, 'btnRemoveFromEditorList');
if (btnRemoveFromEditorList) {
removeElementFromList(btnRemoveFromEditorList);
return;
}
var btnAddTextItem = dom.parentWithClass(e.target, 'btnAddTextItem');
const btnAddTextItem = dom.parentWithClass(e.target, 'btnAddTextItem');
if (btnAddTextItem) {
addElementToList(btnAddTextItem);
}
@ -264,7 +285,7 @@ define(['itemHelper', 'dom', 'layoutManager', 'dialogHelper', 'datetime', 'loadi
}
function bindAll(elems, eventName, fn) {
for (var i = 0, length = elems.length; i < length; i++) {
for (let i = 0, length = elems.length; i < length; i++) {
elems[i].addEventListener(eventName, fn);
}
}
@ -272,11 +293,11 @@ define(['itemHelper', 'dom', 'layoutManager', 'dialogHelper', 'datetime', 'loadi
function init(context, apiClient) {
context.querySelector('.externalIds').addEventListener('click', function (e) {
var btnOpenExternalId = dom.parentWithClass(e.target, 'btnOpenExternalId');
const btnOpenExternalId = dom.parentWithClass(e.target, 'btnOpenExternalId');
if (btnOpenExternalId) {
var field = context.querySelector('#' + btnOpenExternalId.getAttribute('data-fieldid'));
const field = context.querySelector('#' + btnOpenExternalId.getAttribute('data-fieldid'));
var formatString = field.getAttribute('data-formatstring');
const formatString = field.getAttribute('data-formatstring');
if (field.value) {
shell.openUrl(formatString.replace('{0}', field.value));
@ -311,7 +332,7 @@ define(['itemHelper', 'dom', 'layoutManager', 'dialogHelper', 'datetime', 'loadi
context.removeEventListener('click', onEditorClick);
context.addEventListener('click', onEditorClick);
var form = context.querySelector('form');
const form = context.querySelector('form');
form.removeEventListener('submit', onSubmit);
form.addEventListener('submit', onSubmit);
@ -322,15 +343,15 @@ define(['itemHelper', 'dom', 'layoutManager', 'dialogHelper', 'datetime', 'loadi
context.querySelector('#peopleList').addEventListener('click', function (e) {
var index;
var btnDeletePerson = dom.parentWithClass(e.target, 'btnDeletePerson');
let index;
const btnDeletePerson = dom.parentWithClass(e.target, 'btnDeletePerson');
if (btnDeletePerson) {
index = parseInt(btnDeletePerson.getAttribute('data-index'));
currentItem.People.splice(index, 1);
populatePeople(context, currentItem.People);
}
var btnEditPerson = dom.parentWithClass(e.target, 'btnEditPerson');
const btnEditPerson = dom.parentWithClass(e.target, 'btnEditPerson');
if (btnEditPerson) {
index = parseInt(btnEditPerson.getAttribute('data-index'));
editPerson(context, currentItem.People[index], index);
@ -340,7 +361,7 @@ define(['itemHelper', 'dom', 'layoutManager', 'dialogHelper', 'datetime', 'loadi
function getItem(itemId, serverId) {
var apiClient = connectionManager.getApiClient(serverId);
const apiClient = connectionManager.getApiClient(serverId);
if (itemId) {
return apiClient.getItem(apiClient.getCurrentUserId(), itemId);
@ -351,7 +372,7 @@ define(['itemHelper', 'dom', 'layoutManager', 'dialogHelper', 'datetime', 'loadi
function getEditorConfig(itemId, serverId) {
var apiClient = connectionManager.getApiClient(serverId);
const apiClient = connectionManager.getApiClient(serverId);
if (itemId) {
return apiClient.getJSON(apiClient.getUrl('Items/' + itemId + '/MetadataEditor'));
@ -362,13 +383,13 @@ define(['itemHelper', 'dom', 'layoutManager', 'dialogHelper', 'datetime', 'loadi
function populateCountries(select, allCountries) {
var html = '';
let html = '';
html += "<option value=''></option>";
for (var i = 0, length = allCountries.length; i < length; i++) {
for (let i = 0, length = allCountries.length; i < length; i++) {
var culture = allCountries[i];
const culture = allCountries[i];
html += "<option value='" + culture.TwoLetterISORegionName + "'>" + culture.DisplayName + '</option>';
}
@ -378,13 +399,13 @@ define(['itemHelper', 'dom', 'layoutManager', 'dialogHelper', 'datetime', 'loadi
function populateLanguages(select, languages) {
var html = '';
let html = '';
html += "<option value=''></option>";
for (var i = 0, length = languages.length; i < length; i++) {
for (let i = 0, length = languages.length; i < length; i++) {
var culture = languages[i];
const culture = languages[i];
html += "<option value='" + culture.TwoLetterISOLanguageName + "'>" + culture.DisplayName + '</option>';
}
@ -400,41 +421,41 @@ define(['itemHelper', 'dom', 'layoutManager', 'dialogHelper', 'datetime', 'loadi
showElement('#fldContentType', context);
}
var html = metadataInfo.ContentTypeOptions.map(function (i) {
const html = metadataInfo.ContentTypeOptions.map(function (i) {
return '<option value="' + i.Value + '">' + i.Name + '</option>';
}).join('');
var selectEl = context.querySelector('#selectContentType');
const selectEl = context.querySelector('#selectContentType');
selectEl.innerHTML = html;
selectEl.value = metadataInfo.ContentType || '';
}
function loadExternalIds(context, item, externalIds) {
var html = '';
let html = '';
var providerIds = item.ProviderIds || {};
const providerIds = item.ProviderIds || {};
for (var i = 0, length = externalIds.length; i < length; i++) {
for (let i = 0, length = externalIds.length; i < length; i++) {
var idInfo = externalIds[i];
const idInfo = externalIds[i];
var id = 'txt1' + idInfo.Key;
var formatString = idInfo.UrlFormatString || '';
const id = 'txt1' + idInfo.Key;
const formatString = idInfo.UrlFormatString || '';
var fullName = idInfo.Name;
let fullName = idInfo.Name;
if (idInfo.Type) {
fullName = idInfo.Name + ' ' + globalize.translate(idInfo.Type);
}
var labelText = globalize.translate('LabelDynamicExternalId', fullName);
const labelText = globalize.translate('LabelDynamicExternalId', fullName);
html += '<div class="inputContainer">';
html += '<div class="flex align-items-center">';
var value = providerIds[idInfo.Key] || '';
const value = providerIds[idInfo.Key] || '';
html += '<div class="flex-grow">';
html += '<input is="emby-input" class="txtExternalId" value="' + value + '" data-providerkey="' + idInfo.Key + '" data-formatstring="' + formatString + '" id="' + id + '" label="' + labelText + '"/>';
@ -448,7 +469,7 @@ define(['itemHelper', 'dom', 'layoutManager', 'dialogHelper', 'datetime', 'loadi
html += '</div>';
}
var elem = context.querySelector('.externalIds', context);
const elem = context.querySelector('.externalIds', context);
elem.innerHTML = html;
if (externalIds.length) {
@ -465,7 +486,7 @@ define(['itemHelper', 'dom', 'layoutManager', 'dialogHelper', 'datetime', 'loadi
context = context || document;
if (typeof selector === 'string') {
var elements = multiple ? context.querySelectorAll(selector) : [context.querySelector(selector)];
const elements = multiple ? context.querySelectorAll(selector) : [context.querySelector(selector)];
Array.prototype.forEach.call(elements, function (el) {
if (el) {
@ -484,7 +505,7 @@ define(['itemHelper', 'dom', 'layoutManager', 'dialogHelper', 'datetime', 'loadi
context = context || document;
if (typeof selector === 'string') {
var elements = multiple ? context.querySelectorAll(selector) : [context.querySelector(selector)];
const elements = multiple ? context.querySelectorAll(selector) : [context.querySelector(selector)];
Array.prototype.forEach.call(elements, function (el) {
if (el) {
@ -686,7 +707,7 @@ define(['itemHelper', 'dom', 'layoutManager', 'dialogHelper', 'datetime', 'loadi
function fillItemInfo(context, item, parentalRatingOptions) {
var select = context.querySelector('#selectOfficialRating');
let select = context.querySelector('#selectOfficialRating');
populateRatings(parentalRatingOptions, select, item.OfficialRating);
@ -698,7 +719,7 @@ define(['itemHelper', 'dom', 'layoutManager', 'dialogHelper', 'datetime', 'loadi
select.value = item.CustomRating || '';
var selectStatus = context.querySelector('#selectStatus');
const selectStatus = context.querySelector('#selectStatus');
populateStatus(selectStatus);
selectStatus.value = item.Status || '';
@ -717,8 +738,8 @@ define(['itemHelper', 'dom', 'layoutManager', 'dialogHelper', 'datetime', 'loadi
populateListView(context.querySelector('#listTags'), item.Tags);
var lockData = (item.LockData || false);
var chkLockData = context.querySelector('#chkLockData');
const lockData = (item.LockData || false);
const chkLockData = context.querySelector('#chkLockData');
chkLockData.checked = lockData;
if (chkLockData.checked) {
hideElement('.providerSettingsContainer', context);
@ -756,7 +777,7 @@ define(['itemHelper', 'dom', 'layoutManager', 'dialogHelper', 'datetime', 'loadi
return a.Name;
}).join(';');
var date;
let date;
if (item.DateCreated) {
try {
@ -798,7 +819,7 @@ define(['itemHelper', 'dom', 'layoutManager', 'dialogHelper', 'datetime', 'loadi
context.querySelector('#txtAirTime').value = item.AirTime || '';
var placeofBirth = item.ProductionLocations && item.ProductionLocations.length ? item.ProductionLocations[0] : '';
const placeofBirth = item.ProductionLocations && item.ProductionLocations.length ? item.ProductionLocations[0] : '';
context.querySelector('#txtPlaceOfBirth').value = placeofBirth;
context.querySelector('#txtOriginalAspectRatio').value = item.AspectRatio || '';
@ -808,7 +829,7 @@ define(['itemHelper', 'dom', 'layoutManager', 'dialogHelper', 'datetime', 'loadi
if (item.RunTimeTicks) {
var minutes = item.RunTimeTicks / 600000000;
const minutes = item.RunTimeTicks / 600000000;
context.querySelector('#txtSeriesRuntime').value = Math.round(minutes);
} else {
@ -818,18 +839,16 @@ define(['itemHelper', 'dom', 'layoutManager', 'dialogHelper', 'datetime', 'loadi
function populateRatings(allParentalRatings, select, currentValue) {
var html = '';
let html = '';
html += "<option value=''></option>";
var ratings = [];
var i;
var length;
var rating;
const ratings = [];
let rating;
var currentValueFound = false;
let currentValueFound = false;
for (i = 0, length = allParentalRatings.length; i < length; i++) {
for (let i = 0, length = allParentalRatings.length; i < length; i++) {
rating = allParentalRatings[i];
@ -844,7 +863,7 @@ define(['itemHelper', 'dom', 'layoutManager', 'dialogHelper', 'datetime', 'loadi
ratings.push({ Name: currentValue, Value: currentValue });
}
for (i = 0, length = ratings.length; i < length; i++) {
for (let i = 0, length = ratings.length; i < length; i++) {
rating = ratings[i];
@ -855,7 +874,7 @@ define(['itemHelper', 'dom', 'layoutManager', 'dialogHelper', 'datetime', 'loadi
}
function populateStatus(select) {
var html = '';
let html = '';
html += "<option value=''></option>";
html += "<option value='Continuing'>" + globalize.translate('Continuing') + '</option>';
@ -873,8 +892,8 @@ define(['itemHelper', 'dom', 'layoutManager', 'dialogHelper', 'datetime', 'loadi
} else {
items = sortCallback(items);
}
var html = '';
for (var i = 0; i < items.length; i++) {
let html = '';
for (let i = 0; i < items.length; i++) {
html += '<div class="listItem">';
html += '<span class="material-icons listItemIcon live_tv" style="background-color:#333;"></span>';
@ -897,14 +916,14 @@ define(['itemHelper', 'dom', 'layoutManager', 'dialogHelper', 'datetime', 'loadi
function populatePeople(context, people) {
var lastType = '';
var html = '';
let lastType = '';
let html = '';
var elem = context.querySelector('#peopleList');
const elem = context.querySelector('#peopleList');
for (var i = 0, length = people.length; i < length; i++) {
for (let i = 0, length = people.length; i < length; i++) {
var person = people[i];
const person = people[i];
html += '<div class="listItem">';
@ -934,13 +953,13 @@ define(['itemHelper', 'dom', 'layoutManager', 'dialogHelper', 'datetime', 'loadi
function getLockedFieldsHtml(fields, currentFields) {
var html = '';
for (var i = 0; i < fields.length; i++) {
let html = '';
for (let i = 0; i < fields.length; i++) {
var field = fields[i];
var name = field.name;
var value = field.value || field.name;
var checkedHtml = currentFields.indexOf(value) === -1 ? ' checked' : '';
const field = fields[i];
const name = field.name;
const value = field.value || field.name;
const checkedHtml = currentFields.indexOf(value) === -1 ? ' checked' : '';
html += '<label>';
html += '<input type="checkbox" is="emby-checkbox" class="selectLockedField" data-value="' + value + '"' + checkedHtml + '/>';
html += '<span>' + name + '</span>';
@ -950,10 +969,10 @@ define(['itemHelper', 'dom', 'layoutManager', 'dialogHelper', 'datetime', 'loadi
}
function fillMetadataSettings(context, item, lockedFields) {
var container = context.querySelector('.providerSettingsContainer');
const container = context.querySelector('.providerSettingsContainer');
lockedFields = lockedFields || [];
var lockedFieldsList = [
const lockedFieldsList = [
{ name: globalize.translate('Name'), value: 'Name' },
{ name: globalize.translate('Overview'), value: 'Overview' },
{ name: globalize.translate('Genres'), value: 'Genres' },
@ -974,7 +993,7 @@ define(['itemHelper', 'dom', 'layoutManager', 'dialogHelper', 'datetime', 'loadi
lockedFieldsList.push({ name: globalize.translate('Studios'), value: 'Studios' });
lockedFieldsList.push({ name: globalize.translate('Tags'), value: 'Tags' });
var html = '';
let html = '';
html += '<h2>' + globalize.translate('HeaderEnabledFields') + '</h2>';
html += '<p>' + globalize.translate('HeaderEnabledFieldsHelp') + '</p>';
@ -988,13 +1007,13 @@ define(['itemHelper', 'dom', 'layoutManager', 'dialogHelper', 'datetime', 'loadi
Promise.all([getItem(itemId, serverId), getEditorConfig(itemId, serverId)]).then(function (responses) {
var item = responses[0];
const item = responses[0];
metadataEditorInfo = responses[1];
currentItem = item;
var languages = metadataEditorInfo.Cultures;
var countries = metadataEditorInfo.Countries;
const languages = metadataEditorInfo.Cultures;
const countries = metadataEditorInfo.Countries;
renderContentTypeOptions(context, metadataEditorInfo);
@ -1018,7 +1037,7 @@ define(['itemHelper', 'dom', 'layoutManager', 'dialogHelper', 'datetime', 'loadi
function centerFocus(elem, horiz, on) {
require(['scrollHelper'], function (scrollHelper) {
var fn = on ? 'on' : 'off';
const fn = on ? 'on' : 'off';
scrollHelper.centerFocus[fn](elem, horiz);
});
}
@ -1028,7 +1047,7 @@ define(['itemHelper', 'dom', 'layoutManager', 'dialogHelper', 'datetime', 'loadi
require(['text!./metadataEditor.template.html'], function (template) {
var dialogOptions = {
const dialogOptions = {
removeOnClose: true,
scrollY: false
};
@ -1039,11 +1058,11 @@ define(['itemHelper', 'dom', 'layoutManager', 'dialogHelper', 'datetime', 'loadi
dialogOptions.size = 'small';
}
var dlg = dialogHelper.createDialog(dialogOptions);
const dlg = dialogHelper.createDialog(dialogOptions);
dlg.classList.add('formDialog');
var html = '';
let html = '';
html += globalize.translateDocument(template, 'core');
@ -1071,7 +1090,7 @@ define(['itemHelper', 'dom', 'layoutManager', 'dialogHelper', 'datetime', 'loadi
});
}
return {
export default {
show: function (itemId, serverId) {
return new Promise(function (resolve, reject) {
return show(itemId, serverId, resolve, reject);
@ -1101,4 +1120,5 @@ define(['itemHelper', 'dom', 'layoutManager', 'dialogHelper', 'datetime', 'loadi
});
}
};
});
/* eslint-enable indent */

View File

@ -1,9 +1,17 @@
define(['dialogHelper', 'layoutManager', 'globalize', 'require', 'paper-icon-button-light', 'emby-input', 'emby-select', 'css!./../formdialog'], function (dialogHelper, layoutManager, globalize, require) {
'use strict';
import dialogHelper from 'dialogHelper';
import layoutManager from 'layoutManager';
import globalize from 'globalize';
import require from 'require';
import 'paper-icon-button-light';
import 'emby-input';
import 'emby-select';
import 'css!./../formdialog';
/* eslint-disable indent */
function centerFocus(elem, horiz, on) {
require(['scrollHelper'], function (scrollHelper) {
var fn = on ? 'on' : 'off';
const fn = on ? 'on' : 'off';
scrollHelper.centerFocus[fn](elem, horiz);
});
}
@ -13,7 +21,7 @@ define(['dialogHelper', 'layoutManager', 'globalize', 'require', 'paper-icon-but
require(['text!./personEditor.template.html'], function (template) {
var dialogOptions = {
const dialogOptions = {
removeOnClose: true,
scrollY: false
};
@ -24,12 +32,12 @@ define(['dialogHelper', 'layoutManager', 'globalize', 'require', 'paper-icon-but
dialogOptions.size = 'small';
}
var dlg = dialogHelper.createDialog(dialogOptions);
const dlg = dialogHelper.createDialog(dialogOptions);
dlg.classList.add('formDialog');
var html = '';
var submitted = false;
let html = '';
let submitted = false;
html += globalize.translateDocument(template, 'core');
@ -93,7 +101,8 @@ define(['dialogHelper', 'layoutManager', 'globalize', 'require', 'paper-icon-but
});
}
return {
show: show
};
});
export default {
show: show
};
/* eslint-enable indent */

View File

@ -118,7 +118,7 @@ export function show(button) {
});
require(['actionsheet'], function (actionsheet) {
import('actionsheet').then(({default: actionsheet}) => {
loading.hide();
@ -153,8 +153,12 @@ export function show(button) {
}
function showActivePlayerMenu(playerInfo) {
require(['dialogHelper', 'dialog', 'emby-checkbox', 'emby-button'], function (dialogHelper) {
Promise.all([
import('dialogHelper'),
import('dialog'),
import('emby-checkbox'),
import('emby-button')
]).then(([dialogHelper]) => {
showActivePlayerMenuInternal(dialogHelper, playerInfo);
});
}
@ -163,7 +167,7 @@ function disconnectFromPlayer(currentDeviceName) {
if (playbackManager.getSupportedCommands().indexOf('EndSession') !== -1) {
require(['dialog'], function (dialog) {
import('dialog').then(({default: dialog}) => {
var menuItems = [];

View File

@ -1,9 +1,19 @@
define(['events', 'globalize', 'playbackManager', 'connectionManager', 'syncPlayManager', 'playMethodHelper', 'layoutManager', 'serverNotifications', 'paper-icon-button-light', 'css!./playerstats'], function (events, globalize, playbackManager, connectionManager, syncPlayManager, playMethodHelper, layoutManager, serverNotifications) {
'use strict';
import events from 'events';
import globalize from 'globalize';
import playbackManager from 'playbackManager';
import connectionManager from 'connectionManager';
import syncPlayManager from 'syncPlayManager';
import playMethodHelper from 'playMethodHelper';
import layoutManager from 'layoutManager';
import serverNotifications from 'serverNotifications';
import 'paper-icon-button-light';
import 'css!./playerstats';
/* eslint-disable indent */
function init(instance) {
var parent = document.createElement('div');
const parent = document.createElement('div');
parent.classList.add('playerStats');
@ -13,7 +23,7 @@ define(['events', 'globalize', 'playbackManager', 'connectionManager', 'syncPlay
parent.classList.add('hide');
var button;
let button;
if (layoutManager.tv) {
button = '';
@ -21,7 +31,7 @@ define(['events', 'globalize', 'playbackManager', 'connectionManager', 'syncPlay
button = '<button type="button" is="paper-icon-button-light" class="playerStats-closeButton"><span class="material-icons close"></span></button>';
}
var contentClass = layoutManager.tv ? 'playerStats-content playerStats-content-tv' : 'playerStats-content';
const contentClass = layoutManager.tv ? 'playerStats-content playerStats-content-tv' : 'playerStats-content';
parent.innerHTML = '<div class="' + contentClass + '">' + button + '<div class="playerStats-stats"></div></div>';
@ -44,9 +54,9 @@ define(['events', 'globalize', 'playbackManager', 'connectionManager', 'syncPlay
elem.querySelector('.playerStats-stats').innerHTML = categories.map(function (category) {
var categoryHtml = '';
let categoryHtml = '';
var stats = category.stats;
const stats = category.stats;
if (stats.length && category.name) {
categoryHtml += '<div class="playerStats-stat playerStats-stat-header">';
@ -62,11 +72,11 @@ define(['events', 'globalize', 'playbackManager', 'connectionManager', 'syncPlay
categoryHtml += '</div>';
}
for (var i = 0, length = stats.length; i < length; i++) {
for (let i = 0, length = stats.length; i < length; i++) {
categoryHtml += '<div class="playerStats-stat">';
var stat = stats[i];
const stat = stats[i];
categoryHtml += '<div class="playerStats-stat-label">';
categoryHtml += stat.label;
@ -86,13 +96,13 @@ define(['events', 'globalize', 'playbackManager', 'connectionManager', 'syncPlay
function getSession(instance, player) {
var now = new Date().getTime();
const now = new Date().getTime();
if ((now - (instance.lastSessionTime || 0)) < 10000) {
return Promise.resolve(instance.lastSession);
}
var apiClient = connectionManager.getApiClient(playbackManager.currentItem(player).ServerId);
const apiClient = connectionManager.getApiClient(playbackManager.currentItem(player).ServerId);
return apiClient.getSessions({
deviceId: apiClient.deviceId()
@ -114,12 +124,12 @@ define(['events', 'globalize', 'playbackManager', 'connectionManager', 'syncPlay
}
function getTranscodingStats(session, player, displayPlayMethod) {
var sessionStats = [];
const sessionStats = [];
var videoCodec;
var audioCodec;
var totalBitrate;
var audioChannels;
let videoCodec;
let audioCodec;
let totalBitrate;
let audioChannels;
if (session.TranscodingInfo) {
@ -208,11 +218,11 @@ define(['events', 'globalize', 'playbackManager', 'connectionManager', 'syncPlay
function getMediaSourceStats(session, player, displayPlayMethod) {
var sessionStats = [];
const sessionStats = [];
var mediaSource = playbackManager.currentMediaSource(player) || {};
var totalBitrate = mediaSource.Bitrate;
var mediaFileSize = mediaSource.Size;
const mediaSource = playbackManager.currentMediaSource(player) || {};
const totalBitrate = mediaSource.Bitrate;
const mediaFileSize = mediaSource.Size;
if (mediaSource.Container) {
sessionStats.push({
@ -236,26 +246,26 @@ define(['events', 'globalize', 'playbackManager', 'connectionManager', 'syncPlay
});
}
var mediaStreams = mediaSource.MediaStreams || [];
var videoStream = mediaStreams.filter(function (s) {
const mediaStreams = mediaSource.MediaStreams || [];
const videoStream = mediaStreams.filter(function (s) {
return s.Type === 'Video';
})[0] || {};
var videoCodec = videoStream.Codec;
const videoCodec = videoStream.Codec;
var audioStreamIndex = playbackManager.getAudioStreamIndex(player);
var audioStream = playbackManager.audioTracks(player).filter(function (s) {
const audioStreamIndex = playbackManager.getAudioStreamIndex(player);
const audioStream = playbackManager.audioTracks(player).filter(function (s) {
return s.Type === 'Audio' && s.Index === audioStreamIndex;
})[0] || {};
var audioCodec = audioStream.Codec;
var audioChannels = audioStream.Channels;
const audioCodec = audioStream.Codec;
const audioChannels = audioStream.Channels;
var videoInfos = [];
const videoInfos = [];
if (videoCodec) {
videoInfos.push(videoCodec.toUpperCase());
@ -279,7 +289,7 @@ define(['events', 'globalize', 'playbackManager', 'connectionManager', 'syncPlay
});
}
var audioInfos = [];
const audioInfos = [];
if (audioCodec) {
audioInfos.push(audioCodec.toUpperCase());
@ -328,8 +338,8 @@ define(['events', 'globalize', 'playbackManager', 'connectionManager', 'syncPlay
}
function getSyncPlayStats() {
var syncStats = [];
var stats = syncPlayManager.getStats();
const syncStats = [];
const stats = syncPlayManager.getStats();
syncStats.push({
label: globalize.translate('LabelSyncPlayTimeOffset'),
@ -351,18 +361,18 @@ define(['events', 'globalize', 'playbackManager', 'connectionManager', 'syncPlay
function getStats(instance, player) {
var statsPromise = player.getStats ? player.getStats() : Promise.resolve({});
var sessionPromise = getSession(instance, player);
const statsPromise = player.getStats ? player.getStats() : Promise.resolve({});
const sessionPromise = getSession(instance, player);
return Promise.all([statsPromise, sessionPromise]).then(function (responses) {
var playerStatsResult = responses[0];
var playerStats = playerStatsResult.categories || [];
var session = responses[1];
const playerStatsResult = responses[0];
const playerStats = playerStatsResult.categories || [];
const session = responses[1];
var displayPlayMethod = playMethodHelper.getDisplayPlayMethod(session);
const displayPlayMethod = playMethodHelper.getDisplayPlayMethod(session);
var baseCategory = {
const baseCategory = {
stats: [],
name: 'Playback Info'
};
@ -377,13 +387,13 @@ define(['events', 'globalize', 'playbackManager', 'connectionManager', 'syncPlay
value: player.name
});
var categories = [];
const categories = [];
categories.push(baseCategory);
for (var i = 0, length = playerStats.length; i < length; i++) {
for (let i = 0, length = playerStats.length; i < length; i++) {
var category = playerStats[i];
const category = playerStats[i];
if (category.type === 'audio') {
category.name = 'Audio Info';
} else if (category.type === 'video') {
@ -418,7 +428,7 @@ define(['events', 'globalize', 'playbackManager', 'connectionManager', 'syncPlay
function renderPlayerStats(instance, player) {
var now = new Date().getTime();
const now = new Date().getTime();
if ((now - (instance.lastRender || 0)) < 700) {
return;
@ -428,7 +438,7 @@ define(['events', 'globalize', 'playbackManager', 'connectionManager', 'syncPlay
getStats(instance, player).then(function (stats) {
var elem = instance.element;
const elem = instance.element;
if (!elem) {
return;
}
@ -439,7 +449,7 @@ define(['events', 'globalize', 'playbackManager', 'connectionManager', 'syncPlay
function bindEvents(instance, player) {
var localOnTimeUpdate = function () {
const localOnTimeUpdate = function () {
renderPlayerStats(instance, player);
};
@ -449,14 +459,15 @@ define(['events', 'globalize', 'playbackManager', 'connectionManager', 'syncPlay
function unbindEvents(instance, player) {
var localOnTimeUpdate = instance.onTimeUpdate;
const localOnTimeUpdate = instance.onTimeUpdate;
if (localOnTimeUpdate) {
events.off(player, 'timeupdate', localOnTimeUpdate);
}
}
function PlayerStats(options) {
class PlayerStats {
constructor(options) {
this.options = options;
@ -465,13 +476,13 @@ define(['events', 'globalize', 'playbackManager', 'connectionManager', 'syncPlay
this.enabled(true);
}
PlayerStats.prototype.enabled = function (enabled) {
enabled(enabled) {
if (enabled == null) {
return this._enabled;
}
var options = this.options;
const options = this.options;
if (!options) {
return;
@ -485,15 +496,15 @@ define(['events', 'globalize', 'playbackManager', 'connectionManager', 'syncPlay
this.element.classList.add('hide');
unbindEvents(this, options.player);
}
};
}
PlayerStats.prototype.toggle = function () {
toggle() {
this.enabled(!this.enabled());
};
}
PlayerStats.prototype.destroy = function () {
destroy() {
var options = this.options;
const options = this.options;
if (options) {
@ -501,12 +512,14 @@ define(['events', 'globalize', 'playbackManager', 'connectionManager', 'syncPlay
unbindEvents(this, options.player);
}
var elem = this.element;
const elem = this.element;
if (elem) {
elem.parentNode.removeChild(elem);
this.element = null;
}
};
}
}
return PlayerStats;
});
/* eslint-enable indent */
export default PlayerStats;

View File

@ -70,7 +70,7 @@ import 'css!./searchfields';
function embed(elem, instance, options) {
require(['text!./searchfields.template.html'], function (template) {
import('text!./searchfields.template.html').then(({default: template}) => {
let html = globalize.translateDocument(template, 'core');

View File

@ -604,7 +604,7 @@ import 'emby-button';
function embed(elem, instance, options) {
require(['text!./searchresults.template.html'], function (template) {
import('text!./searchresults.template.html').then(({default: template}) => {
if (!enableScrollX()) {
template = replaceAll(template, 'data-horizontal="true"', 'data-horizontal="false"');

View File

@ -90,7 +90,7 @@ function save(instance, context, userId, userSettings, apiClient, enableSaveConf
loading.hide();
if (enableSaveConfirmation) {
require(['toast'], function (toast) {
import('toast').then(({default: toast}) => {
toast(globalize.translate('SettingsSaved'));
});
}
@ -130,7 +130,7 @@ function onAppearanceFieldChange(e) {
function embed(options, self) {
require(['text!./subtitlesettings.template.html'], function (template) {
import('text!./subtitlesettings.template.html').then(({default: template}) => {
options.element.classList.add('subtitlesettings');
options.element.innerHTML = globalize.translateDocument(template, 'core');

View File

@ -43,7 +43,7 @@ import 'emby-select';
$('.taskName', view).html(task.Name);
$('#pTaskDescription', view).html(task.Description);
require(['listViewStyle'], function () {
import('listViewStyle').then(() => {
ScheduledTaskPage.loadTaskTriggers(view, task);
});
@ -137,7 +137,7 @@ import 'emby-select';
$('#popupAddTrigger', view).removeClass('hide');
},
confirmDeleteTrigger: function (view, index) {
require(['confirm'], function (confirm) {
import('confirm').then(({default: confirm}) => {
confirm.default(globalize.translate('MessageDeleteTaskTrigger'), globalize.translate('HeaderDeleteTaskTrigger')).then(function () {
ScheduledTaskPage.deleteTrigger(view, index);
});

View File

@ -964,7 +964,7 @@ define(['playbackManager', 'dom', 'inputManager', 'datetime', 'itemHelper', 'med
if (statsOverlay) {
statsOverlay.toggle();
} else {
statsOverlay = new PlayerStats({
statsOverlay = new PlayerStats.default({
player: player
});
}

View File

@ -1,18 +1,16 @@
define(['loading'], function (loading) {
'use strict';
import loading from 'loading';
function onFinish() {
loading.show();
ApiClient.ajax({
url: ApiClient.getUrl('Startup/Complete'),
type: 'POST'
}).then(function () {
loading.hide();
window.location.href = 'index.html';
});
}
function onFinish() {
loading.show();
ApiClient.ajax({
url: ApiClient.getUrl('Startup/Complete'),
type: 'POST'
}).then(function () {
loading.hide();
window.location.href = 'index.html';
});
}
return function (view, params) {
view.querySelector('.btnWizardNext').addEventListener('click', onFinish);
};
});
export default function (view, params) {
view.querySelector('.btnWizardNext').addEventListener('click', onFinish);
}

View File

@ -1,39 +1,40 @@
define(['loading', 'emby-checkbox', 'emby-button', 'emby-select'], function (loading) {
'use strict';
import loading from 'loading';
import 'emby-checkbox';
import 'emby-button';
import 'emby-select';
function save(page) {
loading.show();
var apiClient = ApiClient;
var config = {};
config.EnableRemoteAccess = page.querySelector('#chkRemoteAccess').checked;
config.EnableAutomaticPortMapping = page.querySelector('#chkEnableUpnp').checked;
apiClient.ajax({
type: 'POST',
data: config,
url: apiClient.getUrl('Startup/RemoteAccess')
}).then(function () {
loading.hide();
navigateToNextPage();
});
}
function save(page) {
loading.show();
const apiClient = ApiClient;
const config = {};
config.EnableRemoteAccess = page.querySelector('#chkRemoteAccess').checked;
config.EnableAutomaticPortMapping = page.querySelector('#chkEnableUpnp').checked;
apiClient.ajax({
type: 'POST',
data: config,
url: apiClient.getUrl('Startup/RemoteAccess')
}).then(function () {
loading.hide();
navigateToNextPage();
});
}
function navigateToNextPage() {
Dashboard.navigate('wizardfinish.html');
}
function navigateToNextPage() {
Dashboard.navigate('wizardfinish.html');
}
function onSubmit(e) {
save(this);
e.preventDefault();
return false;
}
function onSubmit(e) {
save(this);
e.preventDefault();
return false;
}
return function (view, params) {
view.querySelector('.wizardSettingsForm').addEventListener('submit', onSubmit);
view.addEventListener('viewshow', function () {
document.querySelector('.skinHeader').classList.add('noHomeButtonHeader');
});
view.addEventListener('viewhide', function () {
document.querySelector('.skinHeader').classList.remove('noHomeButtonHeader');
});
};
});
export default function (view, params) {
view.querySelector('.wizardSettingsForm').addEventListener('submit', onSubmit);
view.addEventListener('viewshow', function () {
document.querySelector('.skinHeader').classList.add('noHomeButtonHeader');
});
view.addEventListener('viewhide', function () {
document.querySelector('.skinHeader').classList.remove('noHomeButtonHeader');
});
}

View File

@ -1,84 +1,85 @@
define(['loading', 'emby-checkbox', 'emby-button', 'emby-select'], function (loading) {
'use strict';
import loading from 'loading';
import 'emby-checkbox';
import 'emby-button';
import 'emby-select';
function save(page) {
loading.show();
var apiClient = ApiClient;
apiClient.getJSON(apiClient.getUrl('Startup/Configuration')).then(function (config) {
config.PreferredMetadataLanguage = page.querySelector('#selectLanguage').value;
config.MetadataCountryCode = page.querySelector('#selectCountry').value;
apiClient.ajax({
type: 'POST',
data: config,
url: apiClient.getUrl('Startup/Configuration')
}).then(function () {
loading.hide();
navigateToNextPage();
});
function save(page) {
loading.show();
const apiClient = ApiClient;
apiClient.getJSON(apiClient.getUrl('Startup/Configuration')).then(function (config) {
config.PreferredMetadataLanguage = page.querySelector('#selectLanguage').value;
config.MetadataCountryCode = page.querySelector('#selectCountry').value;
apiClient.ajax({
type: 'POST',
data: config,
url: apiClient.getUrl('Startup/Configuration')
}).then(function () {
loading.hide();
navigateToNextPage();
});
});
}
function populateLanguages(select, languages) {
let html = '';
html += "<option value=''></option>";
for (let i = 0, length = languages.length; i < length; i++) {
const culture = languages[i];
html += "<option value='" + culture.TwoLetterISOLanguageName + "'>" + culture.DisplayName + '</option>';
}
function populateLanguages(select, languages) {
var html = '';
html += "<option value=''></option>";
select.innerHTML = html;
}
for (var i = 0, length = languages.length; i < length; i++) {
var culture = languages[i];
html += "<option value='" + culture.TwoLetterISOLanguageName + "'>" + culture.DisplayName + '</option>';
}
function populateCountries(select, allCountries) {
let html = '';
html += "<option value=''></option>";
select.innerHTML = html;
for (let i = 0, length = allCountries.length; i < length; i++) {
const culture = allCountries[i];
html += "<option value='" + culture.TwoLetterISORegionName + "'>" + culture.DisplayName + '</option>';
}
function populateCountries(select, allCountries) {
var html = '';
html += "<option value=''></option>";
select.innerHTML = html;
}
for (var i = 0, length = allCountries.length; i < length; i++) {
var culture = allCountries[i];
html += "<option value='" + culture.TwoLetterISORegionName + "'>" + culture.DisplayName + '</option>';
}
function reloadData(page, config, cultures, countries) {
populateLanguages(page.querySelector('#selectLanguage'), cultures);
populateCountries(page.querySelector('#selectCountry'), countries);
page.querySelector('#selectLanguage').value = config.PreferredMetadataLanguage;
page.querySelector('#selectCountry').value = config.MetadataCountryCode;
loading.hide();
}
select.innerHTML = html;
}
function reload(page) {
loading.show();
const apiClient = ApiClient;
const promise1 = apiClient.getJSON(apiClient.getUrl('Startup/Configuration'));
const promise2 = apiClient.getCultures();
const promise3 = apiClient.getCountries();
Promise.all([promise1, promise2, promise3]).then(function (responses) {
reloadData(page, responses[0], responses[1], responses[2]);
});
}
function reloadData(page, config, cultures, countries) {
populateLanguages(page.querySelector('#selectLanguage'), cultures);
populateCountries(page.querySelector('#selectCountry'), countries);
page.querySelector('#selectLanguage').value = config.PreferredMetadataLanguage;
page.querySelector('#selectCountry').value = config.MetadataCountryCode;
loading.hide();
}
function navigateToNextPage() {
Dashboard.navigate('wizardremoteaccess.html');
}
function reload(page) {
loading.show();
var apiClient = ApiClient;
var promise1 = apiClient.getJSON(apiClient.getUrl('Startup/Configuration'));
var promise2 = apiClient.getCultures();
var promise3 = apiClient.getCountries();
Promise.all([promise1, promise2, promise3]).then(function (responses) {
reloadData(page, responses[0], responses[1], responses[2]);
});
}
function onSubmit(e) {
save(this);
e.preventDefault();
return false;
}
function navigateToNextPage() {
Dashboard.navigate('wizardremoteaccess.html');
}
function onSubmit(e) {
save(this);
e.preventDefault();
return false;
}
return function (view, params) {
view.querySelector('.wizardSettingsForm').addEventListener('submit', onSubmit);
view.addEventListener('viewshow', function () {
document.querySelector('.skinHeader').classList.add('noHomeButtonHeader');
reload(this);
});
view.addEventListener('viewhide', function () {
document.querySelector('.skinHeader').classList.remove('noHomeButtonHeader');
});
};
});
export default function (view, params) {
view.querySelector('.wizardSettingsForm').addEventListener('submit', onSubmit);
view.addEventListener('viewshow', function () {
document.querySelector('.skinHeader').classList.add('noHomeButtonHeader');
reload(this);
});
view.addEventListener('viewhide', function () {
document.querySelector('.skinHeader').classList.remove('noHomeButtonHeader');
});
}

View File

@ -1,48 +1,49 @@
define(['jQuery', 'loading', 'emby-button', 'emby-select'], function ($, loading) {
'use strict';
import $ from 'jQuery';
import loading from 'loading';
import 'emby-button';
import 'emby-select';
function loadPage(page, config, languageOptions) {
$('#selectLocalizationLanguage', page).html(languageOptions.map(function (l) {
return '<option value="' + l.Value + '">' + l.Name + '</option>';
})).val(config.UICulture);
loading.hide();
}
function loadPage(page, config, languageOptions) {
$('#selectLocalizationLanguage', page).html(languageOptions.map(function (l) {
return '<option value="' + l.Value + '">' + l.Name + '</option>';
})).val(config.UICulture);
loading.hide();
}
function save(page) {
function save(page) {
loading.show();
const apiClient = ApiClient;
apiClient.getJSON(apiClient.getUrl('Startup/Configuration')).then(function (config) {
config.UICulture = $('#selectLocalizationLanguage', page).val();
apiClient.ajax({
type: 'POST',
data: config,
url: apiClient.getUrl('Startup/Configuration')
}).then(function () {
Dashboard.navigate('wizarduser.html');
});
});
}
function onSubmit() {
save($(this).parents('.page'));
return false;
}
export default function (view, params) {
$('.wizardStartForm', view).on('submit', onSubmit);
view.addEventListener('viewshow', function () {
document.querySelector('.skinHeader').classList.add('noHomeButtonHeader');
loading.show();
var apiClient = ApiClient;
apiClient.getJSON(apiClient.getUrl('Startup/Configuration')).then(function (config) {
config.UICulture = $('#selectLocalizationLanguage', page).val();
apiClient.ajax({
type: 'POST',
data: config,
url: apiClient.getUrl('Startup/Configuration')
}).then(function () {
Dashboard.navigate('wizarduser.html');
});
const page = this;
const apiClient = ApiClient;
const promise1 = apiClient.getJSON(apiClient.getUrl('Startup/Configuration'));
const promise2 = apiClient.getJSON(apiClient.getUrl('Localization/Options'));
Promise.all([promise1, promise2]).then(function (responses) {
loadPage(page, responses[0], responses[1]);
});
}
function onSubmit() {
save($(this).parents('.page'));
return false;
}
return function (view, params) {
$('.wizardStartForm', view).on('submit', onSubmit);
view.addEventListener('viewshow', function () {
document.querySelector('.skinHeader').classList.add('noHomeButtonHeader');
loading.show();
var page = this;
var apiClient = ApiClient;
var promise1 = apiClient.getJSON(apiClient.getUrl('Startup/Configuration'));
var promise2 = apiClient.getJSON(apiClient.getUrl('Localization/Options'));
Promise.all([promise1, promise2]).then(function (responses) {
loadPage(page, responses[0], responses[1]);
});
});
view.addEventListener('viewhide', function () {
document.querySelector('.skinHeader').classList.remove('noHomeButtonHeader');
});
};
});
});
view.addEventListener('viewhide', function () {
document.querySelector('.skinHeader').classList.remove('noHomeButtonHeader');
});
}

View File

@ -1,67 +1,69 @@
define(['loading', 'globalize', 'dashboardcss', 'emby-input', 'emby-button', 'emby-button'], function (loading, globalize) {
'use strict';
import loading from 'loading';
import globalize from 'globalize';
import 'dashboardcss';
import 'emby-input';
import 'emby-button';
function getApiClient() {
return ApiClient;
function getApiClient() {
return ApiClient;
}
function nextWizardPage() {
Dashboard.navigate('wizardlibrary.html');
}
function onUpdateUserComplete(result) {
console.debug('user update complete: ' + result);
loading.hide();
nextWizardPage();
}
function submit(form) {
loading.show();
const apiClient = getApiClient();
apiClient.ajax({
type: 'POST',
data: {
Name: form.querySelector('#txtUsername').value,
Password: form.querySelector('#txtManualPassword').value
},
url: apiClient.getUrl('Startup/User')
}).then(onUpdateUserComplete);
}
function onSubmit(e) {
const form = this;
if (form.querySelector('#txtManualPassword').value != form.querySelector('#txtPasswordConfirm').value) {
import('toast').then(({default: toast}) => {
toast(globalize.translate('PasswordMatchError'));
});
} else {
submit(form);
}
function nextWizardPage() {
Dashboard.navigate('wizardlibrary.html');
}
e.preventDefault();
return false;
}
function onUpdateUserComplete(result) {
console.debug('user update complete: ' + result);
function onViewShow() {
loading.show();
const page = this;
const apiClient = getApiClient();
apiClient.getJSON(apiClient.getUrl('Startup/User')).then(function (user) {
page.querySelector('#txtUsername').value = user.Name || '';
page.querySelector('#txtManualPassword').value = user.Password || '';
loading.hide();
nextWizardPage();
}
});
}
function submit(form) {
loading.show();
var apiClient = getApiClient();
apiClient.ajax({
type: 'POST',
data: {
Name: form.querySelector('#txtUsername').value,
Password: form.querySelector('#txtManualPassword').value
},
url: apiClient.getUrl('Startup/User')
}).then(onUpdateUserComplete);
}
function onSubmit(e) {
var form = this;
if (form.querySelector('#txtManualPassword').value != form.querySelector('#txtPasswordConfirm').value) {
require(['toast'], function (toast) {
toast(globalize.translate('PasswordMatchError'));
});
} else {
submit(form);
}
e.preventDefault();
return false;
}
function onViewShow() {
loading.show();
var page = this;
var apiClient = getApiClient();
apiClient.getJSON(apiClient.getUrl('Startup/User')).then(function (user) {
page.querySelector('#txtUsername').value = user.Name || '';
page.querySelector('#txtManualPassword').value = user.Password || '';
loading.hide();
});
}
return function (view, params) {
view.querySelector('.wizardUserForm').addEventListener('submit', onSubmit);
view.addEventListener('viewshow', function () {
document.querySelector('.skinHeader').classList.add('noHomeButtonHeader');
});
view.addEventListener('viewhide', function () {
document.querySelector('.skinHeader').classList.remove('noHomeButtonHeader');
});
view.addEventListener('viewshow', onViewShow);
};
});
export default function (view, params) {
view.querySelector('.wizardUserForm').addEventListener('submit', onSubmit);
view.addEventListener('viewshow', function () {
document.querySelector('.skinHeader').classList.add('noHomeButtonHeader');
});
view.addEventListener('viewhide', function () {
document.querySelector('.skinHeader').classList.remove('noHomeButtonHeader');
});
view.addEventListener('viewshow', onViewShow);
}

View File

@ -11,7 +11,7 @@ import 'webcomponents';
this.classList.add('progressring');
const instance = this;
require(['text!./emby-progressring.template.html'], function (template) {
import('text!./emby-progressring.template.html').then(({default: template}) => {
instance.innerHTML = template;
//if (window.MutationObserver) {

View File

@ -156,7 +156,7 @@ import 'css!./emby-scroller';
};
function loadScrollButtons(scroller) {
require(['emby-scrollbuttons'], function () {
import('emby-scrollbuttons').then(() => {
scroller.insertAdjacentHTML('beforebegin', '<div is="emby-scrollbuttons" class="emby-scrollbuttons padded-right"></div>');
});
}

View File

@ -220,7 +220,7 @@ export class BookPlayer {
let apiClient = connectionManager.getApiClient(serverId);
return new Promise((resolve, reject) => {
require(['epubjs'], (epubjs) => {
import('epubjs').then(({default: epubjs}) => {
let downloadHref = apiClient.getItemDownloadUrl(item.Id);
let book = epubjs.default(downloadHref, {openAs: 'epub'});
let rendition = book.renderTo(elem, {width: '100%', height: '97%'});

View File

@ -7,7 +7,7 @@ function alertText(options) {
return new Promise(function (resolve, reject) {
require(['alert'], function (alert) {
import('alert').then(({default: alert}) => {
alert(options).then(resolve, resolve);
});
});

View File

@ -155,7 +155,7 @@ export function enable() {
function attachGamepadScript(e) {
console.log('Gamepad connected! Attaching gamepadtokey.js script');
window.removeEventListener('gamepadconnected', attachGamepadScript);
require(['scripts/gamepadtokey']);
import('scripts/gamepadtokey');
}
// No need to check for gamepads manually at load time, the eventhandler will be fired for that