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

Migration of proflie, profiles and settings (DLNA) to ES6 Modules

This commit is contained in:
Cameron 2020-07-11 16:54:20 +01:00
parent 8730828f6f
commit 7b509fdde4
4 changed files with 118 additions and 94 deletions

View file

@ -137,6 +137,9 @@
"src/controllers/dashboard/logs.js", "src/controllers/dashboard/logs.js",
"src/controllers/user/subtitles.js", "src/controllers/user/subtitles.js",
"src/controllers/dashboard/plugins/repositories.js", "src/controllers/dashboard/plugins/repositories.js",
"src/controllers/dashboard/dlna/profile.js",
"src/controllers/dashboard/dlna/profiles.js",
"src/controllers/dashboard/dlna/settings.js",
"src/plugins/bookPlayer/plugin.js", "src/plugins/bookPlayer/plugin.js",
"src/plugins/bookPlayer/tableOfContents.js", "src/plugins/bookPlayer/tableOfContents.js",
"src/plugins/photoPlayer/plugin.js", "src/plugins/photoPlayer/plugin.js",

View file

@ -1,10 +1,18 @@
define(['jQuery', 'loading', 'globalize', 'emby-select', 'emby-button', 'emby-input', 'emby-checkbox', 'listViewStyle', 'emby-button'], function ($, loading, globalize) { import $ from 'jQuery';
'use strict'; import loading from 'loading';
import globalize from 'globalize';
import 'emby-select';
import 'emby-button';
import 'emby-input';
import 'emby-checkbox';
import 'listViewStyle';
/* eslint-disable indent */
function loadProfile(page) { function loadProfile(page) {
loading.show(); loading.show();
var promise1 = getProfile(); const promise1 = getProfile();
var promise2 = ApiClient.getUsers(); const promise2 = ApiClient.getUsers();
Promise.all([promise1, promise2]).then(function (responses) { Promise.all([promise1, promise2]).then(function (responses) {
currentProfile = responses[0]; currentProfile = responses[0];
renderProfile(page, currentProfile, responses[1]); renderProfile(page, currentProfile, responses[1]);
@ -13,8 +21,8 @@ define(['jQuery', 'loading', 'globalize', 'emby-select', 'emby-button', 'emby-in
} }
function getProfile() { function getProfile() {
var id = getParameterByName('id'); const id = getParameterByName('id');
var url = id ? 'Dlna/Profiles/' + id : 'Dlna/Profiles/Default'; const url = id ? 'Dlna/Profiles/' + id : 'Dlna/Profiles/Default';
return ApiClient.getJSON(ApiClient.getUrl(url)); return ApiClient.getJSON(ApiClient.getUrl(url));
} }
@ -26,7 +34,7 @@ define(['jQuery', 'loading', 'globalize', 'emby-select', 'emby-button', 'emby-in
$('#chkEnableAlbumArtInDidl', page).prop('checked', profile.EnableAlbumArtInDidl); $('#chkEnableAlbumArtInDidl', page).prop('checked', profile.EnableAlbumArtInDidl);
$('#chkEnableSingleImageLimit', page).prop('checked', profile.EnableSingleAlbumArtLimit); $('#chkEnableSingleImageLimit', page).prop('checked', profile.EnableSingleAlbumArtLimit);
renderXmlDocumentAttributes(page, profile.XmlRootAttributes || []); renderXmlDocumentAttributes(page, profile.XmlRootAttributes || []);
var idInfo = profile.Identification || {}; const idInfo = profile.Identification || {};
renderIdentificationHeaders(page, idInfo.Headers || []); renderIdentificationHeaders(page, idInfo.Headers || []);
renderSubtitleProfiles(page, profile.SubtitleProfiles || []); renderSubtitleProfiles(page, profile.SubtitleProfiles || []);
$('#txtInfoFriendlyName', page).val(profile.FriendlyName || ''); $('#txtInfoFriendlyName', page).val(profile.FriendlyName || '');
@ -65,7 +73,7 @@ define(['jQuery', 'loading', 'globalize', 'emby-select', 'emby-button', 'emby-in
profile.ContainerProfiles = profile.ContainerProfiles || []; profile.ContainerProfiles = profile.ContainerProfiles || [];
profile.CodecProfiles = profile.CodecProfiles || []; profile.CodecProfiles = profile.CodecProfiles || [];
profile.ResponseProfiles = profile.ResponseProfiles || []; profile.ResponseProfiles = profile.ResponseProfiles || [];
var usersHtml = '<option></option>' + users.map(function (u) { const usersHtml = '<option></option>' + users.map(function (u) {
return '<option value="' + u.Id + '">' + u.Name + '</option>'; return '<option value="' + u.Id + '">' + u.Name + '</option>';
}).join(''); }).join('');
$('#selectUser', page).html(usersHtml).val(profile.UserId || ''); $('#selectUser', page).html(usersHtml).val(profile.UserId || '');
@ -73,9 +81,9 @@ define(['jQuery', 'loading', 'globalize', 'emby-select', 'emby-button', 'emby-in
} }
function renderIdentificationHeaders(page, headers) { function renderIdentificationHeaders(page, headers) {
var index = 0; let index = 0;
var html = '<div class="paperList">' + headers.map(function (h) { const html = '<div class="paperList">' + headers.map(function (h) {
var li = '<div class="listItem">'; let li = '<div class="listItem">';
li += '<span class="material-icons listItemIcon info"></span>'; li += '<span class="material-icons listItemIcon info"></span>';
li += '<div class="listItemBody">'; li += '<div class="listItemBody">';
li += '<h3 class="listItemBodyText">' + h.Name + ': ' + (h.Value || '') + '</h3>'; li += '<h3 class="listItemBodyText">' + h.Name + ': ' + (h.Value || '') + '</h3>';
@ -86,9 +94,9 @@ define(['jQuery', 'loading', 'globalize', 'emby-select', 'emby-button', 'emby-in
index++; index++;
return li; return li;
}).join('') + '</div>'; }).join('') + '</div>';
var elem = $('.httpHeaderIdentificationList', page).html(html).trigger('create'); const elem = $('.httpHeaderIdentificationList', page).html(html).trigger('create');
$('.btnDeleteIdentificationHeader', elem).on('click', function () { $('.btnDeleteIdentificationHeader', elem).on('click', function () {
var itemIndex = parseInt(this.getAttribute('data-index')); const itemIndex = parseInt(this.getAttribute('data-index'));
currentProfile.Identification.Headers.splice(itemIndex, 1); currentProfile.Identification.Headers.splice(itemIndex, 1);
renderIdentificationHeaders(page, currentProfile.Identification.Headers); renderIdentificationHeaders(page, currentProfile.Identification.Headers);
}); });
@ -106,7 +114,7 @@ define(['jQuery', 'loading', 'globalize', 'emby-select', 'emby-button', 'emby-in
isSubProfileNew = null == header; isSubProfileNew = null == header;
header = header || {}; header = header || {};
currentSubProfile = header; currentSubProfile = header;
var popup = $('#identificationHeaderPopup', page); const popup = $('#identificationHeaderPopup', page);
$('#txtIdentificationHeaderName', popup).val(header.Name || ''); $('#txtIdentificationHeaderName', popup).val(header.Name || '');
$('#txtIdentificationHeaderValue', popup).val(header.Value || ''); $('#txtIdentificationHeaderValue', popup).val(header.Value || '');
$('#selectMatchType', popup).val(header.Match || 'Equals'); $('#selectMatchType', popup).val(header.Match || 'Equals');
@ -130,8 +138,8 @@ define(['jQuery', 'loading', 'globalize', 'emby-select', 'emby-button', 'emby-in
} }
function renderXmlDocumentAttributes(page, attribute) { function renderXmlDocumentAttributes(page, attribute) {
var html = '<div class="paperList">' + attribute.map(function (h) { const html = '<div class="paperList">' + attribute.map(function (h) {
var li = '<div class="listItem">'; let li = '<div class="listItem">';
li += '<span class="material-icons listItemIcon info"></span>'; li += '<span class="material-icons listItemIcon info"></span>';
li += '<div class="listItemBody">'; li += '<div class="listItemBody">';
li += '<h3 class="listItemBodyText">' + h.Name + ' = ' + (h.Value || '') + '</h3>'; li += '<h3 class="listItemBodyText">' + h.Name + ' = ' + (h.Value || '') + '</h3>';
@ -139,9 +147,9 @@ define(['jQuery', 'loading', 'globalize', 'emby-select', 'emby-button', 'emby-in
li += '<button type="button" is="paper-icon-button-light" class="btnDeleteXmlAttribute listItemButton" data-index="0"><span class="material-icons delete"></span></button>'; li += '<button type="button" is="paper-icon-button-light" class="btnDeleteXmlAttribute listItemButton" data-index="0"><span class="material-icons delete"></span></button>';
return li += '</div>'; return li += '</div>';
}).join('') + '</div>'; }).join('') + '</div>';
var elem = $('.xmlDocumentAttributeList', page).html(html).trigger('create'); const elem = $('.xmlDocumentAttributeList', page).html(html).trigger('create');
$('.btnDeleteXmlAttribute', elem).on('click', function () { $('.btnDeleteXmlAttribute', elem).on('click', function () {
var itemIndex = parseInt(this.getAttribute('data-index')); const itemIndex = parseInt(this.getAttribute('data-index'));
currentProfile.XmlRootAttributes.splice(itemIndex, 1); currentProfile.XmlRootAttributes.splice(itemIndex, 1);
renderXmlDocumentAttributes(page, currentProfile.XmlRootAttributes); renderXmlDocumentAttributes(page, currentProfile.XmlRootAttributes);
}); });
@ -151,7 +159,7 @@ define(['jQuery', 'loading', 'globalize', 'emby-select', 'emby-button', 'emby-in
isSubProfileNew = null == attribute; isSubProfileNew = null == attribute;
attribute = attribute || {}; attribute = attribute || {};
currentSubProfile = attribute; currentSubProfile = attribute;
var popup = $('#xmlAttributePopup', page); const popup = $('#xmlAttributePopup', page);
$('#txtXmlAttributeName', popup).val(attribute.Name || ''); $('#txtXmlAttributeName', popup).val(attribute.Name || '');
$('#txtXmlAttributeValue', popup).val(attribute.Value || ''); $('#txtXmlAttributeValue', popup).val(attribute.Value || '');
openPopup(popup[0]); openPopup(popup[0]);
@ -171,9 +179,9 @@ define(['jQuery', 'loading', 'globalize', 'emby-select', 'emby-button', 'emby-in
} }
function renderSubtitleProfiles(page, profiles) { function renderSubtitleProfiles(page, profiles) {
var index = 0; let index = 0;
var html = '<div class="paperList">' + profiles.map(function (h) { const html = '<div class="paperList">' + profiles.map(function (h) {
var li = '<div class="listItem lnkEditSubProfile" data-index="' + index + '">'; let li = '<div class="listItem lnkEditSubProfile" data-index="' + index + '">';
li += '<span class="material-icons listItemIcon info"></span>'; li += '<span class="material-icons listItemIcon info"></span>';
li += '<div class="listItemBody">'; li += '<div class="listItemBody">';
li += '<h3 class="listItemBodyText">' + (h.Format || '') + '</h3>'; li += '<h3 class="listItemBodyText">' + (h.Format || '') + '</h3>';
@ -183,14 +191,14 @@ define(['jQuery', 'loading', 'globalize', 'emby-select', 'emby-button', 'emby-in
index++; index++;
return li; return li;
}).join('') + '</div>'; }).join('') + '</div>';
var elem = $('.subtitleProfileList', page).html(html).trigger('create'); const elem = $('.subtitleProfileList', page).html(html).trigger('create');
$('.btnDeleteProfile', elem).on('click', function () { $('.btnDeleteProfile', elem).on('click', function () {
var itemIndex = parseInt(this.getAttribute('data-index')); const itemIndex = parseInt(this.getAttribute('data-index'));
currentProfile.SubtitleProfiles.splice(itemIndex, 1); currentProfile.SubtitleProfiles.splice(itemIndex, 1);
renderSubtitleProfiles(page, currentProfile.SubtitleProfiles); renderSubtitleProfiles(page, currentProfile.SubtitleProfiles);
}); });
$('.lnkEditSubProfile', elem).on('click', function () { $('.lnkEditSubProfile', elem).on('click', function () {
var itemIndex = parseInt(this.getAttribute('data-index')); const itemIndex = parseInt(this.getAttribute('data-index'));
editSubtitleProfile(page, currentProfile.SubtitleProfiles[itemIndex]); editSubtitleProfile(page, currentProfile.SubtitleProfiles[itemIndex]);
}); });
} }
@ -199,7 +207,7 @@ define(['jQuery', 'loading', 'globalize', 'emby-select', 'emby-button', 'emby-in
isSubProfileNew = null == profile; isSubProfileNew = null == profile;
profile = profile || {}; profile = profile || {};
currentSubProfile = profile; currentSubProfile = profile;
var popup = $('#subtitleProfilePopup', page); const popup = $('#subtitleProfilePopup', page);
$('#txtSubtitleProfileFormat', popup).val(profile.Format || ''); $('#txtSubtitleProfileFormat', popup).val(profile.Format || '');
$('#selectSubtitleProfileMethod', popup).val(profile.Method || ''); $('#selectSubtitleProfileMethod', popup).val(profile.Method || '');
$('#selectSubtitleProfileDidlMode', popup).val(profile.DidlMode || ''); $('#selectSubtitleProfileDidlMode', popup).val(profile.DidlMode || '');
@ -244,12 +252,12 @@ define(['jQuery', 'loading', 'globalize', 'emby-select', 'emby-button', 'emby-in
} }
function renderDirectPlayProfiles(page, profiles) { function renderDirectPlayProfiles(page, profiles) {
var html = ''; let html = '';
html += '<ul data-role="listview" data-inset="true" data-split-icon="delete">'; html += '<ul data-role="listview" data-inset="true" data-split-icon="delete">';
var currentType; let currentType;
for (var i = 0, length = profiles.length; i < length; i++) { for (let i = 0, length = profiles.length; i < length; i++) {
var profile = profiles[i]; const profile = profiles[i];
if (profile.Type !== currentType) { if (profile.Type !== currentType) {
html += '<li data-role="list-divider">' + profile.Type + '</li>'; html += '<li data-role="list-divider">' + profile.Type + '</li>';
@ -275,13 +283,13 @@ define(['jQuery', 'loading', 'globalize', 'emby-select', 'emby-button', 'emby-in
} }
html += '</ul>'; html += '</ul>';
var elem = $('.directPlayProfiles', page).html(html).trigger('create'); const elem = $('.directPlayProfiles', page).html(html).trigger('create');
$('.btnDeleteProfile', elem).on('click', function () { $('.btnDeleteProfile', elem).on('click', function () {
var index = this.getAttribute('data-profileindex'); const index = this.getAttribute('data-profileindex');
deleteDirectPlayProfile(page, index); deleteDirectPlayProfile(page, index);
}); });
$('.lnkEditSubProfile', elem).on('click', function () { $('.lnkEditSubProfile', elem).on('click', function () {
var index = parseInt(this.getAttribute('data-profileindex')); const index = parseInt(this.getAttribute('data-profileindex'));
editDirectPlayProfile(page, currentProfile.DirectPlayProfiles[index]); editDirectPlayProfile(page, currentProfile.DirectPlayProfiles[index]);
}); });
} }
@ -295,7 +303,7 @@ define(['jQuery', 'loading', 'globalize', 'emby-select', 'emby-button', 'emby-in
isSubProfileNew = null == directPlayProfile; isSubProfileNew = null == directPlayProfile;
directPlayProfile = directPlayProfile || {}; directPlayProfile = directPlayProfile || {};
currentSubProfile = directPlayProfile; currentSubProfile = directPlayProfile;
var popup = $('#popupEditDirectPlayProfile', page); const popup = $('#popupEditDirectPlayProfile', page);
$('#selectDirectPlayProfileType', popup).val(directPlayProfile.Type || 'Video').trigger('change'); $('#selectDirectPlayProfileType', popup).val(directPlayProfile.Type || 'Video').trigger('change');
$('#txtDirectPlayContainer', popup).val(directPlayProfile.Container || ''); $('#txtDirectPlayContainer', popup).val(directPlayProfile.Container || '');
$('#txtDirectPlayAudioCodec', popup).val(directPlayProfile.AudioCodec || ''); $('#txtDirectPlayAudioCodec', popup).val(directPlayProfile.AudioCodec || '');
@ -304,12 +312,12 @@ define(['jQuery', 'loading', 'globalize', 'emby-select', 'emby-button', 'emby-in
} }
function renderTranscodingProfiles(page, profiles) { function renderTranscodingProfiles(page, profiles) {
var html = ''; let html = '';
html += '<ul data-role="listview" data-inset="true" data-split-icon="delete">'; html += '<ul data-role="listview" data-inset="true" data-split-icon="delete">';
var currentType; let currentType;
for (var i = 0, length = profiles.length; i < length; i++) { for (let i = 0, length = profiles.length; i < length; i++) {
var profile = profiles[i]; let profile = profiles[i];
if (profile.Type !== currentType) { if (profile.Type !== currentType) {
html += '<li data-role="list-divider">' + profile.Type + '</li>'; html += '<li data-role="list-divider">' + profile.Type + '</li>';
@ -336,13 +344,13 @@ define(['jQuery', 'loading', 'globalize', 'emby-select', 'emby-button', 'emby-in
} }
html += '</ul>'; html += '</ul>';
var elem = $('.transcodingProfiles', page).html(html).trigger('create'); const elem = $('.transcodingProfiles', page).html(html).trigger('create');
$('.btnDeleteProfile', elem).on('click', function () { $('.btnDeleteProfile', elem).on('click', function () {
var index = this.getAttribute('data-profileindex'); const index = this.getAttribute('data-profileindex');
deleteTranscodingProfile(page, index); deleteTranscodingProfile(page, index);
}); });
$('.lnkEditSubProfile', elem).on('click', function () { $('.lnkEditSubProfile', elem).on('click', function () {
var index = parseInt(this.getAttribute('data-profileindex')); const index = parseInt(this.getAttribute('data-profileindex'));
editTranscodingProfile(page, currentProfile.TranscodingProfiles[index]); editTranscodingProfile(page, currentProfile.TranscodingProfiles[index]);
}); });
} }
@ -351,7 +359,7 @@ define(['jQuery', 'loading', 'globalize', 'emby-select', 'emby-button', 'emby-in
isSubProfileNew = null == transcodingProfile; isSubProfileNew = null == transcodingProfile;
transcodingProfile = transcodingProfile || {}; transcodingProfile = transcodingProfile || {};
currentSubProfile = transcodingProfile; currentSubProfile = transcodingProfile;
var popup = $('#transcodingProfilePopup', page); const popup = $('#transcodingProfilePopup', page);
$('#selectTranscodingProfileType', popup).val(transcodingProfile.Type || 'Video').trigger('change'); $('#selectTranscodingProfileType', popup).val(transcodingProfile.Type || 'Video').trigger('change');
$('#txtTranscodingContainer', popup).val(transcodingProfile.Container || ''); $('#txtTranscodingContainer', popup).val(transcodingProfile.Container || '');
$('#txtTranscodingAudioCodec', popup).val(transcodingProfile.AudioCodec || ''); $('#txtTranscodingAudioCodec', popup).val(transcodingProfile.AudioCodec || '');
@ -390,12 +398,12 @@ define(['jQuery', 'loading', 'globalize', 'emby-select', 'emby-button', 'emby-in
} }
function renderContainerProfiles(page, profiles) { function renderContainerProfiles(page, profiles) {
var html = ''; let html = '';
html += '<ul data-role="listview" data-inset="true" data-split-icon="delete">'; html += '<ul data-role="listview" data-inset="true" data-split-icon="delete">';
var currentType; let currentType;
for (var i = 0, length = profiles.length; i < length; i++) { for (let i = 0, length = profiles.length; i < length; i++) {
var profile = profiles[i]; let profile = profiles[i];
if (profile.Type !== currentType) { if (profile.Type !== currentType) {
html += '<li data-role="list-divider">' + profile.Type + '</li>'; html += '<li data-role="list-divider">' + profile.Type + '</li>';
@ -420,13 +428,13 @@ define(['jQuery', 'loading', 'globalize', 'emby-select', 'emby-button', 'emby-in
} }
html += '</ul>'; html += '</ul>';
var elem = $('.containerProfiles', page).html(html).trigger('create'); const elem = $('.containerProfiles', page).html(html).trigger('create');
$('.btnDeleteProfile', elem).on('click', function () { $('.btnDeleteProfile', elem).on('click', function () {
var index = this.getAttribute('data-profileindex'); const index = this.getAttribute('data-profileindex');
deleteContainerProfile(page, index); deleteContainerProfile(page, index);
}); });
$('.lnkEditSubProfile', elem).on('click', function () { $('.lnkEditSubProfile', elem).on('click', function () {
var index = parseInt(this.getAttribute('data-profileindex')); const index = parseInt(this.getAttribute('data-profileindex'));
editContainerProfile(page, currentProfile.ContainerProfiles[index]); editContainerProfile(page, currentProfile.ContainerProfiles[index]);
}); });
} }
@ -440,7 +448,7 @@ define(['jQuery', 'loading', 'globalize', 'emby-select', 'emby-button', 'emby-in
isSubProfileNew = null == containerProfile; isSubProfileNew = null == containerProfile;
containerProfile = containerProfile || {}; containerProfile = containerProfile || {};
currentSubProfile = containerProfile; currentSubProfile = containerProfile;
var popup = $('#containerProfilePopup', page); const popup = $('#containerProfilePopup', page);
$('#selectContainerProfileType', popup).val(containerProfile.Type || 'Video').trigger('change'); $('#selectContainerProfileType', popup).val(containerProfile.Type || 'Video').trigger('change');
$('#txtContainerProfileContainer', popup).val(containerProfile.Container || ''); $('#txtContainerProfileContainer', popup).val(containerProfile.Container || '');
$('.radioTabButton:first', popup).trigger('click'); $('.radioTabButton:first', popup).trigger('click');
@ -461,13 +469,13 @@ define(['jQuery', 'loading', 'globalize', 'emby-select', 'emby-button', 'emby-in
} }
function renderCodecProfiles(page, profiles) { function renderCodecProfiles(page, profiles) {
var html = ''; let html = '';
html += '<ul data-role="listview" data-inset="true" data-split-icon="delete">'; html += '<ul data-role="listview" data-inset="true" data-split-icon="delete">';
var currentType; let currentType;
for (var i = 0, length = profiles.length; i < length; i++) { for (let i = 0, length = profiles.length; i < length; i++) {
var profile = profiles[i]; let profile = profiles[i];
var type = profile.Type.replace('VideoAudio', 'Video Audio'); const type = profile.Type.replace('VideoAudio', 'Video Audio');
if (type !== currentType) { if (type !== currentType) {
html += '<li data-role="list-divider">' + type + '</li>'; html += '<li data-role="list-divider">' + type + '</li>';
@ -492,13 +500,13 @@ define(['jQuery', 'loading', 'globalize', 'emby-select', 'emby-button', 'emby-in
} }
html += '</ul>'; html += '</ul>';
var elem = $('.codecProfiles', page).html(html).trigger('create'); const elem = $('.codecProfiles', page).html(html).trigger('create');
$('.btnDeleteProfile', elem).on('click', function () { $('.btnDeleteProfile', elem).on('click', function () {
var index = this.getAttribute('data-profileindex'); const index = this.getAttribute('data-profileindex');
deleteCodecProfile(page, index); deleteCodecProfile(page, index);
}); });
$('.lnkEditSubProfile', elem).on('click', function () { $('.lnkEditSubProfile', elem).on('click', function () {
var index = parseInt(this.getAttribute('data-profileindex')); const index = parseInt(this.getAttribute('data-profileindex'));
editCodecProfile(page, currentProfile.CodecProfiles[index]); editCodecProfile(page, currentProfile.CodecProfiles[index]);
}); });
} }
@ -512,7 +520,7 @@ define(['jQuery', 'loading', 'globalize', 'emby-select', 'emby-button', 'emby-in
isSubProfileNew = null == codecProfile; isSubProfileNew = null == codecProfile;
codecProfile = codecProfile || {}; codecProfile = codecProfile || {};
currentSubProfile = codecProfile; currentSubProfile = codecProfile;
var popup = $('#codecProfilePopup', page); const popup = $('#codecProfilePopup', page);
$('#selectCodecProfileType', popup).val(codecProfile.Type || 'Video').trigger('change'); $('#selectCodecProfileType', popup).val(codecProfile.Type || 'Video').trigger('change');
$('#txtCodecProfileCodec', popup).val(codecProfile.Codec || ''); $('#txtCodecProfileCodec', popup).val(codecProfile.Codec || '');
$('.radioTabButton:first', popup).trigger('click'); $('.radioTabButton:first', popup).trigger('click');
@ -533,12 +541,12 @@ define(['jQuery', 'loading', 'globalize', 'emby-select', 'emby-button', 'emby-in
} }
function renderResponseProfiles(page, profiles) { function renderResponseProfiles(page, profiles) {
var html = ''; let html = '';
html += '<ul data-role="listview" data-inset="true" data-split-icon="delete">'; html += '<ul data-role="listview" data-inset="true" data-split-icon="delete">';
var currentType; let currentType;
for (var i = 0, length = profiles.length; i < length; i++) { for (let i = 0, length = profiles.length; i < length; i++) {
var profile = profiles[i]; const profile = profiles[i];
if (profile.Type !== currentType) { if (profile.Type !== currentType) {
html += '<li data-role="list-divider">' + profile.Type + '</li>'; html += '<li data-role="list-divider">' + profile.Type + '</li>';
@ -572,13 +580,13 @@ define(['jQuery', 'loading', 'globalize', 'emby-select', 'emby-button', 'emby-in
} }
html += '</ul>'; html += '</ul>';
var elem = $('.mediaProfiles', page).html(html).trigger('create'); const elem = $('.mediaProfiles', page).html(html).trigger('create');
$('.btnDeleteProfile', elem).on('click', function () { $('.btnDeleteProfile', elem).on('click', function () {
var index = this.getAttribute('data-profileindex'); const index = this.getAttribute('data-profileindex');
deleteResponseProfile(page, index); deleteResponseProfile(page, index);
}); });
$('.lnkEditSubProfile', elem).on('click', function () { $('.lnkEditSubProfile', elem).on('click', function () {
var index = parseInt(this.getAttribute('data-profileindex')); const index = parseInt(this.getAttribute('data-profileindex'));
editResponseProfile(page, currentProfile.ResponseProfiles[index]); editResponseProfile(page, currentProfile.ResponseProfiles[index]);
}); });
} }
@ -592,7 +600,7 @@ define(['jQuery', 'loading', 'globalize', 'emby-select', 'emby-button', 'emby-in
isSubProfileNew = null == responseProfile; isSubProfileNew = null == responseProfile;
responseProfile = responseProfile || {}; responseProfile = responseProfile || {};
currentSubProfile = responseProfile; currentSubProfile = responseProfile;
var popup = $('#responseProfilePopup', page); const popup = $('#responseProfilePopup', page);
$('#selectResponseProfileType', popup).val(responseProfile.Type || 'Video').trigger('change'); $('#selectResponseProfileType', popup).val(responseProfile.Type || 'Video').trigger('change');
$('#txtResponseProfileContainer', popup).val(responseProfile.Container || ''); $('#txtResponseProfileContainer', popup).val(responseProfile.Container || '');
$('#txtResponseProfileAudioCodec', popup).val(responseProfile.AudioCodec || ''); $('#txtResponseProfileAudioCodec', popup).val(responseProfile.AudioCodec || '');
@ -618,7 +626,7 @@ define(['jQuery', 'loading', 'globalize', 'emby-select', 'emby-button', 'emby-in
function saveProfile(page, profile) { function saveProfile(page, profile) {
updateProfile(page, profile); updateProfile(page, profile);
var id = getParameterByName('id'); const id = getParameterByName('id');
if (id) { if (id) {
ApiClient.ajax({ ApiClient.ajax({
@ -627,7 +635,7 @@ define(['jQuery', 'loading', 'globalize', 'emby-select', 'emby-button', 'emby-in
data: JSON.stringify(profile), data: JSON.stringify(profile),
contentType: 'application/json' contentType: 'application/json'
}).then(function () { }).then(function () {
require(['toast'], function (toast) { import('toast').then(({default: toast}) => {
toast('Settings saved.'); toast('Settings saved.');
}); });
}, Dashboard.processErrorResponse); }, Dashboard.processErrorResponse);
@ -687,18 +695,18 @@ define(['jQuery', 'loading', 'globalize', 'emby-select', 'emby-button', 'emby-in
profile.UserId = $('#selectUser', page).val(); profile.UserId = $('#selectUser', page).val();
} }
var currentProfile; let currentProfile;
var currentSubProfile; let currentSubProfile;
var isSubProfileNew; let isSubProfileNew;
var allText = globalize.translate('LabelAll'); const allText = globalize.translate('LabelAll');
$(document).on('pageinit', '#dlnaProfilePage', function () { $(document).on('pageinit', '#dlnaProfilePage', function () {
var page = this; const page = this;
$('.radioTabButton', page).on('click', function () { $('.radioTabButton', page).on('click', function () {
$(this).siblings().removeClass('ui-btn-active'); $(this).siblings().removeClass('ui-btn-active');
$(this).addClass('ui-btn-active'); $(this).addClass('ui-btn-active');
var value = 'A' == this.tagName ? this.getAttribute('data-value') : this.value; const value = 'A' == this.tagName ? this.getAttribute('data-value') : this.value;
var elem = $('.' + value, page); const elem = $('.' + value, page);
elem.siblings('.tabContent').hide(); elem.siblings('.tabContent').hide();
elem.show(); elem.show();
}); });
@ -783,7 +791,7 @@ define(['jQuery', 'loading', 'globalize', 'emby-select', 'emby-button', 'emby-in
$('.xmlAttributeForm').off('submit', DlnaProfilePage.onXmlAttributeFormSubmit).on('submit', DlnaProfilePage.onXmlAttributeFormSubmit); $('.xmlAttributeForm').off('submit', DlnaProfilePage.onXmlAttributeFormSubmit).on('submit', DlnaProfilePage.onXmlAttributeFormSubmit);
$('.subtitleProfileForm').off('submit', DlnaProfilePage.onSubtitleProfileFormSubmit).on('submit', DlnaProfilePage.onSubtitleProfileFormSubmit); $('.subtitleProfileForm').off('submit', DlnaProfilePage.onSubtitleProfileFormSubmit).on('submit', DlnaProfilePage.onSubtitleProfileFormSubmit);
}).on('pageshow', '#dlnaProfilePage', function () { }).on('pageshow', '#dlnaProfilePage', function () {
var page = this; const page = this;
$('#radioInfo', page).trigger('click'); $('#radioInfo', page).trigger('click');
loadProfile(page); loadProfile(page);
}); });
@ -826,4 +834,5 @@ define(['jQuery', 'loading', 'globalize', 'emby-select', 'emby-button', 'emby-in
return false; return false;
} }
}; };
});
/* eslint-enable indent */

View file

@ -1,5 +1,11 @@
define(['jQuery', 'globalize', 'loading', 'libraryMenu', 'listViewStyle', 'emby-button'], function ($, globalize, loading, libraryMenu) { import $ from 'jQuery';
'use strict'; import globalize from 'globalize';
import loading from 'loading';
import libraryMenu from 'libraryMenu';
import 'listViewStyle';
import 'emby-button';
/* eslint-disable indent */
function loadProfiles(page) { function loadProfiles(page) {
loading.show(); loading.show();
@ -23,14 +29,14 @@ define(['jQuery', 'globalize', 'loading', 'libraryMenu', 'listViewStyle', 'emby-
} }
function renderProfiles(page, element, profiles) { function renderProfiles(page, element, profiles) {
var html = ''; let html = '';
if (profiles.length) { if (profiles.length) {
html += '<div class="paperList">'; html += '<div class="paperList">';
} }
for (var i = 0, length = profiles.length; i < length; i++) { for (let i = 0, length = profiles.length; i < length; i++) {
var profile = profiles[i]; let profile = profiles[i];
html += '<div class="listItem listItem-border">'; html += '<div class="listItem listItem-border">';
html += '<span class="listItemIcon material-icons live_tv"></span>'; html += '<span class="listItemIcon material-icons live_tv"></span>';
html += '<div class="listItemBody two-line">'; html += '<div class="listItemBody two-line">';
@ -52,13 +58,13 @@ define(['jQuery', 'globalize', 'loading', 'libraryMenu', 'listViewStyle', 'emby-
element.innerHTML = html; element.innerHTML = html;
$('.btnDeleteProfile', element).on('click', function () { $('.btnDeleteProfile', element).on('click', function () {
var id = this.getAttribute('data-profileid'); const id = this.getAttribute('data-profileid');
deleteProfile(page, id); deleteProfile(page, id);
}); });
} }
function deleteProfile(page, id) { function deleteProfile(page, id) {
require(['confirm'], function (confirm) { import('confirm').then(({default: confirm}) => {
confirm(globalize.translate('MessageConfirmProfileDeletion'), globalize.translate('HeaderConfirmProfileDeletion')).then(function () { confirm(globalize.translate('MessageConfirmProfileDeletion'), globalize.translate('HeaderConfirmProfileDeletion')).then(function () {
loading.show(); loading.show();
ApiClient.ajax({ ApiClient.ajax({
@ -86,4 +92,5 @@ define(['jQuery', 'globalize', 'loading', 'libraryMenu', 'listViewStyle', 'emby-
libraryMenu.setTabs('dlna', 1, getTabs); libraryMenu.setTabs('dlna', 1, getTabs);
loadProfiles(this); loadProfiles(this);
}); });
});
/* eslint-enable indent */

View file

@ -1,5 +1,9 @@
define(['jQuery', 'loading', 'libraryMenu', 'globalize'], function ($, loading, libraryMenu, globalize) { import $ from 'jQuery';
'use strict'; import loading from 'loading';
import libraryMenu from 'libraryMenu';
import globalize from 'globalize';
/* eslint-disable indent */
function loadPage(page, config, users) { function loadPage(page, config, users) {
page.querySelector('#chkEnablePlayTo').checked = config.EnablePlayTo; page.querySelector('#chkEnablePlayTo').checked = config.EnablePlayTo;
@ -8,7 +12,7 @@ define(['jQuery', 'loading', 'libraryMenu', 'globalize'], function ($, loading,
$('#chkEnableServer', page).prop('checked', config.EnableServer); $('#chkEnableServer', page).prop('checked', config.EnableServer);
$('#chkBlastAliveMessages', page).prop('checked', config.BlastAliveMessages); $('#chkBlastAliveMessages', page).prop('checked', config.BlastAliveMessages);
$('#txtBlastInterval', page).val(config.BlastAliveMessageIntervalSeconds); $('#txtBlastInterval', page).val(config.BlastAliveMessageIntervalSeconds);
var usersHtml = users.map(function (u) { const usersHtml = users.map(function (u) {
return '<option value="' + u.Id + '">' + u.Name + '</option>'; return '<option value="' + u.Id + '">' + u.Name + '</option>';
}).join(''); }).join('');
$('#selectUser', page).html(usersHtml).val(config.DefaultUserId || ''); $('#selectUser', page).html(usersHtml).val(config.DefaultUserId || '');
@ -17,7 +21,7 @@ define(['jQuery', 'loading', 'libraryMenu', 'globalize'], function ($, loading,
function onSubmit() { function onSubmit() {
loading.show(); loading.show();
var form = this; const form = this;
ApiClient.getNamedConfiguration('dlna').then(function (config) { ApiClient.getNamedConfiguration('dlna').then(function (config) {
config.EnablePlayTo = form.querySelector('#chkEnablePlayTo').checked; config.EnablePlayTo = form.querySelector('#chkEnablePlayTo').checked;
config.EnableDebugLog = form.querySelector('#chkEnableDlnaDebugLogging').checked; config.EnableDebugLog = form.querySelector('#chkEnableDlnaDebugLogging').checked;
@ -46,11 +50,12 @@ define(['jQuery', 'loading', 'libraryMenu', 'globalize'], function ($, loading,
}).on('pageshow', '#dlnaSettingsPage', function () { }).on('pageshow', '#dlnaSettingsPage', function () {
libraryMenu.setTabs('dlna', 0, getTabs); libraryMenu.setTabs('dlna', 0, getTabs);
loading.show(); loading.show();
var page = this; const page = this;
var promise1 = ApiClient.getNamedConfiguration('dlna'); const promise1 = ApiClient.getNamedConfiguration('dlna');
var promise2 = ApiClient.getUsers(); const promise2 = ApiClient.getUsers();
Promise.all([promise1, promise2]).then(function (responses) { Promise.all([promise1, promise2]).then(function (responses) {
loadPage(page, responses[0], responses[1]); loadPage(page, responses[0], responses[1]);
}); });
}); });
});
/* eslint-enable indent */