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

always use const when possible

This commit is contained in:
dkanada 2020-09-12 05:46:15 +09:00
parent eec822ef34
commit a5776e98a7
8 changed files with 80 additions and 80 deletions

View file

@ -31,7 +31,7 @@ function closeAfter(notification, timeoutMs) {
function resetRegistration() { function resetRegistration() {
/* eslint-disable-next-line compat/compat */ /* eslint-disable-next-line compat/compat */
let serviceWorker = navigator.serviceWorker; const serviceWorker = navigator.serviceWorker;
if (serviceWorker) { if (serviceWorker) {
serviceWorker.ready.then(function (registration) { serviceWorker.ready.then(function (registration) {
serviceWorkerRegistration = registration; serviceWorkerRegistration = registration;
@ -47,7 +47,7 @@ function showPersistentNotification(title, options, timeoutMs) {
function showNonPersistentNotification(title, options, timeoutMs) { function showNonPersistentNotification(title, options, timeoutMs) {
try { try {
let notif = new Notification(title, options); /* eslint-disable-line compat/compat */ const notif = new Notification(title, options); /* eslint-disable-line compat/compat */
if (notif.show) { if (notif.show) {
notif.show(); notif.show();
@ -67,7 +67,7 @@ function showNonPersistentNotification(title, options, timeoutMs) {
} }
function showNotification(options, timeoutMs, apiClient) { function showNotification(options, timeoutMs, apiClient) {
let title = options.title; const title = options.title;
options.data = options.data || {}; options.data = options.data || {};
options.data.serverId = apiClient.serverInfo().Id; options.data.serverId = apiClient.serverInfo().Id;
@ -95,7 +95,7 @@ function showNewItemNotification(item, apiClient) {
body = item.SeriesName + ' - ' + body; body = item.SeriesName + ' - ' + body;
} }
let notification = { const notification = {
title: 'New ' + item.Type, title: 'New ' + item.Type,
body: body, body: body,
vibrate: true, vibrate: true,
@ -103,7 +103,7 @@ function showNewItemNotification(item, apiClient) {
data: {} data: {}
}; };
let imageTags = item.ImageTags || {}; const imageTags = item.ImageTags || {};
if (imageTags.Primary) { if (imageTags.Primary) {
notification.icon = apiClient.getScaledImageUrl(item.Id, { notification.icon = apiClient.getScaledImageUrl(item.Id, {
@ -117,7 +117,7 @@ function showNewItemNotification(item, apiClient) {
} }
function onLibraryChanged(data, apiClient) { function onLibraryChanged(data, apiClient) {
let newItems = data.ItemsAdded; const newItems = data.ItemsAdded;
if (!newItems.length) { if (!newItems.length) {
return; return;
@ -140,7 +140,7 @@ function onLibraryChanged(data, apiClient) {
EnableTotalRecordCount: false EnableTotalRecordCount: false
}).then(function (result) { }).then(function (result) {
let items = result.Items; const items = result.Items;
for (const item of items) { for (const item of items) {
showNewItemNotification(item, apiClient); showNewItemNotification(item, apiClient);
@ -159,7 +159,7 @@ function showPackageInstallNotification(apiClient, installation, status) {
return; return;
} }
let notification = { const notification = {
tag: 'install' + installation.Id, tag: 'install' + installation.Id,
data: {} data: {}
}; };
@ -188,12 +188,12 @@ function showPackageInstallNotification(apiClient, installation, status) {
} }
if (status === 'progress') { if (status === 'progress') {
let percentComplete = Math.round(installation.PercentComplete || 0); const percentComplete = Math.round(installation.PercentComplete || 0);
notification.body = percentComplete + '% complete.'; notification.body = percentComplete + '% complete.';
} }
let timeout = status === 'cancelled' ? 5000 : 0; const timeout = status === 'cancelled' ? 5000 : 0;
showNotification(notification, timeout, apiClient); showNotification(notification, timeout, apiClient);
}); });
@ -220,8 +220,8 @@ events.on(serverNotifications, 'PackageInstalling', function (e, apiClient, data
}); });
events.on(serverNotifications, 'ServerShuttingDown', function (e, apiClient, data) { events.on(serverNotifications, 'ServerShuttingDown', function (e, apiClient, data) {
let serverId = apiClient.serverInfo().Id; const serverId = apiClient.serverInfo().Id;
let notification = { const notification = {
tag: 'restart' + serverId, tag: 'restart' + serverId,
title: globalize.translate('ServerNameIsShuttingDown', apiClient.serverInfo().Name) title: globalize.translate('ServerNameIsShuttingDown', apiClient.serverInfo().Name)
}; };
@ -229,8 +229,8 @@ events.on(serverNotifications, 'ServerShuttingDown', function (e, apiClient, dat
}); });
events.on(serverNotifications, 'ServerRestarting', function (e, apiClient, data) { events.on(serverNotifications, 'ServerRestarting', function (e, apiClient, data) {
let serverId = apiClient.serverInfo().Id; const serverId = apiClient.serverInfo().Id;
let notification = { const notification = {
tag: 'restart' + serverId, tag: 'restart' + serverId,
title: globalize.translate('ServerNameIsRestarting', apiClient.serverInfo().Name) title: globalize.translate('ServerNameIsRestarting', apiClient.serverInfo().Name)
}; };
@ -238,8 +238,8 @@ events.on(serverNotifications, 'ServerRestarting', function (e, apiClient, data)
}); });
events.on(serverNotifications, 'RestartRequired', function (e, apiClient) { events.on(serverNotifications, 'RestartRequired', function (e, apiClient) {
let serverId = apiClient.serverInfo().Id; const serverId = apiClient.serverInfo().Id;
let notification = { const notification = {
tag: 'restart' + serverId, tag: 'restart' + serverId,
title: globalize.translate('PleaseRestartServerName', apiClient.serverInfo().Name) title: globalize.translate('PleaseRestartServerName', apiClient.serverInfo().Name)
}; };

View file

@ -1110,8 +1110,8 @@ class PlaybackManager {
self.increasePlaybackRate = function (player) { self.increasePlaybackRate = function (player) {
player = player || self._currentPlayer; player = player || self._currentPlayer;
if (player) { if (player) {
let current = self.getPlaybackRate(player); const current = self.getPlaybackRate(player);
let supported = self.getSupportedPlaybackRates(player); const supported = self.getSupportedPlaybackRates(player);
let index = -1; let index = -1;
for (let i = 0, length = supported.length; i < length; i++) { for (let i = 0, length = supported.length; i < length; i++) {
@ -1129,8 +1129,8 @@ class PlaybackManager {
self.decreasePlaybackRate = function (player) { self.decreasePlaybackRate = function (player) {
player = player || self._currentPlayer; player = player || self._currentPlayer;
if (player) { if (player) {
let current = self.getPlaybackRate(player); const current = self.getPlaybackRate(player);
let supported = self.getSupportedPlaybackRates(player); const supported = self.getSupportedPlaybackRates(player);
let index = -1; let index = -1;
for (let i = 0, length = supported.length; i < length; i++) { for (let i = 0, length = supported.length; i < length; i++) {

View file

@ -18,9 +18,9 @@ let currentItem;
let hasChanges; let hasChanges;
function downloadRemoteSubtitles(context, id) { function downloadRemoteSubtitles(context, id) {
let url = 'Items/' + currentItem.Id + '/RemoteSearch/Subtitles/' + id; const url = 'Items/' + currentItem.Id + '/RemoteSearch/Subtitles/' + id;
let apiClient = window.connectionManager.getApiClient(currentItem.ServerId); const apiClient = window.connectionManager.getApiClient(currentItem.ServerId);
apiClient.ajax({ apiClient.ajax({
type: 'POST', type: 'POST',
@ -38,7 +38,7 @@ function downloadRemoteSubtitles(context, id) {
} }
function deleteLocalSubtitle(context, index) { function deleteLocalSubtitle(context, index) {
let msg = globalize.translate('MessageAreYouSureDeleteSubtitles'); const msg = globalize.translate('MessageAreYouSureDeleteSubtitles');
import('confirm').then(({default: confirm}) => { import('confirm').then(({default: confirm}) => {
confirm({ confirm({
@ -51,10 +51,10 @@ function deleteLocalSubtitle(context, index) {
}).then(function () { }).then(function () {
loading.show(); loading.show();
let itemId = currentItem.Id; const itemId = currentItem.Id;
let url = 'Videos/' + itemId + '/Subtitles/' + index; const url = 'Videos/' + itemId + '/Subtitles/' + index;
let apiClient = window.connectionManager.getApiClient(currentItem.ServerId); const apiClient = window.connectionManager.getApiClient(currentItem.ServerId);
apiClient.ajax({ apiClient.ajax({
@ -70,9 +70,9 @@ function deleteLocalSubtitle(context, index) {
} }
function fillSubtitleList(context, item) { function fillSubtitleList(context, item) {
let streams = item.MediaStreams || []; const streams = item.MediaStreams || [];
let subs = streams.filter(function (s) { const subs = streams.filter(function (s) {
return s.Type === 'Subtitle'; return s.Type === 'Subtitle';
}); });
@ -86,7 +86,7 @@ function fillSubtitleList(context, item) {
html += subs.map(function (s) { html += subs.map(function (s) {
let itemHtml = ''; let itemHtml = '';
let tagName = layoutManager.tv ? 'button' : 'div'; const tagName = layoutManager.tv ? 'button' : 'div';
let className = layoutManager.tv && s.Path ? 'listItem listItem-border btnDelete' : 'listItem listItem-border'; let className = layoutManager.tv && s.Path ? 'listItem listItem-border btnDelete' : 'listItem listItem-border';
if (layoutManager.tv) { if (layoutManager.tv) {
@ -126,7 +126,7 @@ function fillSubtitleList(context, item) {
html += '</div>'; html += '</div>';
} }
let elem = context.querySelector('.subtitleList'); const elem = context.querySelector('.subtitleList');
if (subs.length) { if (subs.length) {
elem.classList.remove('hide'); elem.classList.remove('hide');
@ -137,18 +137,18 @@ function fillSubtitleList(context, item) {
} }
function fillLanguages(context, apiClient, languages) { function fillLanguages(context, apiClient, languages) {
let selectLanguage = context.querySelector('#selectLanguage'); const selectLanguage = context.querySelector('#selectLanguage');
selectLanguage.innerHTML = languages.map(function (l) { selectLanguage.innerHTML = languages.map(function (l) {
return '<option value="' + l.ThreeLetterISOLanguageName + '">' + l.DisplayName + '</option>'; return '<option value="' + l.ThreeLetterISOLanguageName + '">' + l.DisplayName + '</option>';
}); });
let lastLanguage = userSettings.get('subtitleeditor-language'); const lastLanguage = userSettings.get('subtitleeditor-language');
if (lastLanguage) { if (lastLanguage) {
selectLanguage.value = lastLanguage; selectLanguage.value = lastLanguage;
} else { } else {
apiClient.getCurrentUser().then(function (user) { apiClient.getCurrentUser().then(function (user) {
let lang = user.Configuration.SubtitleLanguagePreference; const lang = user.Configuration.SubtitleLanguagePreference;
if (lang) { if (lang) {
selectLanguage.value = lang; selectLanguage.value = lang;
@ -171,9 +171,9 @@ function renderSearchResults(context, results) {
context.querySelector('.noSearchResults').classList.add('hide'); context.querySelector('.noSearchResults').classList.add('hide');
for (let i = 0, length = results.length; i < length; i++) { for (let i = 0, length = results.length; i < length; i++) {
let result = results[i]; const result = results[i];
let provider = result.ProviderName; const provider = result.ProviderName;
if (provider !== lastProvider) { if (provider !== lastProvider) {
if (i > 0) { if (i > 0) {
@ -184,7 +184,7 @@ function renderSearchResults(context, results) {
lastProvider = provider; lastProvider = provider;
} }
let tagName = layoutManager.tv ? 'button' : 'div'; const tagName = layoutManager.tv ? 'button' : 'div';
let className = layoutManager.tv ? 'listItem listItem-border btnOptions' : 'listItem listItem-border'; let className = layoutManager.tv ? 'listItem listItem-border btnOptions' : 'listItem listItem-border';
if (layoutManager.tv) { if (layoutManager.tv) {
className += ' listItem-focusscale listItem-button'; className += ' listItem-focusscale listItem-button';
@ -194,7 +194,7 @@ function renderSearchResults(context, results) {
html += '<span class="listItemIcon material-icons closed_caption"></span>'; html += '<span class="listItemIcon material-icons closed_caption"></span>';
let bodyClass = result.Comment || result.IsHashMatch ? 'three-line' : 'two-line'; const bodyClass = result.Comment || result.IsHashMatch ? 'three-line' : 'two-line';
html += '<div class="listItemBody ' + bodyClass + '">'; html += '<div class="listItemBody ' + bodyClass + '">';
@ -231,7 +231,7 @@ function renderSearchResults(context, results) {
html += '</div>'; html += '</div>';
} }
let elem = context.querySelector('.subtitleResults'); const elem = context.querySelector('.subtitleResults');
elem.innerHTML = html; elem.innerHTML = html;
loading.hide(); loading.hide();
@ -242,8 +242,8 @@ function searchForSubtitles(context, language) {
loading.show(); loading.show();
let apiClient = window.connectionManager.getApiClient(currentItem.ServerId); const apiClient = window.connectionManager.getApiClient(currentItem.ServerId);
let url = apiClient.getUrl('Items/' + currentItem.Id + '/RemoteSearch/Subtitles/' + language); const url = apiClient.getUrl('Items/' + currentItem.Id + '/RemoteSearch/Subtitles/' + language);
apiClient.getJSON(url).then(function (results) { apiClient.getJSON(url).then(function (results) {
renderSearchResults(context, results); renderSearchResults(context, results);
@ -258,7 +258,7 @@ function reload(context, apiClient, itemId) {
fillSubtitleList(context, item); fillSubtitleList(context, item);
let file = item.Path || ''; let file = item.Path || '';
let index = Math.max(file.lastIndexOf('/'), file.lastIndexOf('\\')); const index = Math.max(file.lastIndexOf('/'), file.lastIndexOf('\\'));
if (index > -1) { if (index > -1) {
file = file.substring(index + 1); file = file.substring(index + 1);
} }
@ -282,9 +282,9 @@ function reload(context, apiClient, itemId) {
} }
function onSearchSubmit(e) { function onSearchSubmit(e) {
let form = this; const form = this;
let lang = form.querySelector('#selectLanguage', form).value; const lang = form.querySelector('#selectLanguage', form).value;
searchForSubtitles(dom.parentWithClass(form, 'formDialogContent'), lang); searchForSubtitles(dom.parentWithClass(form, 'formDialogContent'), lang);
@ -293,10 +293,10 @@ function onSearchSubmit(e) {
} }
function onSubtitleListClick(e) { function onSubtitleListClick(e) {
let btnDelete = dom.parentWithClass(e.target, 'btnDelete'); const btnDelete = dom.parentWithClass(e.target, 'btnDelete');
if (btnDelete) { if (btnDelete) {
let index = btnDelete.getAttribute('data-index'); const index = btnDelete.getAttribute('data-index');
let context = dom.parentWithClass(btnDelete, 'subtitleEditorDialog'); const context = dom.parentWithClass(btnDelete, 'subtitleEditorDialog');
deleteLocalSubtitle(context, index); deleteLocalSubtitle(context, index);
} }
} }
@ -305,14 +305,14 @@ function onSubtitleResultsClick(e) {
let subtitleId; let subtitleId;
let context; let context;
let btnOptions = dom.parentWithClass(e.target, 'btnOptions'); const btnOptions = dom.parentWithClass(e.target, 'btnOptions');
if (btnOptions) { if (btnOptions) {
subtitleId = btnOptions.getAttribute('data-subid'); subtitleId = btnOptions.getAttribute('data-subid');
context = dom.parentWithClass(btnOptions, 'subtitleEditorDialog'); context = dom.parentWithClass(btnOptions, 'subtitleEditorDialog');
showDownloadOptions(btnOptions, context, subtitleId); showDownloadOptions(btnOptions, context, subtitleId);
} }
let btnDownload = dom.parentWithClass(e.target, 'btnDownload'); const btnDownload = dom.parentWithClass(e.target, 'btnDownload');
if (btnDownload) { if (btnDownload) {
subtitleId = btnDownload.getAttribute('data-subid'); subtitleId = btnDownload.getAttribute('data-subid');
context = dom.parentWithClass(btnDownload, 'subtitleEditorDialog'); context = dom.parentWithClass(btnDownload, 'subtitleEditorDialog');
@ -321,7 +321,7 @@ function onSubtitleResultsClick(e) {
} }
function showDownloadOptions(button, context, subtitleId) { function showDownloadOptions(button, context, subtitleId) {
let items = []; const items = [];
items.push({ items.push({
name: globalize.translate('Download'), name: globalize.translate('Download'),
@ -347,7 +347,7 @@ function showDownloadOptions(button, context, subtitleId) {
function centerFocus(elem, horiz, on) { function centerFocus(elem, horiz, on) {
import('scrollHelper').then(({default: scrollHelper}) => { import('scrollHelper').then(({default: scrollHelper}) => {
let fn = on ? 'on' : 'off'; const fn = on ? 'on' : 'off';
scrollHelper.centerFocus[fn](elem, horiz); scrollHelper.centerFocus[fn](elem, horiz);
}); });
} }
@ -355,9 +355,9 @@ function centerFocus(elem, horiz, on) {
function showEditorInternal(itemId, serverId, template) { function showEditorInternal(itemId, serverId, template) {
hasChanges = false; hasChanges = false;
let apiClient = window.connectionManager.getApiClient(serverId); const apiClient = window.connectionManager.getApiClient(serverId);
return apiClient.getItem(apiClient.getCurrentUserId(), itemId).then(function (item) { return apiClient.getItem(apiClient.getCurrentUserId(), itemId).then(function (item) {
let dialogOptions = { const dialogOptions = {
removeOnClose: true, removeOnClose: true,
scrollY: false scrollY: false
}; };
@ -368,7 +368,7 @@ function showEditorInternal(itemId, serverId, template) {
dialogOptions.size = 'small'; dialogOptions.size = 'small';
} }
let dlg = dialogHelper.createDialog(dialogOptions); const dlg = dialogHelper.createDialog(dialogOptions);
dlg.classList.add('formDialog'); dlg.classList.add('formDialog');
dlg.classList.add('subtitleEditorDialog'); dlg.classList.add('subtitleEditorDialog');
@ -379,7 +379,7 @@ function showEditorInternal(itemId, serverId, template) {
dlg.querySelector('.subtitleSearchForm').addEventListener('submit', onSearchSubmit); dlg.querySelector('.subtitleSearchForm').addEventListener('submit', onSearchSubmit);
let btnSubmit = dlg.querySelector('.btnSubmit'); const btnSubmit = dlg.querySelector('.btnSubmit');
if (layoutManager.tv) { if (layoutManager.tv) {
centerFocus(dlg.querySelector('.formDialogContent'), false, true); centerFocus(dlg.querySelector('.formDialogContent'), false, true);
@ -388,7 +388,7 @@ function showEditorInternal(itemId, serverId, template) {
btnSubmit.classList.add('hide'); btnSubmit.classList.add('hide');
} }
let editorContent = dlg.querySelector('.formDialogContent'); const editorContent = dlg.querySelector('.formDialogContent');
dlg.querySelector('.subtitleList').addEventListener('click', onSubtitleListClick); dlg.querySelector('.subtitleList').addEventListener('click', onSubtitleListClick);
dlg.querySelector('.subtitleResults').addEventListener('click', onSubtitleResultsClick); dlg.querySelector('.subtitleResults').addEventListener('click', onSubtitleResultsClick);

View file

@ -14,7 +14,7 @@ import 'css!components/viewManager/viewContainer';
} }
controllerUrl = Dashboard.getPluginUrl(controllerUrl); controllerUrl = Dashboard.getPluginUrl(controllerUrl);
let apiUrl = ApiClient.getUrl('/web/' + controllerUrl); const apiUrl = ApiClient.getUrl('/web/' + controllerUrl);
return import(apiUrl).then((ControllerFactory) => { return import(apiUrl).then((ControllerFactory) => {
options.controllerFactory = ControllerFactory; options.controllerFactory = ControllerFactory;
}); });

View file

@ -163,11 +163,11 @@ import 'emby-itemscontainer';
itemsContainer.fetchData = fetchData; itemsContainer.fetchData = fetchData;
itemsContainer.getItemsHtml = getItemsHtml; itemsContainer.getItemsHtml = getItemsHtml;
itemsContainer.afterRefresh = afterRefresh; itemsContainer.afterRefresh = afterRefresh;
let alphaPickerElement = tabContent.querySelector('.alphaPicker'); const alphaPickerElement = tabContent.querySelector('.alphaPicker');
if (alphaPickerElement) { if (alphaPickerElement) {
alphaPickerElement.addEventListener('alphavaluechanged', function (e) { alphaPickerElement.addEventListener('alphavaluechanged', function (e) {
let newValue = e.detail.value; const newValue = e.detail.value;
query.NameStartsWith = newValue; query.NameStartsWith = newValue;
query.StartIndex = 0; query.StartIndex = 0;
itemsContainer.refreshItems(); itemsContainer.refreshItems();
@ -237,7 +237,7 @@ import 'emby-itemscontainer';
libraryBrowser.showLayoutMenu(e.target, this.getCurrentViewStyle, 'Banner,List,Poster,PosterCard,Thumb,ThumbCard'.split(',')); libraryBrowser.showLayoutMenu(e.target, this.getCurrentViewStyle, 'Banner,List,Poster,PosterCard,Thumb,ThumbCard'.split(','));
}); });
btnSelectView.addEventListener('layoutchange', function (e) { btnSelectView.addEventListener('layoutchange', function (e) {
let viewStyle = e.detail.viewStyle; const viewStyle = e.detail.viewStyle;
userSettings.set(savedViewKey, viewStyle); userSettings.set(savedViewKey, viewStyle);
query.StartIndex = 0; query.StartIndex = 0;
onViewStyleChange(); onViewStyleChange();
@ -274,7 +274,7 @@ import 'emby-itemscontainer';
this.showFilterMenu = function () { this.showFilterMenu = function () {
import('components/filterdialog/filterdialog').then(({default: filterDialogFactory}) => { import('components/filterdialog/filterdialog').then(({default: filterDialogFactory}) => {
let filterDialog = new filterDialogFactory({ const filterDialog = new filterDialogFactory({
query: query, query: query,
mode: 'movies', mode: 'movies',
serverId: ApiClient.serverId() serverId: ApiClient.serverId()

View file

@ -58,7 +58,7 @@ import 'emby-button';
} }
function loadResume(page, userId, parentId) { function loadResume(page, userId, parentId) {
let screenWidth = dom.getWindowSize().innerWidth; const screenWidth = dom.getWindowSize().innerWidth;
const options = { const options = {
SortBy: 'DatePlayed', SortBy: 'DatePlayed',
SortOrder: 'Descending', SortOrder: 'Descending',
@ -154,8 +154,8 @@ import 'emby-button';
} }
function loadSuggestions(page, userId, parentId) { function loadSuggestions(page, userId, parentId) {
let screenWidth = dom.getWindowSize().innerWidth; const screenWidth = dom.getWindowSize().innerWidth;
let url = ApiClient.getUrl('Movies/Recommendations', { const url = ApiClient.getUrl('Movies/Recommendations', {
userId: userId, userId: userId,
categoryLimit: 6, categoryLimit: 6,
ItemLimit: screenWidth >= 1920 ? 8 : screenWidth >= 1600 ? 8 : screenWidth >= 1200 ? 6 : 5, ItemLimit: screenWidth >= 1920 ? 8 : screenWidth >= 1600 ? 8 : screenWidth >= 1200 ? 6 : 5,
@ -172,7 +172,7 @@ import 'emby-button';
const html = recommendations.map(getRecommendationHtml).join(''); const html = recommendations.map(getRecommendationHtml).join('');
page.querySelector('.noItemsMessage').classList.add('hide'); page.querySelector('.noItemsMessage').classList.add('hide');
let recs = page.querySelector('.recommendations'); const recs = page.querySelector('.recommendations');
recs.innerHTML = html; recs.innerHTML = html;
imageLoader.lazyChildren(recs); imageLoader.lazyChildren(recs);
@ -381,16 +381,16 @@ import 'emby-button';
const suggestionsTabIndex = 1; const suggestionsTabIndex = 1;
this.initTab = function () { this.initTab = function () {
let tabContent = view.querySelector(".pageTabContent[data-index='" + suggestionsTabIndex + "']"); const tabContent = view.querySelector(".pageTabContent[data-index='" + suggestionsTabIndex + "']");
initSuggestedTab(view, tabContent); initSuggestedTab(view, tabContent);
}; };
this.renderTab = function () { this.renderTab = function () {
let tabContent = view.querySelector(".pageTabContent[data-index='" + suggestionsTabIndex + "']"); const tabContent = view.querySelector(".pageTabContent[data-index='" + suggestionsTabIndex + "']");
loadSuggestionsTab(view, params, tabContent); loadSuggestionsTab(view, params, tabContent);
}; };
let tabControllers = []; const tabControllers = [];
let renderedTabs = []; let renderedTabs = [];
view.addEventListener('viewshow', function (e) { view.addEventListener('viewshow', function (e) {
initTabs(); initTabs();

View file

@ -19,14 +19,14 @@ export class ComicsPlayer {
play(options) { play(options) {
this.progress = 0; this.progress = 0;
let elem = this.createMediaElement(); const elem = this.createMediaElement();
return this.setCurrentSrc(elem, options); return this.setCurrentSrc(elem, options);
} }
stop() { stop() {
this.unbindEvents(); this.unbindEvents();
let elem = this.mediaElement; const elem = this.mediaElement;
if (elem) { if (elem) {
dialogHelper.close(elem); dialogHelper.close(elem);
this.mediaElement = null; this.mediaElement = null;
@ -40,7 +40,7 @@ export class ComicsPlayer {
} }
onWindowKeyUp(e) { onWindowKeyUp(e) {
let key = keyboardnavigation.getKeyName(e); const key = keyboardnavigation.getKeyName(e);
switch (key) { switch (key) {
case 'Escape': case 'Escape':
this.stop(); this.stop();
@ -87,20 +87,20 @@ export class ComicsPlayer {
} }
setCurrentSrc(elem, options) { setCurrentSrc(elem, options) {
let item = options.items[0]; const item = options.items[0];
this.currentItem = item; this.currentItem = item;
loading.show(); loading.show();
let serverId = item.ServerId; const serverId = item.ServerId;
let apiClient = window.connectionManager.getApiClient(serverId); const apiClient = window.connectionManager.getApiClient(serverId);
libarchive.Archive.init({ libarchive.Archive.init({
workerUrl: appRouter.baseUrl() + '/libraries/worker-bundle.js' workerUrl: appRouter.baseUrl() + '/libraries/worker-bundle.js'
}); });
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
let downloadUrl = apiClient.getItemDownloadUrl(item.Id); const downloadUrl = apiClient.getItemDownloadUrl(item.Id);
const archiveSource = new ArchiveSource(downloadUrl); const archiveSource = new ArchiveSource(downloadUrl);
var instance = this; var instance = this;
@ -169,18 +169,18 @@ class ArchiveSource {
} }
async load() { async load() {
let res = await fetch(this.url); const res = await fetch(this.url);
if (!res.ok) { if (!res.ok) {
return; return;
} }
let blob = await res.blob(); const blob = await res.blob();
this.archive = await libarchive.Archive.open(blob); this.archive = await libarchive.Archive.open(blob);
this.raw = await this.archive.getFilesArray(); this.raw = await this.archive.getFilesArray();
this.numberOfFiles = this.raw.length; this.numberOfFiles = this.raw.length;
await this.archive.extractFiles(); await this.archive.extractFiles();
let files = await this.archive.getFilesArray(); const files = await this.archive.getFilesArray();
files.sort((a, b) => { files.sort((a, b) => {
if (a.file.name < b.file.name) { if (a.file.name < b.file.name) {
return -1; return -1;
@ -189,9 +189,9 @@ class ArchiveSource {
} }
}); });
for (let file of files) { for (const file of files) {
/* eslint-disable-next-line compat/compat */ /* eslint-disable-next-line compat/compat */
let url = URL.createObjectURL(file.file); const url = URL.createObjectURL(file.file);
this.urls.push(url); this.urls.push(url);
} }
} }

View file

@ -141,7 +141,7 @@ export function alert(options) {
} }
export function capabilities(appHost) { export function capabilities(appHost) {
let capabilities = { const capabilities = {
PlayableMediaTypes: ['Audio', 'Video'], PlayableMediaTypes: ['Audio', 'Video'],
SupportedCommands: ['MoveUp', 'MoveDown', 'MoveLeft', 'MoveRight', 'PageUp', 'PageDown', 'PreviousLetter', 'NextLetter', 'ToggleOsd', 'ToggleContextMenu', 'Select', 'Back', 'SendKey', 'SendString', 'GoHome', 'GoToSettings', 'VolumeUp', 'VolumeDown', 'Mute', 'Unmute', 'ToggleMute', 'SetVolume', 'SetAudioStreamIndex', 'SetSubtitleStreamIndex', 'DisplayContent', 'GoToSearch', 'DisplayMessage', 'SetRepeatMode', 'SetShuffleQueue', 'ChannelUp', 'ChannelDown', 'PlayMediaSource', 'PlayTrailers'], SupportedCommands: ['MoveUp', 'MoveDown', 'MoveLeft', 'MoveRight', 'PageUp', 'PageDown', 'PreviousLetter', 'NextLetter', 'ToggleOsd', 'ToggleContextMenu', 'Select', 'Back', 'SendKey', 'SendString', 'GoHome', 'GoToSettings', 'VolumeUp', 'VolumeDown', 'Mute', 'Unmute', 'ToggleMute', 'SetVolume', 'SetAudioStreamIndex', 'SetSubtitleStreamIndex', 'DisplayContent', 'GoToSearch', 'DisplayMessage', 'SetRepeatMode', 'SetShuffleQueue', 'ChannelUp', 'ChannelDown', 'PlayMediaSource', 'PlayTrailers'],
SupportsPersistentIdentifier: window.appMode === 'cordova' || window.appMode === 'android', SupportsPersistentIdentifier: window.appMode === 'cordova' || window.appMode === 'android',