mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Merge branch 'es6' into migrate-to-ES6-13
This commit is contained in:
commit
4592594b04
50 changed files with 1123 additions and 1093 deletions
20
package.json
20
package.json
|
@ -118,6 +118,7 @@
|
|||
"src/components/itemidentifier/itemidentifier.js",
|
||||
"src/components/itemMediaInfo/itemMediaInfo.js",
|
||||
"src/components/lazyLoader/lazyLoaderIntersectionObserver.js",
|
||||
"src/components/mediainfo/mediainfo.js",
|
||||
"src/components/multiSelect/multiSelect.js",
|
||||
"src/components/maintabsmanager.js",
|
||||
"src/components/mediaLibraryCreator/mediaLibraryCreator.js",
|
||||
|
@ -163,6 +164,8 @@
|
|||
"src/controllers/dashboard/dashboard.js",
|
||||
"src/controllers/dashboard/encodingsettings.js",
|
||||
"src/controllers/dashboard/logs.js",
|
||||
"src/controllers/user/menu.js",
|
||||
"src/controllers/user/profile.js",
|
||||
"src/controllers/user/subtitles.js",
|
||||
"src/controllers/dashboard/general.js",
|
||||
"src/controllers/dashboard/librarydisplay.js",
|
||||
|
@ -228,6 +231,11 @@
|
|||
"src/plugins/bookPlayer/plugin.js",
|
||||
"src/plugins/bookPlayer/tableOfContents.js",
|
||||
"src/plugins/photoPlayer/plugin.js",
|
||||
"src/scripts/alphanumericshortcuts.js",
|
||||
"src/scripts/autoBackdrops.js",
|
||||
"src/scripts/settings/appSettings.js",
|
||||
"src/scripts/settings/userSettings.js",
|
||||
"src/scripts/settings/webSettings.js",
|
||||
"src/scripts/datetime.js",
|
||||
"src/scripts/deleteHelper.js",
|
||||
"src/scripts/dfnshelper.js",
|
||||
|
@ -237,13 +245,19 @@
|
|||
"src/scripts/imagehelper.js",
|
||||
"src/scripts/inputManager.js",
|
||||
"src/plugins/backdropScreensaver/plugin.js",
|
||||
"src/plugins/youtubePlayer/plugin.js",
|
||||
"src/components/filterdialog/filterdialog.js",
|
||||
"src/components/fetchhelper.js",
|
||||
"src/scripts/editorsidebar.js",
|
||||
"src/scripts/globalize.js",
|
||||
"src/scripts/playlists.js",
|
||||
"src/scripts/keyboardNavigation.js",
|
||||
"src/scripts/settings/appSettings.js",
|
||||
"src/scripts/settings/userSettings.js",
|
||||
"src/scripts/taskbutton.js",
|
||||
"src/scripts/touchHelper.js",
|
||||
"src/scripts/themeLoader.js",
|
||||
"src/scripts/settings/webSettings.js"
|
||||
"src/plugins/backdropScreensaver/plugin.js",
|
||||
"src/components/filterdialog/filterdialog.js",
|
||||
"src/components/fetchhelper.js"
|
||||
],
|
||||
"plugins": [
|
||||
"@babel/plugin-transform-modules-amd",
|
||||
|
|
|
@ -66,7 +66,7 @@ import 'formDialogStyle';
|
|||
});
|
||||
dlg.classList.add('formDialog');
|
||||
let html = '';
|
||||
html += globalize.translateDocument(template);
|
||||
html += globalize.translateHtml(template);
|
||||
dlg.innerHTML = html;
|
||||
populateHours(dlg);
|
||||
loadSchedule(dlg, options.schedule);
|
||||
|
|
|
@ -465,7 +465,7 @@ define(['loading', 'globalize', 'events', 'viewManager', 'skinManager', 'backdro
|
|||
|
||||
function loadContent(ctx, route, html, request) {
|
||||
|
||||
html = globalize.translateDocument(html, route.dictionary);
|
||||
html = globalize.translateHtml(html, route.dictionary);
|
||||
request.view = html;
|
||||
|
||||
viewManager.loadView(request);
|
||||
|
|
|
@ -412,7 +412,7 @@ import 'css!./style.css';
|
|||
dlg.classList.add('background-theme-a');
|
||||
dlg.classList.add('formDialog');
|
||||
dlg.classList.add('filterDialog');
|
||||
dlg.innerHTML = globalize.translateDocument(template);
|
||||
dlg.innerHTML = globalize.translateHtml(template);
|
||||
setVisibility(dlg, this.options);
|
||||
dialogHelper.open(dlg);
|
||||
dlg.addEventListener('close', resolve);
|
||||
|
|
|
@ -286,7 +286,7 @@ define(['require', 'dom', 'focusManager', 'dialogHelper', 'loading', 'apphost',
|
|||
|
||||
html += template;
|
||||
|
||||
dlg.innerHTML = globalize.translateDocument(html, 'core');
|
||||
dlg.innerHTML = globalize.translateHtml(html, 'core');
|
||||
|
||||
var settingElements = dlg.querySelectorAll('.viewSetting');
|
||||
for (var i = 0, length = settingElements.length; i < length; i++) {
|
||||
|
|
|
@ -114,7 +114,7 @@ define(['dialogHelper', 'globalize', 'userSettings', 'layoutManager', 'connectio
|
|||
|
||||
var html = '';
|
||||
|
||||
html += globalize.translateDocument(template, 'core');
|
||||
html += globalize.translateHtml(template, 'core');
|
||||
|
||||
dlg.innerHTML = html;
|
||||
|
||||
|
|
|
@ -1151,7 +1151,7 @@ define(['require', 'inputManager', 'browser', 'globalize', 'connectionManager',
|
|||
|
||||
context.classList.add('tvguide');
|
||||
|
||||
context.innerHTML = globalize.translateDocument(template, 'core');
|
||||
context.innerHTML = globalize.translateHtml(template, 'core');
|
||||
|
||||
programGrid = context.querySelector('.programGrid');
|
||||
var timeslotHeaders = context.querySelector('.timeslotHeaders');
|
||||
|
|
|
@ -464,7 +464,7 @@ import 'emby-checkbox';
|
|||
template = template.replace(`{section${i}label}`, globalize.translate('LabelHomeScreenSectionValue', i));
|
||||
}
|
||||
|
||||
options.element.innerHTML = globalize.translateDocument(template, 'core');
|
||||
options.element.innerHTML = globalize.translateHtml(template, 'core');
|
||||
|
||||
options.element.querySelector('.viewOrderList').addEventListener('click', onSectionOrderListClick);
|
||||
options.element.querySelector('form').addEventListener('submit', onSubmit.bind(self));
|
||||
|
|
|
@ -339,7 +339,7 @@ define(['dom', 'loading', 'apphost', 'dialogHelper', 'connectionManager', 'image
|
|||
|
||||
var dlg = dialogHelper.createDialog(dialogOptions);
|
||||
|
||||
dlg.innerHTML = globalize.translateDocument(template, 'core');
|
||||
dlg.innerHTML = globalize.translateHtml(template, 'core');
|
||||
|
||||
if (layoutManager.tv) {
|
||||
scrollHelper.centerFocus.on(dlg, false);
|
||||
|
|
|
@ -92,7 +92,7 @@ define(['globalize', 'dom', 'dialogHelper', 'emby-checkbox', 'emby-select', 'emb
|
|||
scrollY: false
|
||||
});
|
||||
dlg.classList.add('formDialog');
|
||||
dlg.innerHTML = globalize.translateDocument(template);
|
||||
dlg.innerHTML = globalize.translateHtml(template);
|
||||
dlg.addEventListener('close', function () {
|
||||
saveValues(dlg, options);
|
||||
});
|
||||
|
|
|
@ -161,7 +161,7 @@ import 'css!./style';
|
|||
|
||||
dlg.classList.add('formDialog');
|
||||
|
||||
dlg.innerHTML = globalize.translateDocument(template, 'core');
|
||||
dlg.innerHTML = globalize.translateHtml(template, 'core');
|
||||
|
||||
if (layoutManager.tv) {
|
||||
scrollHelper.centerFocus.on(dlg, false);
|
||||
|
|
|
@ -464,7 +464,7 @@ define(['dialogHelper', 'connectionManager', 'loading', 'dom', 'layoutManager',
|
|||
|
||||
dlg.classList.add('formDialog');
|
||||
|
||||
dlg.innerHTML = globalize.translateDocument(template, 'core');
|
||||
dlg.innerHTML = globalize.translateHtml(template, 'core');
|
||||
|
||||
if (layoutManager.tv) {
|
||||
scrollHelper.centerFocus.on(dlg, false);
|
||||
|
|
|
@ -150,7 +150,7 @@ import 'flexStyles';
|
|||
const dlg = dialogHelper.createDialog(dialogOptions);
|
||||
dlg.classList.add('formDialog');
|
||||
let html = '';
|
||||
html += globalize.translateDocument(template, 'core');
|
||||
html += globalize.translateHtml(template, 'core');
|
||||
dlg.innerHTML = html;
|
||||
if (layoutManager.tv) {
|
||||
dlg.querySelector('.formDialogContent');
|
||||
|
|
|
@ -382,7 +382,7 @@ import 'cardStyle';
|
|||
dlg.classList.add('recordingDialog');
|
||||
|
||||
let html = '';
|
||||
html += globalize.translateDocument(template, 'core');
|
||||
html += globalize.translateHtml(template, 'core');
|
||||
|
||||
dlg.innerHTML = html;
|
||||
|
||||
|
@ -464,7 +464,7 @@ import 'cardStyle';
|
|||
dlg.classList.add('recordingDialog');
|
||||
|
||||
let html = '';
|
||||
html += globalize.translateDocument(template, 'core');
|
||||
html += globalize.translateHtml(template, 'core');
|
||||
|
||||
dlg.innerHTML = html;
|
||||
|
||||
|
|
|
@ -359,7 +359,7 @@ define(['globalize', 'dom', 'emby-checkbox', 'emby-select', 'emby-input'], funct
|
|||
xhr.open('GET', 'components/libraryoptionseditor/libraryoptionseditor.template.html', true);
|
||||
xhr.onload = function(e) {
|
||||
var template = this.response;
|
||||
parent.innerHTML = globalize.translateDocument(template);
|
||||
parent.innerHTML = globalize.translateHtml(template);
|
||||
populateRefreshInterval(parent.querySelector('#selectAutoRefreshInterval'));
|
||||
var promises = [populateLanguages(parent), populateCountries(parent.querySelector('#selectCountry'))];
|
||||
Promise.all(promises).then(function() {
|
||||
|
|
|
@ -211,7 +211,7 @@ export class showEditor {
|
|||
dlg.classList.add('background-theme-a');
|
||||
dlg.classList.add('dlg-librarycreator');
|
||||
dlg.classList.add('formDialog');
|
||||
dlg.innerHTML = globalize.translateDocument(template);
|
||||
dlg.innerHTML = globalize.translateHtml(template);
|
||||
initEditor(dlg, options.collectionTypeOptions);
|
||||
dlg.addEventListener('close', onDialogClosed);
|
||||
dialogHelper.open(dlg);
|
||||
|
|
|
@ -226,7 +226,7 @@ export class showEditor {
|
|||
dlg.classList.add('ui-body-a');
|
||||
dlg.classList.add('background-theme-a');
|
||||
dlg.classList.add('formDialog');
|
||||
dlg.innerHTML = globalize.translateDocument(template);
|
||||
dlg.innerHTML = globalize.translateHtml(template);
|
||||
dlg.querySelector('.formDialogHeaderTitle').innerHTML = options.library.Name;
|
||||
initEditor(dlg, options);
|
||||
dlg.addEventListener('close', onDialogClosed);
|
||||
|
|
|
@ -1,9 +1,18 @@
|
|||
define(['datetime', 'globalize', 'appRouter', 'itemHelper', 'indicators', 'material-icons', 'css!./mediainfo.css', 'programStyles', 'emby-button'], function (datetime, globalize, appRouter, itemHelper, indicators) {
|
||||
'use strict';
|
||||
import datetime from 'datetime';
|
||||
import globalize from 'globalize';
|
||||
import appRouter from 'appRouter';
|
||||
import itemHelper from 'itemHelper';
|
||||
import indicators from 'indicators';
|
||||
import 'material-icons';
|
||||
import 'css!./mediainfo.css';
|
||||
import 'programStyles';
|
||||
import 'emby-button';
|
||||
|
||||
/* eslint-disable indent */
|
||||
|
||||
function getTimerIndicator(item) {
|
||||
|
||||
var status;
|
||||
let status;
|
||||
|
||||
if (item.Type === 'SeriesTimer') {
|
||||
return '<span class="material-icons mediaInfoItem mediaInfoIconItem mediaInfoTimerIcon fiber_smart_record"></span>';
|
||||
|
@ -30,11 +39,11 @@ define(['datetime', 'globalize', 'appRouter', 'itemHelper', 'indicators', 'mater
|
|||
}
|
||||
|
||||
function getProgramInfoHtml(item, options) {
|
||||
var html = '';
|
||||
let html = '';
|
||||
|
||||
var miscInfo = [];
|
||||
var text;
|
||||
var date;
|
||||
const miscInfo = [];
|
||||
let text;
|
||||
let date;
|
||||
|
||||
if (item.StartDate && options.programTime !== false) {
|
||||
|
||||
|
@ -48,35 +57,35 @@ define(['datetime', 'globalize', 'appRouter', 'itemHelper', 'indicators', 'mater
|
|||
text += datetime.toLocaleDateString(date, { weekday: 'short', month: 'short', day: 'numeric' });
|
||||
}
|
||||
|
||||
text += ' ' + datetime.getDisplayTime(date);
|
||||
text += ` ${datetime.getDisplayTime(date)}`;
|
||||
|
||||
if (item.EndDate) {
|
||||
date = datetime.parseISO8601Date(item.EndDate);
|
||||
text += ' - ' + datetime.getDisplayTime(date);
|
||||
text += ` - ${datetime.getDisplayTime(date)}`;
|
||||
}
|
||||
|
||||
miscInfo.push(text);
|
||||
} catch (e) {
|
||||
console.error('error parsing date: ' + item.StartDate);
|
||||
console.error('error parsing date:', item.StartDate);
|
||||
}
|
||||
}
|
||||
|
||||
if (item.ChannelNumber) {
|
||||
miscInfo.push('CH ' + item.ChannelNumber);
|
||||
miscInfo.push(`CH ${item.ChannelNumber}`);
|
||||
}
|
||||
|
||||
if (item.ChannelName) {
|
||||
|
||||
if (options.interactive && item.ChannelId) {
|
||||
miscInfo.push({
|
||||
html: '<a is="emby-linkbutton" class="button-flat mediaInfoItem" href="' + appRouter.getRouteUrl({
|
||||
html: `<a is="emby-linkbutton" class="button-flat mediaInfoItem" href="${appRouter.getRouteUrl({
|
||||
|
||||
ServerId: item.ServerId,
|
||||
Type: 'TvChannel',
|
||||
Name: item.ChannelName,
|
||||
Id: item.ChannelId
|
||||
|
||||
}) + '">' + item.ChannelName + '</a>'
|
||||
})}">${item.ChannelName}</a>`
|
||||
});
|
||||
} else {
|
||||
miscInfo.push(item.ChannelName);
|
||||
|
@ -84,7 +93,7 @@ define(['datetime', 'globalize', 'appRouter', 'itemHelper', 'indicators', 'mater
|
|||
}
|
||||
|
||||
if (options.timerIndicator !== false) {
|
||||
var timerHtml = getTimerIndicator(item);
|
||||
const timerHtml = getTimerIndicator(item);
|
||||
if (timerHtml) {
|
||||
miscInfo.push({
|
||||
html: timerHtml
|
||||
|
@ -92,24 +101,24 @@ define(['datetime', 'globalize', 'appRouter', 'itemHelper', 'indicators', 'mater
|
|||
}
|
||||
}
|
||||
|
||||
html += miscInfo.map(function (m) {
|
||||
html += miscInfo.map(m => {
|
||||
return getMediaInfoItem(m);
|
||||
}).join('');
|
||||
|
||||
return html;
|
||||
}
|
||||
|
||||
function getMediaInfoHtml(item, options) {
|
||||
var html = '';
|
||||
export function getMediaInfoHtml(item, options) {
|
||||
let html = '';
|
||||
|
||||
var miscInfo = [];
|
||||
const miscInfo = [];
|
||||
options = options || {};
|
||||
var text;
|
||||
var date;
|
||||
var minutes;
|
||||
var count;
|
||||
let text;
|
||||
let date;
|
||||
let minutes;
|
||||
let count;
|
||||
|
||||
var showFolderRuntime = item.Type === 'MusicAlbum' || item.MediaType === 'MusicArtist' || item.MediaType === 'Playlist' || item.MediaType === 'MusicGenre';
|
||||
const showFolderRuntime = item.Type === 'MusicAlbum' || item.MediaType === 'MusicArtist' || item.MediaType === 'Playlist' || item.MediaType === 'MusicGenre';
|
||||
|
||||
if (showFolderRuntime) {
|
||||
|
||||
|
@ -143,7 +152,7 @@ define(['datetime', 'globalize', 'appRouter', 'itemHelper', 'indicators', 'mater
|
|||
text = datetime.toLocaleDateString(date);
|
||||
miscInfo.push(text);
|
||||
} catch (e) {
|
||||
console.error('error parsing date: ' + item.PremiereDate);
|
||||
console.error('error parsing date:', item.PremiereDate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -176,7 +185,7 @@ define(['datetime', 'globalize', 'appRouter', 'itemHelper', 'indicators', 'mater
|
|||
miscInfo.push(text);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('error parsing date: ' + item.StartDate);
|
||||
console.error('error parsing date:', item.StartDate);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -193,14 +202,14 @@ define(['datetime', 'globalize', 'appRouter', 'itemHelper', 'indicators', 'mater
|
|||
|
||||
try {
|
||||
|
||||
var endYear = datetime.parseISO8601Date(item.EndDate).getFullYear();
|
||||
const endYear = datetime.parseISO8601Date(item.EndDate).getFullYear();
|
||||
|
||||
if (endYear !== item.ProductionYear) {
|
||||
text += '-' + datetime.parseISO8601Date(item.EndDate).getFullYear();
|
||||
text += `-${datetime.parseISO8601Date(item.EndDate).getFullYear()}`;
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
console.error('error parsing date: ' + item.EndDate);
|
||||
console.error('error parsing date:', item.EndDate);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -213,19 +222,19 @@ define(['datetime', 'globalize', 'appRouter', 'itemHelper', 'indicators', 'mater
|
|||
if (options.programIndicator !== false) {
|
||||
if (item.IsLive) {
|
||||
miscInfo.push({
|
||||
html: '<div class="mediaInfoProgramAttribute mediaInfoItem liveTvProgram">' + globalize.translate('Live') + '</div>'
|
||||
html: `<div class="mediaInfoProgramAttribute mediaInfoItem liveTvProgram">${globalize.translate('Live')}</div>`
|
||||
});
|
||||
} else if (item.IsPremiere) {
|
||||
miscInfo.push({
|
||||
html: '<div class="mediaInfoProgramAttribute mediaInfoItem premiereTvProgram">' + globalize.translate('Premiere') + '</div>'
|
||||
html: `<div class="mediaInfoProgramAttribute mediaInfoItem premiereTvProgram">${globalize.translate('Premiere')}</div>`
|
||||
});
|
||||
} else if (item.IsSeries && !item.IsRepeat) {
|
||||
miscInfo.push({
|
||||
html: '<div class="mediaInfoProgramAttribute mediaInfoItem newTvProgram">' + globalize.translate('AttributeNew') + '</div>'
|
||||
html: `<div class="mediaInfoProgramAttribute mediaInfoItem newTvProgram">${globalize.translate('AttributeNew')}</div>`
|
||||
});
|
||||
} else if (item.IsSeries && item.IsRepeat) {
|
||||
miscInfo.push({
|
||||
html: '<div class="mediaInfoProgramAttribute mediaInfoItem repeatTvProgram">' + globalize.translate('Repeat') + '</div>'
|
||||
html: `<div class="mediaInfoProgramAttribute mediaInfoItem repeatTvProgram">${globalize.translate('Repeat')}</div>`
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -248,7 +257,7 @@ define(['datetime', 'globalize', 'appRouter', 'itemHelper', 'indicators', 'mater
|
|||
text = globalize.translate('OriginalAirDateValue', datetime.toLocaleDateString(date));
|
||||
miscInfo.push(text);
|
||||
} catch (e) {
|
||||
console.error('error parsing date: ' + item.PremiereDate);
|
||||
console.error('error parsing date:', item.PremiereDate);
|
||||
}
|
||||
} else if (item.ProductionYear) {
|
||||
miscInfo.push(item.ProductionYear);
|
||||
|
@ -267,7 +276,7 @@ define(['datetime', 'globalize', 'appRouter', 'itemHelper', 'indicators', 'mater
|
|||
text = datetime.parseISO8601Date(item.PremiereDate).getFullYear();
|
||||
miscInfo.push(text);
|
||||
} catch (e) {
|
||||
console.error('error parsing date: ' + item.PremiereDate);
|
||||
console.error('error parsing date:', item.PremiereDate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -284,7 +293,7 @@ define(['datetime', 'globalize', 'appRouter', 'itemHelper', 'indicators', 'mater
|
|||
|
||||
minutes = minutes || 1;
|
||||
|
||||
miscInfo.push(Math.round(minutes) + ' mins');
|
||||
miscInfo.push(`${Math.round(minutes)} mins`);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -300,14 +309,14 @@ define(['datetime', 'globalize', 'appRouter', 'itemHelper', 'indicators', 'mater
|
|||
}
|
||||
|
||||
if (item.MediaType === 'Photo' && item.Width && item.Height) {
|
||||
miscInfo.push(item.Width + 'x' + item.Height);
|
||||
miscInfo.push(`${item.Width}x${item.Height}`);
|
||||
}
|
||||
|
||||
if (options.container !== false && item.Type === 'Audio' && item.Container) {
|
||||
miscInfo.push(item.Container);
|
||||
}
|
||||
|
||||
html += miscInfo.map(function (m) {
|
||||
html += miscInfo.map(m => {
|
||||
return getMediaInfoItem(m);
|
||||
}).join('');
|
||||
|
||||
|
@ -320,15 +329,15 @@ define(['datetime', 'globalize', 'appRouter', 'itemHelper', 'indicators', 'mater
|
|||
if (item.CriticRating && options.criticRating !== false) {
|
||||
|
||||
if (item.CriticRating >= 60) {
|
||||
html += '<div class="mediaInfoItem mediaInfoCriticRating mediaInfoCriticRatingFresh">' + item.CriticRating + '</div>';
|
||||
html += `<div class="mediaInfoItem mediaInfoCriticRating mediaInfoCriticRatingFresh">${item.CriticRating}</div>`;
|
||||
} else {
|
||||
html += '<div class="mediaInfoItem mediaInfoCriticRating mediaInfoCriticRatingRotten">' + item.CriticRating + '</div>';
|
||||
html += `<div class="mediaInfoItem mediaInfoCriticRating mediaInfoCriticRatingRotten">${item.CriticRating}</div>`;
|
||||
}
|
||||
}
|
||||
|
||||
if (options.endsAt !== false) {
|
||||
|
||||
var endsAt = getEndsAt(item);
|
||||
const endsAt = getEndsAt(item);
|
||||
if (endsAt) {
|
||||
html += getMediaInfoItem(endsAt, 'endsAt');
|
||||
}
|
||||
|
@ -339,15 +348,15 @@ define(['datetime', 'globalize', 'appRouter', 'itemHelper', 'indicators', 'mater
|
|||
return html;
|
||||
}
|
||||
|
||||
function getEndsAt(item) {
|
||||
export function getEndsAt(item) {
|
||||
|
||||
if (item.MediaType === 'Video' && item.RunTimeTicks) {
|
||||
|
||||
if (!item.StartDate) {
|
||||
var endDate = new Date().getTime() + (item.RunTimeTicks / 10000);
|
||||
let endDate = new Date().getTime() + (item.RunTimeTicks / 10000);
|
||||
endDate = new Date(endDate);
|
||||
|
||||
var displayTime = datetime.getDisplayTime(endDate);
|
||||
const displayTime = datetime.getDisplayTime(endDate);
|
||||
return globalize.translate('EndsAtValue', displayTime);
|
||||
}
|
||||
}
|
||||
|
@ -355,12 +364,12 @@ define(['datetime', 'globalize', 'appRouter', 'itemHelper', 'indicators', 'mater
|
|||
return null;
|
||||
}
|
||||
|
||||
function getEndsAtFromPosition(runtimeTicks, positionTicks, includeText) {
|
||||
export function getEndsAtFromPosition(runtimeTicks, positionTicks, includeText) {
|
||||
|
||||
var endDate = new Date().getTime() + ((runtimeTicks - (positionTicks || 0)) / 10000);
|
||||
let endDate = new Date().getTime() + ((runtimeTicks - (positionTicks || 0)) / 10000);
|
||||
endDate = new Date(endDate);
|
||||
|
||||
var displayTime = datetime.getDisplayTime(endDate);
|
||||
const displayTime = datetime.getDisplayTime(endDate);
|
||||
|
||||
if (includeText === false) {
|
||||
return displayTime;
|
||||
|
@ -370,8 +379,8 @@ define(['datetime', 'globalize', 'appRouter', 'itemHelper', 'indicators', 'mater
|
|||
|
||||
function getMediaInfoItem(m, cssClass) {
|
||||
|
||||
cssClass = cssClass ? (cssClass + ' mediaInfoItem') : 'mediaInfoItem';
|
||||
var mediaInfoText = m;
|
||||
cssClass = cssClass ? (`${cssClass} mediaInfoItem`) : 'mediaInfoItem';
|
||||
let mediaInfoText = m;
|
||||
|
||||
if (typeof (m) !== 'string' && typeof (m) !== 'number') {
|
||||
|
||||
|
@ -379,13 +388,13 @@ define(['datetime', 'globalize', 'appRouter', 'itemHelper', 'indicators', 'mater
|
|||
return m.html;
|
||||
}
|
||||
mediaInfoText = m.text;
|
||||
cssClass += ' ' + m.cssClass;
|
||||
cssClass += ` ${m.cssClass}`;
|
||||
}
|
||||
return '<div class="' + cssClass + '">' + mediaInfoText + '</div>';
|
||||
return `<div class="${cssClass}">${mediaInfoText}</div>`;
|
||||
}
|
||||
|
||||
function getStarIconsHtml(item) {
|
||||
var html = '';
|
||||
let html = '';
|
||||
|
||||
if (item.CommunityRating) {
|
||||
html += '<div class="starRatingContainer mediaInfoItem">';
|
||||
|
@ -400,7 +409,7 @@ define(['datetime', 'globalize', 'appRouter', 'itemHelper', 'indicators', 'mater
|
|||
|
||||
function dynamicEndTime(elem, item) {
|
||||
|
||||
var interval = setInterval(function () {
|
||||
const interval = setInterval(() => {
|
||||
|
||||
if (!document.body.contains(elem)) {
|
||||
|
||||
|
@ -413,15 +422,15 @@ define(['datetime', 'globalize', 'appRouter', 'itemHelper', 'indicators', 'mater
|
|||
}, 60000);
|
||||
}
|
||||
|
||||
function fillPrimaryMediaInfo(elem, item, options) {
|
||||
var html = getPrimaryMediaInfoHtml(item, options);
|
||||
export function fillPrimaryMediaInfo(elem, item, options) {
|
||||
const html = getPrimaryMediaInfoHtml(item, options);
|
||||
|
||||
elem.innerHTML = html;
|
||||
afterFill(elem, item, options);
|
||||
}
|
||||
|
||||
function fillSecondaryMediaInfo(elem, item, options) {
|
||||
var html = getSecondaryMediaInfoHtml(item, options);
|
||||
export function fillSecondaryMediaInfo(elem, item, options) {
|
||||
const html = getSecondaryMediaInfoHtml(item, options);
|
||||
|
||||
elem.innerHTML = html;
|
||||
afterFill(elem, item, options);
|
||||
|
@ -430,13 +439,13 @@ define(['datetime', 'globalize', 'appRouter', 'itemHelper', 'indicators', 'mater
|
|||
function afterFill(elem, item, options) {
|
||||
|
||||
if (options.endsAt !== false) {
|
||||
var endsAtElem = elem.querySelector('.endsAt');
|
||||
const endsAtElem = elem.querySelector('.endsAt');
|
||||
if (endsAtElem) {
|
||||
dynamicEndTime(endsAtElem, item);
|
||||
}
|
||||
}
|
||||
|
||||
var lnkChannel = elem.querySelector('.lnkChannel');
|
||||
const lnkChannel = elem.querySelector('.lnkChannel');
|
||||
if (lnkChannel) {
|
||||
lnkChannel.addEventListener('click', onChannelLinkClick);
|
||||
}
|
||||
|
@ -444,8 +453,8 @@ define(['datetime', 'globalize', 'appRouter', 'itemHelper', 'indicators', 'mater
|
|||
|
||||
function onChannelLinkClick(e) {
|
||||
|
||||
var channelId = this.getAttribute('data-id');
|
||||
var serverId = this.getAttribute('data-serverid');
|
||||
const channelId = this.getAttribute('data-id');
|
||||
const serverId = this.getAttribute('data-serverid');
|
||||
|
||||
appRouter.showItem(channelId, serverId);
|
||||
|
||||
|
@ -453,7 +462,7 @@ define(['datetime', 'globalize', 'appRouter', 'itemHelper', 'indicators', 'mater
|
|||
return false;
|
||||
}
|
||||
|
||||
function getPrimaryMediaInfoHtml(item, options) {
|
||||
export function getPrimaryMediaInfoHtml(item, options) {
|
||||
|
||||
options = options || {};
|
||||
if (options.interactive == null) {
|
||||
|
@ -463,7 +472,7 @@ define(['datetime', 'globalize', 'appRouter', 'itemHelper', 'indicators', 'mater
|
|||
return getMediaInfoHtml(item, options);
|
||||
}
|
||||
|
||||
function getSecondaryMediaInfoHtml(item, options) {
|
||||
export function getSecondaryMediaInfoHtml(item, options) {
|
||||
|
||||
options = options || {};
|
||||
if (options.interactive == null) {
|
||||
|
@ -476,10 +485,10 @@ define(['datetime', 'globalize', 'appRouter', 'itemHelper', 'indicators', 'mater
|
|||
return '';
|
||||
}
|
||||
|
||||
function getResolutionText(i) {
|
||||
export function getResolutionText(i) {
|
||||
|
||||
var width = i.Width;
|
||||
var height = i.Height;
|
||||
const width = i.Width;
|
||||
const height = i.Height;
|
||||
|
||||
if (width && height) {
|
||||
|
||||
|
@ -522,28 +531,28 @@ define(['datetime', 'globalize', 'appRouter', 'itemHelper', 'indicators', 'mater
|
|||
return null;
|
||||
}
|
||||
|
||||
var mediaSource = item.MediaSources[0];
|
||||
const mediaSource = item.MediaSources[0];
|
||||
if (!mediaSource) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (mediaSource.MediaStreams || []).filter(function (i) {
|
||||
return (mediaSource.MediaStreams || []).filter(i => {
|
||||
return i.Type === 'Audio' && (i.Index === mediaSource.DefaultAudioStreamIndex || mediaSource.DefaultAudioStreamIndex == null);
|
||||
})[0];
|
||||
}
|
||||
|
||||
function getMediaInfoStats(item, options) {
|
||||
export function getMediaInfoStats(item, options) {
|
||||
|
||||
options = options || {};
|
||||
|
||||
var list = [];
|
||||
const list = [];
|
||||
|
||||
var mediaSource = (item.MediaSources || [])[0] || {};
|
||||
const mediaSource = (item.MediaSources || [])[0] || {};
|
||||
|
||||
var videoStream = (mediaSource.MediaStreams || []).filter(function (i) {
|
||||
const videoStream = (mediaSource.MediaStreams || []).filter(i => {
|
||||
return i.Type === 'Video';
|
||||
})[0] || {};
|
||||
var audioStream = getAudioStreamForDisplay(item) || {};
|
||||
const audioStream = getAudioStreamForDisplay(item) || {};
|
||||
|
||||
if (item.VideoType === 'Dvd') {
|
||||
list.push({
|
||||
|
@ -563,7 +572,7 @@ define(['datetime', 'globalize', 'appRouter', 'itemHelper', 'indicators', 'mater
|
|||
// html += '<div class="mediaInfoIcon mediaInfoText">' + mediaSource.Container + '</div>';
|
||||
//}
|
||||
|
||||
var resolutionText = getResolutionText(videoStream);
|
||||
const resolutionText = getResolutionText(videoStream);
|
||||
if (resolutionText) {
|
||||
list.push({
|
||||
type: 'mediainfo',
|
||||
|
@ -578,8 +587,8 @@ define(['datetime', 'globalize', 'appRouter', 'itemHelper', 'indicators', 'mater
|
|||
});
|
||||
}
|
||||
|
||||
var channels = audioStream.Channels;
|
||||
var channelText;
|
||||
const channels = audioStream.Channels;
|
||||
let channelText;
|
||||
|
||||
if (channels === 8) {
|
||||
|
||||
|
@ -605,7 +614,7 @@ define(['datetime', 'globalize', 'appRouter', 'itemHelper', 'indicators', 'mater
|
|||
});
|
||||
}
|
||||
|
||||
var audioCodec = (audioStream.Codec || '').toLowerCase();
|
||||
const audioCodec = (audioStream.Codec || '').toLowerCase();
|
||||
|
||||
if ((audioCodec === 'dca' || audioCodec === 'dts') && audioStream.Profile) {
|
||||
list.push({
|
||||
|
@ -621,27 +630,27 @@ define(['datetime', 'globalize', 'appRouter', 'itemHelper', 'indicators', 'mater
|
|||
|
||||
if (item.DateCreated && itemHelper.enableDateAddedDisplay(item)) {
|
||||
|
||||
var dateCreated = datetime.parseISO8601Date(item.DateCreated);
|
||||
const dateCreated = datetime.parseISO8601Date(item.DateCreated);
|
||||
|
||||
list.push({
|
||||
type: 'added',
|
||||
text: globalize.translate('AddedOnValue', datetime.toLocaleDateString(dateCreated) + ' ' + datetime.getDisplayTime(dateCreated))
|
||||
text: globalize.translate('AddedOnValue', `${datetime.toLocaleDateString(dateCreated)} ${datetime.getDisplayTime(dateCreated)}`)
|
||||
});
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
return {
|
||||
getMediaInfoHtml: getPrimaryMediaInfoHtml,
|
||||
fill: fillPrimaryMediaInfo,
|
||||
getEndsAt: getEndsAt,
|
||||
getEndsAtFromPosition: getEndsAtFromPosition,
|
||||
getPrimaryMediaInfoHtml: getPrimaryMediaInfoHtml,
|
||||
getSecondaryMediaInfoHtml: getSecondaryMediaInfoHtml,
|
||||
fillPrimaryMediaInfo: fillPrimaryMediaInfo,
|
||||
fillSecondaryMediaInfo: fillSecondaryMediaInfo,
|
||||
getMediaInfoStats: getMediaInfoStats,
|
||||
getResolutionText: getResolutionText
|
||||
};
|
||||
});
|
||||
/* eslint-enable indent */
|
||||
|
||||
export default {
|
||||
getMediaInfoHtml: getPrimaryMediaInfoHtml,
|
||||
getEndsAt: getEndsAt,
|
||||
getEndsAtFromPosition: getEndsAtFromPosition,
|
||||
getPrimaryMediaInfoHtml: getPrimaryMediaInfoHtml,
|
||||
getSecondaryMediaInfoHtml: getSecondaryMediaInfoHtml,
|
||||
fillPrimaryMediaInfo: fillPrimaryMediaInfo,
|
||||
fillSecondaryMediaInfo: fillSecondaryMediaInfo,
|
||||
getMediaInfoStats: getMediaInfoStats,
|
||||
getResolutionText: getResolutionText
|
||||
};
|
||||
|
|
|
@ -1064,7 +1064,7 @@ import 'flexStyles';
|
|||
|
||||
let html = '';
|
||||
|
||||
html += globalize.translateDocument(template, 'core');
|
||||
html += globalize.translateHtml(template, 'core');
|
||||
|
||||
dlg.innerHTML = html;
|
||||
|
||||
|
@ -1104,7 +1104,7 @@ import 'flexStyles';
|
|||
|
||||
require(['text!./metadataEditor.template.html'], function (template) {
|
||||
|
||||
elem.innerHTML = globalize.translateDocument(template, 'core');
|
||||
elem.innerHTML = globalize.translateHtml(template, 'core');
|
||||
|
||||
elem.querySelector('.formDialogFooter').classList.remove('formDialogFooter');
|
||||
elem.querySelector('.btnHeaderSave').classList.remove('hide');
|
||||
|
|
|
@ -39,7 +39,7 @@ import 'css!./../formdialog';
|
|||
let html = '';
|
||||
let submitted = false;
|
||||
|
||||
html += globalize.translateDocument(template, 'core');
|
||||
html += globalize.translateHtml(template, 'core');
|
||||
|
||||
dlg.innerHTML = html;
|
||||
|
||||
|
|
|
@ -302,7 +302,7 @@ import 'emby-checkbox';
|
|||
|
||||
return import('text!./playbackSettings.template.html').then(({default: template}) => {
|
||||
|
||||
options.element.innerHTML = globalize.translateDocument(template, 'core');
|
||||
options.element.innerHTML = globalize.translateHtml(template, 'core');
|
||||
|
||||
options.element.querySelector('form').addEventListener('submit', onSubmit.bind(self));
|
||||
|
||||
|
|
|
@ -156,7 +156,7 @@ define(['dialogHelper', 'globalize', 'layoutManager', 'mediaInfo', 'apphost', 'c
|
|||
|
||||
var html = '';
|
||||
|
||||
html += globalize.translateDocument(template, 'core');
|
||||
html += globalize.translateHtml(template, 'core');
|
||||
|
||||
dlg.innerHTML = html;
|
||||
|
||||
|
|
|
@ -116,7 +116,7 @@ define(['dialogHelper', 'globalize', 'layoutManager', 'mediaInfo', 'apphost', 'c
|
|||
|
||||
var html = '';
|
||||
|
||||
html += globalize.translateDocument(template, 'core');
|
||||
html += globalize.translateHtml(template, 'core');
|
||||
|
||||
dlg.innerHTML = html;
|
||||
|
||||
|
|
|
@ -219,7 +219,7 @@ define(['globalize', 'connectionManager', 'serverNotifications', 'require', 'loa
|
|||
require(['text!./recordingfields.template.html'], function (template) {
|
||||
var options = self.options;
|
||||
var context = options.parent;
|
||||
context.innerHTML = globalize.translateDocument(template, 'core');
|
||||
context.innerHTML = globalize.translateHtml(template, 'core');
|
||||
|
||||
context.querySelector('.singleRecordingButton').addEventListener('click', onRecordChange.bind(self));
|
||||
context.querySelector('.seriesRecordingButton').addEventListener('click', onRecordSeriesChange.bind(self));
|
||||
|
|
|
@ -168,7 +168,7 @@ define(['dialogHelper', 'globalize', 'layoutManager', 'mediaInfo', 'apphost', 'c
|
|||
var dlg = options.context;
|
||||
|
||||
dlg.classList.add('hide');
|
||||
dlg.innerHTML = globalize.translateDocument(template, 'core');
|
||||
dlg.innerHTML = globalize.translateHtml(template, 'core');
|
||||
|
||||
dlg.querySelector('.formDialogHeader').classList.add('hide');
|
||||
dlg.querySelector('.formDialogFooter').classList.add('hide');
|
||||
|
@ -221,7 +221,7 @@ define(['dialogHelper', 'globalize', 'layoutManager', 'mediaInfo', 'apphost', 'c
|
|||
|
||||
var html = '';
|
||||
|
||||
html += globalize.translateDocument(template, 'core');
|
||||
html += globalize.translateHtml(template, 'core');
|
||||
|
||||
dlg.innerHTML = html;
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ import 'css!./searchfields';
|
|||
|
||||
import('text!./searchfields.template.html').then(({default: template}) => {
|
||||
|
||||
let html = globalize.translateDocument(template, 'core');
|
||||
let html = globalize.translateHtml(template, 'core');
|
||||
|
||||
if (browser.tizen || browser.orsay) {
|
||||
html = html.replace('<input ', '<input readonly ');
|
||||
|
|
|
@ -611,7 +611,7 @@ import 'emby-button';
|
|||
template = replaceAll(template, 'itemsContainer scrollSlider', 'itemsContainer scrollSlider vertical-wrap');
|
||||
}
|
||||
|
||||
const html = globalize.translateDocument(template, 'core');
|
||||
const html = globalize.translateHtml(template, 'core');
|
||||
|
||||
elem.innerHTML = html;
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ define(['require', 'dom', 'focusManager', 'dialogHelper', 'loading', 'layoutMana
|
|||
|
||||
html += template;
|
||||
|
||||
dlg.innerHTML = globalize.translateDocument(html, 'core');
|
||||
dlg.innerHTML = globalize.translateHtml(html, 'core');
|
||||
|
||||
fillSortBy(dlg, options.sortOptions);
|
||||
initEditor(dlg, options.settings);
|
||||
|
|
|
@ -448,7 +448,7 @@ define(['dialogHelper', 'require', 'layoutManager', 'globalize', 'userSettings',
|
|||
dlg.classList.add('formDialog');
|
||||
dlg.classList.add('subtitleEditorDialog');
|
||||
|
||||
dlg.innerHTML = globalize.translateDocument(template, 'core');
|
||||
dlg.innerHTML = globalize.translateHtml(template, 'core');
|
||||
|
||||
dlg.querySelector('.originalSubtitleFileLabel').innerHTML = globalize.translate('File');
|
||||
|
||||
|
|
|
@ -133,7 +133,7 @@ function embed(options, self) {
|
|||
import('text!./subtitlesettings.template.html').then(({default: template}) => {
|
||||
|
||||
options.element.classList.add('subtitlesettings');
|
||||
options.element.innerHTML = globalize.translateDocument(template, 'core');
|
||||
options.element.innerHTML = globalize.translateHtml(template, 'core');
|
||||
|
||||
options.element.querySelector('form').addEventListener('submit', self.onSubmit.bind(self));
|
||||
|
||||
|
|
|
@ -331,7 +331,7 @@ define(['playbackManager', 'userSettings', 'alphaPicker', 'alphaNumericShortcuts
|
|||
}
|
||||
|
||||
if (this.enableAlphaNumericShortcuts !== false) {
|
||||
this.alphaNumericShortcuts = new AlphaNumericShortcuts({
|
||||
this.alphaNumericShortcuts = new AlphaNumericShortcuts.default({
|
||||
itemsContainer: this.itemsContainer
|
||||
});
|
||||
}
|
||||
|
@ -561,7 +561,7 @@ define(['playbackManager', 'userSettings', 'alphaPicker', 'alphaNumericShortcuts
|
|||
|
||||
var alphaNumericShortcuts = this.alphaNumericShortcuts;
|
||||
if (alphaNumericShortcuts) {
|
||||
alphaNumericShortcuts.destroy();
|
||||
alphaNumericShortcuts.default.destroy();
|
||||
this.alphaNumericShortcuts = null;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -84,7 +84,7 @@ define(['require', 'dialogHelper', 'loading', 'apphost', 'layoutManager', 'conne
|
|||
|
||||
html += template;
|
||||
|
||||
dlg.innerHTML = globalize.translateDocument(html, 'core');
|
||||
dlg.innerHTML = globalize.translateHtml(html, 'core');
|
||||
|
||||
var settingElements = dlg.querySelectorAll('.viewSetting');
|
||||
for (var i = 0, length = settingElements.length; i < length; i++) {
|
||||
|
|
|
@ -380,6 +380,7 @@ import 'emby-itemrefreshindicator';
|
|||
});
|
||||
pageIdOn('pageshow', 'mediaLibraryPage', function () {
|
||||
libraryMenu.setTabs('librarysetup', 0, getTabs);
|
||||
|
||||
const page = this;
|
||||
taskButton({
|
||||
mode: 'on',
|
||||
|
@ -389,6 +390,7 @@ import 'emby-itemrefreshindicator';
|
|||
});
|
||||
});
|
||||
pageIdOn('pagebeforehide', 'mediaLibraryPage', function () {
|
||||
|
||||
const page = this;
|
||||
taskButton({
|
||||
mode: 'off',
|
||||
|
|
|
@ -803,7 +803,7 @@ define(['globalize', 'listView', 'layoutManager', 'userSettings', 'focusManager'
|
|||
bindAll(view.querySelectorAll('.btnShuffle'), 'click', shuffle);
|
||||
}
|
||||
|
||||
this.alphaNumericShortcuts = new AlphaNumericShortcuts({
|
||||
this.alphaNumericShortcuts = new AlphaNumericShortcuts.default({
|
||||
itemsContainer: self.itemsContainer
|
||||
});
|
||||
});
|
||||
|
@ -817,7 +817,7 @@ define(['globalize', 'listView', 'layoutManager', 'userSettings', 'focusManager'
|
|||
var alphaNumericShortcuts = self.alphaNumericShortcuts;
|
||||
|
||||
if (alphaNumericShortcuts) {
|
||||
alphaNumericShortcuts.destroy();
|
||||
alphaNumericShortcuts.default.destroy();
|
||||
self.alphaNumericShortcuts = null;
|
||||
}
|
||||
});
|
||||
|
|
|
@ -17,7 +17,7 @@ define(['events', 'loading', 'globalize'], function (events, loading, globalize)
|
|||
|
||||
function loadTemplate(page, type, providerId) {
|
||||
require(['text!./components/tvproviders/' + type + '.template.html'], function (html) {
|
||||
page.querySelector('.providerTemplate').innerHTML = globalize.translateDocument(html);
|
||||
page.querySelector('.providerTemplate').innerHTML = globalize.translateHtml(html);
|
||||
init(page, type, providerId);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -303,7 +303,7 @@ define(['jQuery', 'globalize', 'scripts/taskbutton', 'dom', 'libraryMenu', 'layo
|
|||
}).on('pageshow', '#liveTvStatusPage', function () {
|
||||
var page = this;
|
||||
reload(page);
|
||||
taskButton({
|
||||
taskButton.default({
|
||||
mode: 'on',
|
||||
progressElem: page.querySelector('.refreshGuideProgress'),
|
||||
taskKey: 'RefreshGuide',
|
||||
|
@ -311,7 +311,7 @@ define(['jQuery', 'globalize', 'scripts/taskbutton', 'dom', 'libraryMenu', 'layo
|
|||
});
|
||||
}).on('pagehide', '#liveTvStatusPage', function () {
|
||||
var page = this;
|
||||
taskButton({
|
||||
taskButton.default({
|
||||
mode: 'off',
|
||||
progressElem: page.querySelector('.refreshGuideProgress'),
|
||||
taskKey: 'RefreshGuide',
|
||||
|
|
|
@ -1533,7 +1533,7 @@ define(['playbackManager', 'dom', 'inputManager', 'datetime', 'itemHelper', 'med
|
|||
if (browser.touch) {
|
||||
(function () {
|
||||
require(['touchHelper'], function (TouchHelper) {
|
||||
self.touchHelper = new TouchHelper(view, {
|
||||
self.touchHelper = new TouchHelper.default(view, {
|
||||
swipeYThreshold: 30,
|
||||
triggerOnMove: true,
|
||||
preventDefaultOnMove: true,
|
||||
|
|
|
@ -1,58 +1,60 @@
|
|||
define(['apphost', 'connectionManager', 'layoutManager', 'listViewStyle', 'emby-button'], function(appHost, connectionManager, layoutManager) {
|
||||
'use strict';
|
||||
import appHost from 'apphost';
|
||||
import connectionManager from 'connectionManager';
|
||||
import layoutManager from 'layoutManager';
|
||||
import 'listViewStyle';
|
||||
import 'emby-button';
|
||||
|
||||
return function(view, params) {
|
||||
view.querySelector('.btnLogout').addEventListener('click', function() {
|
||||
Dashboard.logout();
|
||||
});
|
||||
export default function (view, params) {
|
||||
view.querySelector('.btnLogout').addEventListener('click', function () {
|
||||
Dashboard.logout();
|
||||
});
|
||||
|
||||
view.querySelector('.selectServer').addEventListener('click', function () {
|
||||
Dashboard.selectServer();
|
||||
});
|
||||
view.querySelector('.selectServer').addEventListener('click', function () {
|
||||
Dashboard.selectServer();
|
||||
});
|
||||
|
||||
view.querySelector('.clientSettings').addEventListener('click', function () {
|
||||
window.NativeShell.openClientSettings();
|
||||
});
|
||||
view.querySelector('.clientSettings').addEventListener('click', function () {
|
||||
window.NativeShell.openClientSettings();
|
||||
});
|
||||
|
||||
view.addEventListener('viewshow', function() {
|
||||
// this page can also be used by admins to change user preferences from the user edit page
|
||||
var userId = params.userId || Dashboard.getCurrentUserId();
|
||||
var page = this;
|
||||
view.addEventListener('viewshow', function () {
|
||||
// this page can also be used by admins to change user preferences from the user edit page
|
||||
const userId = params.userId || Dashboard.getCurrentUserId();
|
||||
const page = this;
|
||||
|
||||
page.querySelector('.lnkMyProfile').setAttribute('href', 'myprofile.html?userId=' + userId);
|
||||
page.querySelector('.lnkDisplayPreferences').setAttribute('href', 'mypreferencesdisplay.html?userId=' + userId);
|
||||
page.querySelector('.lnkHomePreferences').setAttribute('href', 'mypreferenceshome.html?userId=' + userId);
|
||||
page.querySelector('.lnkPlaybackPreferences').setAttribute('href', 'mypreferencesplayback.html?userId=' + userId);
|
||||
page.querySelector('.lnkSubtitlePreferences').setAttribute('href', 'mypreferencessubtitles.html?userId=' + userId);
|
||||
page.querySelector('.lnkMyProfile').setAttribute('href', 'myprofile.html?userId=' + userId);
|
||||
page.querySelector('.lnkDisplayPreferences').setAttribute('href', 'mypreferencesdisplay.html?userId=' + userId);
|
||||
page.querySelector('.lnkHomePreferences').setAttribute('href', 'mypreferenceshome.html?userId=' + userId);
|
||||
page.querySelector('.lnkPlaybackPreferences').setAttribute('href', 'mypreferencesplayback.html?userId=' + userId);
|
||||
page.querySelector('.lnkSubtitlePreferences').setAttribute('href', 'mypreferencessubtitles.html?userId=' + userId);
|
||||
|
||||
if (window.NativeShell && window.NativeShell.AppHost.supports('clientsettings')) {
|
||||
page.querySelector('.clientSettings').classList.remove('hide');
|
||||
} else {
|
||||
page.querySelector('.clientSettings').classList.add('hide');
|
||||
}
|
||||
if (window.NativeShell && window.NativeShell.AppHost.supports('clientsettings')) {
|
||||
page.querySelector('.clientSettings').classList.remove('hide');
|
||||
} else {
|
||||
page.querySelector('.clientSettings').classList.add('hide');
|
||||
}
|
||||
|
||||
if (appHost.supports('multiserver')) {
|
||||
page.querySelector('.selectServer').classList.remove('hide');
|
||||
} else {
|
||||
page.querySelector('.selectServer').classList.add('hide');
|
||||
}
|
||||
if (appHost.supports('multiserver')) {
|
||||
page.querySelector('.selectServer').classList.remove('hide');
|
||||
} else {
|
||||
page.querySelector('.selectServer').classList.add('hide');
|
||||
}
|
||||
|
||||
// hide the actions if user preferences are being edited for a different user
|
||||
if (params.userId && params.userId !== Dashboard.getCurrentUserId) {
|
||||
page.querySelector('.userSection').classList.add('hide');
|
||||
// hide the actions if user preferences are being edited for a different user
|
||||
if (params.userId && params.userId !== Dashboard.getCurrentUserId) {
|
||||
page.querySelector('.userSection').classList.add('hide');
|
||||
page.querySelector('.adminSection').classList.add('hide');
|
||||
}
|
||||
|
||||
ApiClient.getUser(userId).then(function (user) {
|
||||
page.querySelector('.headerUsername').innerHTML = user.Name;
|
||||
if (!user.Policy.IsAdministrator) {
|
||||
page.querySelector('.adminSection').classList.add('hide');
|
||||
}
|
||||
|
||||
ApiClient.getUser(userId).then(function(user) {
|
||||
page.querySelector('.headerUsername').innerHTML = user.Name;
|
||||
if (!user.Policy.IsAdministrator) {
|
||||
page.querySelector('.adminSection').classList.add('hide');
|
||||
}
|
||||
});
|
||||
|
||||
require(['autoFocuser'], function (autoFocuser) {
|
||||
autoFocuser.autoFocus(view);
|
||||
});
|
||||
});
|
||||
};
|
||||
});
|
||||
|
||||
import('autoFocuser').then(({default: autoFocuser}) => {
|
||||
autoFocuser.autoFocus(view);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,106 +1,109 @@
|
|||
define(['controllers/dashboard/users/userpasswordpage', 'loading', 'libraryMenu', 'apphost', 'globalize', 'emby-button'], function (UserPasswordPage, loading, libraryMenu, appHost, globalize) {
|
||||
'use strict';
|
||||
import UserPasswordPage from 'controllers/dashboard/users/userpasswordpage';
|
||||
import loading from 'loading';
|
||||
import libraryMenu from 'libraryMenu';
|
||||
import appHost from 'apphost';
|
||||
import globalize from 'globalize';
|
||||
import 'emby-button';
|
||||
|
||||
function reloadUser(page) {
|
||||
var userId = getParameterByName('userId');
|
||||
loading.show();
|
||||
ApiClient.getUser(userId).then(function (user) {
|
||||
page.querySelector('.username').innerHTML = user.Name;
|
||||
libraryMenu.setTitle(user.Name);
|
||||
function reloadUser(page) {
|
||||
const userId = getParameterByName('userId');
|
||||
loading.show();
|
||||
ApiClient.getUser(userId).then(function (user) {
|
||||
page.querySelector('.username').innerHTML = user.Name;
|
||||
libraryMenu.setTitle(user.Name);
|
||||
|
||||
var imageUrl = 'assets/img/avatar.png';
|
||||
let imageUrl = 'assets/img/avatar.png';
|
||||
if (user.PrimaryImageTag) {
|
||||
imageUrl = ApiClient.getUserImageUrl(user.Id, {
|
||||
tag: user.PrimaryImageTag,
|
||||
type: 'Primary'
|
||||
});
|
||||
}
|
||||
|
||||
const userImage = page.querySelector('#image');
|
||||
userImage.style.backgroundImage = 'url(' + imageUrl + ')';
|
||||
|
||||
Dashboard.getCurrentUser().then(function (loggedInUser) {
|
||||
if (user.PrimaryImageTag) {
|
||||
imageUrl = ApiClient.getUserImageUrl(user.Id, {
|
||||
tag: user.PrimaryImageTag,
|
||||
type: 'Primary'
|
||||
});
|
||||
page.querySelector('#btnAddImage').classList.add('hide');
|
||||
page.querySelector('#btnDeleteImage').classList.remove('hide');
|
||||
} else if (appHost.supports('fileinput') && (loggedInUser.Policy.IsAdministrator || user.Policy.EnableUserPreferenceAccess)) {
|
||||
page.querySelector('#btnDeleteImage').classList.add('hide');
|
||||
page.querySelector('#btnAddImage').classList.remove('hide');
|
||||
}
|
||||
});
|
||||
loading.hide();
|
||||
});
|
||||
}
|
||||
|
||||
var userImage = page.querySelector('#image');
|
||||
userImage.style.backgroundImage = 'url(' + imageUrl + ')';
|
||||
|
||||
Dashboard.getCurrentUser().then(function (loggedInUser) {
|
||||
if (user.PrimaryImageTag) {
|
||||
page.querySelector('#btnAddImage').classList.add('hide');
|
||||
page.querySelector('#btnDeleteImage').classList.remove('hide');
|
||||
} else if (appHost.supports('fileinput') && (loggedInUser.Policy.IsAdministrator || user.Policy.EnableUserPreferenceAccess)) {
|
||||
page.querySelector('#btnDeleteImage').classList.add('hide');
|
||||
page.querySelector('#btnAddImage').classList.remove('hide');
|
||||
}
|
||||
function onFileReaderError(evt) {
|
||||
loading.hide();
|
||||
switch (evt.target.error.code) {
|
||||
case evt.target.error.NOT_FOUND_ERR:
|
||||
import('toast').then(({default: toast}) => {
|
||||
toast(globalize.translate('FileNotFound'));
|
||||
});
|
||||
break;
|
||||
case evt.target.error.ABORT_ERR:
|
||||
onFileReaderAbort();
|
||||
break;
|
||||
case evt.target.error.NOT_READABLE_ERR:
|
||||
default:
|
||||
import('toast').then(({default: toast}) => {
|
||||
toast(globalize.translate('FileReadError'));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function onFileReaderAbort(evt) {
|
||||
loading.hide();
|
||||
import('toast').then(({default: toast}) => {
|
||||
toast(globalize.translate('FileReadCancelled'));
|
||||
});
|
||||
}
|
||||
|
||||
function setFiles(page, files) {
|
||||
const userImage = page.querySelector('#image');
|
||||
const file = files[0];
|
||||
|
||||
if (!file || !file.type.match('image.*')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const reader = new FileReader();
|
||||
reader.onerror = onFileReaderError;
|
||||
reader.onabort = onFileReaderAbort;
|
||||
reader.onload = function (evt) {
|
||||
userImage.style.backgroundImage = 'url(' + evt.target.result + ')';
|
||||
const userId = getParameterByName('userId');
|
||||
ApiClient.uploadUserImage(userId, 'Primary', file).then(function () {
|
||||
loading.hide();
|
||||
});
|
||||
}
|
||||
|
||||
function onFileReaderError(evt) {
|
||||
loading.hide();
|
||||
switch (evt.target.error.code) {
|
||||
case evt.target.error.NOT_FOUND_ERR:
|
||||
require(['toast'], function (toast) {
|
||||
toast(globalize.translate('FileNotFound'));
|
||||
});
|
||||
break;
|
||||
case evt.target.error.ABORT_ERR:
|
||||
onFileReaderAbort();
|
||||
break;
|
||||
case evt.target.error.NOT_READABLE_ERR:
|
||||
default:
|
||||
require(['toast'], function (toast) {
|
||||
toast(globalize.translate('FileReadError'));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function onFileReaderAbort(evt) {
|
||||
loading.hide();
|
||||
require(['toast'], function (toast) {
|
||||
toast(globalize.translate('FileReadCancelled'));
|
||||
});
|
||||
}
|
||||
|
||||
function setFiles(page, files) {
|
||||
var userImage = page.querySelector('#image');
|
||||
var file = files[0];
|
||||
|
||||
if (!file || !file.type.match('image.*')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var reader = new FileReader();
|
||||
reader.onerror = onFileReaderError;
|
||||
reader.onabort = onFileReaderAbort;
|
||||
reader.onload = function (evt) {
|
||||
userImage.style.backgroundImage = 'url(' + evt.target.result + ')';
|
||||
var userId = getParameterByName('userId');
|
||||
ApiClient.uploadUserImage(userId, 'Primary', file).then(function () {
|
||||
loading.hide();
|
||||
reloadUser(page);
|
||||
});
|
||||
};
|
||||
|
||||
reader.readAsDataURL(file);
|
||||
}
|
||||
|
||||
return function (view, params) {
|
||||
reloadUser(view);
|
||||
new UserPasswordPage.default(view, params);
|
||||
view.querySelector('#btnDeleteImage').addEventListener('click', function () {
|
||||
require(['confirm'], function (confirm) {
|
||||
confirm.default(globalize.translate('DeleteImageConfirmation'), globalize.translate('DeleteImage')).then(function () {
|
||||
loading.show();
|
||||
var userId = getParameterByName('userId');
|
||||
ApiClient.deleteUserImage(userId, 'primary').then(function () {
|
||||
loading.hide();
|
||||
reloadUser(view);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
view.querySelector('#btnAddImage').addEventListener('click', function (evt) {
|
||||
view.querySelector('#uploadImage').click();
|
||||
});
|
||||
view.querySelector('#uploadImage').addEventListener('change', function (evt) {
|
||||
setFiles(view, evt.target.files);
|
||||
reloadUser(page);
|
||||
});
|
||||
};
|
||||
});
|
||||
|
||||
reader.readAsDataURL(file);
|
||||
}
|
||||
|
||||
export default function (view, params) {
|
||||
reloadUser(view);
|
||||
new UserPasswordPage(view, params);
|
||||
view.querySelector('#btnDeleteImage').addEventListener('click', function () {
|
||||
import('confirm').then(({default: confirm}) => {
|
||||
confirm(globalize.translate('DeleteImageConfirmation'), globalize.translate('DeleteImage')).then(function () {
|
||||
loading.show();
|
||||
const userId = getParameterByName('userId');
|
||||
ApiClient.deleteUserImage(userId, 'primary').then(function () {
|
||||
loading.hide();
|
||||
reloadUser(view);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
view.querySelector('#btnAddImage').addEventListener('click', function (evt) {
|
||||
view.querySelector('#uploadImage').click();
|
||||
});
|
||||
view.querySelector('#uploadImage').addEventListener('change', function (evt) {
|
||||
setFiles(view, evt.target.files);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,199 +1,204 @@
|
|||
define(['require', 'events', 'browser', 'appRouter', 'loading'], function (require, events, browser, appRouter, loading) {
|
||||
'use strict';
|
||||
/* globals YT */
|
||||
import require from 'require';
|
||||
import events from 'events';
|
||||
import browser from 'browser';
|
||||
import appRouter from 'appRouter';
|
||||
import loading from 'loading';
|
||||
|
||||
function zoomIn(elem, iterations) {
|
||||
var keyframes = [
|
||||
{ transform: 'scale3d(.2, .2, .2) ', opacity: '.6', offset: 0 },
|
||||
{ transform: 'none', opacity: '1', offset: 1 }
|
||||
];
|
||||
/* globals YT */
|
||||
|
||||
var timing = { duration: 240, iterations: iterations };
|
||||
return elem.animate(keyframes, timing);
|
||||
}
|
||||
function zoomIn(elem, iterations) {
|
||||
const keyframes = [
|
||||
{ transform: 'scale3d(.2, .2, .2) ', opacity: '.6', offset: 0 },
|
||||
{ transform: 'none', opacity: '1', offset: 1 }
|
||||
];
|
||||
|
||||
function createMediaElement(instance, options) {
|
||||
const timing = { duration: 240, iterations: iterations };
|
||||
return elem.animate(keyframes, timing);
|
||||
}
|
||||
|
||||
return new Promise(function (resolve, reject) {
|
||||
function createMediaElement(instance, options) {
|
||||
|
||||
var dlg = document.querySelector('.youtubePlayerContainer');
|
||||
return new Promise(function (resolve, reject) {
|
||||
|
||||
if (!dlg) {
|
||||
const dlg = document.querySelector('.youtubePlayerContainer');
|
||||
|
||||
require(['css!./style'], function () {
|
||||
if (!dlg) {
|
||||
|
||||
loading.show();
|
||||
import('css!./style').then(() => {
|
||||
|
||||
var dlg = document.createElement('div');
|
||||
loading.show();
|
||||
|
||||
dlg.classList.add('youtubePlayerContainer');
|
||||
const dlg = document.createElement('div');
|
||||
|
||||
if (options.fullscreen) {
|
||||
dlg.classList.add('onTop');
|
||||
}
|
||||
dlg.classList.add('youtubePlayerContainer');
|
||||
|
||||
dlg.innerHTML = '<div id="player"></div>';
|
||||
var videoElement = dlg.querySelector('#player');
|
||||
|
||||
document.body.insertBefore(dlg, document.body.firstChild);
|
||||
instance.videoDialog = dlg;
|
||||
|
||||
if (options.fullscreen && dlg.animate && !browser.slow) {
|
||||
zoomIn(dlg, 1).onfinish = function () {
|
||||
resolve(videoElement);
|
||||
};
|
||||
} else {
|
||||
resolve(videoElement);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
} else {
|
||||
resolve(dlg.querySelector('#player'));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function onVideoResize() {
|
||||
var instance = this;
|
||||
var player = instance.currentYoutubePlayer;
|
||||
var dlg = instance.videoDialog;
|
||||
if (player && dlg) {
|
||||
player.setSize(dlg.offsetWidth, dlg.offsetHeight);
|
||||
}
|
||||
}
|
||||
|
||||
function clearTimeUpdateInterval(instance) {
|
||||
if (instance.timeUpdateInterval) {
|
||||
clearInterval(instance.timeUpdateInterval);
|
||||
}
|
||||
instance.timeUpdateInterval = null;
|
||||
}
|
||||
|
||||
function onEndedInternal(instance) {
|
||||
|
||||
clearTimeUpdateInterval(instance);
|
||||
var resizeListener = instance.resizeListener;
|
||||
if (resizeListener) {
|
||||
window.removeEventListener('resize', resizeListener);
|
||||
window.removeEventListener('orientationChange', resizeListener);
|
||||
instance.resizeListener = null;
|
||||
}
|
||||
|
||||
var stopInfo = {
|
||||
src: instance._currentSrc
|
||||
};
|
||||
|
||||
events.trigger(instance, 'stopped', [stopInfo]);
|
||||
|
||||
instance._currentSrc = null;
|
||||
if (instance.currentYoutubePlayer) {
|
||||
instance.currentYoutubePlayer.destroy();
|
||||
}
|
||||
instance.currentYoutubePlayer = null;
|
||||
}
|
||||
|
||||
// 4. The API will call this function when the video player is ready.
|
||||
function onPlayerReady(event) {
|
||||
event.target.playVideo();
|
||||
}
|
||||
|
||||
function onTimeUpdate(e) {
|
||||
|
||||
events.trigger(this, 'timeupdate');
|
||||
}
|
||||
|
||||
function onPlaying(instance, playOptions, resolve) {
|
||||
|
||||
if (!instance.started) {
|
||||
|
||||
instance.started = true;
|
||||
resolve();
|
||||
clearTimeUpdateInterval(instance);
|
||||
instance.timeUpdateInterval = setInterval(onTimeUpdate.bind(instance), 500);
|
||||
|
||||
if (playOptions.fullscreen) {
|
||||
|
||||
appRouter.showVideoOsd().then(function () {
|
||||
instance.videoDialog.classList.remove('onTop');
|
||||
});
|
||||
|
||||
} else {
|
||||
appRouter.setTransparency('backdrop');
|
||||
instance.videoDialog.classList.remove('onTop');
|
||||
}
|
||||
|
||||
require(['loading'], function (loading) {
|
||||
|
||||
loading.hide();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function setCurrentSrc(instance, elem, options) {
|
||||
|
||||
return new Promise(function (resolve, reject) {
|
||||
|
||||
require(['queryString'], function (queryString) {
|
||||
|
||||
instance._currentSrc = options.url;
|
||||
var params = queryString.parse(options.url.split('?')[1]);
|
||||
// 3. This function creates an <iframe> (and YouTube player)
|
||||
// after the API code downloads.
|
||||
window.onYouTubeIframeAPIReady = function () {
|
||||
instance.currentYoutubePlayer = new YT.Player('player', {
|
||||
height: instance.videoDialog.offsetHeight,
|
||||
width: instance.videoDialog.offsetWidth,
|
||||
videoId: params.v,
|
||||
events: {
|
||||
'onReady': onPlayerReady,
|
||||
'onStateChange': function (event) {
|
||||
if (event.data === YT.PlayerState.PLAYING) {
|
||||
onPlaying(instance, options, resolve);
|
||||
} else if (event.data === YT.PlayerState.ENDED) {
|
||||
onEndedInternal(instance);
|
||||
} else if (event.data === YT.PlayerState.PAUSED) {
|
||||
events.trigger(instance, 'pause');
|
||||
}
|
||||
}
|
||||
},
|
||||
playerVars: {
|
||||
controls: 0,
|
||||
enablejsapi: 1,
|
||||
modestbranding: 1,
|
||||
rel: 0,
|
||||
showinfo: 0,
|
||||
fs: 0,
|
||||
playsinline: 1
|
||||
}
|
||||
});
|
||||
|
||||
var resizeListener = instance.resizeListener;
|
||||
if (resizeListener) {
|
||||
window.removeEventListener('resize', resizeListener);
|
||||
window.addEventListener('resize', resizeListener);
|
||||
} else {
|
||||
resizeListener = instance.resizeListener = onVideoResize.bind(instance);
|
||||
window.addEventListener('resize', resizeListener);
|
||||
}
|
||||
window.removeEventListener('orientationChange', resizeListener);
|
||||
window.addEventListener('orientationChange', resizeListener);
|
||||
};
|
||||
|
||||
if (!window.YT) {
|
||||
var tag = document.createElement('script');
|
||||
tag.src = 'https://www.youtube.com/iframe_api';
|
||||
var firstScriptTag = document.getElementsByTagName('script')[0];
|
||||
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
|
||||
} else {
|
||||
window.onYouTubeIframeAPIReady();
|
||||
if (options.fullscreen) {
|
||||
dlg.classList.add('onTop');
|
||||
}
|
||||
|
||||
dlg.innerHTML = '<div id="player"></div>';
|
||||
const videoElement = dlg.querySelector('#player');
|
||||
|
||||
document.body.insertBefore(dlg, document.body.firstChild);
|
||||
instance.videoDialog = dlg;
|
||||
|
||||
if (options.fullscreen && dlg.animate && !browser.slow) {
|
||||
zoomIn(dlg, 1).onfinish = function () {
|
||||
resolve(videoElement);
|
||||
};
|
||||
} else {
|
||||
resolve(videoElement);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
} else {
|
||||
resolve(dlg.querySelector('#player'));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function onVideoResize() {
|
||||
const instance = this;
|
||||
const player = instance.currentYoutubePlayer;
|
||||
const dlg = instance.videoDialog;
|
||||
if (player && dlg) {
|
||||
player.setSize(dlg.offsetWidth, dlg.offsetHeight);
|
||||
}
|
||||
}
|
||||
|
||||
function clearTimeUpdateInterval(instance) {
|
||||
if (instance.timeUpdateInterval) {
|
||||
clearInterval(instance.timeUpdateInterval);
|
||||
}
|
||||
instance.timeUpdateInterval = null;
|
||||
}
|
||||
|
||||
function onEndedInternal(instance) {
|
||||
|
||||
clearTimeUpdateInterval(instance);
|
||||
const resizeListener = instance.resizeListener;
|
||||
if (resizeListener) {
|
||||
window.removeEventListener('resize', resizeListener);
|
||||
window.removeEventListener('orientationChange', resizeListener);
|
||||
instance.resizeListener = null;
|
||||
}
|
||||
|
||||
function YoutubePlayer() {
|
||||
const stopInfo = {
|
||||
src: instance._currentSrc
|
||||
};
|
||||
|
||||
events.trigger(instance, 'stopped', [stopInfo]);
|
||||
|
||||
instance._currentSrc = null;
|
||||
if (instance.currentYoutubePlayer) {
|
||||
instance.currentYoutubePlayer.destroy();
|
||||
}
|
||||
instance.currentYoutubePlayer = null;
|
||||
}
|
||||
|
||||
// 4. The API will call this function when the video player is ready.
|
||||
function onPlayerReady(event) {
|
||||
event.target.playVideo();
|
||||
}
|
||||
|
||||
function onTimeUpdate(e) {
|
||||
|
||||
events.trigger(this, 'timeupdate');
|
||||
}
|
||||
|
||||
function onPlaying(instance, playOptions, resolve) {
|
||||
|
||||
if (!instance.started) {
|
||||
|
||||
instance.started = true;
|
||||
resolve();
|
||||
clearTimeUpdateInterval(instance);
|
||||
instance.timeUpdateInterval = setInterval(onTimeUpdate.bind(instance), 500);
|
||||
|
||||
if (playOptions.fullscreen) {
|
||||
|
||||
appRouter.showVideoOsd().then(function () {
|
||||
instance.videoDialog.classList.remove('onTop');
|
||||
});
|
||||
|
||||
} else {
|
||||
appRouter.setTransparency('backdrop');
|
||||
instance.videoDialog.classList.remove('onTop');
|
||||
}
|
||||
|
||||
import('loading').then(({default: loading}) => {
|
||||
|
||||
loading.hide();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function setCurrentSrc(instance, elem, options) {
|
||||
|
||||
return new Promise(function (resolve, reject) {
|
||||
|
||||
import('queryString').then(({default: queryString}) => {
|
||||
|
||||
instance._currentSrc = options.url;
|
||||
const params = queryString.parse(options.url.split('?')[1]);
|
||||
// 3. This function creates an <iframe> (and YouTube player)
|
||||
// after the API code downloads.
|
||||
window.onYouTubeIframeAPIReady = function () {
|
||||
instance.currentYoutubePlayer = new YT.Player('player', {
|
||||
height: instance.videoDialog.offsetHeight,
|
||||
width: instance.videoDialog.offsetWidth,
|
||||
videoId: params.v,
|
||||
events: {
|
||||
'onReady': onPlayerReady,
|
||||
'onStateChange': function (event) {
|
||||
if (event.data === YT.PlayerState.PLAYING) {
|
||||
onPlaying(instance, options, resolve);
|
||||
} else if (event.data === YT.PlayerState.ENDED) {
|
||||
onEndedInternal(instance);
|
||||
} else if (event.data === YT.PlayerState.PAUSED) {
|
||||
events.trigger(instance, 'pause');
|
||||
}
|
||||
}
|
||||
},
|
||||
playerVars: {
|
||||
controls: 0,
|
||||
enablejsapi: 1,
|
||||
modestbranding: 1,
|
||||
rel: 0,
|
||||
showinfo: 0,
|
||||
fs: 0,
|
||||
playsinline: 1
|
||||
}
|
||||
});
|
||||
|
||||
let resizeListener = instance.resizeListener;
|
||||
if (resizeListener) {
|
||||
window.removeEventListener('resize', resizeListener);
|
||||
window.addEventListener('resize', resizeListener);
|
||||
} else {
|
||||
resizeListener = instance.resizeListener = onVideoResize.bind(instance);
|
||||
window.addEventListener('resize', resizeListener);
|
||||
}
|
||||
window.removeEventListener('orientationChange', resizeListener);
|
||||
window.addEventListener('orientationChange', resizeListener);
|
||||
};
|
||||
|
||||
if (!window.YT) {
|
||||
const tag = document.createElement('script');
|
||||
tag.src = 'https://www.youtube.com/iframe_api';
|
||||
const firstScriptTag = document.getElementsByTagName('script')[0];
|
||||
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
|
||||
} else {
|
||||
window.onYouTubeIframeAPIReady();
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
class YoutubePlayer {
|
||||
constructor() {
|
||||
|
||||
this.name = 'Youtube Player';
|
||||
this.type = 'mediaplayer';
|
||||
|
@ -202,21 +207,19 @@ define(['require', 'events', 'browser', 'appRouter', 'loading'], function (requi
|
|||
// Let any players created by plugins take priority
|
||||
this.priority = 1;
|
||||
}
|
||||
|
||||
YoutubePlayer.prototype.play = function (options) {
|
||||
play(options) {
|
||||
|
||||
this.started = false;
|
||||
var instance = this;
|
||||
const instance = this;
|
||||
|
||||
return createMediaElement(this, options).then(function (elem) {
|
||||
|
||||
return setCurrentSrc(instance, elem, options);
|
||||
});
|
||||
};
|
||||
}
|
||||
stop(destroyPlayer) {
|
||||
|
||||
YoutubePlayer.prototype.stop = function (destroyPlayer) {
|
||||
|
||||
var src = this._currentSrc;
|
||||
const src = this._currentSrc;
|
||||
|
||||
if (src) {
|
||||
|
||||
|
@ -231,63 +234,52 @@ define(['require', 'events', 'browser', 'appRouter', 'loading'], function (requi
|
|||
}
|
||||
|
||||
return Promise.resolve();
|
||||
};
|
||||
|
||||
YoutubePlayer.prototype.destroy = function () {
|
||||
}
|
||||
destroy() {
|
||||
|
||||
appRouter.setTransparency('none');
|
||||
|
||||
var dlg = this.videoDialog;
|
||||
const dlg = this.videoDialog;
|
||||
if (dlg) {
|
||||
|
||||
this.videoDialog = null;
|
||||
|
||||
dlg.parentNode.removeChild(dlg);
|
||||
}
|
||||
};
|
||||
|
||||
YoutubePlayer.prototype.canPlayMediaType = function (mediaType) {
|
||||
}
|
||||
canPlayMediaType(mediaType) {
|
||||
|
||||
mediaType = (mediaType || '').toLowerCase();
|
||||
|
||||
return mediaType === 'audio' || mediaType === 'video';
|
||||
};
|
||||
|
||||
YoutubePlayer.prototype.canPlayItem = function (item) {
|
||||
}
|
||||
canPlayItem(item) {
|
||||
|
||||
// Does not play server items
|
||||
return false;
|
||||
};
|
||||
|
||||
YoutubePlayer.prototype.canPlayUrl = function (url) {
|
||||
}
|
||||
canPlayUrl(url) {
|
||||
|
||||
return url.toLowerCase().indexOf('youtube.com') !== -1;
|
||||
};
|
||||
|
||||
YoutubePlayer.prototype.getDeviceProfile = function () {
|
||||
}
|
||||
getDeviceProfile() {
|
||||
|
||||
return Promise.resolve({});
|
||||
};
|
||||
|
||||
YoutubePlayer.prototype.currentSrc = function () {
|
||||
}
|
||||
currentSrc() {
|
||||
return this._currentSrc;
|
||||
};
|
||||
|
||||
YoutubePlayer.prototype.setSubtitleStreamIndex = function (index) {
|
||||
};
|
||||
|
||||
YoutubePlayer.prototype.canSetAudioStreamIndex = function () {
|
||||
}
|
||||
setSubtitleStreamIndex(index) {
|
||||
}
|
||||
canSetAudioStreamIndex() {
|
||||
return false;
|
||||
};
|
||||
|
||||
YoutubePlayer.prototype.setAudioStreamIndex = function (index) {
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
setAudioStreamIndex(index) {
|
||||
}
|
||||
// Save this for when playback stops, because querying the time at that point might return 0
|
||||
YoutubePlayer.prototype.currentTime = function (val) {
|
||||
currentTime(val) {
|
||||
|
||||
var currentYoutubePlayer = this.currentYoutubePlayer;
|
||||
const currentYoutubePlayer = this.currentYoutubePlayer;
|
||||
|
||||
if (currentYoutubePlayer) {
|
||||
if (val != null) {
|
||||
|
@ -297,92 +289,84 @@ define(['require', 'events', 'browser', 'appRouter', 'loading'], function (requi
|
|||
|
||||
return currentYoutubePlayer.getCurrentTime() * 1000;
|
||||
}
|
||||
};
|
||||
}
|
||||
duration(val) {
|
||||
|
||||
YoutubePlayer.prototype.duration = function (val) {
|
||||
|
||||
var currentYoutubePlayer = this.currentYoutubePlayer;
|
||||
const currentYoutubePlayer = this.currentYoutubePlayer;
|
||||
|
||||
if (currentYoutubePlayer) {
|
||||
return currentYoutubePlayer.getDuration() * 1000;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
}
|
||||
pause() {
|
||||
|
||||
YoutubePlayer.prototype.pause = function () {
|
||||
|
||||
var currentYoutubePlayer = this.currentYoutubePlayer;
|
||||
const currentYoutubePlayer = this.currentYoutubePlayer;
|
||||
|
||||
if (currentYoutubePlayer) {
|
||||
currentYoutubePlayer.pauseVideo();
|
||||
|
||||
var instance = this;
|
||||
const instance = this;
|
||||
|
||||
// This needs a delay before the youtube player will report the correct player state
|
||||
setTimeout(function () {
|
||||
events.trigger(instance, 'pause');
|
||||
}, 200);
|
||||
}
|
||||
};
|
||||
}
|
||||
unpause() {
|
||||
|
||||
YoutubePlayer.prototype.unpause = function () {
|
||||
|
||||
var currentYoutubePlayer = this.currentYoutubePlayer;
|
||||
const currentYoutubePlayer = this.currentYoutubePlayer;
|
||||
|
||||
if (currentYoutubePlayer) {
|
||||
currentYoutubePlayer.playVideo();
|
||||
|
||||
var instance = this;
|
||||
const instance = this;
|
||||
|
||||
// This needs a delay before the youtube player will report the correct player state
|
||||
setTimeout(function () {
|
||||
events.trigger(instance, 'unpause');
|
||||
}, 200);
|
||||
}
|
||||
};
|
||||
}
|
||||
paused() {
|
||||
|
||||
YoutubePlayer.prototype.paused = function () {
|
||||
|
||||
var currentYoutubePlayer = this.currentYoutubePlayer;
|
||||
const currentYoutubePlayer = this.currentYoutubePlayer;
|
||||
|
||||
if (currentYoutubePlayer) {
|
||||
return currentYoutubePlayer.getPlayerState() === 2;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
YoutubePlayer.prototype.volume = function (val) {
|
||||
}
|
||||
volume(val) {
|
||||
if (val != null) {
|
||||
return this.setVolume(val);
|
||||
}
|
||||
|
||||
return this.getVolume();
|
||||
};
|
||||
}
|
||||
setVolume(val) {
|
||||
|
||||
YoutubePlayer.prototype.setVolume = function (val) {
|
||||
|
||||
var currentYoutubePlayer = this.currentYoutubePlayer;
|
||||
const currentYoutubePlayer = this.currentYoutubePlayer;
|
||||
|
||||
if (currentYoutubePlayer) {
|
||||
if (val != null) {
|
||||
currentYoutubePlayer.setVolume(val);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
getVolume() {
|
||||
|
||||
YoutubePlayer.prototype.getVolume = function () {
|
||||
|
||||
var currentYoutubePlayer = this.currentYoutubePlayer;
|
||||
const currentYoutubePlayer = this.currentYoutubePlayer;
|
||||
|
||||
if (currentYoutubePlayer) {
|
||||
return currentYoutubePlayer.getVolume();
|
||||
}
|
||||
};
|
||||
}
|
||||
setMute(mute) {
|
||||
|
||||
YoutubePlayer.prototype.setMute = function (mute) {
|
||||
|
||||
var currentYoutubePlayer = this.currentYoutubePlayer;
|
||||
const currentYoutubePlayer = this.currentYoutubePlayer;
|
||||
|
||||
if (mute) {
|
||||
if (currentYoutubePlayer) {
|
||||
|
@ -394,16 +378,15 @@ define(['require', 'events', 'browser', 'appRouter', 'loading'], function (requi
|
|||
currentYoutubePlayer.unMute();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
isMuted() {
|
||||
|
||||
YoutubePlayer.prototype.isMuted = function () {
|
||||
|
||||
var currentYoutubePlayer = this.currentYoutubePlayer;
|
||||
const currentYoutubePlayer = this.currentYoutubePlayer;
|
||||
|
||||
if (currentYoutubePlayer) {
|
||||
return currentYoutubePlayer.isMuted();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return YoutubePlayer;
|
||||
});
|
||||
export default YoutubePlayer;
|
||||
|
|
|
@ -1,110 +1,111 @@
|
|||
define(['dom', 'focusManager'], function (dom, focusManager) {
|
||||
'use strict';
|
||||
import dom from 'dom';
|
||||
import focusManager from 'focusManager';
|
||||
|
||||
var inputDisplayElement;
|
||||
var currentDisplayText = '';
|
||||
var currentDisplayTextContainer;
|
||||
let inputDisplayElement;
|
||||
let currentDisplayText = '';
|
||||
let currentDisplayTextContainer;
|
||||
|
||||
function onKeyDown(e) {
|
||||
function onKeyDown(e) {
|
||||
|
||||
if (e.ctrlKey) {
|
||||
return;
|
||||
}
|
||||
if (e.shiftKey) {
|
||||
return;
|
||||
}
|
||||
if (e.altKey) {
|
||||
return;
|
||||
}
|
||||
|
||||
var key = e.key;
|
||||
var chr = key ? alphanumeric(key) : null;
|
||||
|
||||
if (chr) {
|
||||
|
||||
chr = chr.toString().toUpperCase();
|
||||
|
||||
if (chr.length === 1) {
|
||||
currentDisplayTextContainer = this.options.itemsContainer;
|
||||
onAlphanumericKeyPress(e, chr);
|
||||
}
|
||||
}
|
||||
if (e.ctrlKey) {
|
||||
return;
|
||||
}
|
||||
if (e.shiftKey) {
|
||||
return;
|
||||
}
|
||||
if (e.altKey) {
|
||||
return;
|
||||
}
|
||||
|
||||
function alphanumeric(value) {
|
||||
var letterNumber = /^[0-9a-zA-Z]+$/;
|
||||
return value.match(letterNumber);
|
||||
}
|
||||
const key = e.key;
|
||||
let chr = key ? alphanumeric(key) : null;
|
||||
|
||||
function ensureInputDisplayElement() {
|
||||
if (!inputDisplayElement) {
|
||||
inputDisplayElement = document.createElement('div');
|
||||
inputDisplayElement.classList.add('alphanumeric-shortcut');
|
||||
inputDisplayElement.classList.add('hide');
|
||||
if (chr) {
|
||||
|
||||
document.body.appendChild(inputDisplayElement);
|
||||
chr = chr.toString().toUpperCase();
|
||||
|
||||
if (chr.length === 1) {
|
||||
currentDisplayTextContainer = this.options.itemsContainer;
|
||||
onAlphanumericKeyPress(e, chr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var alpanumericShortcutTimeout;
|
||||
function clearAlphaNumericShortcutTimeout() {
|
||||
if (alpanumericShortcutTimeout) {
|
||||
clearTimeout(alpanumericShortcutTimeout);
|
||||
alpanumericShortcutTimeout = null;
|
||||
}
|
||||
}
|
||||
function resetAlphaNumericShortcutTimeout() {
|
||||
clearAlphaNumericShortcutTimeout();
|
||||
alpanumericShortcutTimeout = setTimeout(onAlphanumericShortcutTimeout, 2000);
|
||||
}
|
||||
function alphanumeric(value) {
|
||||
const letterNumber = /^[0-9a-zA-Z]+$/;
|
||||
return value.match(letterNumber);
|
||||
}
|
||||
|
||||
function onAlphanumericKeyPress(e, chr) {
|
||||
if (currentDisplayText.length >= 3) {
|
||||
return;
|
||||
}
|
||||
ensureInputDisplayElement();
|
||||
currentDisplayText += chr;
|
||||
inputDisplayElement.innerHTML = currentDisplayText;
|
||||
inputDisplayElement.classList.remove('hide');
|
||||
resetAlphaNumericShortcutTimeout();
|
||||
}
|
||||
|
||||
function onAlphanumericShortcutTimeout() {
|
||||
var value = currentDisplayText;
|
||||
var container = currentDisplayTextContainer;
|
||||
|
||||
currentDisplayText = '';
|
||||
currentDisplayTextContainer = null;
|
||||
inputDisplayElement.innerHTML = '';
|
||||
function ensureInputDisplayElement() {
|
||||
if (!inputDisplayElement) {
|
||||
inputDisplayElement = document.createElement('div');
|
||||
inputDisplayElement.classList.add('alphanumeric-shortcut');
|
||||
inputDisplayElement.classList.add('hide');
|
||||
clearAlphaNumericShortcutTimeout();
|
||||
selectByShortcutValue(container, value);
|
||||
|
||||
document.body.appendChild(inputDisplayElement);
|
||||
}
|
||||
}
|
||||
|
||||
let alpanumericShortcutTimeout;
|
||||
function clearAlphaNumericShortcutTimeout() {
|
||||
if (alpanumericShortcutTimeout) {
|
||||
clearTimeout(alpanumericShortcutTimeout);
|
||||
alpanumericShortcutTimeout = null;
|
||||
}
|
||||
}
|
||||
function resetAlphaNumericShortcutTimeout() {
|
||||
clearAlphaNumericShortcutTimeout();
|
||||
alpanumericShortcutTimeout = setTimeout(onAlphanumericShortcutTimeout, 2000);
|
||||
}
|
||||
|
||||
function onAlphanumericKeyPress(e, chr) {
|
||||
if (currentDisplayText.length >= 3) {
|
||||
return;
|
||||
}
|
||||
ensureInputDisplayElement();
|
||||
currentDisplayText += chr;
|
||||
inputDisplayElement.innerHTML = currentDisplayText;
|
||||
inputDisplayElement.classList.remove('hide');
|
||||
resetAlphaNumericShortcutTimeout();
|
||||
}
|
||||
|
||||
function onAlphanumericShortcutTimeout() {
|
||||
const value = currentDisplayText;
|
||||
const container = currentDisplayTextContainer;
|
||||
|
||||
currentDisplayText = '';
|
||||
currentDisplayTextContainer = null;
|
||||
inputDisplayElement.innerHTML = '';
|
||||
inputDisplayElement.classList.add('hide');
|
||||
clearAlphaNumericShortcutTimeout();
|
||||
selectByShortcutValue(container, value);
|
||||
}
|
||||
|
||||
function selectByShortcutValue(container, value) {
|
||||
|
||||
value = value.toUpperCase();
|
||||
|
||||
let focusElem;
|
||||
if (value === '#') {
|
||||
|
||||
focusElem = container.querySelector('*[data-prefix]');
|
||||
}
|
||||
|
||||
function selectByShortcutValue(container, value) {
|
||||
|
||||
value = value.toUpperCase();
|
||||
|
||||
var focusElem;
|
||||
if (value === '#') {
|
||||
|
||||
focusElem = container.querySelector('*[data-prefix]');
|
||||
}
|
||||
|
||||
if (!focusElem) {
|
||||
focusElem = container.querySelector('*[data-prefix^=\'' + value + '\']');
|
||||
}
|
||||
|
||||
if (focusElem) {
|
||||
focusManager.focus(focusElem);
|
||||
}
|
||||
if (!focusElem) {
|
||||
focusElem = container.querySelector('*[data-prefix^=\'' + value + '\']');
|
||||
}
|
||||
|
||||
function AlphaNumericShortcuts(options) {
|
||||
if (focusElem) {
|
||||
focusManager.focus(focusElem);
|
||||
}
|
||||
}
|
||||
|
||||
class AlphaNumericShortcuts {
|
||||
constructor(options) {
|
||||
|
||||
this.options = options;
|
||||
|
||||
var keyDownHandler = onKeyDown.bind(this);
|
||||
const keyDownHandler = onKeyDown.bind(this);
|
||||
|
||||
dom.addEventListener(window, 'keydown', keyDownHandler, {
|
||||
passive: true
|
||||
|
@ -112,10 +113,9 @@ define(['dom', 'focusManager'], function (dom, focusManager) {
|
|||
|
||||
this.keyDownHandler = keyDownHandler;
|
||||
}
|
||||
destroy() {
|
||||
|
||||
AlphaNumericShortcuts.prototype.destroy = function () {
|
||||
|
||||
var keyDownHandler = this.keyDownHandler;
|
||||
const keyDownHandler = this.keyDownHandler;
|
||||
|
||||
if (keyDownHandler) {
|
||||
dom.removeEventListener(window, 'keydown', keyDownHandler, {
|
||||
|
@ -124,7 +124,7 @@ define(['dom', 'focusManager'], function (dom, focusManager) {
|
|||
this.keyDownHandler = null;
|
||||
}
|
||||
this.options = null;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return AlphaNumericShortcuts;
|
||||
});
|
||||
export default AlphaNumericShortcuts;
|
||||
|
|
|
@ -1,77 +1,78 @@
|
|||
define(['backdrop', 'userSettings', 'libraryMenu'], function (backdrop, userSettings, libraryMenu) {
|
||||
'use strict';
|
||||
import backdrop from 'backdrop';
|
||||
import * as userSettings from 'userSettings';
|
||||
import libraryMenu from 'libraryMenu';
|
||||
|
||||
var cache = {};
|
||||
const cache = {};
|
||||
|
||||
function enabled() {
|
||||
return userSettings.enableBackdrops();
|
||||
function enabled() {
|
||||
return userSettings.enableBackdrops();
|
||||
}
|
||||
|
||||
function getBackdropItemIds(apiClient, userId, types, parentId) {
|
||||
const key = `backdrops2_${userId + (types || '') + (parentId || '')}`;
|
||||
let data = cache[key];
|
||||
|
||||
if (data) {
|
||||
console.debug(`Found backdrop id list in cache. Key: ${key}`);
|
||||
data = JSON.parse(data);
|
||||
return Promise.resolve(data);
|
||||
}
|
||||
|
||||
function getBackdropItemIds(apiClient, userId, types, parentId) {
|
||||
var key = `backdrops2_${userId + (types || '') + (parentId || '')}`;
|
||||
var data = cache[key];
|
||||
|
||||
if (data) {
|
||||
console.debug(`Found backdrop id list in cache. Key: ${key}`);
|
||||
data = JSON.parse(data);
|
||||
return Promise.resolve(data);
|
||||
}
|
||||
|
||||
var options = {
|
||||
SortBy: 'IsFavoriteOrLiked,Random',
|
||||
Limit: 20,
|
||||
Recursive: true,
|
||||
IncludeItemTypes: types,
|
||||
ImageTypes: 'Backdrop',
|
||||
ParentId: parentId,
|
||||
EnableTotalRecordCount: false
|
||||
};
|
||||
return apiClient.getItems(apiClient.getCurrentUserId(), options).then(function (result) {
|
||||
var images = result.Items.map(function (i) {
|
||||
return {
|
||||
Id: i.Id,
|
||||
tag: i.BackdropImageTags[0],
|
||||
ServerId: i.ServerId
|
||||
};
|
||||
});
|
||||
cache[key] = JSON.stringify(images);
|
||||
return images;
|
||||
const options = {
|
||||
SortBy: 'IsFavoriteOrLiked,Random',
|
||||
Limit: 20,
|
||||
Recursive: true,
|
||||
IncludeItemTypes: types,
|
||||
ImageTypes: 'Backdrop',
|
||||
ParentId: parentId,
|
||||
EnableTotalRecordCount: false
|
||||
};
|
||||
return apiClient.getItems(apiClient.getCurrentUserId(), options).then(function (result) {
|
||||
const images = result.Items.map(function (i) {
|
||||
return {
|
||||
Id: i.Id,
|
||||
tag: i.BackdropImageTags[0],
|
||||
ServerId: i.ServerId
|
||||
};
|
||||
});
|
||||
}
|
||||
cache[key] = JSON.stringify(images);
|
||||
return images;
|
||||
});
|
||||
}
|
||||
|
||||
function showBackdrop(type, parentId) {
|
||||
var apiClient = window.ApiClient;
|
||||
function showBackdrop(type, parentId) {
|
||||
const apiClient = window.ApiClient;
|
||||
|
||||
if (apiClient) {
|
||||
getBackdropItemIds(apiClient, apiClient.getCurrentUserId(), type, parentId).then(function (images) {
|
||||
if (images.length) {
|
||||
backdrop.setBackdrops(images.map(function (i) {
|
||||
i.BackdropImageTags = [i.tag];
|
||||
return i;
|
||||
}));
|
||||
} else {
|
||||
backdrop.clearBackdrop();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
pageClassOn('pageshow', 'page', function () {
|
||||
var page = this;
|
||||
|
||||
if (!page.classList.contains('selfBackdropPage')) {
|
||||
if (page.classList.contains('backdropPage')) {
|
||||
if (enabled()) {
|
||||
var type = page.getAttribute('data-backdroptype');
|
||||
var parentId = page.classList.contains('globalBackdropPage') ? '' : libraryMenu.getTopParentId();
|
||||
showBackdrop(type, parentId);
|
||||
} else {
|
||||
page.classList.remove('backdropPage');
|
||||
backdrop.clearBackdrop();
|
||||
}
|
||||
if (apiClient) {
|
||||
getBackdropItemIds(apiClient, apiClient.getCurrentUserId(), type, parentId).then(function (images) {
|
||||
if (images.length) {
|
||||
backdrop.setBackdrops(images.map(function (i) {
|
||||
i.BackdropImageTags = [i.tag];
|
||||
return i;
|
||||
}));
|
||||
} else {
|
||||
backdrop.clearBackdrop();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
pageClassOn('pageshow', 'page', function () {
|
||||
const page = this;
|
||||
|
||||
if (!page.classList.contains('selfBackdropPage')) {
|
||||
if (page.classList.contains('backdropPage')) {
|
||||
if (enabled()) {
|
||||
const type = page.getAttribute('data-backdroptype');
|
||||
const parentId = page.classList.contains('globalBackdropPage') ? '' : libraryMenu.getTopParentId();
|
||||
showBackdrop(type, parentId);
|
||||
} else {
|
||||
page.classList.remove('backdropPage');
|
||||
backdrop.clearBackdrop();
|
||||
}
|
||||
} else {
|
||||
backdrop.clearBackdrop();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
define(['datetime', 'jQuery', 'globalize', 'material-icons'], function (datetime, $, globalize) {
|
||||
'use strict';
|
||||
import datetime from 'datetime';
|
||||
import $ from 'jQuery';
|
||||
import globalize from 'globalize';
|
||||
import 'material-icons';
|
||||
|
||||
/* eslint-disable indent */
|
||||
|
||||
function getNode(item, folderState, selected) {
|
||||
var htmlName = getNodeInnerHtml(item);
|
||||
|
@ -179,7 +183,7 @@ define(['datetime', 'jQuery', 'globalize', 'material-icons'], function (datetime
|
|||
}
|
||||
|
||||
function initializeTree(page, currentUser, openItems, selectedId) {
|
||||
require(['jstree'], function () {
|
||||
import('jstree').then(() => {
|
||||
initializeTreeInternal(page, currentUser, openItems, selectedId);
|
||||
});
|
||||
}
|
||||
|
@ -299,7 +303,7 @@ define(['datetime', 'jQuery', 'globalize', 'material-icons'], function (datetime
|
|||
$(document).on('itemsaved', '.metadataEditorPage', function (e, item) {
|
||||
updateEditorNode(this, item);
|
||||
}).on('pagebeforeshow', '.metadataEditorPage', function () {
|
||||
require(['css!assets/css/metadataeditor.css']);
|
||||
import('css!assets/css/metadataeditor.css');
|
||||
}).on('pagebeforeshow', '.metadataEditorPage', function () {
|
||||
var page = this;
|
||||
Dashboard.getCurrentUser().then(function (user) {
|
||||
|
@ -331,4 +335,5 @@ define(['datetime', 'jQuery', 'globalize', 'material-icons'], function (datetime
|
|||
getCurrentItemId: getCurrentItemId,
|
||||
setCurrentItemId: setCurrentItemId
|
||||
};
|
||||
});
|
||||
|
||||
/* eslint-enable indent */
|
||||
|
|
|
@ -1,21 +1,24 @@
|
|||
define(['userSettings', 'events'], function (userSettings, events) {
|
||||
'use strict';
|
||||
var fallbackCulture = 'en-us';
|
||||
import * as userSettings from 'userSettings';
|
||||
import events from 'events';
|
||||
|
||||
var allTranslations = {};
|
||||
var currentCulture;
|
||||
var currentDateTimeCulture;
|
||||
/* eslint-disable indent */
|
||||
|
||||
function getCurrentLocale() {
|
||||
const fallbackCulture = 'en-us';
|
||||
|
||||
const allTranslations = {};
|
||||
let currentCulture;
|
||||
let currentDateTimeCulture;
|
||||
|
||||
export function getCurrentLocale() {
|
||||
return currentCulture;
|
||||
}
|
||||
|
||||
function getCurrentDateTimeLocale() {
|
||||
export function getCurrentDateTimeLocale() {
|
||||
return currentDateTimeCulture;
|
||||
}
|
||||
|
||||
function getDefaultLanguage() {
|
||||
var culture = document.documentElement.getAttribute('data-culture');
|
||||
const culture = document.documentElement.getAttribute('data-culture');
|
||||
if (culture) {
|
||||
return culture;
|
||||
}
|
||||
|
@ -33,8 +36,8 @@ define(['userSettings', 'events'], function (userSettings, events) {
|
|||
return fallbackCulture;
|
||||
}
|
||||
|
||||
function updateCurrentCulture() {
|
||||
var culture;
|
||||
export function updateCurrentCulture() {
|
||||
let culture;
|
||||
try {
|
||||
culture = userSettings.language();
|
||||
} catch (err) {
|
||||
|
@ -44,7 +47,7 @@ define(['userSettings', 'events'], function (userSettings, events) {
|
|||
|
||||
currentCulture = normalizeLocaleName(culture);
|
||||
|
||||
var dateTimeCulture;
|
||||
let dateTimeCulture;
|
||||
try {
|
||||
dateTimeCulture = userSettings.dateTimeLocale();
|
||||
} catch (err) {
|
||||
|
@ -60,11 +63,11 @@ define(['userSettings', 'events'], function (userSettings, events) {
|
|||
}
|
||||
|
||||
function ensureTranslations(culture) {
|
||||
for (var i in allTranslations) {
|
||||
for (let i in allTranslations) {
|
||||
ensureTranslation(allTranslations[i], culture);
|
||||
}
|
||||
if (culture !== fallbackCulture) {
|
||||
for (var i in allTranslations) {
|
||||
for (let i in allTranslations) {
|
||||
ensureTranslation(allTranslations[i], fallbackCulture);
|
||||
}
|
||||
}
|
||||
|
@ -85,14 +88,14 @@ define(['userSettings', 'events'], function (userSettings, events) {
|
|||
culture = culture.replace('_', '-');
|
||||
|
||||
// convert de-DE to de
|
||||
var parts = culture.split('-');
|
||||
const parts = culture.split('-');
|
||||
if (parts.length === 2) {
|
||||
if (parts[0].toLowerCase() === parts[1].toLowerCase()) {
|
||||
culture = parts[0].toLowerCase();
|
||||
}
|
||||
}
|
||||
|
||||
var lower = culture.toLowerCase();
|
||||
const lower = culture.toLowerCase();
|
||||
if (lower === 'ca-es') {
|
||||
return 'ca';
|
||||
}
|
||||
|
@ -110,7 +113,7 @@ define(['userSettings', 'events'], function (userSettings, events) {
|
|||
module = defaultModule();
|
||||
}
|
||||
|
||||
var translations = allTranslations[module];
|
||||
const translations = allTranslations[module];
|
||||
if (!translations) {
|
||||
return {};
|
||||
}
|
||||
|
@ -118,17 +121,17 @@ define(['userSettings', 'events'], function (userSettings, events) {
|
|||
return translations.dictionaries[locale];
|
||||
}
|
||||
|
||||
function register(options) {
|
||||
export function register(options) {
|
||||
allTranslations[options.name] = {
|
||||
translations: options.strings || options.translations,
|
||||
dictionaries: {}
|
||||
};
|
||||
}
|
||||
|
||||
function loadStrings(options) {
|
||||
var locale = getCurrentLocale();
|
||||
var promises = [];
|
||||
var optionsName;
|
||||
export function loadStrings(options) {
|
||||
const locale = getCurrentLocale();
|
||||
const promises = [];
|
||||
let optionsName;
|
||||
if (typeof options === 'string') {
|
||||
optionsName = options;
|
||||
} else {
|
||||
|
@ -140,10 +143,10 @@ define(['userSettings', 'events'], function (userSettings, events) {
|
|||
return Promise.all(promises);
|
||||
}
|
||||
|
||||
var cacheParam = new Date().getTime();
|
||||
const cacheParam = new Date().getTime();
|
||||
function loadTranslation(translations, lang) {
|
||||
lang = normalizeLocaleName(lang);
|
||||
var filtered = translations.filter(function (t) {
|
||||
let filtered = translations.filter(function (t) {
|
||||
return normalizeLocaleName(t.lang) === lang;
|
||||
});
|
||||
|
||||
|
@ -159,12 +162,12 @@ define(['userSettings', 'events'], function (userSettings, events) {
|
|||
return;
|
||||
}
|
||||
|
||||
var url = filtered[0].path;
|
||||
let url = filtered[0].path;
|
||||
|
||||
url += url.indexOf('?') === -1 ? '?' : '&';
|
||||
url += 'v=' + cacheParam;
|
||||
|
||||
var xhr = new XMLHttpRequest();
|
||||
const xhr = new XMLHttpRequest();
|
||||
xhr.open('GET', url, true);
|
||||
|
||||
xhr.onload = function (e) {
|
||||
|
@ -183,8 +186,8 @@ define(['userSettings', 'events'], function (userSettings, events) {
|
|||
}
|
||||
|
||||
function translateKey(key) {
|
||||
var parts = key.split('#');
|
||||
var module;
|
||||
const parts = key.split('#');
|
||||
let module;
|
||||
|
||||
if (parts.length > 1) {
|
||||
module = parts[0];
|
||||
|
@ -195,7 +198,7 @@ define(['userSettings', 'events'], function (userSettings, events) {
|
|||
}
|
||||
|
||||
function translateKeyFromModule(key, module) {
|
||||
var dictionary = getDictionary(module, getCurrentLocale());
|
||||
let dictionary = getDictionary(module, getCurrentLocale());
|
||||
if (!dictionary || !dictionary[key]) {
|
||||
dictionary = getDictionary(module, fallbackCulture);
|
||||
}
|
||||
|
@ -209,15 +212,15 @@ define(['userSettings', 'events'], function (userSettings, events) {
|
|||
return str.split(find).join(replace);
|
||||
}
|
||||
|
||||
function translate(key) {
|
||||
var val = translateKey(key);
|
||||
for (var i = 1; i < arguments.length; i++) {
|
||||
export function translate(key) {
|
||||
let val = translateKey(key);
|
||||
for (let i = 1; i < arguments.length; i++) {
|
||||
val = replaceAll(val, '{' + (i - 1) + '}', arguments[i]);
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
function translateHtml(html, module) {
|
||||
export function translateHtml(html, module) {
|
||||
if (!module) {
|
||||
module = defaultModule();
|
||||
}
|
||||
|
@ -225,26 +228,26 @@ define(['userSettings', 'events'], function (userSettings, events) {
|
|||
throw new Error('module cannot be null or empty');
|
||||
}
|
||||
|
||||
var startIndex = html.indexOf('${');
|
||||
let startIndex = html.indexOf('${');
|
||||
if (startIndex === -1) {
|
||||
return html;
|
||||
}
|
||||
|
||||
startIndex += 2;
|
||||
var endIndex = html.indexOf('}', startIndex);
|
||||
const endIndex = html.indexOf('}', startIndex);
|
||||
if (endIndex === -1) {
|
||||
return html;
|
||||
}
|
||||
|
||||
var key = html.substring(startIndex, endIndex);
|
||||
var val = translateKeyFromModule(key, module);
|
||||
const key = html.substring(startIndex, endIndex);
|
||||
const val = translateKeyFromModule(key, module);
|
||||
|
||||
html = html.replace('${' + key + '}', val);
|
||||
return translateHtml(html, module);
|
||||
}
|
||||
|
||||
var _defaultModule;
|
||||
function defaultModule(val) {
|
||||
let _defaultModule;
|
||||
export function defaultModule(val) {
|
||||
if (val) {
|
||||
_defaultModule = val;
|
||||
}
|
||||
|
@ -259,16 +262,15 @@ define(['userSettings', 'events'], function (userSettings, events) {
|
|||
}
|
||||
});
|
||||
|
||||
return {
|
||||
getString: translate,
|
||||
translate: translate,
|
||||
translateDocument: translateHtml,
|
||||
translateHtml: translateHtml,
|
||||
loadStrings: loadStrings,
|
||||
defaultModule: defaultModule,
|
||||
getCurrentLocale: getCurrentLocale,
|
||||
getCurrentDateTimeLocale: getCurrentDateTimeLocale,
|
||||
register: register,
|
||||
updateCurrentCulture: updateCurrentCulture
|
||||
};
|
||||
});
|
||||
export default {
|
||||
translate,
|
||||
translateHtml,
|
||||
loadStrings,
|
||||
defaultModule,
|
||||
getCurrentLocale,
|
||||
getCurrentDateTimeLocale,
|
||||
register,
|
||||
updateCurrentCulture
|
||||
};
|
||||
|
||||
/* eslint-enable indent */
|
||||
|
|
|
@ -1,195 +1,202 @@
|
|||
define(['loading', 'listView', 'cardBuilder', 'libraryMenu', 'libraryBrowser', 'apphost', 'imageLoader', 'userSettings', 'emby-itemscontainer'], function (loading, listView, cardBuilder, libraryMenu, libraryBrowser, appHost, imageLoader, userSettings) {
|
||||
'use strict';
|
||||
import loading from 'loading';
|
||||
import listView from 'listView';
|
||||
import cardBuilder from 'cardBuilder';
|
||||
import libraryMenu from 'libraryMenu';
|
||||
import libraryBrowser from 'libraryBrowser';
|
||||
import appHost from 'apphost';
|
||||
import imageLoader from 'imageLoader';
|
||||
import userSettings from 'userSettings';
|
||||
import 'emby-itemscontainer';
|
||||
|
||||
return function (view, params) {
|
||||
function getPageData(context) {
|
||||
var key = getSavedQueryKey(context);
|
||||
var pageData = data[key];
|
||||
export default function (view, params) {
|
||||
function getPageData(context) {
|
||||
const key = getSavedQueryKey(context);
|
||||
let pageData = data[key];
|
||||
|
||||
if (!pageData) {
|
||||
pageData = data[key] = {
|
||||
query: {
|
||||
SortBy: 'SortName',
|
||||
SortOrder: 'Ascending',
|
||||
IncludeItemTypes: 'Playlist',
|
||||
Recursive: true,
|
||||
Fields: 'PrimaryImageAspectRatio,SortName,CumulativeRunTimeTicks,CanDelete',
|
||||
StartIndex: 0
|
||||
},
|
||||
view: libraryBrowser.getSavedView(key) || 'Poster'
|
||||
};
|
||||
if (!pageData) {
|
||||
pageData = data[key] = {
|
||||
query: {
|
||||
SortBy: 'SortName',
|
||||
SortOrder: 'Ascending',
|
||||
IncludeItemTypes: 'Playlist',
|
||||
Recursive: true,
|
||||
Fields: 'PrimaryImageAspectRatio,SortName,CumulativeRunTimeTicks,CanDelete',
|
||||
StartIndex: 0
|
||||
},
|
||||
view: libraryBrowser.getSavedView(key) || 'Poster'
|
||||
};
|
||||
|
||||
if (userSettings.libraryPageSize() > 0) {
|
||||
pageData.query['Limit'] = userSettings.libraryPageSize();
|
||||
}
|
||||
|
||||
pageData.query.ParentId = libraryMenu.getTopParentId();
|
||||
libraryBrowser.loadSavedQueryValues(key, pageData.query);
|
||||
if (userSettings.libraryPageSize() > 0) {
|
||||
pageData.query['Limit'] = userSettings.libraryPageSize();
|
||||
}
|
||||
|
||||
return pageData;
|
||||
pageData.query.ParentId = libraryMenu.getTopParentId();
|
||||
libraryBrowser.loadSavedQueryValues(key, pageData.query);
|
||||
}
|
||||
|
||||
function getQuery(context) {
|
||||
return getPageData(context).query;
|
||||
return pageData;
|
||||
}
|
||||
|
||||
function getQuery(context) {
|
||||
return getPageData(context).query;
|
||||
}
|
||||
|
||||
function getSavedQueryKey(context) {
|
||||
if (!context.savedQueryKey) {
|
||||
context.savedQueryKey = libraryBrowser.getSavedQueryKey();
|
||||
}
|
||||
|
||||
function getSavedQueryKey(context) {
|
||||
if (!context.savedQueryKey) {
|
||||
context.savedQueryKey = libraryBrowser.getSavedQueryKey();
|
||||
}
|
||||
return context.savedQueryKey;
|
||||
}
|
||||
|
||||
return context.savedQueryKey;
|
||||
function showLoadingMessage() {
|
||||
loading.show();
|
||||
}
|
||||
|
||||
function hideLoadingMessage() {
|
||||
loading.hide();
|
||||
}
|
||||
|
||||
function onViewStyleChange() {
|
||||
const viewStyle = getPageData(view).view;
|
||||
const itemsContainer = view.querySelector('.itemsContainer');
|
||||
|
||||
if ('List' == viewStyle) {
|
||||
itemsContainer.classList.add('vertical-list');
|
||||
itemsContainer.classList.remove('vertical-wrap');
|
||||
} else {
|
||||
itemsContainer.classList.remove('vertical-list');
|
||||
itemsContainer.classList.add('vertical-wrap');
|
||||
}
|
||||
|
||||
function showLoadingMessage() {
|
||||
loading.show();
|
||||
}
|
||||
itemsContainer.innerHTML = '';
|
||||
}
|
||||
|
||||
function hideLoadingMessage() {
|
||||
loading.hide();
|
||||
}
|
||||
function reloadItems() {
|
||||
showLoadingMessage();
|
||||
const query = getQuery(view);
|
||||
const promise1 = ApiClient.getItems(Dashboard.getCurrentUserId(), query);
|
||||
// TODO: promise2 is unused, check if necessary.
|
||||
const promise2 = Dashboard.getCurrentUser();
|
||||
Promise.all([promise1, promise2]).then(function (responses) {
|
||||
const result = responses[0];
|
||||
// TODO: Is the scroll necessary?
|
||||
window.scrollTo(0, 0);
|
||||
let html = '';
|
||||
const viewStyle = getPageData(view).view;
|
||||
view.querySelector('.listTopPaging').innerHTML = libraryBrowser.getQueryPagingHtml({
|
||||
startIndex: query.StartIndex,
|
||||
limit: query.Limit,
|
||||
totalRecordCount: result.TotalRecordCount,
|
||||
viewButton: false,
|
||||
showLimit: false,
|
||||
updatePageSizeSetting: false,
|
||||
addLayoutButton: true,
|
||||
layouts: 'List,Poster,PosterCard,Thumb,ThumbCard',
|
||||
currentLayout: viewStyle
|
||||
});
|
||||
|
||||
function onViewStyleChange() {
|
||||
var viewStyle = getPageData(view).view;
|
||||
var itemsContainer = view.querySelector('.itemsContainer');
|
||||
|
||||
if ('List' == viewStyle) {
|
||||
itemsContainer.classList.add('vertical-list');
|
||||
itemsContainer.classList.remove('vertical-wrap');
|
||||
} else {
|
||||
itemsContainer.classList.remove('vertical-list');
|
||||
itemsContainer.classList.add('vertical-wrap');
|
||||
}
|
||||
|
||||
itemsContainer.innerHTML = '';
|
||||
}
|
||||
|
||||
function reloadItems() {
|
||||
showLoadingMessage();
|
||||
var query = getQuery(view);
|
||||
var promise1 = ApiClient.getItems(Dashboard.getCurrentUserId(), query);
|
||||
// TODO: promise2 is unused, check if necessary.
|
||||
var promise2 = Dashboard.getCurrentUser();
|
||||
Promise.all([promise1, promise2]).then(function (responses) {
|
||||
var result = responses[0];
|
||||
// TODO: Is the scroll necessary?
|
||||
window.scrollTo(0, 0);
|
||||
var html = '';
|
||||
var viewStyle = getPageData(view).view;
|
||||
view.querySelector('.listTopPaging').innerHTML = libraryBrowser.getQueryPagingHtml({
|
||||
startIndex: query.StartIndex,
|
||||
limit: query.Limit,
|
||||
totalRecordCount: result.TotalRecordCount,
|
||||
viewButton: false,
|
||||
showLimit: false,
|
||||
updatePageSizeSetting: false,
|
||||
addLayoutButton: true,
|
||||
layouts: 'List,Poster,PosterCard,Thumb,ThumbCard',
|
||||
currentLayout: viewStyle
|
||||
});
|
||||
|
||||
if (result.TotalRecordCount) {
|
||||
if (viewStyle == 'List') {
|
||||
html = listView.getListViewHtml({
|
||||
items: result.Items,
|
||||
sortBy: query.SortBy
|
||||
});
|
||||
} else if (viewStyle == 'PosterCard') {
|
||||
html = cardBuilder.getCardsHtml({
|
||||
items: result.Items,
|
||||
shape: 'square',
|
||||
coverImage: true,
|
||||
showTitle: true,
|
||||
cardLayout: true
|
||||
});
|
||||
} else if (viewStyle == 'Thumb') {
|
||||
html = cardBuilder.getCardsHtml({
|
||||
items: result.Items,
|
||||
shape: 'backdrop',
|
||||
showTitle: true,
|
||||
centerText: true,
|
||||
preferThumb: true,
|
||||
overlayPlayButton: true
|
||||
});
|
||||
} else if (viewStyle == 'ThumbCard') {
|
||||
html = cardBuilder.getCardsHtml({
|
||||
items: result.Items,
|
||||
shape: 'backdrop',
|
||||
showTitle: true,
|
||||
preferThumb: true,
|
||||
cardLayout: true
|
||||
});
|
||||
} else {
|
||||
html = cardBuilder.getCardsHtml({
|
||||
items: result.Items,
|
||||
shape: 'square',
|
||||
showTitle: true,
|
||||
coverImage: true,
|
||||
centerText: true,
|
||||
overlayPlayButton: true
|
||||
});
|
||||
}
|
||||
view.querySelector('.noItemsMessage').classList.add('hide');
|
||||
if (result.TotalRecordCount) {
|
||||
if (viewStyle == 'List') {
|
||||
html = listView.getListViewHtml({
|
||||
items: result.Items,
|
||||
sortBy: query.SortBy
|
||||
});
|
||||
} else if (viewStyle == 'PosterCard') {
|
||||
html = cardBuilder.getCardsHtml({
|
||||
items: result.Items,
|
||||
shape: 'square',
|
||||
coverImage: true,
|
||||
showTitle: true,
|
||||
cardLayout: true
|
||||
});
|
||||
} else if (viewStyle == 'Thumb') {
|
||||
html = cardBuilder.getCardsHtml({
|
||||
items: result.Items,
|
||||
shape: 'backdrop',
|
||||
showTitle: true,
|
||||
centerText: true,
|
||||
preferThumb: true,
|
||||
overlayPlayButton: true
|
||||
});
|
||||
} else if (viewStyle == 'ThumbCard') {
|
||||
html = cardBuilder.getCardsHtml({
|
||||
items: result.Items,
|
||||
shape: 'backdrop',
|
||||
showTitle: true,
|
||||
preferThumb: true,
|
||||
cardLayout: true
|
||||
});
|
||||
} else {
|
||||
view.querySelector('.noItemsMessage').classList.remove('hide');
|
||||
}
|
||||
|
||||
var elem = view.querySelector('.itemsContainer');
|
||||
elem.innerHTML = html;
|
||||
imageLoader.lazyChildren(elem);
|
||||
var btnNextPage = view.querySelector('.btnNextPage');
|
||||
|
||||
if (btnNextPage) {
|
||||
btnNextPage.addEventListener('click', function () {
|
||||
if (userSettings.libraryPageSize() > 0) {
|
||||
query.StartIndex += query.Limit;
|
||||
}
|
||||
reloadItems();
|
||||
html = cardBuilder.getCardsHtml({
|
||||
items: result.Items,
|
||||
shape: 'square',
|
||||
showTitle: true,
|
||||
coverImage: true,
|
||||
centerText: true,
|
||||
overlayPlayButton: true
|
||||
});
|
||||
}
|
||||
view.querySelector('.noItemsMessage').classList.add('hide');
|
||||
} else {
|
||||
view.querySelector('.noItemsMessage').classList.remove('hide');
|
||||
}
|
||||
|
||||
var btnPreviousPage = view.querySelector('.btnPreviousPage');
|
||||
const elem = view.querySelector('.itemsContainer');
|
||||
elem.innerHTML = html;
|
||||
imageLoader.lazyChildren(elem);
|
||||
const btnNextPage = view.querySelector('.btnNextPage');
|
||||
|
||||
if (btnPreviousPage) {
|
||||
btnPreviousPage.addEventListener('click', function () {
|
||||
if (userSettings.libraryPageSize() > 0) {
|
||||
query.StartIndex = Math.max(0, query.StartIndex - query.Limit);
|
||||
}
|
||||
reloadItems();
|
||||
});
|
||||
}
|
||||
|
||||
var btnChangeLayout = view.querySelector('.btnChangeLayout');
|
||||
|
||||
if (btnChangeLayout) {
|
||||
btnChangeLayout.addEventListener('layoutchange', function (e) {
|
||||
var layout = e.detail.viewStyle;
|
||||
getPageData(view).view = layout;
|
||||
libraryBrowser.saveViewSetting(getSavedQueryKey(view), layout);
|
||||
onViewStyleChange();
|
||||
reloadItems();
|
||||
});
|
||||
}
|
||||
|
||||
libraryBrowser.saveQueryValues(getSavedQueryKey(view), query);
|
||||
hideLoadingMessage();
|
||||
});
|
||||
}
|
||||
|
||||
var data = {};
|
||||
view.addEventListener('viewbeforeshow', function () {
|
||||
reloadItems();
|
||||
});
|
||||
view.querySelector('.btnNewPlaylist').addEventListener('click', function () {
|
||||
require(['playlistEditor'], function (playlistEditor) {
|
||||
var serverId = ApiClient.serverInfo().Id;
|
||||
new playlistEditor.showEditor({
|
||||
items: [],
|
||||
serverId: serverId
|
||||
if (btnNextPage) {
|
||||
btnNextPage.addEventListener('click', function () {
|
||||
if (userSettings.libraryPageSize() > 0) {
|
||||
query.StartIndex += query.Limit;
|
||||
}
|
||||
reloadItems();
|
||||
});
|
||||
}
|
||||
|
||||
const btnPreviousPage = view.querySelector('.btnPreviousPage');
|
||||
|
||||
if (btnPreviousPage) {
|
||||
btnPreviousPage.addEventListener('click', function () {
|
||||
if (userSettings.libraryPageSize() > 0) {
|
||||
query.StartIndex = Math.max(0, query.StartIndex - query.Limit);
|
||||
}
|
||||
reloadItems();
|
||||
});
|
||||
}
|
||||
|
||||
const btnChangeLayout = view.querySelector('.btnChangeLayout');
|
||||
|
||||
if (btnChangeLayout) {
|
||||
btnChangeLayout.addEventListener('layoutchange', function (e) {
|
||||
const layout = e.detail.viewStyle;
|
||||
getPageData(view).view = layout;
|
||||
libraryBrowser.saveViewSetting(getSavedQueryKey(view), layout);
|
||||
onViewStyleChange();
|
||||
reloadItems();
|
||||
});
|
||||
}
|
||||
|
||||
libraryBrowser.saveQueryValues(getSavedQueryKey(view), query);
|
||||
hideLoadingMessage();
|
||||
});
|
||||
}
|
||||
|
||||
const data = {};
|
||||
view.addEventListener('viewbeforeshow', function () {
|
||||
reloadItems();
|
||||
});
|
||||
view.querySelector('.btnNewPlaylist').addEventListener('click', function () {
|
||||
import('playlistEditor').then(({default: playlistEditor}) => {
|
||||
const serverId = ApiClient.serverInfo().Id;
|
||||
new playlistEditor.showEditor({
|
||||
items: [],
|
||||
serverId: serverId
|
||||
});
|
||||
});
|
||||
onViewStyleChange();
|
||||
};
|
||||
});
|
||||
});
|
||||
onViewStyleChange();
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ import events from 'events';
|
|||
}
|
||||
|
||||
export function enableAutomaticBitrateDetection(isInNetwork, mediaType, val) {
|
||||
var key = 'enableautobitratebitrate-' + mediaType + '-' + isInNetwork;
|
||||
const key = 'enableautobitratebitrate-' + mediaType + '-' + isInNetwork;
|
||||
if (val !== undefined) {
|
||||
if (isInNetwork && mediaType === 'Audio') {
|
||||
val = true;
|
||||
|
@ -45,7 +45,7 @@ import events from 'events';
|
|||
}
|
||||
|
||||
export function maxStreamingBitrate(isInNetwork, mediaType, val) {
|
||||
var key = 'maxbitrate-' + mediaType + '-' + isInNetwork;
|
||||
const key = 'maxbitrate-' + mediaType + '-' + isInNetwork;
|
||||
if (val !== undefined) {
|
||||
if (isInNetwork && mediaType === 'Audio') {
|
||||
// nothing to do, this is always a max value
|
||||
|
@ -67,7 +67,7 @@ import events from 'events';
|
|||
this.set('maxStaticMusicBitrate', val);
|
||||
}
|
||||
|
||||
var defaultValue = 320000;
|
||||
const defaultValue = 320000;
|
||||
return parseInt(this.get('maxStaticMusicBitrate') || defaultValue.toString()) || defaultValue;
|
||||
}
|
||||
|
||||
|
@ -118,7 +118,7 @@ import events from 'events';
|
|||
}
|
||||
|
||||
export function set(name, value, userId) {
|
||||
var currentValue = this.get(name, userId);
|
||||
const currentValue = this.get(name, userId);
|
||||
appStorage.setItem(getKey(name, userId), value);
|
||||
|
||||
if (currentValue !== value) {
|
||||
|
|
|
@ -2,7 +2,7 @@ import appSettings from 'appSettings';
|
|||
import events from 'events';
|
||||
|
||||
function onSaveTimeout() {
|
||||
var self = this;
|
||||
const self = this;
|
||||
self.saveTimeout = null;
|
||||
self.currentApiClient.updateDisplayPreferences('usersettings', self.displayPrefs, self.currentUserId, 'emby');
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ export class UserSettings {
|
|||
return Promise.resolve();
|
||||
}
|
||||
|
||||
var self = this;
|
||||
const self = this;
|
||||
|
||||
return apiClient.getDisplayPreferences('usersettings', userId, 'emby').then(function (result) {
|
||||
result.CustomPrefs = result.CustomPrefs || {};
|
||||
|
@ -63,9 +63,9 @@ export class UserSettings {
|
|||
* @param {boolean} enableOnServer - Flag to save preferences on server.
|
||||
*/
|
||||
set(name, value, enableOnServer) {
|
||||
var userId = this.currentUserId;
|
||||
var currentValue = this.get(name, enableOnServer);
|
||||
var result = appSettings.set(name, value, userId);
|
||||
const userId = this.currentUserId;
|
||||
const currentValue = this.get(name, enableOnServer);
|
||||
const result = appSettings.set(name, value, userId);
|
||||
|
||||
if (enableOnServer !== false && this.displayPrefs) {
|
||||
this.displayPrefs.CustomPrefs[name] = value == null ? value : value.toString();
|
||||
|
@ -86,7 +86,7 @@ export class UserSettings {
|
|||
* @return {string} Value of setting.
|
||||
*/
|
||||
get(name, enableOnServer) {
|
||||
var userId = this.currentUserId;
|
||||
const userId = this.currentUserId;
|
||||
if (enableOnServer !== false && this.displayPrefs) {
|
||||
return this.displayPrefs.CustomPrefs[name];
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ export class UserSettings {
|
|||
* @return {Object|Promise} Configuration or Promise.
|
||||
*/
|
||||
serverConfig(config) {
|
||||
var apiClient = this.currentApiClient;
|
||||
const apiClient = this.currentApiClient;
|
||||
if (config) {
|
||||
return apiClient.updateUserConfiguration(this.currentUserId, config);
|
||||
}
|
||||
|
@ -349,7 +349,7 @@ export class UserSettings {
|
|||
return this.set('libraryPageSize', parseInt(val, 10), false);
|
||||
}
|
||||
|
||||
var libraryPageSize = parseInt(this.get('libraryPageSize', false), 10);
|
||||
const libraryPageSize = parseInt(this.get('libraryPageSize', false), 10);
|
||||
if (libraryPageSize === 0) {
|
||||
// Explicitly return 0 to avoid returning 100 because 0 is falsy.
|
||||
return 0;
|
||||
|
@ -378,7 +378,7 @@ export class UserSettings {
|
|||
* @return {Object} Query.
|
||||
*/
|
||||
loadQuerySettings(key, query) {
|
||||
var values = this.get(key);
|
||||
let values = this.get(key);
|
||||
if (values) {
|
||||
values = JSON.parse(values);
|
||||
return Object.assign(query, values);
|
||||
|
@ -393,7 +393,7 @@ export class UserSettings {
|
|||
* @param {Object} query - Query.
|
||||
*/
|
||||
saveQuerySettings(key, query) {
|
||||
var values = {};
|
||||
const values = {};
|
||||
if (query.SortBy) {
|
||||
values.SortBy = query.SortBy;
|
||||
}
|
||||
|
|
|
@ -422,7 +422,7 @@ var AppInfo = {};
|
|||
require(['globalize', 'browser'], function (globalize, browser) {
|
||||
window.Globalize = globalize;
|
||||
loadCoreDictionary(globalize).then(function () {
|
||||
onGlobalizeInit(browser);
|
||||
onGlobalizeInit(browser, globalize);
|
||||
});
|
||||
});
|
||||
require(['keyboardnavigation'], function(keyboardnavigation) {
|
||||
|
@ -455,14 +455,14 @@ var AppInfo = {};
|
|||
});
|
||||
}
|
||||
|
||||
function onGlobalizeInit(browser) {
|
||||
function onGlobalizeInit(browser, globalize) {
|
||||
if ('android' === self.appMode) {
|
||||
if (-1 !== self.location.href.toString().toLowerCase().indexOf('start=backgroundsync')) {
|
||||
return onAppReady(browser);
|
||||
}
|
||||
}
|
||||
|
||||
document.title = Globalize.translateDocument(document.title, 'core');
|
||||
document.title = globalize.translateHtml(document.title, 'core');
|
||||
|
||||
if (browser.tv && !browser.android) {
|
||||
console.debug('using system fonts with explicit sizes');
|
||||
|
|
|
@ -1,119 +1,122 @@
|
|||
define(['events', 'userSettings', 'serverNotifications', 'connectionManager', 'globalize', 'emby-button'], function (events, userSettings, serverNotifications, connectionManager, globalize) {
|
||||
'use strict';
|
||||
import events from 'events';
|
||||
import * as userSettings from 'userSettings';
|
||||
import serverNotifications from 'serverNotifications';
|
||||
import connectionManager from 'connectionManager';
|
||||
import globalize from 'globalize';
|
||||
import 'emby-button';
|
||||
|
||||
return function (options) {
|
||||
function pollTasks() {
|
||||
connectionManager.getApiClient(serverId).getScheduledTasks({
|
||||
IsEnabled: true
|
||||
}).then(updateTasks);
|
||||
}
|
||||
export default function (options) {
|
||||
function pollTasks() {
|
||||
connectionManager.getApiClient(serverId).getScheduledTasks({
|
||||
IsEnabled: true
|
||||
}).then(updateTasks);
|
||||
}
|
||||
|
||||
function updateTasks(tasks) {
|
||||
var task = tasks.filter(function (t) {
|
||||
return t.Key == options.taskKey;
|
||||
})[0];
|
||||
|
||||
if (options.panel) {
|
||||
if (task) {
|
||||
options.panel.classList.remove('hide');
|
||||
} else {
|
||||
options.panel.classList.add('hide');
|
||||
}
|
||||
}
|
||||
|
||||
if (!task) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (task.State == 'Idle') {
|
||||
button.removeAttribute('disabled');
|
||||
} else {
|
||||
button.setAttribute('disabled', 'disabled');
|
||||
}
|
||||
|
||||
button.setAttribute('data-taskid', task.Id);
|
||||
var progress = (task.CurrentProgressPercentage || 0).toFixed(1);
|
||||
|
||||
if (options.progressElem) {
|
||||
options.progressElem.value = progress;
|
||||
|
||||
if (task.State == 'Running') {
|
||||
options.progressElem.classList.remove('hide');
|
||||
} else {
|
||||
options.progressElem.classList.add('hide');
|
||||
}
|
||||
}
|
||||
|
||||
if (options.lastResultElem) {
|
||||
var lastResult = task.LastExecutionResult ? task.LastExecutionResult.Status : '';
|
||||
|
||||
if (lastResult == 'Failed') {
|
||||
options.lastResultElem.html('<span style="color:#FF0000;">(' + globalize.translate('LabelFailed') + ')</span>');
|
||||
} else if (lastResult == 'Cancelled') {
|
||||
options.lastResultElem.html('<span style="color:#0026FF;">(' + globalize.translate('LabelCancelled') + ')</span>');
|
||||
} else if (lastResult == 'Aborted') {
|
||||
options.lastResultElem.html('<span style="color:#FF0000;">' + globalize.translate('LabelAbortedByServerShutdown') + '</span>');
|
||||
} else {
|
||||
options.lastResultElem.html(lastResult);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function onScheduledTaskMessageConfirmed(id) {
|
||||
connectionManager.getApiClient(serverId).startScheduledTask(id).then(pollTasks);
|
||||
}
|
||||
|
||||
function onButtonClick() {
|
||||
onScheduledTaskMessageConfirmed(this.getAttribute('data-taskid'));
|
||||
}
|
||||
|
||||
function onScheduledTasksUpdate(e, apiClient, info) {
|
||||
if (apiClient.serverId() === serverId) {
|
||||
updateTasks(info);
|
||||
}
|
||||
}
|
||||
|
||||
var pollInterval;
|
||||
var button = options.button;
|
||||
var serverId = ApiClient.serverId();
|
||||
|
||||
function onPollIntervalFired() {
|
||||
if (!connectionManager.getApiClient(serverId).isMessageChannelOpen()) {
|
||||
pollTasks();
|
||||
}
|
||||
}
|
||||
|
||||
function startInterval() {
|
||||
var apiClient = connectionManager.getApiClient(serverId);
|
||||
|
||||
if (pollInterval) {
|
||||
clearInterval(pollInterval);
|
||||
}
|
||||
apiClient.sendMessage('ScheduledTasksInfoStart', '1000,1000');
|
||||
pollInterval = setInterval(onPollIntervalFired, 5000);
|
||||
}
|
||||
|
||||
function stopInterval() {
|
||||
connectionManager.getApiClient(serverId).sendMessage('ScheduledTasksInfoStop');
|
||||
|
||||
if (pollInterval) {
|
||||
clearInterval(pollInterval);
|
||||
}
|
||||
}
|
||||
function updateTasks(tasks) {
|
||||
const task = tasks.filter(function (t) {
|
||||
return t.Key == options.taskKey;
|
||||
})[0];
|
||||
|
||||
if (options.panel) {
|
||||
options.panel.classList.add('hide');
|
||||
if (task) {
|
||||
options.panel.classList.remove('hide');
|
||||
} else {
|
||||
options.panel.classList.add('hide');
|
||||
}
|
||||
}
|
||||
|
||||
if (options.mode == 'off') {
|
||||
button.removeEventListener('click', onButtonClick);
|
||||
events.off(serverNotifications, 'ScheduledTasksInfo', onScheduledTasksUpdate);
|
||||
stopInterval();
|
||||
} else {
|
||||
button.addEventListener('click', onButtonClick);
|
||||
pollTasks();
|
||||
startInterval();
|
||||
events.on(serverNotifications, 'ScheduledTasksInfo', onScheduledTasksUpdate);
|
||||
if (!task) {
|
||||
return;
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
if (task.State == 'Idle') {
|
||||
button.removeAttribute('disabled');
|
||||
} else {
|
||||
button.setAttribute('disabled', 'disabled');
|
||||
}
|
||||
|
||||
button.setAttribute('data-taskid', task.Id);
|
||||
const progress = (task.CurrentProgressPercentage || 0).toFixed(1);
|
||||
|
||||
if (options.progressElem) {
|
||||
options.progressElem.value = progress;
|
||||
|
||||
if (task.State == 'Running') {
|
||||
options.progressElem.classList.remove('hide');
|
||||
} else {
|
||||
options.progressElem.classList.add('hide');
|
||||
}
|
||||
}
|
||||
|
||||
if (options.lastResultElem) {
|
||||
const lastResult = task.LastExecutionResult ? task.LastExecutionResult.Status : '';
|
||||
|
||||
if (lastResult == 'Failed') {
|
||||
options.lastResultElem.html('<span style="color:#FF0000;">(' + globalize.translate('LabelFailed') + ')</span>');
|
||||
} else if (lastResult == 'Cancelled') {
|
||||
options.lastResultElem.html('<span style="color:#0026FF;">(' + globalize.translate('LabelCancelled') + ')</span>');
|
||||
} else if (lastResult == 'Aborted') {
|
||||
options.lastResultElem.html('<span style="color:#FF0000;">' + globalize.translate('LabelAbortedByServerShutdown') + '</span>');
|
||||
} else {
|
||||
options.lastResultElem.html(lastResult);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function onScheduledTaskMessageConfirmed(id) {
|
||||
connectionManager.getApiClient(serverId).startScheduledTask(id).then(pollTasks);
|
||||
}
|
||||
|
||||
function onButtonClick() {
|
||||
onScheduledTaskMessageConfirmed(this.getAttribute('data-taskid'));
|
||||
}
|
||||
|
||||
function onScheduledTasksUpdate(e, apiClient, info) {
|
||||
if (apiClient.serverId() === serverId) {
|
||||
updateTasks(info);
|
||||
}
|
||||
}
|
||||
|
||||
let pollInterval;
|
||||
const button = options.button;
|
||||
const serverId = ApiClient.serverId();
|
||||
|
||||
function onPollIntervalFired() {
|
||||
if (!connectionManager.getApiClient(serverId).isMessageChannelOpen()) {
|
||||
pollTasks();
|
||||
}
|
||||
}
|
||||
|
||||
function startInterval() {
|
||||
const apiClient = connectionManager.getApiClient(serverId);
|
||||
|
||||
if (pollInterval) {
|
||||
clearInterval(pollInterval);
|
||||
}
|
||||
apiClient.sendMessage('ScheduledTasksInfoStart', '1000,1000');
|
||||
pollInterval = setInterval(onPollIntervalFired, 5000);
|
||||
}
|
||||
|
||||
function stopInterval() {
|
||||
connectionManager.getApiClient(serverId).sendMessage('ScheduledTasksInfoStop');
|
||||
|
||||
if (pollInterval) {
|
||||
clearInterval(pollInterval);
|
||||
}
|
||||
}
|
||||
|
||||
if (options.panel) {
|
||||
options.panel.classList.add('hide');
|
||||
}
|
||||
|
||||
if (options.mode == 'off') {
|
||||
button.removeEventListener('click', onButtonClick);
|
||||
events.off(serverNotifications, 'ScheduledTasksInfo', onScheduledTasksUpdate);
|
||||
stopInterval();
|
||||
} else {
|
||||
button.addEventListener('click', onButtonClick);
|
||||
pollTasks();
|
||||
startInterval();
|
||||
events.on(serverNotifications, 'ScheduledTasksInfo', onScheduledTasksUpdate);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,31 +1,31 @@
|
|||
define(['dom', 'events'], function (dom, events) {
|
||||
'use strict';
|
||||
import dom from 'dom';
|
||||
import events from 'events';
|
||||
|
||||
function getTouches(e) {
|
||||
function getTouches(e) {
|
||||
return e.changedTouches || e.targetTouches || e.touches;
|
||||
}
|
||||
|
||||
return e.changedTouches || e.targetTouches || e.touches;
|
||||
}
|
||||
|
||||
function TouchHelper(elem, options) {
|
||||
class TouchHelper {
|
||||
constructor(elem, options) {
|
||||
|
||||
options = options || {};
|
||||
var touchTarget;
|
||||
var touchStartX;
|
||||
var touchStartY;
|
||||
var lastDeltaX;
|
||||
var lastDeltaY;
|
||||
var thresholdYMet;
|
||||
var self = this;
|
||||
let touchTarget;
|
||||
let touchStartX;
|
||||
let touchStartY;
|
||||
let lastDeltaX;
|
||||
let lastDeltaY;
|
||||
let thresholdYMet;
|
||||
const self = this;
|
||||
|
||||
var swipeXThreshold = options.swipeXThreshold || 50;
|
||||
var swipeYThreshold = options.swipeYThreshold || 50;
|
||||
var swipeXMaxY = 30;
|
||||
const swipeXThreshold = options.swipeXThreshold || 50;
|
||||
const swipeYThreshold = options.swipeYThreshold || 50;
|
||||
const swipeXMaxY = 30;
|
||||
|
||||
var excludeTagNames = options.ignoreTagNames || [];
|
||||
const excludeTagNames = options.ignoreTagNames || [];
|
||||
|
||||
var touchStart = function (e) {
|
||||
const touchStart = function (e) {
|
||||
|
||||
var touch = getTouches(e)[0];
|
||||
const touch = getTouches(e)[0];
|
||||
touchTarget = null;
|
||||
touchStartX = 0;
|
||||
touchStartY = 0;
|
||||
|
@ -35,7 +35,7 @@ define(['dom', 'events'], function (dom, events) {
|
|||
|
||||
if (touch) {
|
||||
|
||||
var currentTouchTarget = touch.target;
|
||||
const currentTouchTarget = touch.target;
|
||||
|
||||
if (dom.parentWithTag(currentTouchTarget, excludeTagNames)) {
|
||||
return;
|
||||
|
@ -47,18 +47,18 @@ define(['dom', 'events'], function (dom, events) {
|
|||
}
|
||||
};
|
||||
|
||||
var touchEnd = function (e) {
|
||||
const touchEnd = function (e) {
|
||||
|
||||
var isTouchMove = e.type === 'touchmove';
|
||||
const isTouchMove = e.type === 'touchmove';
|
||||
|
||||
if (touchTarget) {
|
||||
var touch = getTouches(e)[0];
|
||||
const touch = getTouches(e)[0];
|
||||
|
||||
var deltaX;
|
||||
var deltaY;
|
||||
let deltaX;
|
||||
let deltaY;
|
||||
|
||||
var clientX;
|
||||
var clientY;
|
||||
let clientX;
|
||||
let clientY;
|
||||
|
||||
if (touch) {
|
||||
clientX = touch.clientX || 0;
|
||||
|
@ -70,8 +70,8 @@ define(['dom', 'events'], function (dom, events) {
|
|||
deltaY = 0;
|
||||
}
|
||||
|
||||
var currentDeltaX = lastDeltaX == null ? deltaX : (deltaX - lastDeltaX);
|
||||
var currentDeltaY = lastDeltaY == null ? deltaY : (deltaY - lastDeltaY);
|
||||
const currentDeltaX = lastDeltaX == null ? deltaX : (deltaX - lastDeltaX);
|
||||
const currentDeltaY = lastDeltaY == null ? deltaY : (deltaY - lastDeltaY);
|
||||
|
||||
lastDeltaX = deltaX;
|
||||
lastDeltaY = deltaY;
|
||||
|
@ -138,14 +138,13 @@ define(['dom', 'events'], function (dom, events) {
|
|||
passive: true
|
||||
});
|
||||
}
|
||||
destroy() {
|
||||
|
||||
TouchHelper.prototype.destroy = function () {
|
||||
|
||||
var elem = this.elem;
|
||||
const elem = this.elem;
|
||||
|
||||
if (elem) {
|
||||
var touchStart = this.touchStart;
|
||||
var touchEnd = this.touchEnd;
|
||||
const touchStart = this.touchStart;
|
||||
const touchEnd = this.touchEnd;
|
||||
|
||||
dom.removeEventListener(elem, 'touchstart', touchStart, {
|
||||
passive: true
|
||||
|
@ -165,7 +164,7 @@ define(['dom', 'events'], function (dom, events) {
|
|||
this.touchEnd = null;
|
||||
|
||||
this.elem = null;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return TouchHelper;
|
||||
});
|
||||
export default TouchHelper;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue