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