mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
merge branch master into comic-reader
This commit is contained in:
commit
d92eceb45f
530 changed files with 43583 additions and 42733 deletions
|
@ -1,110 +1,106 @@
|
|||
define(['dom', 'focusManager'], function (dom, focusManager) {
|
||||
'use strict';
|
||||
import dom from 'dom';
|
||||
import focusManager from 'focusManager';
|
||||
|
||||
var inputDisplayElement;
|
||||
var currentDisplayText = '';
|
||||
var currentDisplayTextContainer;
|
||||
let inputDisplayElement;
|
||||
let currentDisplayText = '';
|
||||
let currentDisplayTextContainer;
|
||||
|
||||
function onKeyDown(e) {
|
||||
|
||||
if (e.ctrlKey) {
|
||||
return;
|
||||
}
|
||||
if (e.shiftKey) {
|
||||
return;
|
||||
}
|
||||
if (e.altKey) {
|
||||
return;
|
||||
}
|
||||
|
||||
var key = e.key;
|
||||
var chr = key ? alphanumeric(key) : null;
|
||||
|
||||
if (chr) {
|
||||
|
||||
chr = chr.toString().toUpperCase();
|
||||
|
||||
if (chr.length === 1) {
|
||||
currentDisplayTextContainer = this.options.itemsContainer;
|
||||
onAlphanumericKeyPress(e, chr);
|
||||
}
|
||||
}
|
||||
function onKeyDown(e) {
|
||||
if (e.ctrlKey) {
|
||||
return;
|
||||
}
|
||||
if (e.shiftKey) {
|
||||
return;
|
||||
}
|
||||
if (e.altKey) {
|
||||
return;
|
||||
}
|
||||
|
||||
function alphanumeric(value) {
|
||||
var letterNumber = /^[0-9a-zA-Z]+$/;
|
||||
return value.match(letterNumber);
|
||||
}
|
||||
const key = e.key;
|
||||
let chr = key ? alphanumeric(key) : null;
|
||||
|
||||
function ensureInputDisplayElement() {
|
||||
if (!inputDisplayElement) {
|
||||
inputDisplayElement = document.createElement('div');
|
||||
inputDisplayElement.classList.add('alphanumeric-shortcut');
|
||||
inputDisplayElement.classList.add('hide');
|
||||
if (chr) {
|
||||
chr = chr.toString().toUpperCase();
|
||||
|
||||
document.body.appendChild(inputDisplayElement);
|
||||
if (chr.length === 1) {
|
||||
currentDisplayTextContainer = this.options.itemsContainer;
|
||||
onAlphanumericKeyPress(e, chr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var alpanumericShortcutTimeout;
|
||||
function clearAlphaNumericShortcutTimeout() {
|
||||
if (alpanumericShortcutTimeout) {
|
||||
clearTimeout(alpanumericShortcutTimeout);
|
||||
alpanumericShortcutTimeout = null;
|
||||
}
|
||||
}
|
||||
function resetAlphaNumericShortcutTimeout() {
|
||||
clearAlphaNumericShortcutTimeout();
|
||||
alpanumericShortcutTimeout = setTimeout(onAlphanumericShortcutTimeout, 2000);
|
||||
}
|
||||
function alphanumeric(value) {
|
||||
const letterNumber = /^[0-9a-zA-Z]+$/;
|
||||
return value.match(letterNumber);
|
||||
}
|
||||
|
||||
function onAlphanumericKeyPress(e, chr) {
|
||||
if (currentDisplayText.length >= 3) {
|
||||
return;
|
||||
}
|
||||
ensureInputDisplayElement();
|
||||
currentDisplayText += chr;
|
||||
inputDisplayElement.innerHTML = currentDisplayText;
|
||||
inputDisplayElement.classList.remove('hide');
|
||||
resetAlphaNumericShortcutTimeout();
|
||||
}
|
||||
|
||||
function onAlphanumericShortcutTimeout() {
|
||||
var value = currentDisplayText;
|
||||
var container = currentDisplayTextContainer;
|
||||
|
||||
currentDisplayText = '';
|
||||
currentDisplayTextContainer = null;
|
||||
inputDisplayElement.innerHTML = '';
|
||||
function ensureInputDisplayElement() {
|
||||
if (!inputDisplayElement) {
|
||||
inputDisplayElement = document.createElement('div');
|
||||
inputDisplayElement.classList.add('alphanumeric-shortcut');
|
||||
inputDisplayElement.classList.add('hide');
|
||||
clearAlphaNumericShortcutTimeout();
|
||||
selectByShortcutValue(container, value);
|
||||
|
||||
document.body.appendChild(inputDisplayElement);
|
||||
}
|
||||
}
|
||||
|
||||
let alpanumericShortcutTimeout;
|
||||
function clearAlphaNumericShortcutTimeout() {
|
||||
if (alpanumericShortcutTimeout) {
|
||||
clearTimeout(alpanumericShortcutTimeout);
|
||||
alpanumericShortcutTimeout = null;
|
||||
}
|
||||
}
|
||||
function resetAlphaNumericShortcutTimeout() {
|
||||
clearAlphaNumericShortcutTimeout();
|
||||
alpanumericShortcutTimeout = setTimeout(onAlphanumericShortcutTimeout, 2000);
|
||||
}
|
||||
|
||||
function onAlphanumericKeyPress(e, chr) {
|
||||
if (currentDisplayText.length >= 3) {
|
||||
return;
|
||||
}
|
||||
ensureInputDisplayElement();
|
||||
currentDisplayText += chr;
|
||||
inputDisplayElement.innerHTML = currentDisplayText;
|
||||
inputDisplayElement.classList.remove('hide');
|
||||
resetAlphaNumericShortcutTimeout();
|
||||
}
|
||||
|
||||
function onAlphanumericShortcutTimeout() {
|
||||
const value = currentDisplayText;
|
||||
const container = currentDisplayTextContainer;
|
||||
|
||||
currentDisplayText = '';
|
||||
currentDisplayTextContainer = null;
|
||||
inputDisplayElement.innerHTML = '';
|
||||
inputDisplayElement.classList.add('hide');
|
||||
clearAlphaNumericShortcutTimeout();
|
||||
selectByShortcutValue(container, value);
|
||||
}
|
||||
|
||||
function selectByShortcutValue(container, value) {
|
||||
value = value.toUpperCase();
|
||||
|
||||
let focusElem;
|
||||
if (value === '#') {
|
||||
focusElem = container.querySelector('*[data-prefix]');
|
||||
}
|
||||
|
||||
function selectByShortcutValue(container, value) {
|
||||
|
||||
value = value.toUpperCase();
|
||||
|
||||
var focusElem;
|
||||
if (value === '#') {
|
||||
|
||||
focusElem = container.querySelector('*[data-prefix]');
|
||||
}
|
||||
|
||||
if (!focusElem) {
|
||||
focusElem = container.querySelector('*[data-prefix^=\'' + value + '\']');
|
||||
}
|
||||
|
||||
if (focusElem) {
|
||||
focusManager.focus(focusElem);
|
||||
}
|
||||
if (!focusElem) {
|
||||
focusElem = container.querySelector('*[data-prefix^=\'' + value + '\']');
|
||||
}
|
||||
|
||||
function AlphaNumericShortcuts(options) {
|
||||
if (focusElem) {
|
||||
focusManager.focus(focusElem);
|
||||
}
|
||||
}
|
||||
|
||||
class AlphaNumericShortcuts {
|
||||
constructor(options) {
|
||||
this.options = options;
|
||||
|
||||
var keyDownHandler = onKeyDown.bind(this);
|
||||
const keyDownHandler = onKeyDown.bind(this);
|
||||
|
||||
dom.addEventListener(window, 'keydown', keyDownHandler, {
|
||||
passive: true
|
||||
|
@ -112,10 +108,8 @@ define(['dom', 'focusManager'], function (dom, focusManager) {
|
|||
|
||||
this.keyDownHandler = keyDownHandler;
|
||||
}
|
||||
|
||||
AlphaNumericShortcuts.prototype.destroy = function () {
|
||||
|
||||
var keyDownHandler = this.keyDownHandler;
|
||||
destroy() {
|
||||
const keyDownHandler = this.keyDownHandler;
|
||||
|
||||
if (keyDownHandler) {
|
||||
dom.removeEventListener(window, 'keydown', keyDownHandler, {
|
||||
|
@ -124,7 +118,7 @@ define(['dom', 'focusManager'], function (dom, focusManager) {
|
|||
this.keyDownHandler = null;
|
||||
}
|
||||
this.options = null;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return AlphaNumericShortcuts;
|
||||
});
|
||||
export default AlphaNumericShortcuts;
|
||||
|
|
|
@ -1,16 +1,15 @@
|
|||
(function() {
|
||||
'use strict';
|
||||
|
||||
function injectScriptElement(src, onload) {
|
||||
if (!src) {
|
||||
return;
|
||||
}
|
||||
|
||||
var script = document.createElement('script');
|
||||
if (self.dashboardVersion) {
|
||||
src += `?v=${self.dashboardVersion}`;
|
||||
const script = document.createElement('script');
|
||||
if (window.dashboardVersion) {
|
||||
src += `?v=${window.dashboardVersion}`;
|
||||
}
|
||||
script.src = src;
|
||||
script.setAttribute('async', '');
|
||||
|
||||
if (onload) {
|
||||
script.onload = onload;
|
||||
|
@ -36,10 +35,10 @@
|
|||
// Promise() being missing on some legacy browser, and a funky one
|
||||
// is Promise() present but buggy on WebOS 2
|
||||
window.Promise = undefined;
|
||||
self.Promise = undefined;
|
||||
window.Promise = undefined;
|
||||
}
|
||||
|
||||
if (!self.Promise) {
|
||||
if (!window.Promise) {
|
||||
// Load Promise polyfill if they are not natively supported
|
||||
injectScriptElement(
|
||||
'./libraries/npo.js',
|
||||
|
|
|
@ -1,77 +1,78 @@
|
|||
define(['backdrop', 'userSettings', 'libraryMenu'], function (backdrop, userSettings, libraryMenu) {
|
||||
'use strict';
|
||||
import backdrop from 'backdrop';
|
||||
import * as userSettings from 'userSettings';
|
||||
import libraryMenu from 'libraryMenu';
|
||||
|
||||
var cache = {};
|
||||
const cache = {};
|
||||
|
||||
function enabled() {
|
||||
return userSettings.enableBackdrops();
|
||||
function enabled() {
|
||||
return userSettings.enableBackdrops();
|
||||
}
|
||||
|
||||
function getBackdropItemIds(apiClient, userId, types, parentId) {
|
||||
const key = `backdrops2_${userId + (types || '') + (parentId || '')}`;
|
||||
let data = cache[key];
|
||||
|
||||
if (data) {
|
||||
console.debug(`Found backdrop id list in cache. Key: ${key}`);
|
||||
data = JSON.parse(data);
|
||||
return Promise.resolve(data);
|
||||
}
|
||||
|
||||
function getBackdropItemIds(apiClient, userId, types, parentId) {
|
||||
var key = `backdrops2_${userId + (types || '') + (parentId || '')}`;
|
||||
var data = cache[key];
|
||||
const options = {
|
||||
SortBy: 'IsFavoriteOrLiked,Random',
|
||||
Limit: 20,
|
||||
Recursive: true,
|
||||
IncludeItemTypes: types,
|
||||
ImageTypes: 'Backdrop',
|
||||
ParentId: parentId,
|
||||
EnableTotalRecordCount: false
|
||||
};
|
||||
return apiClient.getItems(apiClient.getCurrentUserId(), options).then(function (result) {
|
||||
const images = result.Items.map(function (i) {
|
||||
return {
|
||||
Id: i.Id,
|
||||
tag: i.BackdropImageTags[0],
|
||||
ServerId: i.ServerId
|
||||
};
|
||||
});
|
||||
cache[key] = JSON.stringify(images);
|
||||
return images;
|
||||
});
|
||||
}
|
||||
|
||||
if (data) {
|
||||
console.debug(`Found backdrop id list in cache. Key: ${key}`);
|
||||
data = JSON.parse(data);
|
||||
return Promise.resolve(data);
|
||||
}
|
||||
function showBackdrop(type, parentId) {
|
||||
const apiClient = window.ApiClient;
|
||||
|
||||
var options = {
|
||||
SortBy: 'IsFavoriteOrLiked,Random',
|
||||
Limit: 20,
|
||||
Recursive: true,
|
||||
IncludeItemTypes: types,
|
||||
ImageTypes: 'Backdrop',
|
||||
ParentId: parentId,
|
||||
EnableTotalRecordCount: false
|
||||
};
|
||||
return apiClient.getItems(apiClient.getCurrentUserId(), options).then(function (result) {
|
||||
var images = result.Items.map(function (i) {
|
||||
return {
|
||||
Id: i.Id,
|
||||
tag: i.BackdropImageTags[0],
|
||||
ServerId: i.ServerId
|
||||
};
|
||||
});
|
||||
cache[key] = JSON.stringify(images);
|
||||
return images;
|
||||
if (apiClient) {
|
||||
getBackdropItemIds(apiClient, apiClient.getCurrentUserId(), type, parentId).then(function (images) {
|
||||
if (images.length) {
|
||||
backdrop.setBackdrops(images.map(function (i) {
|
||||
i.BackdropImageTags = [i.tag];
|
||||
return i;
|
||||
}));
|
||||
} else {
|
||||
backdrop.clearBackdrop();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function showBackdrop(type, parentId) {
|
||||
var apiClient = window.ApiClient;
|
||||
pageClassOn('pageshow', 'page', function () {
|
||||
const page = this;
|
||||
|
||||
if (apiClient) {
|
||||
getBackdropItemIds(apiClient, apiClient.getCurrentUserId(), type, parentId).then(function (images) {
|
||||
if (images.length) {
|
||||
backdrop.setBackdrops(images.map(function (i) {
|
||||
i.BackdropImageTags = [i.tag];
|
||||
return i;
|
||||
}));
|
||||
} else {
|
||||
backdrop.clear();
|
||||
}
|
||||
});
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
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.clear();
|
||||
}
|
||||
} else {
|
||||
backdrop.clear();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
|
12
src/scripts/autoThemes.js
Normal file
12
src/scripts/autoThemes.js
Normal file
|
@ -0,0 +1,12 @@
|
|||
import * as userSettings from 'userSettings';
|
||||
import skinManager from 'skinManager';
|
||||
import connectionManager from 'connectionManager';
|
||||
import events from 'events';
|
||||
|
||||
// Set the default theme when loading
|
||||
skinManager.setTheme(userSettings.theme());
|
||||
|
||||
// Set the user's prefered theme when signing in
|
||||
events.on(connectionManager, 'localusersignedin', function (e, user) {
|
||||
skinManager.setTheme(userSettings.theme());
|
||||
});
|
|
@ -1,275 +1,256 @@
|
|||
define([], function () {
|
||||
'use strict';
|
||||
function isTv() {
|
||||
// This is going to be really difficult to get right
|
||||
const userAgent = navigator.userAgent.toLowerCase();
|
||||
|
||||
function isTv() {
|
||||
|
||||
// This is going to be really difficult to get right
|
||||
var userAgent = navigator.userAgent.toLowerCase();
|
||||
|
||||
if (userAgent.indexOf('tv') !== -1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (userAgent.indexOf('samsungbrowser') !== -1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (userAgent.indexOf('nintendo') !== -1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (userAgent.indexOf('viera') !== -1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (userAgent.indexOf('web0s') !== -1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
if (userAgent.indexOf('tv') !== -1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
function isMobile(userAgent) {
|
||||
var terms = [
|
||||
'mobi',
|
||||
'ipad',
|
||||
'iphone',
|
||||
'ipod',
|
||||
'silk',
|
||||
'gt-p1000',
|
||||
'nexus 7',
|
||||
'kindle fire',
|
||||
'opera mini'
|
||||
];
|
||||
|
||||
var lower = userAgent.toLowerCase();
|
||||
|
||||
for (var i = 0, length = terms.length; i < length; i++) {
|
||||
if (lower.indexOf(terms[i]) !== -1) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
if (userAgent.indexOf('samsungbrowser') !== -1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
function hasKeyboard(browser) {
|
||||
|
||||
if (browser.touch) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (browser.xboxOne) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (browser.ps4) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (browser.edgeUwp) {
|
||||
// This is OK for now, but this won't always be true
|
||||
// Should we use this?
|
||||
// https://gist.github.com/wagonli/40d8a31bd0d6f0dd7a5d
|
||||
return true;
|
||||
}
|
||||
|
||||
if (browser.tv) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
if (userAgent.indexOf('viera') !== -1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
function iOSversion() {
|
||||
// MacIntel: Apple iPad Pro 11 iOS 13.1
|
||||
if (/iP(hone|od|ad)|MacIntel/.test(navigator.platform)) {
|
||||
// supports iOS 2.0 and later: <http://bit.ly/TJjs1V>
|
||||
var v = (navigator.appVersion).match(/OS (\d+)_(\d+)_?(\d+)?/);
|
||||
return [parseInt(v[1], 10), parseInt(v[2], 10), parseInt(v[3] || 0, 10)];
|
||||
if (userAgent.indexOf('web0s') !== -1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function isMobile(userAgent) {
|
||||
const terms = [
|
||||
'mobi',
|
||||
'ipad',
|
||||
'iphone',
|
||||
'ipod',
|
||||
'silk',
|
||||
'gt-p1000',
|
||||
'nexus 7',
|
||||
'kindle fire',
|
||||
'opera mini'
|
||||
];
|
||||
|
||||
const lower = userAgent.toLowerCase();
|
||||
|
||||
for (let i = 0, length = terms.length; i < length; i++) {
|
||||
if (lower.indexOf(terms[i]) !== -1) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
var _supportsCssAnimation;
|
||||
var _supportsCssAnimationWithPrefix;
|
||||
function supportsCssAnimation(allowPrefix) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (allowPrefix) {
|
||||
if (_supportsCssAnimationWithPrefix === true || _supportsCssAnimationWithPrefix === false) {
|
||||
return _supportsCssAnimationWithPrefix;
|
||||
}
|
||||
} else {
|
||||
if (_supportsCssAnimation === true || _supportsCssAnimation === false) {
|
||||
return _supportsCssAnimation;
|
||||
}
|
||||
}
|
||||
function hasKeyboard(browser) {
|
||||
if (browser.touch) {
|
||||
return true;
|
||||
}
|
||||
|
||||
var animation = false;
|
||||
var animationstring = 'animation';
|
||||
var keyframeprefix = '';
|
||||
var domPrefixes = ['Webkit', 'O', 'Moz'];
|
||||
var pfx = '';
|
||||
var elm = document.createElement('div');
|
||||
if (browser.xboxOne) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (elm.style.animationName !== undefined) {
|
||||
animation = true;
|
||||
}
|
||||
if (browser.ps4) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (animation === false && allowPrefix) {
|
||||
for (var i = 0; i < domPrefixes.length; i++) {
|
||||
if (elm.style[domPrefixes[i] + 'AnimationName'] !== undefined) {
|
||||
pfx = domPrefixes[i];
|
||||
animationstring = pfx + 'Animation';
|
||||
keyframeprefix = '-' + pfx.toLowerCase() + '-';
|
||||
animation = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (browser.edgeUwp) {
|
||||
// This is OK for now, but this won't always be true
|
||||
// Should we use this?
|
||||
// https://gist.github.com/wagonli/40d8a31bd0d6f0dd7a5d
|
||||
return true;
|
||||
}
|
||||
|
||||
if (allowPrefix) {
|
||||
_supportsCssAnimationWithPrefix = animation;
|
||||
if (browser.tv) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function iOSversion() {
|
||||
// MacIntel: Apple iPad Pro 11 iOS 13.1
|
||||
if (/iP(hone|od|ad)|MacIntel/.test(navigator.platform)) {
|
||||
// supports iOS 2.0 and later: <http://bit.ly/TJjs1V>
|
||||
const v = (navigator.appVersion).match(/OS (\d+)_(\d+)_?(\d+)?/);
|
||||
return [parseInt(v[1], 10), parseInt(v[2], 10), parseInt(v[3] || 0, 10)];
|
||||
}
|
||||
}
|
||||
|
||||
let _supportsCssAnimation;
|
||||
let _supportsCssAnimationWithPrefix;
|
||||
function supportsCssAnimation(allowPrefix) {
|
||||
// TODO: Assess if this is still needed, as all of our targets should natively support CSS animations.
|
||||
if (allowPrefix) {
|
||||
if (_supportsCssAnimationWithPrefix === true || _supportsCssAnimationWithPrefix === false) {
|
||||
return _supportsCssAnimationWithPrefix;
|
||||
} else {
|
||||
_supportsCssAnimation = animation;
|
||||
}
|
||||
} else {
|
||||
if (_supportsCssAnimation === true || _supportsCssAnimation === false) {
|
||||
return _supportsCssAnimation;
|
||||
}
|
||||
}
|
||||
|
||||
var uaMatch = function (ua) {
|
||||
ua = ua.toLowerCase();
|
||||
let animation = false;
|
||||
const domPrefixes = ['Webkit', 'O', 'Moz'];
|
||||
const elm = document.createElement('div');
|
||||
|
||||
var match = /(edge)[ \/]([\w.]+)/.exec(ua) ||
|
||||
/(opera)[ \/]([\w.]+)/.exec(ua) ||
|
||||
/(opr)[ \/]([\w.]+)/.exec(ua) ||
|
||||
/(chrome)[ \/]([\w.]+)/.exec(ua) ||
|
||||
/(safari)[ \/]([\w.]+)/.exec(ua) ||
|
||||
/(firefox)[ \/]([\w.]+)/.exec(ua) ||
|
||||
/(msie) ([\w.]+)/.exec(ua) ||
|
||||
ua.indexOf('compatible') < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec(ua) ||
|
||||
[];
|
||||
if (elm.style.animationName !== undefined) {
|
||||
animation = true;
|
||||
}
|
||||
|
||||
var versionMatch = /(version)[ \/]([\w.]+)/.exec(ua);
|
||||
|
||||
var platform_match = /(ipad)/.exec(ua) ||
|
||||
/(iphone)/.exec(ua) ||
|
||||
/(windows)/.exec(ua) ||
|
||||
/(android)/.exec(ua) ||
|
||||
[];
|
||||
|
||||
var browser = match[1] || '';
|
||||
|
||||
if (browser === 'edge') {
|
||||
platform_match = [''];
|
||||
} else {
|
||||
if (ua.indexOf('windows phone') !== -1 || ua.indexOf('iemobile') !== -1) {
|
||||
|
||||
// http://www.neowin.net/news/ie11-fakes-user-agent-to-fool-gmail-in-windows-phone-81-gdr1-update
|
||||
browser = 'msie';
|
||||
} else if (ua.indexOf('like gecko') !== -1 && ua.indexOf('webkit') === -1 && ua.indexOf('opera') === -1 && ua.indexOf('chrome') === -1 && ua.indexOf('safari') === -1) {
|
||||
browser = 'msie';
|
||||
if (animation === false && allowPrefix) {
|
||||
for (let i = 0; i < domPrefixes.length; i++) {
|
||||
if (elm.style[domPrefixes[i] + 'AnimationName'] !== undefined) {
|
||||
animation = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (browser === 'opr') {
|
||||
browser = 'opera';
|
||||
}
|
||||
|
||||
var version;
|
||||
if (versionMatch && versionMatch.length > 2) {
|
||||
version = versionMatch[2];
|
||||
}
|
||||
|
||||
version = version || match[2] || '0';
|
||||
|
||||
var versionMajor = parseInt(version.split('.')[0]);
|
||||
|
||||
if (isNaN(versionMajor)) {
|
||||
versionMajor = 0;
|
||||
}
|
||||
|
||||
return {
|
||||
browser: browser,
|
||||
version: version,
|
||||
platform: platform_match[0] || '',
|
||||
versionMajor: versionMajor
|
||||
};
|
||||
};
|
||||
|
||||
var userAgent = navigator.userAgent;
|
||||
|
||||
var matched = uaMatch(userAgent);
|
||||
var browser = {};
|
||||
|
||||
if (matched.browser) {
|
||||
browser[matched.browser] = true;
|
||||
browser.version = matched.version;
|
||||
browser.versionMajor = matched.versionMajor;
|
||||
}
|
||||
|
||||
if (matched.platform) {
|
||||
browser[matched.platform] = true;
|
||||
}
|
||||
|
||||
if (!browser.chrome && !browser.msie && !browser.edge && !browser.opera && userAgent.toLowerCase().indexOf('webkit') !== -1) {
|
||||
browser.safari = true;
|
||||
}
|
||||
|
||||
if (userAgent.toLowerCase().indexOf('playstation 4') !== -1) {
|
||||
browser.ps4 = true;
|
||||
browser.tv = true;
|
||||
}
|
||||
|
||||
if (isMobile(userAgent)) {
|
||||
browser.mobile = true;
|
||||
}
|
||||
|
||||
browser.xboxOne = userAgent.toLowerCase().indexOf('xbox') !== -1;
|
||||
browser.animate = typeof document !== 'undefined' && document.documentElement.animate != null;
|
||||
browser.tizen = userAgent.toLowerCase().indexOf('tizen') !== -1 || self.tizen != null;
|
||||
browser.web0s = userAgent.toLowerCase().indexOf('Web0S'.toLowerCase()) !== -1;
|
||||
browser.edgeUwp = browser.edge && (userAgent.toLowerCase().indexOf('msapphost') !== -1 || userAgent.toLowerCase().indexOf('webview') !== -1);
|
||||
|
||||
if (!browser.tizen) {
|
||||
browser.orsay = userAgent.toLowerCase().indexOf('smarthub') !== -1;
|
||||
if (allowPrefix) {
|
||||
_supportsCssAnimationWithPrefix = animation;
|
||||
return _supportsCssAnimationWithPrefix;
|
||||
} else {
|
||||
var v = (navigator.appVersion).match(/Tizen (\d+).(\d+)/);
|
||||
browser.tizenVersion = parseInt(v[1]);
|
||||
_supportsCssAnimation = animation;
|
||||
return _supportsCssAnimation;
|
||||
}
|
||||
}
|
||||
|
||||
const uaMatch = function (ua) {
|
||||
ua = ua.toLowerCase();
|
||||
|
||||
const match = /(edg)[ \/]([\w.]+)/.exec(ua) ||
|
||||
/(edga)[ \/]([\w.]+)/.exec(ua) ||
|
||||
/(edgios)[ \/]([\w.]+)/.exec(ua) ||
|
||||
/(edge)[ \/]([\w.]+)/.exec(ua) ||
|
||||
/(opera)[ \/]([\w.]+)/.exec(ua) ||
|
||||
/(opr)[ \/]([\w.]+)/.exec(ua) ||
|
||||
/(chrome)[ \/]([\w.]+)/.exec(ua) ||
|
||||
/(safari)[ \/]([\w.]+)/.exec(ua) ||
|
||||
/(firefox)[ \/]([\w.]+)/.exec(ua) ||
|
||||
ua.indexOf('compatible') < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec(ua) ||
|
||||
[];
|
||||
|
||||
const versionMatch = /(version)[ \/]([\w.]+)/.exec(ua);
|
||||
|
||||
let platform_match = /(ipad)/.exec(ua) ||
|
||||
/(iphone)/.exec(ua) ||
|
||||
/(windows)/.exec(ua) ||
|
||||
/(android)/.exec(ua) ||
|
||||
[];
|
||||
|
||||
let browser = match[1] || '';
|
||||
|
||||
if (browser === 'edge') {
|
||||
platform_match = [''];
|
||||
}
|
||||
|
||||
if (browser.edgeUwp) {
|
||||
browser.edge = true;
|
||||
if (browser === 'opr') {
|
||||
browser = 'opera';
|
||||
}
|
||||
|
||||
browser.tv = isTv();
|
||||
browser.operaTv = browser.tv && userAgent.toLowerCase().indexOf('opr/') !== -1;
|
||||
|
||||
if (browser.mobile || browser.tv) {
|
||||
browser.slow = true;
|
||||
let version;
|
||||
if (versionMatch && versionMatch.length > 2) {
|
||||
version = versionMatch[2];
|
||||
}
|
||||
|
||||
if (typeof document !== 'undefined') {
|
||||
/* eslint-disable-next-line compat/compat */
|
||||
if (('ontouchstart' in window) || (navigator.maxTouchPoints > 0)) {
|
||||
browser.touch = true;
|
||||
}
|
||||
version = version || match[2] || '0';
|
||||
|
||||
let versionMajor = parseInt(version.split('.')[0]);
|
||||
|
||||
if (isNaN(versionMajor)) {
|
||||
versionMajor = 0;
|
||||
}
|
||||
|
||||
browser.keyboard = hasKeyboard(browser);
|
||||
browser.supportsCssAnimation = supportsCssAnimation;
|
||||
return {
|
||||
browser: browser,
|
||||
version: version,
|
||||
platform: platform_match[0] || '',
|
||||
versionMajor: versionMajor
|
||||
};
|
||||
};
|
||||
|
||||
browser.osx = userAgent.toLowerCase().indexOf('os x') !== -1;
|
||||
browser.iOS = browser.ipad || browser.iphone || browser.ipod;
|
||||
const userAgent = navigator.userAgent;
|
||||
|
||||
if (browser.iOS) {
|
||||
browser.iOSVersion = iOSversion();
|
||||
const matched = uaMatch(userAgent);
|
||||
const browser = {};
|
||||
|
||||
if (browser.iOSVersion && browser.iOSVersion.length >= 2) {
|
||||
browser.iOSVersion = browser.iOSVersion[0] + (browser.iOSVersion[1] / 10);
|
||||
}
|
||||
if (matched.browser) {
|
||||
browser[matched.browser] = true;
|
||||
browser.version = matched.version;
|
||||
browser.versionMajor = matched.versionMajor;
|
||||
}
|
||||
|
||||
if (matched.platform) {
|
||||
browser[matched.platform] = true;
|
||||
}
|
||||
|
||||
browser.edgeChromium = browser.edg || browser.edga || browser.edgios;
|
||||
|
||||
if (!browser.chrome && !browser.edgeChromium && !browser.edge && !browser.opera && userAgent.toLowerCase().indexOf('webkit') !== -1) {
|
||||
browser.safari = true;
|
||||
}
|
||||
|
||||
if (userAgent.toLowerCase().indexOf('playstation 4') !== -1) {
|
||||
browser.ps4 = true;
|
||||
browser.tv = true;
|
||||
}
|
||||
|
||||
if (isMobile(userAgent)) {
|
||||
browser.mobile = true;
|
||||
}
|
||||
|
||||
if (userAgent.toLowerCase().indexOf('xbox') !== -1) {
|
||||
browser.xboxOne = true;
|
||||
browser.tv = true;
|
||||
}
|
||||
browser.animate = typeof document !== 'undefined' && document.documentElement.animate != null;
|
||||
browser.tizen = userAgent.toLowerCase().indexOf('tizen') !== -1 || window.tizen != null;
|
||||
browser.web0s = userAgent.toLowerCase().indexOf('Web0S'.toLowerCase()) !== -1;
|
||||
browser.edgeUwp = browser.edge && (userAgent.toLowerCase().indexOf('msapphost') !== -1 || userAgent.toLowerCase().indexOf('webview') !== -1);
|
||||
|
||||
if (!browser.tizen) {
|
||||
browser.orsay = userAgent.toLowerCase().indexOf('smarthub') !== -1;
|
||||
} else {
|
||||
const v = (navigator.appVersion).match(/Tizen (\d+).(\d+)/);
|
||||
browser.tizenVersion = parseInt(v[1]);
|
||||
}
|
||||
|
||||
if (browser.edgeUwp) {
|
||||
browser.edge = true;
|
||||
}
|
||||
|
||||
browser.tv = isTv();
|
||||
browser.operaTv = browser.tv && userAgent.toLowerCase().indexOf('opr/') !== -1;
|
||||
|
||||
if (browser.mobile || browser.tv) {
|
||||
browser.slow = true;
|
||||
}
|
||||
|
||||
if (typeof document !== 'undefined') {
|
||||
/* eslint-disable-next-line compat/compat */
|
||||
if (('ontouchstart' in window) || (navigator.maxTouchPoints > 0)) {
|
||||
browser.touch = true;
|
||||
}
|
||||
}
|
||||
|
||||
browser.chromecast = browser.chrome && userAgent.toLowerCase().indexOf('crkey') !== -1;
|
||||
browser.keyboard = hasKeyboard(browser);
|
||||
browser.supportsCssAnimation = supportsCssAnimation;
|
||||
|
||||
return browser;
|
||||
});
|
||||
browser.osx = userAgent.toLowerCase().indexOf('os x') !== -1;
|
||||
browser.iOS = browser.ipad || browser.iphone || browser.ipod;
|
||||
|
||||
if (browser.iOS) {
|
||||
browser.iOSVersion = iOSversion();
|
||||
|
||||
if (browser.iOSVersion && browser.iOSVersion.length >= 2) {
|
||||
browser.iOSVersion = browser.iOSVersion[0] + (browser.iOSVersion[1] / 10);
|
||||
}
|
||||
}
|
||||
|
||||
export default browser;
|
||||
|
|
|
@ -1,23 +1,17 @@
|
|||
define(['browser'], function (browser) {
|
||||
'use strict';
|
||||
|
||||
browser = browser.default || browser;
|
||||
|
||||
function canPlayH264(videoTestElement) {
|
||||
return !!(videoTestElement.canPlayType && videoTestElement.canPlayType('video/mp4; codecs="avc1.42E01E, mp4a.40.2"').replace(/no/, ''));
|
||||
}
|
||||
|
||||
function canPlayH265(videoTestElement, options) {
|
||||
if (browser.tizen || browser.orsay || browser.xboxOne || browser.web0s || options.supportsHevc) {
|
||||
if (browser.tizen || browser.xboxOne || browser.web0s || options.supportsHevc) {
|
||||
return true;
|
||||
}
|
||||
|
||||
var userAgent = navigator.userAgent.toLowerCase();
|
||||
if (browser.chromecast) {
|
||||
var isChromecastUltra = userAgent.indexOf('aarch64') !== -1;
|
||||
if (isChromecastUltra) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (browser.ps4) {
|
||||
return false;
|
||||
}
|
||||
|
@ -31,7 +25,7 @@ define(['browser'], function (browser) {
|
|||
|
||||
var _supportsTextTracks;
|
||||
function supportsTextTracks() {
|
||||
if (browser.tizen || browser.orsay) {
|
||||
if (browser.tizen) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -53,7 +47,7 @@ define(['browser'], function (browser) {
|
|||
}
|
||||
|
||||
function canPlayNativeHls() {
|
||||
if (browser.tizen || browser.orsay) {
|
||||
if (browser.tizen) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -68,11 +62,11 @@ define(['browser'], function (browser) {
|
|||
|
||||
function canPlayHlsWithMSE() {
|
||||
// text tracks don’t work with this in firefox
|
||||
return window.MediaSource != null;
|
||||
return window.MediaSource != null; /* eslint-disable-line compat/compat */
|
||||
}
|
||||
|
||||
function supportsAc3(videoTestElement) {
|
||||
if (browser.edgeUwp || browser.tizen || browser.orsay || browser.web0s) {
|
||||
if (browser.edgeUwp || browser.tizen || browser.web0s) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -80,7 +74,7 @@ define(['browser'], function (browser) {
|
|||
}
|
||||
|
||||
function supportsEac3(videoTestElement) {
|
||||
if (browser.tizen || browser.orsay || browser.web0s) {
|
||||
if (browser.tizen || browser.web0s) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -88,7 +82,7 @@ define(['browser'], function (browser) {
|
|||
}
|
||||
|
||||
function supportsAc3InHls(videoTestElement) {
|
||||
if (browser.tizen || browser.orsay || browser.web0s) {
|
||||
if (browser.tizen || browser.web0s) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -104,11 +98,11 @@ define(['browser'], function (browser) {
|
|||
var typeString;
|
||||
|
||||
if (format === 'flac') {
|
||||
if (browser.tizen || browser.orsay || browser.web0s || browser.edgeUwp) {
|
||||
if (browser.tizen || browser.web0s || browser.edgeUwp) {
|
||||
return true;
|
||||
}
|
||||
} else if (format === 'wma') {
|
||||
if (browser.tizen || browser.orsay || browser.edgeUwp) {
|
||||
if (browser.tizen || browser.edgeUwp) {
|
||||
return true;
|
||||
}
|
||||
} else if (format === 'asf') {
|
||||
|
@ -143,7 +137,7 @@ define(['browser'], function (browser) {
|
|||
}
|
||||
|
||||
function testCanPlayMkv(videoTestElement) {
|
||||
if (browser.tizen || browser.orsay || browser.web0s) {
|
||||
if (browser.tizen || browser.web0s) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -152,20 +146,7 @@ define(['browser'], function (browser) {
|
|||
return true;
|
||||
}
|
||||
|
||||
// Unfortunately there's no real way to detect mkv support
|
||||
if (browser.chrome) {
|
||||
// Not supported on opera tv
|
||||
if (browser.operaTv) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var userAgent = navigator.userAgent.toLowerCase();
|
||||
|
||||
// Filter out browsers based on chromium that don't support mkv
|
||||
if (userAgent.indexOf('vivaldi') !== -1 || userAgent.indexOf('opera') !== -1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (browser.edgeChromium && browser.windows) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -176,30 +157,26 @@ define(['browser'], function (browser) {
|
|||
return false;
|
||||
}
|
||||
|
||||
function testCanPlayAv1(videoTestElement) {
|
||||
if (browser.tizenVersion >= 5.5) {
|
||||
return true;
|
||||
} else if (browser.web0sVersion >= 5 && window.outerHeight >= 2160) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return videoTestElement.canPlayType('video/webm; codecs="av01.0.15M.10"').replace(/no/, '');
|
||||
}
|
||||
|
||||
function testCanPlayTs() {
|
||||
return browser.tizen || browser.orsay || browser.web0s || browser.edgeUwp;
|
||||
return browser.tizen || browser.web0s || browser.edgeUwp;
|
||||
}
|
||||
|
||||
function supportsMpeg2Video() {
|
||||
return browser.tizen || browser.orsay || browser.web0s || browser.edgeUwp;
|
||||
return browser.tizen || browser.web0s || browser.edgeUwp;
|
||||
}
|
||||
|
||||
function supportsVc1() {
|
||||
return browser.tizen || browser.orsay || browser.web0s || browser.edgeUwp;
|
||||
}
|
||||
|
||||
function getFlvMseDirectPlayProfile() {
|
||||
var videoAudioCodecs = ['aac'];
|
||||
if (!browser.edge && !browser.msie) {
|
||||
videoAudioCodecs.push('mp3');
|
||||
}
|
||||
|
||||
return {
|
||||
Container: 'flv',
|
||||
Type: 'Video',
|
||||
VideoCodec: 'h264',
|
||||
AudioCodec: videoAudioCodecs.join(',')
|
||||
};
|
||||
function supportsVc1(videoTestElement) {
|
||||
return browser.tizen || browser.web0s || browser.edgeUwp || videoTestElement.canPlayType('video/mp4; codecs="vc-1"').replace(/no/, '');
|
||||
}
|
||||
|
||||
function getDirectPlayProfileForVideoContainer(container, videoAudioCodecs, videoTestElement, options) {
|
||||
|
@ -209,11 +186,11 @@ define(['browser'], function (browser) {
|
|||
|
||||
switch (container) {
|
||||
case 'asf':
|
||||
supported = browser.tizen || browser.orsay || browser.web0s || browser.edgeUwp;
|
||||
supported = browser.tizen || browser.web0s || browser.edgeUwp;
|
||||
videoAudioCodecs = [];
|
||||
break;
|
||||
case 'avi':
|
||||
supported = browser.tizen || browser.orsay || browser.web0s || browser.edgeUwp;
|
||||
supported = browser.tizen || browser.web0s || browser.edgeUwp;
|
||||
// New Samsung TV don't support XviD/DivX
|
||||
// Explicitly add supported codecs to make other codecs be transcoded
|
||||
if (browser.tizenVersion >= 4) {
|
||||
|
@ -226,29 +203,26 @@ define(['browser'], function (browser) {
|
|||
break;
|
||||
case 'mpg':
|
||||
case 'mpeg':
|
||||
supported = browser.tizen || browser.orsay || browser.web0s || browser.edgeUwp;
|
||||
supported = browser.tizen || browser.web0s || browser.edgeUwp;
|
||||
break;
|
||||
case 'flv':
|
||||
supported = browser.tizen || browser.orsay;
|
||||
//if (!supported && window.MediaSource != null && window.MediaSource.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"')) {
|
||||
// return getFlvMseDirectPlayProfile();
|
||||
//}
|
||||
supported = browser.tizen;
|
||||
break;
|
||||
case '3gp':
|
||||
case 'mts':
|
||||
case 'trp':
|
||||
case 'vob':
|
||||
case 'vro':
|
||||
supported = browser.tizen || browser.orsay;
|
||||
supported = browser.tizen;
|
||||
break;
|
||||
case 'mov':
|
||||
supported = browser.tizen || browser.orsay || browser.web0s || browser.chrome || browser.edgeUwp;
|
||||
supported = browser.tizen || browser.web0s || browser.chrome || browser.edgeChromium || browser.edgeUwp;
|
||||
videoCodecs.push('h264');
|
||||
break;
|
||||
case 'm2ts':
|
||||
supported = browser.tizen || browser.orsay || browser.web0s || browser.edgeUwp;
|
||||
supported = browser.tizen || browser.web0s || browser.edgeUwp;
|
||||
videoCodecs.push('h264');
|
||||
if (supportsVc1()) {
|
||||
if (supportsVc1(videoTestElement)) {
|
||||
videoCodecs.push('vc1');
|
||||
}
|
||||
if (supportsMpeg2Video()) {
|
||||
|
@ -256,7 +230,7 @@ define(['browser'], function (browser) {
|
|||
}
|
||||
break;
|
||||
case 'wmv':
|
||||
supported = browser.tizen || browser.orsay || browser.web0s || browser.edgeUwp;
|
||||
supported = browser.tizen || browser.web0s || browser.edgeUwp;
|
||||
videoAudioCodecs = [];
|
||||
break;
|
||||
case 'ts':
|
||||
|
@ -266,7 +240,7 @@ define(['browser'], function (browser) {
|
|||
videoCodecs.push('h265');
|
||||
videoCodecs.push('hevc');
|
||||
}
|
||||
if (supportsVc1()) {
|
||||
if (supportsVc1(videoTestElement)) {
|
||||
videoCodecs.push('vc1');
|
||||
}
|
||||
if (supportsMpeg2Video()) {
|
||||
|
@ -291,21 +265,6 @@ define(['browser'], function (browser) {
|
|||
}
|
||||
|
||||
function getGlobalMaxVideoBitrate() {
|
||||
var userAgent = navigator.userAgent.toLowerCase();
|
||||
if (browser.chromecast) {
|
||||
var isChromecastUltra = userAgent.indexOf('aarch64') !== -1;
|
||||
if (isChromecastUltra) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// This is a hack to try and detect chromecast on vizio
|
||||
if (self.screen && self.screen.width >= 3800) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return 30000000;
|
||||
}
|
||||
|
||||
var isTizenFhd = false;
|
||||
if (browser.tizen) {
|
||||
try {
|
||||
|
@ -334,7 +293,6 @@ define(['browser'], function (browser) {
|
|||
|
||||
var canPlayVp8 = videoTestElement.canPlayType('video/webm; codecs="vp8"').replace(/no/, '');
|
||||
var canPlayVp9 = videoTestElement.canPlayType('video/webm; codecs="vp9"').replace(/no/, '');
|
||||
var canPlayAv1 = videoTestElement.canPlayType('video/webm; codecs="av1"').replace(/no/, '');
|
||||
var webmAudioCodecs = ['vorbis'];
|
||||
|
||||
var canPlayMkv = testCanPlayMkv(videoTestElement);
|
||||
|
@ -350,32 +308,29 @@ define(['browser'], function (browser) {
|
|||
var videoAudioCodecs = [];
|
||||
var hlsVideoAudioCodecs = [];
|
||||
|
||||
var supportsMp3VideoAudio = videoTestElement.canPlayType('video/mp4; codecs="avc1.640029, mp4a.69"').replace(/no/, '') ||
|
||||
videoTestElement.canPlayType('video/mp4; codecs="avc1.640029, mp4a.6B"').replace(/no/, '');
|
||||
var supportsMp3VideoAudio = videoTestElement.canPlayType('video/mp4; codecs="avc1.640029, mp4a.69"').replace(/no/, '')
|
||||
|| videoTestElement.canPlayType('video/mp4; codecs="avc1.640029, mp4a.6B"').replace(/no/, '')
|
||||
|| videoTestElement.canPlayType('video/mp4; codecs="avc1.640029, mp3"').replace(/no/, '');
|
||||
|
||||
// Not sure how to test for this
|
||||
var supportsMp2VideoAudio = browser.edgeUwp || browser.tizen || browser.orsay || browser.web0s;
|
||||
var supportsMp2VideoAudio = browser.edgeUwp || browser.tizen || browser.web0s;
|
||||
|
||||
/* eslint-disable compat/compat */
|
||||
var maxVideoWidth = browser.xboxOne ?
|
||||
(self.screen ? self.screen.width : null) :
|
||||
(window.screen ? window.screen.width : null) :
|
||||
null;
|
||||
|
||||
/* eslint-enable compat/compat */
|
||||
if (options.maxVideoWidth) {
|
||||
maxVideoWidth = options.maxVideoWidth;
|
||||
}
|
||||
|
||||
var canPlayAacVideoAudio = videoTestElement.canPlayType('video/mp4; codecs="avc1.640029, mp4a.40.2"').replace(/no/, '');
|
||||
|
||||
if (canPlayAacVideoAudio && browser.chromecast && physicalAudioChannels <= 2) {
|
||||
// prioritize this first
|
||||
videoAudioCodecs.push('aac');
|
||||
}
|
||||
|
||||
// Only put mp3 first if mkv support is there
|
||||
// Otherwise with HLS and mp3 audio we're seeing some browsers
|
||||
// safari is lying
|
||||
if (supportsAc3(videoTestElement)) {
|
||||
|
||||
videoAudioCodecs.push('ac3');
|
||||
|
||||
var eAc3 = supportsEac3(videoTestElement);
|
||||
|
@ -393,11 +348,6 @@ define(['browser'], function (browser) {
|
|||
}
|
||||
}
|
||||
|
||||
if (canPlayAacVideoAudio && browser.chromecast && videoAudioCodecs.indexOf('aac') === -1) {
|
||||
// prioritize this first
|
||||
videoAudioCodecs.push('aac');
|
||||
}
|
||||
|
||||
if (supportsMp3VideoAudio) {
|
||||
videoAudioCodecs.push('mp3');
|
||||
|
||||
|
@ -432,7 +382,7 @@ define(['browser'], function (browser) {
|
|||
videoAudioCodecs.push('mp2');
|
||||
}
|
||||
|
||||
var supportsDts = browser.tizen || browser.orsay || browser.web0s || options.supportsDts;
|
||||
var supportsDts = browser.tizen || browser.web0s || options.supportsDts || videoTestElement.canPlayType('video/mp4; codecs="dts-"').replace(/no/, '') || videoTestElement.canPlayType('video/mp4; codecs="dts+"').replace(/no/, '');
|
||||
|
||||
// DTS audio not supported in 2018 models (Tizen 4.0)
|
||||
if (browser.tizenVersion >= 4) {
|
||||
|
@ -444,7 +394,7 @@ define(['browser'], function (browser) {
|
|||
videoAudioCodecs.push('dts');
|
||||
}
|
||||
|
||||
if (browser.tizen || browser.orsay || browser.web0s) {
|
||||
if (browser.tizen || browser.web0s) {
|
||||
videoAudioCodecs.push('pcm_s16le');
|
||||
videoAudioCodecs.push('pcm_s24le');
|
||||
}
|
||||
|
@ -453,7 +403,7 @@ define(['browser'], function (browser) {
|
|||
videoAudioCodecs.push('truehd');
|
||||
}
|
||||
|
||||
if (browser.tizen || browser.orsay) {
|
||||
if (browser.tizen) {
|
||||
videoAudioCodecs.push('aac_latm');
|
||||
}
|
||||
|
||||
|
@ -476,6 +426,7 @@ define(['browser'], function (browser) {
|
|||
});
|
||||
|
||||
var mp4VideoCodecs = [];
|
||||
var webmVideoCodecs = [];
|
||||
var hlsVideoCodecs = [];
|
||||
|
||||
if (canPlayH264(videoTestElement)) {
|
||||
|
@ -497,26 +448,42 @@ define(['browser'], function (browser) {
|
|||
mp4VideoCodecs.push('mpeg2video');
|
||||
}
|
||||
|
||||
if (supportsVc1()) {
|
||||
if (supportsVc1(videoTestElement)) {
|
||||
mp4VideoCodecs.push('vc1');
|
||||
}
|
||||
|
||||
if (browser.tizen || browser.orsay) {
|
||||
if (browser.tizen) {
|
||||
mp4VideoCodecs.push('msmpeg4v2');
|
||||
}
|
||||
|
||||
if (canPlayVp8) {
|
||||
mp4VideoCodecs.push('vp8');
|
||||
webmVideoCodecs.push('vp8');
|
||||
}
|
||||
|
||||
if (canPlayVp9) {
|
||||
mp4VideoCodecs.push('vp9');
|
||||
webmVideoCodecs.push('vp9');
|
||||
}
|
||||
|
||||
if (canPlayVp8 || browser.tizen || browser.orsay) {
|
||||
if (testCanPlayAv1(videoTestElement)) {
|
||||
mp4VideoCodecs.push('av1');
|
||||
webmVideoCodecs.push('av1');
|
||||
}
|
||||
|
||||
if (canPlayVp8 || browser.tizen) {
|
||||
videoAudioCodecs.push('vorbis');
|
||||
}
|
||||
|
||||
if (webmVideoCodecs.length) {
|
||||
profile.DirectPlayProfiles.push({
|
||||
Container: 'webm',
|
||||
Type: 'Video',
|
||||
VideoCodec: webmVideoCodecs.join(','),
|
||||
AudioCodec: webmAudioCodecs.join(',')
|
||||
});
|
||||
}
|
||||
|
||||
if (mp4VideoCodecs.length) {
|
||||
profile.DirectPlayProfiles.push({
|
||||
Container: 'mp4,m4v',
|
||||
|
@ -545,7 +512,6 @@ define(['browser'], function (browser) {
|
|||
});
|
||||
|
||||
['opus', 'mp3', 'mp2', 'aac', 'flac', 'alac', 'webma', 'wma', 'wav', 'ogg', 'oga'].filter(canPlayAudioFormat).forEach(function (audioFormat) {
|
||||
|
||||
if (audioFormat === 'mp2') {
|
||||
profile.DirectPlayProfiles.push({
|
||||
Container: 'mp2,mp3',
|
||||
|
@ -575,33 +541,6 @@ define(['browser'], function (browser) {
|
|||
}
|
||||
});
|
||||
|
||||
if (canPlayVp8) {
|
||||
profile.DirectPlayProfiles.push({
|
||||
Container: 'webm',
|
||||
Type: 'Video',
|
||||
AudioCodec: webmAudioCodecs.join(','),
|
||||
VideoCodec: 'VP8'
|
||||
});
|
||||
}
|
||||
|
||||
if (canPlayVp9) {
|
||||
profile.DirectPlayProfiles.push({
|
||||
Container: 'webm',
|
||||
Type: 'Video',
|
||||
AudioCodec: webmAudioCodecs.join(','),
|
||||
VideoCodec: 'VP9'
|
||||
});
|
||||
}
|
||||
|
||||
if (canPlayAv1) {
|
||||
profile.DirectPlayProfiles.push({
|
||||
Container: 'webm',
|
||||
Type: 'Video',
|
||||
AudioCodec: webmAudioCodecs.join(','),
|
||||
VideoCodec: 'AV1'
|
||||
});
|
||||
}
|
||||
|
||||
profile.TranscodingProfiles = [];
|
||||
|
||||
var hlsBreakOnNonKeyFrames = browser.iOS || browser.osx || browser.edge || !canPlayNativeHls() ? true : false;
|
||||
|
@ -645,7 +584,7 @@ define(['browser'], function (browser) {
|
|||
});
|
||||
});
|
||||
|
||||
if (canPlayMkv && !browser.tizen && !browser.orsay && options.enableMkvProgressive !== false) {
|
||||
if (canPlayMkv && !browser.tizen && options.enableMkvProgressive !== false) {
|
||||
profile.TranscodingProfiles.push({
|
||||
Container: 'mkv',
|
||||
Type: 'Video',
|
||||
|
@ -710,7 +649,7 @@ define(['browser'], function (browser) {
|
|||
|
||||
profile.CodecProfiles = [];
|
||||
|
||||
var supportsSecondaryAudio = browser.tizen || browser.orsay || videoTestElement.audioTracks;
|
||||
var supportsSecondaryAudio = browser.tizen || videoTestElement.audioTracks;
|
||||
|
||||
var aacCodecProfileConditions = [];
|
||||
|
||||
|
@ -733,15 +672,6 @@ define(['browser'], function (browser) {
|
|||
});
|
||||
}
|
||||
|
||||
if (browser.chromecast) {
|
||||
aacCodecProfileConditions.push({
|
||||
Condition: 'LessThanEqual',
|
||||
Property: 'AudioChannels',
|
||||
Value: '2',
|
||||
IsRequired: true
|
||||
});
|
||||
}
|
||||
|
||||
if (aacCodecProfileConditions.length) {
|
||||
profile.CodecProfiles.push({
|
||||
Type: 'VideoAudio',
|
||||
|
@ -767,7 +697,7 @@ define(['browser'], function (browser) {
|
|||
var maxH264Level = 42;
|
||||
var h264Profiles = 'high|main|baseline|constrained baseline';
|
||||
|
||||
if (browser.tizen || browser.orsay || browser.web0s ||
|
||||
if (browser.tizen || browser.web0s ||
|
||||
videoTestElement.canPlayType('video/mp4; codecs="avc1.640833"').replace(/no/, '')) {
|
||||
maxH264Level = 51;
|
||||
}
|
||||
|
@ -777,58 +707,46 @@ define(['browser'], function (browser) {
|
|||
maxH264Level = 52;
|
||||
}
|
||||
|
||||
if (browser.tizen || browser.orsay ||
|
||||
if (browser.tizen ||
|
||||
videoTestElement.canPlayType('video/mp4; codecs="avc1.6e0033"').replace(/no/, '')) {
|
||||
|
||||
// These tests are passing in safari, but playback is failing
|
||||
if (!browser.safari && !browser.iOS && !browser.web0s && !browser.edge && !browser.mobile) {
|
||||
h264Profiles += '|high 10';
|
||||
}
|
||||
}
|
||||
|
||||
profile.CodecProfiles.push({
|
||||
Type: 'Video',
|
||||
Codec: 'h264',
|
||||
Conditions: [
|
||||
{
|
||||
Condition: 'NotEquals',
|
||||
Property: 'IsAnamorphic',
|
||||
Value: 'true',
|
||||
IsRequired: false
|
||||
},
|
||||
{
|
||||
Condition: 'EqualsAny',
|
||||
Property: 'VideoProfile',
|
||||
Value: h264Profiles,
|
||||
IsRequired: false
|
||||
},
|
||||
{
|
||||
Condition: 'LessThanEqual',
|
||||
Property: 'VideoLevel',
|
||||
Value: maxH264Level.toString(),
|
||||
IsRequired: false
|
||||
}
|
||||
]
|
||||
});
|
||||
const h264CodecProfileConditions = [
|
||||
{
|
||||
Condition: 'NotEquals',
|
||||
Property: 'IsAnamorphic',
|
||||
Value: 'true',
|
||||
IsRequired: false
|
||||
},
|
||||
{
|
||||
Condition: 'EqualsAny',
|
||||
Property: 'VideoProfile',
|
||||
Value: h264Profiles,
|
||||
IsRequired: false
|
||||
},
|
||||
{
|
||||
Condition: 'LessThanEqual',
|
||||
Property: 'VideoLevel',
|
||||
Value: maxH264Level.toString(),
|
||||
IsRequired: false
|
||||
}
|
||||
];
|
||||
|
||||
if (!browser.edgeUwp && !browser.tizen && !browser.orsay && !browser.web0s) {
|
||||
//profile.CodecProfiles[profile.CodecProfiles.length - 1].Conditions.push({
|
||||
// Condition: 'NotEquals',
|
||||
// Property: 'IsAVC',
|
||||
// Value: 'false',
|
||||
// IsRequired: false
|
||||
//});
|
||||
|
||||
//profile.CodecProfiles[profile.CodecProfiles.length - 1].Conditions.push({
|
||||
// Condition: 'NotEquals',
|
||||
// Property: 'IsInterlaced',
|
||||
// Value: 'true',
|
||||
// IsRequired: false
|
||||
//});
|
||||
if (!browser.edgeUwp && !browser.tizen && !browser.web0s) {
|
||||
h264CodecProfileConditions.push({
|
||||
Condition: 'NotEquals',
|
||||
Property: 'IsInterlaced',
|
||||
Value: 'true',
|
||||
IsRequired: false
|
||||
});
|
||||
}
|
||||
|
||||
if (maxVideoWidth) {
|
||||
profile.CodecProfiles[profile.CodecProfiles.length - 1].Conditions.push({
|
||||
h264CodecProfileConditions.push({
|
||||
Condition: 'LessThanEqual',
|
||||
Property: 'Width',
|
||||
Value: maxVideoWidth.toString(),
|
||||
|
@ -841,7 +759,7 @@ define(['browser'], function (browser) {
|
|||
var h264MaxVideoBitrate = globalMaxVideoBitrate;
|
||||
|
||||
if (h264MaxVideoBitrate) {
|
||||
profile.CodecProfiles[profile.CodecProfiles.length - 1].Conditions.push({
|
||||
h264CodecProfileConditions.push({
|
||||
Condition: 'LessThanEqual',
|
||||
Property: 'VideoBitrate',
|
||||
Value: h264MaxVideoBitrate,
|
||||
|
@ -849,6 +767,33 @@ define(['browser'], function (browser) {
|
|||
});
|
||||
}
|
||||
|
||||
// On iOS 12.x, for TS container max h264 level is 4.2
|
||||
if (browser.iOS && browser.iOSVersion < 13) {
|
||||
const codecProfile = {
|
||||
Type: 'Video',
|
||||
Codec: 'h264',
|
||||
Container: 'ts',
|
||||
Conditions: h264CodecProfileConditions.filter((condition) => {
|
||||
return condition.Property !== 'VideoLevel';
|
||||
})
|
||||
};
|
||||
|
||||
codecProfile.Conditions.push({
|
||||
Condition: 'LessThanEqual',
|
||||
Property: 'VideoLevel',
|
||||
Value: '42',
|
||||
IsRequired: false
|
||||
});
|
||||
|
||||
profile.CodecProfiles.push(codecProfile);
|
||||
}
|
||||
|
||||
profile.CodecProfiles.push({
|
||||
Type: 'Video',
|
||||
Codec: 'h264',
|
||||
Conditions: h264CodecProfileConditions
|
||||
});
|
||||
|
||||
var globalVideoConditions = [];
|
||||
|
||||
if (globalMaxVideoBitrate) {
|
||||
|
@ -875,19 +820,6 @@ define(['browser'], function (browser) {
|
|||
});
|
||||
}
|
||||
|
||||
if (browser.chromecast) {
|
||||
profile.CodecProfiles.push({
|
||||
Type: 'Audio',
|
||||
Codec: 'flac',
|
||||
Conditions: [
|
||||
{
|
||||
Condition: 'LessThanEqual',
|
||||
Property: 'AudioSampleRate',
|
||||
Value: '96000'
|
||||
}]
|
||||
});
|
||||
}
|
||||
|
||||
// Subtitle profiles
|
||||
// External vtt or burn in
|
||||
profile.SubtitleProfiles = [];
|
||||
|
|
233
src/scripts/clientUtils.js
Normal file
233
src/scripts/clientUtils.js
Normal file
|
@ -0,0 +1,233 @@
|
|||
|
||||
export function getCurrentUser() {
|
||||
return window.ApiClient.getCurrentUser(false);
|
||||
}
|
||||
|
||||
//TODO: investigate url prefix support for serverAddress function
|
||||
export function serverAddress() {
|
||||
if (AppInfo.isNativeApp) {
|
||||
const apiClient = window.ApiClient;
|
||||
|
||||
if (apiClient) {
|
||||
return apiClient.serverAddress();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
const urlLower = window.location.href.toLowerCase();
|
||||
const index = urlLower.lastIndexOf('/web');
|
||||
|
||||
if (index != -1) {
|
||||
return urlLower.substring(0, index);
|
||||
}
|
||||
|
||||
const loc = window.location;
|
||||
let address = loc.protocol + '//' + loc.hostname;
|
||||
|
||||
if (loc.port) {
|
||||
address += ':' + loc.port;
|
||||
}
|
||||
|
||||
return address;
|
||||
}
|
||||
|
||||
export function getCurrentUserId() {
|
||||
const apiClient = window.ApiClient;
|
||||
|
||||
if (apiClient) {
|
||||
return apiClient.getCurrentUserId();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
export function onServerChanged(userId, accessToken, apiClient) {
|
||||
apiClient = apiClient || window.ApiClient;
|
||||
window.ApiClient = apiClient;
|
||||
}
|
||||
|
||||
export function logout() {
|
||||
ConnectionManager.logout().then(function () {
|
||||
let loginPage;
|
||||
|
||||
if (AppInfo.isNativeApp) {
|
||||
loginPage = 'selectserver.html';
|
||||
window.ApiClient = null;
|
||||
} else {
|
||||
loginPage = 'login.html';
|
||||
}
|
||||
|
||||
navigate(loginPage);
|
||||
});
|
||||
}
|
||||
|
||||
export function getConfigurationPageUrl(name) {
|
||||
return 'configurationpage?name=' + encodeURIComponent(name);
|
||||
}
|
||||
|
||||
export function getConfigurationResourceUrl(name) {
|
||||
if (AppInfo.isNativeApp) {
|
||||
return ApiClient.getUrl('web/ConfigurationPage', {
|
||||
name: name
|
||||
});
|
||||
}
|
||||
|
||||
return getConfigurationPageUrl(name);
|
||||
}
|
||||
|
||||
export function navigate(url, preserveQueryString) {
|
||||
if (!url) {
|
||||
throw new Error('url cannot be null or empty');
|
||||
}
|
||||
|
||||
const queryString = getWindowLocationSearch();
|
||||
|
||||
if (preserveQueryString && queryString) {
|
||||
url += queryString;
|
||||
}
|
||||
|
||||
return new Promise(function (resolve, reject) {
|
||||
import('appRouter').then(({default: appRouter}) => {
|
||||
return appRouter.show(url).then(resolve, reject);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export function processPluginConfigurationUpdateResult() {
|
||||
Promise.all([
|
||||
import('loading'),
|
||||
import('toast')
|
||||
])
|
||||
.then(([{default: loading}, {default: toast}]) => {
|
||||
loading.hide();
|
||||
toast(Globalize.translate('SettingsSaved'));
|
||||
});
|
||||
}
|
||||
|
||||
export function processServerConfigurationUpdateResult(result) {
|
||||
Promise.all([
|
||||
import('loading'),
|
||||
import('toast')
|
||||
])
|
||||
.then(([{default: loading}, {default: toast}]) => {
|
||||
loading.hide();
|
||||
toast(Globalize.translate('SettingsSaved'));
|
||||
});
|
||||
}
|
||||
|
||||
export function processErrorResponse(response) {
|
||||
import('loading').then(({default: loading}) => {
|
||||
loading.hide();
|
||||
});
|
||||
|
||||
let status = '' + response.status;
|
||||
|
||||
if (response.statusText) {
|
||||
status = response.statusText;
|
||||
}
|
||||
|
||||
alert({
|
||||
title: status,
|
||||
message: response.headers ? response.headers.get('X-Application-Error-Code') : null
|
||||
});
|
||||
}
|
||||
|
||||
export function alert(options) {
|
||||
if (typeof options == 'string') {
|
||||
return void import('toast').then(({default: toast}) => {
|
||||
toast({
|
||||
text: options
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
import('alert').then(({default: alert}) => {
|
||||
alert({
|
||||
title: options.title || Globalize.translate('HeaderAlert'),
|
||||
text: options.message
|
||||
}).then(options.callback || function () {});
|
||||
});
|
||||
}
|
||||
|
||||
export function capabilities(appHost) {
|
||||
let capabilities = {
|
||||
PlayableMediaTypes: ['Audio', 'Video'],
|
||||
SupportedCommands: ['MoveUp', 'MoveDown', 'MoveLeft', 'MoveRight', 'PageUp', 'PageDown', 'PreviousLetter', 'NextLetter', 'ToggleOsd', 'ToggleContextMenu', 'Select', 'Back', 'SendKey', 'SendString', 'GoHome', 'GoToSettings', 'VolumeUp', 'VolumeDown', 'Mute', 'Unmute', 'ToggleMute', 'SetVolume', 'SetAudioStreamIndex', 'SetSubtitleStreamIndex', 'DisplayContent', 'GoToSearch', 'DisplayMessage', 'SetRepeatMode', 'SetShuffleQueue', 'ChannelUp', 'ChannelDown', 'PlayMediaSource', 'PlayTrailers'],
|
||||
SupportsPersistentIdentifier: window.appMode === 'cordova' || window.appMode === 'android',
|
||||
SupportsMediaControl: true
|
||||
};
|
||||
return Object.assign(capabilities, appHost.getPushTokenInfo());
|
||||
}
|
||||
|
||||
export function selectServer() {
|
||||
if (window.NativeShell && typeof window.NativeShell.selectServer === 'function') {
|
||||
window.NativeShell.selectServer();
|
||||
} else {
|
||||
navigate('selectserver.html');
|
||||
}
|
||||
}
|
||||
|
||||
export function hideLoadingMsg() {
|
||||
import('loading').then(({default: loading}) => {
|
||||
loading.hide();
|
||||
});
|
||||
}
|
||||
|
||||
export function showLoadingMsg() {
|
||||
import('loading').then(({default: loading}) => {
|
||||
loading.show();
|
||||
});
|
||||
}
|
||||
|
||||
export function confirm(message, title, callback) {
|
||||
import('confirm').then(({default: confirm}) => {
|
||||
confirm(message, title).then(function() {
|
||||
callback(!0);
|
||||
}).catch(function() {
|
||||
callback(!1);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// This is used in plugins and templates, so keep it defined for now.
|
||||
// TODO: Remove once plugins don't need it
|
||||
window.Dashboard = {
|
||||
alert,
|
||||
capabilities,
|
||||
confirm,
|
||||
getConfigurationPageUrl,
|
||||
getConfigurationResourceUrl,
|
||||
getCurrentUser,
|
||||
getCurrentUserId,
|
||||
hideLoadingMsg,
|
||||
logout,
|
||||
navigate,
|
||||
onServerChanged,
|
||||
processErrorResponse,
|
||||
processPluginConfigurationUpdateResult,
|
||||
processServerConfigurationUpdateResult,
|
||||
selectServer,
|
||||
serverAddress,
|
||||
showLoadingMsg
|
||||
};
|
||||
|
||||
export default {
|
||||
alert,
|
||||
capabilities,
|
||||
confirm,
|
||||
getConfigurationPageUrl,
|
||||
getConfigurationResourceUrl,
|
||||
getCurrentUser,
|
||||
getCurrentUserId,
|
||||
hideLoadingMsg,
|
||||
logout,
|
||||
navigate,
|
||||
onServerChanged,
|
||||
processErrorResponse,
|
||||
processPluginConfigurationUpdateResult,
|
||||
processServerConfigurationUpdateResult,
|
||||
selectServer,
|
||||
serverAddress,
|
||||
showLoadingMsg
|
||||
};
|
|
@ -1,15 +1,15 @@
|
|||
define(['globalize'], function (globalize) {
|
||||
'use strict';
|
||||
import globalize from 'globalize';
|
||||
|
||||
function parseISO8601Date(s, toLocal) {
|
||||
/* eslint-disable indent */
|
||||
|
||||
export function parseISO8601Date(s, toLocal) {
|
||||
// parenthese matches:
|
||||
// year month day hours minutes seconds
|
||||
// dotmilliseconds
|
||||
// tzstring plusminus hours minutes
|
||||
var re = /(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(\.\d+)?(Z|([+-])(\d{2}):(\d{2}))?/;
|
||||
const re = /(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(\.\d+)?(Z|([+-])(\d{2}):(\d{2}))?/;
|
||||
|
||||
var d = s.match(re);
|
||||
const d = s.match(re);
|
||||
|
||||
// "2010-12-07T11:00:00.000-09:00" parses to:
|
||||
// ["2010-12-07T11:00:00.000-09:00", "2010", "12", "07", "11",
|
||||
|
@ -19,13 +19,12 @@ define(['globalize'], function (globalize) {
|
|||
// "00", "00", ".000", "Z", undefined, undefined, undefined]
|
||||
|
||||
if (!d) {
|
||||
|
||||
throw "Couldn't parse ISO 8601 date string '" + s + "'";
|
||||
}
|
||||
|
||||
// parse strings, leading zeros into proper ints
|
||||
var a = [1, 2, 3, 4, 5, 6, 10, 11];
|
||||
for (var i in a) {
|
||||
const a = [1, 2, 3, 4, 5, 6, 10, 11];
|
||||
for (const i in a) {
|
||||
d[a[i]] = parseInt(d[a[i]], 10);
|
||||
}
|
||||
d[7] = parseFloat(d[7]);
|
||||
|
@ -33,7 +32,7 @@ define(['globalize'], function (globalize) {
|
|||
// Date.UTC(year, month[, date[, hrs[, min[, sec[, ms]]]]])
|
||||
// note that month is 0-11, not 1-12
|
||||
// see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Date/UTC
|
||||
var ms = Date.UTC(d[1], d[2] - 1, d[3], d[4], d[5], d[6]);
|
||||
let ms = Date.UTC(d[1], d[2] - 1, d[3], d[4], d[5], d[6]);
|
||||
|
||||
// if there are milliseconds, add them
|
||||
if (d[7] > 0) {
|
||||
|
@ -42,7 +41,7 @@ define(['globalize'], function (globalize) {
|
|||
|
||||
// if there's a timezone, calculate it
|
||||
if (d[8] !== 'Z' && d[10]) {
|
||||
var offset = d[10] * 60 * 60 * 1000;
|
||||
let offset = d[10] * 60 * 60 * 1000;
|
||||
if (d[11]) {
|
||||
offset += d[11] * 60 * 1000;
|
||||
}
|
||||
|
@ -58,14 +57,14 @@ define(['globalize'], function (globalize) {
|
|||
return new Date(ms);
|
||||
}
|
||||
|
||||
function getDisplayRunningTime(ticks) {
|
||||
var ticksPerHour = 36000000000;
|
||||
var ticksPerMinute = 600000000;
|
||||
var ticksPerSecond = 10000000;
|
||||
export function getDisplayRunningTime(ticks) {
|
||||
const ticksPerHour = 36000000000;
|
||||
const ticksPerMinute = 600000000;
|
||||
const ticksPerSecond = 10000000;
|
||||
|
||||
var parts = [];
|
||||
const parts = [];
|
||||
|
||||
var hours = ticks / ticksPerHour;
|
||||
let hours = ticks / ticksPerHour;
|
||||
hours = Math.floor(hours);
|
||||
|
||||
if (hours) {
|
||||
|
@ -74,7 +73,7 @@ define(['globalize'], function (globalize) {
|
|||
|
||||
ticks -= (hours * ticksPerHour);
|
||||
|
||||
var minutes = ticks / ticksPerMinute;
|
||||
let minutes = ticks / ticksPerMinute;
|
||||
minutes = Math.floor(minutes);
|
||||
|
||||
ticks -= (minutes * ticksPerMinute);
|
||||
|
@ -84,7 +83,7 @@ define(['globalize'], function (globalize) {
|
|||
}
|
||||
parts.push(minutes);
|
||||
|
||||
var seconds = ticks / ticksPerSecond;
|
||||
let seconds = ticks / ticksPerSecond;
|
||||
seconds = Math.floor(seconds);
|
||||
|
||||
if (seconds < 10) {
|
||||
|
@ -95,7 +94,7 @@ define(['globalize'], function (globalize) {
|
|||
return parts.join(':');
|
||||
}
|
||||
|
||||
var toLocaleTimeStringSupportsLocales = function () {
|
||||
const toLocaleTimeStringSupportsLocales = function () {
|
||||
try {
|
||||
new Date().toLocaleTimeString('i');
|
||||
} catch (e) {
|
||||
|
@ -105,10 +104,9 @@ define(['globalize'], function (globalize) {
|
|||
}();
|
||||
|
||||
function getOptionList(options) {
|
||||
const list = [];
|
||||
|
||||
var list = [];
|
||||
|
||||
for (var i in options) {
|
||||
for (const i in options) {
|
||||
list.push({
|
||||
name: i,
|
||||
value: options[i]
|
||||
|
@ -118,8 +116,7 @@ define(['globalize'], function (globalize) {
|
|||
return list;
|
||||
}
|
||||
|
||||
function toLocaleString(date, options) {
|
||||
|
||||
export function toLocaleString(date, options) {
|
||||
if (!date) {
|
||||
throw new Error('date cannot be null');
|
||||
}
|
||||
|
@ -127,8 +124,7 @@ define(['globalize'], function (globalize) {
|
|||
options = options || {};
|
||||
|
||||
if (toLocaleTimeStringSupportsLocales) {
|
||||
|
||||
var currentLocale = globalize.getCurrentDateTimeLocale();
|
||||
const currentLocale = globalize.getCurrentDateTimeLocale();
|
||||
|
||||
if (currentLocale) {
|
||||
return date.toLocaleString(currentLocale, options);
|
||||
|
@ -138,8 +134,7 @@ define(['globalize'], function (globalize) {
|
|||
return date.toLocaleString();
|
||||
}
|
||||
|
||||
function toLocaleDateString(date, options) {
|
||||
|
||||
export function toLocaleDateString(date, options) {
|
||||
if (!date) {
|
||||
throw new Error('date cannot be null');
|
||||
}
|
||||
|
@ -147,8 +142,7 @@ define(['globalize'], function (globalize) {
|
|||
options = options || {};
|
||||
|
||||
if (toLocaleTimeStringSupportsLocales) {
|
||||
|
||||
var currentLocale = globalize.getCurrentDateTimeLocale();
|
||||
const currentLocale = globalize.getCurrentDateTimeLocale();
|
||||
|
||||
if (currentLocale) {
|
||||
return date.toLocaleDateString(currentLocale, options);
|
||||
|
@ -156,9 +150,9 @@ define(['globalize'], function (globalize) {
|
|||
}
|
||||
|
||||
// This is essentially a hard-coded polyfill
|
||||
var optionList = getOptionList(options);
|
||||
const optionList = getOptionList(options);
|
||||
if (optionList.length === 1 && optionList[0].name === 'weekday') {
|
||||
var weekday = [];
|
||||
const weekday = [];
|
||||
weekday[0] = 'Sun';
|
||||
weekday[1] = 'Mon';
|
||||
weekday[2] = 'Tue';
|
||||
|
@ -172,8 +166,7 @@ define(['globalize'], function (globalize) {
|
|||
return date.toLocaleDateString();
|
||||
}
|
||||
|
||||
function toLocaleTimeString(date, options) {
|
||||
|
||||
export function toLocaleTimeString(date, options) {
|
||||
if (!date) {
|
||||
throw new Error('date cannot be null');
|
||||
}
|
||||
|
@ -181,8 +174,7 @@ define(['globalize'], function (globalize) {
|
|||
options = options || {};
|
||||
|
||||
if (toLocaleTimeStringSupportsLocales) {
|
||||
|
||||
var currentLocale = globalize.getCurrentDateTimeLocale();
|
||||
const currentLocale = globalize.getCurrentDateTimeLocale();
|
||||
|
||||
if (currentLocale) {
|
||||
return date.toLocaleTimeString(currentLocale, options);
|
||||
|
@ -192,17 +184,14 @@ define(['globalize'], function (globalize) {
|
|||
return date.toLocaleTimeString();
|
||||
}
|
||||
|
||||
function getDisplayTime(date) {
|
||||
|
||||
export function getDisplayTime(date) {
|
||||
if (!date) {
|
||||
throw new Error('date cannot be null');
|
||||
}
|
||||
|
||||
if ((typeof date).toString().toLowerCase() === 'string') {
|
||||
try {
|
||||
|
||||
date = parseISO8601Date(date, true);
|
||||
|
||||
} catch (err) {
|
||||
return date;
|
||||
}
|
||||
|
@ -217,19 +206,18 @@ define(['globalize'], function (globalize) {
|
|||
});
|
||||
}
|
||||
|
||||
var time = toLocaleTimeString(date);
|
||||
let time = toLocaleTimeString(date);
|
||||
|
||||
var timeLower = time.toLowerCase();
|
||||
const timeLower = time.toLowerCase();
|
||||
|
||||
if (timeLower.indexOf('am') !== -1 || timeLower.indexOf('pm') !== -1) {
|
||||
|
||||
time = timeLower;
|
||||
var hour = date.getHours() % 12;
|
||||
var suffix = date.getHours() > 11 ? 'pm' : 'am';
|
||||
let hour = date.getHours() % 12;
|
||||
const suffix = date.getHours() > 11 ? 'pm' : 'am';
|
||||
if (!hour) {
|
||||
hour = 12;
|
||||
}
|
||||
var minutes = date.getMinutes();
|
||||
let minutes = date.getMinutes();
|
||||
|
||||
if (minutes < 10) {
|
||||
minutes = '0' + minutes;
|
||||
|
@ -238,12 +226,10 @@ define(['globalize'], function (globalize) {
|
|||
minutes = ':' + minutes;
|
||||
time = hour + minutes + suffix;
|
||||
} else {
|
||||
|
||||
var timeParts = time.split(':');
|
||||
const timeParts = time.split(':');
|
||||
|
||||
// Trim off seconds
|
||||
if (timeParts.length > 2) {
|
||||
|
||||
// setting to 2 also handles '21:00:28 GMT+9:30'
|
||||
timeParts.length = 2;
|
||||
time = timeParts.join(':');
|
||||
|
@ -253,21 +239,20 @@ define(['globalize'], function (globalize) {
|
|||
return time;
|
||||
}
|
||||
|
||||
function isRelativeDay(date, offsetInDays) {
|
||||
|
||||
export function isRelativeDay(date, offsetInDays) {
|
||||
if (!date) {
|
||||
throw new Error('date cannot be null');
|
||||
}
|
||||
|
||||
var yesterday = new Date();
|
||||
var day = yesterday.getDate() + offsetInDays;
|
||||
const yesterday = new Date();
|
||||
const day = yesterday.getDate() + offsetInDays;
|
||||
|
||||
yesterday.setDate(day); // automatically adjusts month/year appropriately
|
||||
|
||||
return date.getFullYear() === yesterday.getFullYear() && date.getMonth() === yesterday.getMonth() && date.getDate() === day;
|
||||
}
|
||||
|
||||
return {
|
||||
export default {
|
||||
parseISO8601Date: parseISO8601Date,
|
||||
getDisplayRunningTime: getDisplayRunningTime,
|
||||
toLocaleDateString: toLocaleDateString,
|
||||
|
@ -279,4 +264,5 @@ define(['globalize'], function (globalize) {
|
|||
return toLocaleTimeStringSupportsLocales;
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
/* eslint-enable indent */
|
||||
|
|
|
@ -4,21 +4,18 @@ import appRouter from 'appRouter';
|
|||
import globalize from 'globalize';
|
||||
|
||||
function alertText(options) {
|
||||
|
||||
return new Promise(function (resolve, reject) {
|
||||
|
||||
require(['alert'], function (alert) {
|
||||
import('alert').then(({default: alert}) => {
|
||||
alert(options).then(resolve, resolve);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export function deleteItem(options) {
|
||||
|
||||
const item = options.item;
|
||||
const parentId = item.SeasonId || item.SeriesId || item.ParentId;
|
||||
|
||||
let apiClient = connectionManager.getApiClient(item.ServerId);
|
||||
const apiClient = connectionManager.getApiClient(item.ServerId);
|
||||
|
||||
return confirm({
|
||||
|
||||
|
@ -28,9 +25,7 @@ export function deleteItem(options) {
|
|||
primary: 'delete'
|
||||
|
||||
}).then(function () {
|
||||
|
||||
return apiClient.deleteItem(item.Id).then(function () {
|
||||
|
||||
if (options.navigate) {
|
||||
if (parentId) {
|
||||
appRouter.showItem(parentId, item.ServerId);
|
||||
|
@ -39,8 +34,7 @@ export function deleteItem(options) {
|
|||
}
|
||||
}
|
||||
}, function (err) {
|
||||
|
||||
let result = function () {
|
||||
const result = function () {
|
||||
return Promise.reject(err);
|
||||
};
|
||||
|
||||
|
|
|
@ -183,11 +183,9 @@
|
|||
width = height * (16.0 / 9.0);
|
||||
}
|
||||
|
||||
const closest = standardWidths.sort(function (a, b) {
|
||||
return standardWidths.sort(function (a, b) {
|
||||
return Math.abs(width - a) - Math.abs(width - b);
|
||||
})[0];
|
||||
|
||||
return closest;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -211,7 +209,7 @@
|
|||
'MozAnimation': 'animationend',
|
||||
'WebkitAnimation': 'webkitAnimationEnd'
|
||||
};
|
||||
for (let t in animations) {
|
||||
for (const t in animations) {
|
||||
if (el.style[t] !== undefined) {
|
||||
_animationEvent = animations[t];
|
||||
return animations[t];
|
||||
|
@ -251,7 +249,7 @@
|
|||
'MozTransition': 'transitionend',
|
||||
'WebkitTransition': 'webkitTransitionEnd'
|
||||
};
|
||||
for (let t in transitions) {
|
||||
for (const t in transitions) {
|
||||
if (el.style[t] !== undefined) {
|
||||
_transitionEvent = transitions[t];
|
||||
return transitions[t];
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
define(['datetime', 'jQuery', 'globalize', 'material-icons'], function (datetime, $, globalize) {
|
||||
'use strict';
|
||||
import $ from 'jQuery';
|
||||
import globalize from 'globalize';
|
||||
import 'material-icons';
|
||||
|
||||
/* eslint-disable indent */
|
||||
|
||||
function getNode(item, folderState, selected) {
|
||||
var htmlName = getNodeInnerHtml(item);
|
||||
|
@ -83,7 +86,7 @@ define(['datetime', 'jQuery', 'globalize', 'material-icons'], function (datetime
|
|||
if (result.TotalRecordCount) {
|
||||
nodes.push({
|
||||
id: 'livetv',
|
||||
text: globalize.translate('HeaderLiveTV'),
|
||||
text: globalize.translate('LiveTV'),
|
||||
state: {
|
||||
opened: false
|
||||
},
|
||||
|
@ -179,7 +182,7 @@ define(['datetime', 'jQuery', 'globalize', 'material-icons'], function (datetime
|
|||
}
|
||||
|
||||
function initializeTree(page, currentUser, openItems, selectedId) {
|
||||
require(['jstree'], function () {
|
||||
import('jstree').then(() => {
|
||||
initializeTreeInternal(page, currentUser, openItems, selectedId);
|
||||
});
|
||||
}
|
||||
|
@ -209,7 +212,7 @@ define(['datetime', 'jQuery', 'globalize', 'material-icons'], function (datetime
|
|||
function onNodeOpen(event, data) {
|
||||
var page = $(this).parents('.page')[0];
|
||||
var node = data.node;
|
||||
if (node.children && node.children) {
|
||||
if (node.children) {
|
||||
loadNodesToLoad(page, node);
|
||||
}
|
||||
if (node.li_attr && node.id != '#' && !node.li_attr.loadedFromServer) {
|
||||
|
@ -221,7 +224,7 @@ define(['datetime', 'jQuery', 'globalize', 'material-icons'], function (datetime
|
|||
function onNodeLoad(event, data) {
|
||||
var page = $(this).parents('.page')[0];
|
||||
var node = data.node;
|
||||
if (node.children && node.children) {
|
||||
if (node.children) {
|
||||
loadNodesToLoad(page, node);
|
||||
}
|
||||
if (node.li_attr && node.id != '#' && !node.li_attr.loadedFromServer) {
|
||||
|
@ -299,7 +302,8 @@ define(['datetime', 'jQuery', 'globalize', 'material-icons'], function (datetime
|
|||
$(document).on('itemsaved', '.metadataEditorPage', function (e, item) {
|
||||
updateEditorNode(this, item);
|
||||
}).on('pagebeforeshow', '.metadataEditorPage', function () {
|
||||
require(['css!assets/css/metadataeditor.css']);
|
||||
/* eslint-disable-next-line @babel/no-unused-expressions */
|
||||
import('css!assets/css/metadataeditor.css');
|
||||
}).on('pagebeforeshow', '.metadataEditorPage', function () {
|
||||
var page = this;
|
||||
Dashboard.getCurrentUser().then(function (user) {
|
||||
|
@ -331,4 +335,5 @@ define(['datetime', 'jQuery', 'globalize', 'material-icons'], function (datetime
|
|||
getCurrentItemId: getCurrentItemId,
|
||||
setCurrentItemId: setCurrentItemId
|
||||
};
|
||||
});
|
||||
|
||||
/* eslint-enable indent */
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import multiDownload from 'multi-download';
|
||||
|
||||
export function download(items) {
|
||||
|
||||
if (window.NativeShell) {
|
||||
items.map(function (item) {
|
||||
window.NativeShell.downloadFile(item);
|
||||
|
|
|
@ -19,392 +19,383 @@
|
|||
// # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// # THE SOFTWARE.
|
||||
require(['apphost'], function (appHost) {
|
||||
'use strict';
|
||||
|
||||
var _GAMEPAD_A_BUTTON_INDEX = 0;
|
||||
var _GAMEPAD_B_BUTTON_INDEX = 1;
|
||||
var _GAMEPAD_DPAD_UP_BUTTON_INDEX = 12;
|
||||
var _GAMEPAD_DPAD_DOWN_BUTTON_INDEX = 13;
|
||||
var _GAMEPAD_DPAD_LEFT_BUTTON_INDEX = 14;
|
||||
var _GAMEPAD_DPAD_RIGHT_BUTTON_INDEX = 15;
|
||||
var _GAMEPAD_A_KEY = 'GamepadA';
|
||||
var _GAMEPAD_B_KEY = 'GamepadB';
|
||||
var _GAMEPAD_DPAD_UP_KEY = 'GamepadDPadUp';
|
||||
var _GAMEPAD_DPAD_DOWN_KEY = 'GamepadDPadDown';
|
||||
var _GAMEPAD_DPAD_LEFT_KEY = 'GamepadDPadLeft';
|
||||
var _GAMEPAD_DPAD_RIGHT_KEY = 'GamepadDPadRight';
|
||||
var _GAMEPAD_LEFT_THUMBSTICK_UP_KEY = 'GamepadLeftThumbStickUp';
|
||||
var _GAMEPAD_LEFT_THUMBSTICK_DOWN_KEY = 'GamepadLeftThumbStickDown';
|
||||
var _GAMEPAD_LEFT_THUMBSTICK_LEFT_KEY = 'GamepadLeftThumbStickLeft';
|
||||
var _GAMEPAD_LEFT_THUMBSTICK_RIGHT_KEY = 'GamepadLeftThumbStickRight';
|
||||
var _GAMEPAD_A_KEYCODE = 0;
|
||||
var _GAMEPAD_B_KEYCODE = 27;
|
||||
var _GAMEPAD_DPAD_UP_KEYCODE = 38;
|
||||
var _GAMEPAD_DPAD_DOWN_KEYCODE = 40;
|
||||
var _GAMEPAD_DPAD_LEFT_KEYCODE = 37;
|
||||
var _GAMEPAD_DPAD_RIGHT_KEYCODE = 39;
|
||||
var _GAMEPAD_LEFT_THUMBSTICK_UP_KEYCODE = 38;
|
||||
var _GAMEPAD_LEFT_THUMBSTICK_DOWN_KEYCODE = 40;
|
||||
var _GAMEPAD_LEFT_THUMBSTICK_LEFT_KEYCODE = 37;
|
||||
var _GAMEPAD_LEFT_THUMBSTICK_RIGHT_KEYCODE = 39;
|
||||
var _THUMB_STICK_THRESHOLD = 0.75;
|
||||
import appHost from 'apphost';
|
||||
|
||||
var _leftThumbstickUpPressed = false;
|
||||
var _leftThumbstickDownPressed = false;
|
||||
var _leftThumbstickLeftPressed = false;
|
||||
var _leftThumbstickRightPressed = false;
|
||||
var _dPadUpPressed = false;
|
||||
var _dPadDownPressed = false;
|
||||
var _dPadLeftPressed = false;
|
||||
var _dPadRightPressed = false;
|
||||
var _gamepadAPressed = false;
|
||||
var _gamepadBPressed = false;
|
||||
var _GAMEPAD_A_BUTTON_INDEX = 0;
|
||||
var _GAMEPAD_B_BUTTON_INDEX = 1;
|
||||
var _GAMEPAD_DPAD_UP_BUTTON_INDEX = 12;
|
||||
var _GAMEPAD_DPAD_DOWN_BUTTON_INDEX = 13;
|
||||
var _GAMEPAD_DPAD_LEFT_BUTTON_INDEX = 14;
|
||||
var _GAMEPAD_DPAD_RIGHT_BUTTON_INDEX = 15;
|
||||
var _GAMEPAD_A_KEY = 'GamepadA';
|
||||
var _GAMEPAD_B_KEY = 'GamepadB';
|
||||
var _GAMEPAD_DPAD_UP_KEY = 'GamepadDPadUp';
|
||||
var _GAMEPAD_DPAD_DOWN_KEY = 'GamepadDPadDown';
|
||||
var _GAMEPAD_DPAD_LEFT_KEY = 'GamepadDPadLeft';
|
||||
var _GAMEPAD_DPAD_RIGHT_KEY = 'GamepadDPadRight';
|
||||
var _GAMEPAD_LEFT_THUMBSTICK_UP_KEY = 'GamepadLeftThumbStickUp';
|
||||
var _GAMEPAD_LEFT_THUMBSTICK_DOWN_KEY = 'GamepadLeftThumbStickDown';
|
||||
var _GAMEPAD_LEFT_THUMBSTICK_LEFT_KEY = 'GamepadLeftThumbStickLeft';
|
||||
var _GAMEPAD_LEFT_THUMBSTICK_RIGHT_KEY = 'GamepadLeftThumbStickRight';
|
||||
var _GAMEPAD_A_KEYCODE = 0;
|
||||
var _GAMEPAD_B_KEYCODE = 27;
|
||||
var _GAMEPAD_DPAD_UP_KEYCODE = 38;
|
||||
var _GAMEPAD_DPAD_DOWN_KEYCODE = 40;
|
||||
var _GAMEPAD_DPAD_LEFT_KEYCODE = 37;
|
||||
var _GAMEPAD_DPAD_RIGHT_KEYCODE = 39;
|
||||
var _GAMEPAD_LEFT_THUMBSTICK_UP_KEYCODE = 38;
|
||||
var _GAMEPAD_LEFT_THUMBSTICK_DOWN_KEYCODE = 40;
|
||||
var _GAMEPAD_LEFT_THUMBSTICK_LEFT_KEYCODE = 37;
|
||||
var _GAMEPAD_LEFT_THUMBSTICK_RIGHT_KEYCODE = 39;
|
||||
var _THUMB_STICK_THRESHOLD = 0.75;
|
||||
|
||||
// The set of buttons on the gamepad we listen for.
|
||||
var ProcessedButtons = [
|
||||
_GAMEPAD_DPAD_UP_BUTTON_INDEX,
|
||||
_GAMEPAD_DPAD_DOWN_BUTTON_INDEX,
|
||||
_GAMEPAD_DPAD_LEFT_BUTTON_INDEX,
|
||||
_GAMEPAD_DPAD_RIGHT_BUTTON_INDEX,
|
||||
_GAMEPAD_A_BUTTON_INDEX,
|
||||
_GAMEPAD_B_BUTTON_INDEX
|
||||
];
|
||||
var _leftThumbstickUpPressed = false;
|
||||
var _leftThumbstickDownPressed = false;
|
||||
var _leftThumbstickLeftPressed = false;
|
||||
var _leftThumbstickRightPressed = false;
|
||||
var _dPadUpPressed = false;
|
||||
var _dPadDownPressed = false;
|
||||
var _dPadLeftPressed = false;
|
||||
var _dPadRightPressed = false;
|
||||
var _gamepadAPressed = false;
|
||||
var _gamepadBPressed = false;
|
||||
|
||||
var _ButtonPressedState = {};
|
||||
_ButtonPressedState.getgamepadA = function () {
|
||||
return _gamepadAPressed;
|
||||
};
|
||||
// The set of buttons on the gamepad we listen for.
|
||||
var ProcessedButtons = [
|
||||
_GAMEPAD_DPAD_UP_BUTTON_INDEX,
|
||||
_GAMEPAD_DPAD_DOWN_BUTTON_INDEX,
|
||||
_GAMEPAD_DPAD_LEFT_BUTTON_INDEX,
|
||||
_GAMEPAD_DPAD_RIGHT_BUTTON_INDEX,
|
||||
_GAMEPAD_A_BUTTON_INDEX,
|
||||
_GAMEPAD_B_BUTTON_INDEX
|
||||
];
|
||||
|
||||
_ButtonPressedState.setgamepadA = function (newPressedState) {
|
||||
raiseKeyEvent(_gamepadAPressed, newPressedState, _GAMEPAD_A_KEY, _GAMEPAD_A_KEYCODE, false, true);
|
||||
_gamepadAPressed = newPressedState;
|
||||
};
|
||||
var _ButtonPressedState = {};
|
||||
_ButtonPressedState.getgamepadA = function () {
|
||||
return _gamepadAPressed;
|
||||
};
|
||||
|
||||
_ButtonPressedState.getgamepadB = function () {
|
||||
return _gamepadBPressed;
|
||||
};
|
||||
_ButtonPressedState.setgamepadA = function (newPressedState) {
|
||||
raiseKeyEvent(_gamepadAPressed, newPressedState, _GAMEPAD_A_KEY, _GAMEPAD_A_KEYCODE, false, true);
|
||||
_gamepadAPressed = newPressedState;
|
||||
};
|
||||
|
||||
_ButtonPressedState.setgamepadB = function (newPressedState) {
|
||||
raiseKeyEvent(_gamepadBPressed, newPressedState, _GAMEPAD_B_KEY, _GAMEPAD_B_KEYCODE);
|
||||
_gamepadBPressed = newPressedState;
|
||||
};
|
||||
_ButtonPressedState.getgamepadB = function () {
|
||||
return _gamepadBPressed;
|
||||
};
|
||||
|
||||
_ButtonPressedState.getleftThumbstickUp = function () {
|
||||
return _leftThumbstickUpPressed;
|
||||
};
|
||||
_ButtonPressedState.setgamepadB = function (newPressedState) {
|
||||
raiseKeyEvent(_gamepadBPressed, newPressedState, _GAMEPAD_B_KEY, _GAMEPAD_B_KEYCODE);
|
||||
_gamepadBPressed = newPressedState;
|
||||
};
|
||||
|
||||
_ButtonPressedState.setleftThumbstickUp = function (newPressedState) {
|
||||
raiseKeyEvent(_leftThumbstickUpPressed, newPressedState, _GAMEPAD_LEFT_THUMBSTICK_UP_KEY, _GAMEPAD_LEFT_THUMBSTICK_UP_KEYCODE, true);
|
||||
_leftThumbstickUpPressed = newPressedState;
|
||||
};
|
||||
_ButtonPressedState.getleftThumbstickUp = function () {
|
||||
return _leftThumbstickUpPressed;
|
||||
};
|
||||
|
||||
_ButtonPressedState.getleftThumbstickDown = function () {
|
||||
return _leftThumbstickDownPressed;
|
||||
};
|
||||
_ButtonPressedState.setleftThumbstickUp = function (newPressedState) {
|
||||
raiseKeyEvent(_leftThumbstickUpPressed, newPressedState, _GAMEPAD_LEFT_THUMBSTICK_UP_KEY, _GAMEPAD_LEFT_THUMBSTICK_UP_KEYCODE, true);
|
||||
_leftThumbstickUpPressed = newPressedState;
|
||||
};
|
||||
|
||||
_ButtonPressedState.setleftThumbstickDown = function (newPressedState) {
|
||||
raiseKeyEvent(_leftThumbstickDownPressed, newPressedState, _GAMEPAD_LEFT_THUMBSTICK_DOWN_KEY, _GAMEPAD_LEFT_THUMBSTICK_DOWN_KEYCODE, true);
|
||||
_leftThumbstickDownPressed = newPressedState;
|
||||
};
|
||||
_ButtonPressedState.getleftThumbstickDown = function () {
|
||||
return _leftThumbstickDownPressed;
|
||||
};
|
||||
|
||||
_ButtonPressedState.getleftThumbstickLeft = function () {
|
||||
return _leftThumbstickLeftPressed;
|
||||
};
|
||||
_ButtonPressedState.setleftThumbstickDown = function (newPressedState) {
|
||||
raiseKeyEvent(_leftThumbstickDownPressed, newPressedState, _GAMEPAD_LEFT_THUMBSTICK_DOWN_KEY, _GAMEPAD_LEFT_THUMBSTICK_DOWN_KEYCODE, true);
|
||||
_leftThumbstickDownPressed = newPressedState;
|
||||
};
|
||||
|
||||
_ButtonPressedState.setleftThumbstickLeft = function (newPressedState) {
|
||||
raiseKeyEvent(_leftThumbstickLeftPressed, newPressedState, _GAMEPAD_LEFT_THUMBSTICK_LEFT_KEY, _GAMEPAD_LEFT_THUMBSTICK_LEFT_KEYCODE, true);
|
||||
_leftThumbstickLeftPressed = newPressedState;
|
||||
};
|
||||
_ButtonPressedState.getleftThumbstickLeft = function () {
|
||||
return _leftThumbstickLeftPressed;
|
||||
};
|
||||
|
||||
_ButtonPressedState.getleftThumbstickRight = function () {
|
||||
return _leftThumbstickRightPressed;
|
||||
};
|
||||
_ButtonPressedState.setleftThumbstickLeft = function (newPressedState) {
|
||||
raiseKeyEvent(_leftThumbstickLeftPressed, newPressedState, _GAMEPAD_LEFT_THUMBSTICK_LEFT_KEY, _GAMEPAD_LEFT_THUMBSTICK_LEFT_KEYCODE, true);
|
||||
_leftThumbstickLeftPressed = newPressedState;
|
||||
};
|
||||
|
||||
_ButtonPressedState.setleftThumbstickRight = function (newPressedState) {
|
||||
raiseKeyEvent(_leftThumbstickRightPressed, newPressedState, _GAMEPAD_LEFT_THUMBSTICK_RIGHT_KEY, _GAMEPAD_LEFT_THUMBSTICK_RIGHT_KEYCODE, true);
|
||||
_leftThumbstickRightPressed = newPressedState;
|
||||
};
|
||||
_ButtonPressedState.getleftThumbstickRight = function () {
|
||||
return _leftThumbstickRightPressed;
|
||||
};
|
||||
|
||||
_ButtonPressedState.getdPadUp = function () {
|
||||
return _dPadUpPressed;
|
||||
};
|
||||
_ButtonPressedState.setleftThumbstickRight = function (newPressedState) {
|
||||
raiseKeyEvent(_leftThumbstickRightPressed, newPressedState, _GAMEPAD_LEFT_THUMBSTICK_RIGHT_KEY, _GAMEPAD_LEFT_THUMBSTICK_RIGHT_KEYCODE, true);
|
||||
_leftThumbstickRightPressed = newPressedState;
|
||||
};
|
||||
|
||||
_ButtonPressedState.setdPadUp = function (newPressedState) {
|
||||
raiseKeyEvent(_dPadUpPressed, newPressedState, _GAMEPAD_DPAD_UP_KEY, _GAMEPAD_DPAD_UP_KEYCODE, true);
|
||||
_dPadUpPressed = newPressedState;
|
||||
};
|
||||
_ButtonPressedState.getdPadUp = function () {
|
||||
return _dPadUpPressed;
|
||||
};
|
||||
|
||||
_ButtonPressedState.getdPadDown = function () {
|
||||
return _dPadDownPressed;
|
||||
};
|
||||
_ButtonPressedState.setdPadUp = function (newPressedState) {
|
||||
raiseKeyEvent(_dPadUpPressed, newPressedState, _GAMEPAD_DPAD_UP_KEY, _GAMEPAD_DPAD_UP_KEYCODE, true);
|
||||
_dPadUpPressed = newPressedState;
|
||||
};
|
||||
|
||||
_ButtonPressedState.setdPadDown = function (newPressedState) {
|
||||
raiseKeyEvent(_dPadDownPressed, newPressedState, _GAMEPAD_DPAD_DOWN_KEY, _GAMEPAD_DPAD_DOWN_KEYCODE, true);
|
||||
_dPadDownPressed = newPressedState;
|
||||
};
|
||||
_ButtonPressedState.getdPadDown = function () {
|
||||
return _dPadDownPressed;
|
||||
};
|
||||
|
||||
_ButtonPressedState.getdPadLeft = function () {
|
||||
return _dPadLeftPressed;
|
||||
};
|
||||
_ButtonPressedState.setdPadDown = function (newPressedState) {
|
||||
raiseKeyEvent(_dPadDownPressed, newPressedState, _GAMEPAD_DPAD_DOWN_KEY, _GAMEPAD_DPAD_DOWN_KEYCODE, true);
|
||||
_dPadDownPressed = newPressedState;
|
||||
};
|
||||
|
||||
_ButtonPressedState.setdPadLeft = function (newPressedState) {
|
||||
raiseKeyEvent(_dPadLeftPressed, newPressedState, _GAMEPAD_DPAD_LEFT_KEY, _GAMEPAD_DPAD_LEFT_KEYCODE, true);
|
||||
_dPadLeftPressed = newPressedState;
|
||||
};
|
||||
_ButtonPressedState.getdPadLeft = function () {
|
||||
return _dPadLeftPressed;
|
||||
};
|
||||
|
||||
_ButtonPressedState.getdPadRight = function () {
|
||||
return _dPadRightPressed;
|
||||
};
|
||||
_ButtonPressedState.setdPadLeft = function (newPressedState) {
|
||||
raiseKeyEvent(_dPadLeftPressed, newPressedState, _GAMEPAD_DPAD_LEFT_KEY, _GAMEPAD_DPAD_LEFT_KEYCODE, true);
|
||||
_dPadLeftPressed = newPressedState;
|
||||
};
|
||||
|
||||
_ButtonPressedState.setdPadRight = function (newPressedState) {
|
||||
raiseKeyEvent(_dPadRightPressed, newPressedState, _GAMEPAD_DPAD_RIGHT_KEY, _GAMEPAD_DPAD_RIGHT_KEYCODE, true);
|
||||
_dPadRightPressed = newPressedState;
|
||||
};
|
||||
_ButtonPressedState.getdPadRight = function () {
|
||||
return _dPadRightPressed;
|
||||
};
|
||||
|
||||
var times = {};
|
||||
_ButtonPressedState.setdPadRight = function (newPressedState) {
|
||||
raiseKeyEvent(_dPadRightPressed, newPressedState, _GAMEPAD_DPAD_RIGHT_KEY, _GAMEPAD_DPAD_RIGHT_KEYCODE, true);
|
||||
_dPadRightPressed = newPressedState;
|
||||
};
|
||||
|
||||
function throttle(key) {
|
||||
var time = times[key] || 0;
|
||||
var now = new Date().getTime();
|
||||
var times = {};
|
||||
|
||||
if ((now - time) >= 200) {
|
||||
//times[key] = now;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function resetThrottle(key) {
|
||||
times[key] = new Date().getTime();
|
||||
}
|
||||
|
||||
var isElectron = navigator.userAgent.toLowerCase().indexOf('electron') !== -1;
|
||||
function allowInput() {
|
||||
|
||||
// This would be nice but always seems to return true with electron
|
||||
if (!isElectron && document.hidden) { /* eslint-disable-line compat/compat */
|
||||
return false;
|
||||
}
|
||||
|
||||
if (appHost.getWindowState() === 'Minimized') {
|
||||
return false;
|
||||
}
|
||||
function throttle(key) {
|
||||
var time = times[key] || 0;
|
||||
var now = new Date().getTime();
|
||||
|
||||
if ((now - time) >= 200) {
|
||||
//times[key] = now;
|
||||
return true;
|
||||
}
|
||||
|
||||
function raiseEvent(name, key, keyCode) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!allowInput()) {
|
||||
return;
|
||||
}
|
||||
function resetThrottle(key) {
|
||||
times[key] = new Date().getTime();
|
||||
}
|
||||
|
||||
var event = document.createEvent('Event');
|
||||
event.initEvent(name, true, true);
|
||||
event.key = key;
|
||||
event.keyCode = keyCode;
|
||||
(document.activeElement || document.body).dispatchEvent(event);
|
||||
var isElectron = navigator.userAgent.toLowerCase().indexOf('electron') !== -1;
|
||||
function allowInput() {
|
||||
// This would be nice but always seems to return true with electron
|
||||
if (!isElectron && document.hidden) { /* eslint-disable-line compat/compat */
|
||||
return false;
|
||||
}
|
||||
|
||||
function clickElement(elem) {
|
||||
|
||||
if (!allowInput()) {
|
||||
return;
|
||||
}
|
||||
|
||||
elem.click();
|
||||
if (appHost.getWindowState() === 'Minimized') {
|
||||
return false;
|
||||
}
|
||||
|
||||
function raiseKeyEvent(oldPressedState, newPressedState, key, keyCode, enableRepeatKeyDown, clickonKeyUp) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// No-op if oldPressedState === newPressedState
|
||||
if (newPressedState === true) {
|
||||
function raiseEvent(name, key, keyCode) {
|
||||
if (!allowInput()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// button down
|
||||
var fire = false;
|
||||
var event = document.createEvent('Event');
|
||||
event.initEvent(name, true, true);
|
||||
event.key = key;
|
||||
event.keyCode = keyCode;
|
||||
(document.activeElement || document.body).dispatchEvent(event);
|
||||
}
|
||||
|
||||
// always fire if this is the initial down press
|
||||
if (oldPressedState === false) {
|
||||
fire = true;
|
||||
resetThrottle(key);
|
||||
} else if (enableRepeatKeyDown) {
|
||||
fire = throttle(key);
|
||||
}
|
||||
function clickElement(elem) {
|
||||
if (!allowInput()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (fire && keyCode) {
|
||||
raiseEvent('keydown', key, keyCode);
|
||||
}
|
||||
elem.click();
|
||||
}
|
||||
|
||||
} else if (newPressedState === false && oldPressedState === true) {
|
||||
function raiseKeyEvent(oldPressedState, newPressedState, key, keyCode, enableRepeatKeyDown, clickonKeyUp) {
|
||||
// No-op if oldPressedState === newPressedState
|
||||
if (newPressedState === true) {
|
||||
// button down
|
||||
var fire = false;
|
||||
|
||||
// always fire if this is the initial down press
|
||||
if (oldPressedState === false) {
|
||||
fire = true;
|
||||
resetThrottle(key);
|
||||
} else if (enableRepeatKeyDown) {
|
||||
fire = throttle(key);
|
||||
}
|
||||
|
||||
// button up
|
||||
if (keyCode) {
|
||||
raiseEvent('keyup', key, keyCode);
|
||||
}
|
||||
if (clickonKeyUp) {
|
||||
clickElement(document.activeElement || window);
|
||||
}
|
||||
if (fire && keyCode) {
|
||||
raiseEvent('keydown', key, keyCode);
|
||||
}
|
||||
} else if (newPressedState === false && oldPressedState === true) {
|
||||
resetThrottle(key);
|
||||
|
||||
// button up
|
||||
if (keyCode) {
|
||||
raiseEvent('keyup', key, keyCode);
|
||||
}
|
||||
if (clickonKeyUp) {
|
||||
clickElement(document.activeElement || window);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var inputLoopTimer;
|
||||
function runInputLoop() {
|
||||
// Get the latest gamepad state.
|
||||
var gamepads = navigator.getGamepads(); /* eslint-disable-line compat/compat */
|
||||
for (var i = 0, len = gamepads.length; i < len; i++) {
|
||||
var gamepad = gamepads[i];
|
||||
if (!gamepad) {
|
||||
continue;
|
||||
}
|
||||
// Iterate through the axes
|
||||
var axes = gamepad.axes;
|
||||
var leftStickX = axes[0];
|
||||
var leftStickY = axes[1];
|
||||
if (leftStickX > _THUMB_STICK_THRESHOLD) { // Right
|
||||
_ButtonPressedState.setleftThumbstickRight(true);
|
||||
} else if (leftStickX < -_THUMB_STICK_THRESHOLD) { // Left
|
||||
_ButtonPressedState.setleftThumbstickLeft(true);
|
||||
} else if (leftStickY < -_THUMB_STICK_THRESHOLD) { // Up
|
||||
_ButtonPressedState.setleftThumbstickUp(true);
|
||||
} else if (leftStickY > _THUMB_STICK_THRESHOLD) { // Down
|
||||
_ButtonPressedState.setleftThumbstickDown(true);
|
||||
} else {
|
||||
_ButtonPressedState.setleftThumbstickLeft(false);
|
||||
_ButtonPressedState.setleftThumbstickRight(false);
|
||||
_ButtonPressedState.setleftThumbstickUp(false);
|
||||
_ButtonPressedState.setleftThumbstickDown(false);
|
||||
}
|
||||
// Iterate through the buttons to see if Left thumbstick, DPad, A and B are pressed.
|
||||
var buttons = gamepad.buttons;
|
||||
for (var j = 0, len = buttons.length; j < len; j++) {
|
||||
if (ProcessedButtons.indexOf(j) !== -1) {
|
||||
if (buttons[j].pressed) {
|
||||
switch (j) {
|
||||
case _GAMEPAD_DPAD_UP_BUTTON_INDEX:
|
||||
_ButtonPressedState.setdPadUp(true);
|
||||
break;
|
||||
case _GAMEPAD_DPAD_DOWN_BUTTON_INDEX:
|
||||
_ButtonPressedState.setdPadDown(true);
|
||||
break;
|
||||
case _GAMEPAD_DPAD_LEFT_BUTTON_INDEX:
|
||||
_ButtonPressedState.setdPadLeft(true);
|
||||
break;
|
||||
case _GAMEPAD_DPAD_RIGHT_BUTTON_INDEX:
|
||||
_ButtonPressedState.setdPadRight(true);
|
||||
break;
|
||||
case _GAMEPAD_A_BUTTON_INDEX:
|
||||
_ButtonPressedState.setgamepadA(true);
|
||||
break;
|
||||
case _GAMEPAD_B_BUTTON_INDEX:
|
||||
_ButtonPressedState.setgamepadB(true);
|
||||
break;
|
||||
default:
|
||||
// No-op
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
switch (j) {
|
||||
case _GAMEPAD_DPAD_UP_BUTTON_INDEX:
|
||||
if (_ButtonPressedState.getdPadUp()) {
|
||||
_ButtonPressedState.setdPadUp(false);
|
||||
}
|
||||
break;
|
||||
case _GAMEPAD_DPAD_DOWN_BUTTON_INDEX:
|
||||
if (_ButtonPressedState.getdPadDown()) {
|
||||
_ButtonPressedState.setdPadDown(false);
|
||||
}
|
||||
break;
|
||||
case _GAMEPAD_DPAD_LEFT_BUTTON_INDEX:
|
||||
if (_ButtonPressedState.getdPadLeft()) {
|
||||
_ButtonPressedState.setdPadLeft(false);
|
||||
}
|
||||
break;
|
||||
case _GAMEPAD_DPAD_RIGHT_BUTTON_INDEX:
|
||||
if (_ButtonPressedState.getdPadRight()) {
|
||||
_ButtonPressedState.setdPadRight(false);
|
||||
}
|
||||
break;
|
||||
case _GAMEPAD_A_BUTTON_INDEX:
|
||||
if (_ButtonPressedState.getgamepadA()) {
|
||||
_ButtonPressedState.setgamepadA(false);
|
||||
}
|
||||
break;
|
||||
case _GAMEPAD_B_BUTTON_INDEX:
|
||||
if (_ButtonPressedState.getgamepadB()) {
|
||||
_ButtonPressedState.setgamepadB(false);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
// No-op
|
||||
break;
|
||||
}
|
||||
var inputLoopTimer;
|
||||
function runInputLoop() {
|
||||
// Get the latest gamepad state.
|
||||
var gamepads = navigator.getGamepads(); /* eslint-disable-line compat/compat */
|
||||
for (var i = 0, len = gamepads.length; i < len; i++) {
|
||||
var gamepad = gamepads[i];
|
||||
if (!gamepad) {
|
||||
continue;
|
||||
}
|
||||
// Iterate through the axes
|
||||
var axes = gamepad.axes;
|
||||
var leftStickX = axes[0];
|
||||
var leftStickY = axes[1];
|
||||
if (leftStickX > _THUMB_STICK_THRESHOLD) { // Right
|
||||
_ButtonPressedState.setleftThumbstickRight(true);
|
||||
} else if (leftStickX < -_THUMB_STICK_THRESHOLD) { // Left
|
||||
_ButtonPressedState.setleftThumbstickLeft(true);
|
||||
} else if (leftStickY < -_THUMB_STICK_THRESHOLD) { // Up
|
||||
_ButtonPressedState.setleftThumbstickUp(true);
|
||||
} else if (leftStickY > _THUMB_STICK_THRESHOLD) { // Down
|
||||
_ButtonPressedState.setleftThumbstickDown(true);
|
||||
} else {
|
||||
_ButtonPressedState.setleftThumbstickLeft(false);
|
||||
_ButtonPressedState.setleftThumbstickRight(false);
|
||||
_ButtonPressedState.setleftThumbstickUp(false);
|
||||
_ButtonPressedState.setleftThumbstickDown(false);
|
||||
}
|
||||
// Iterate through the buttons to see if Left thumbstick, DPad, A and B are pressed.
|
||||
var buttons = gamepad.buttons;
|
||||
for (var j = 0, len = buttons.length; j < len; j++) {
|
||||
if (ProcessedButtons.indexOf(j) !== -1) {
|
||||
if (buttons[j].pressed) {
|
||||
switch (j) {
|
||||
case _GAMEPAD_DPAD_UP_BUTTON_INDEX:
|
||||
_ButtonPressedState.setdPadUp(true);
|
||||
break;
|
||||
case _GAMEPAD_DPAD_DOWN_BUTTON_INDEX:
|
||||
_ButtonPressedState.setdPadDown(true);
|
||||
break;
|
||||
case _GAMEPAD_DPAD_LEFT_BUTTON_INDEX:
|
||||
_ButtonPressedState.setdPadLeft(true);
|
||||
break;
|
||||
case _GAMEPAD_DPAD_RIGHT_BUTTON_INDEX:
|
||||
_ButtonPressedState.setdPadRight(true);
|
||||
break;
|
||||
case _GAMEPAD_A_BUTTON_INDEX:
|
||||
_ButtonPressedState.setgamepadA(true);
|
||||
break;
|
||||
case _GAMEPAD_B_BUTTON_INDEX:
|
||||
_ButtonPressedState.setgamepadB(true);
|
||||
break;
|
||||
default:
|
||||
// No-op
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
switch (j) {
|
||||
case _GAMEPAD_DPAD_UP_BUTTON_INDEX:
|
||||
if (_ButtonPressedState.getdPadUp()) {
|
||||
_ButtonPressedState.setdPadUp(false);
|
||||
}
|
||||
break;
|
||||
case _GAMEPAD_DPAD_DOWN_BUTTON_INDEX:
|
||||
if (_ButtonPressedState.getdPadDown()) {
|
||||
_ButtonPressedState.setdPadDown(false);
|
||||
}
|
||||
break;
|
||||
case _GAMEPAD_DPAD_LEFT_BUTTON_INDEX:
|
||||
if (_ButtonPressedState.getdPadLeft()) {
|
||||
_ButtonPressedState.setdPadLeft(false);
|
||||
}
|
||||
break;
|
||||
case _GAMEPAD_DPAD_RIGHT_BUTTON_INDEX:
|
||||
if (_ButtonPressedState.getdPadRight()) {
|
||||
_ButtonPressedState.setdPadRight(false);
|
||||
}
|
||||
break;
|
||||
case _GAMEPAD_A_BUTTON_INDEX:
|
||||
if (_ButtonPressedState.getgamepadA()) {
|
||||
_ButtonPressedState.setgamepadA(false);
|
||||
}
|
||||
break;
|
||||
case _GAMEPAD_B_BUTTON_INDEX:
|
||||
if (_ButtonPressedState.getgamepadB()) {
|
||||
_ButtonPressedState.setgamepadB(false);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
// No-op
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Schedule the next one
|
||||
inputLoopTimer = requestAnimationFrame(runInputLoop);
|
||||
}
|
||||
// Schedule the next one
|
||||
inputLoopTimer = requestAnimationFrame(runInputLoop);
|
||||
}
|
||||
|
||||
function startInputLoop() {
|
||||
if (!inputLoopTimer) {
|
||||
runInputLoop();
|
||||
function startInputLoop() {
|
||||
if (!inputLoopTimer) {
|
||||
runInputLoop();
|
||||
}
|
||||
}
|
||||
|
||||
function stopInputLoop() {
|
||||
cancelAnimationFrame(inputLoopTimer);
|
||||
inputLoopTimer = undefined;
|
||||
}
|
||||
|
||||
function isGamepadConnected() {
|
||||
var gamepads = navigator.getGamepads(); /* eslint-disable-line compat/compat */
|
||||
for (var i = 0, len = gamepads.length; i < len; i++) {
|
||||
var gamepad = gamepads[i];
|
||||
if (gamepad && gamepad.connected) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function stopInputLoop() {
|
||||
cancelAnimationFrame(inputLoopTimer);
|
||||
inputLoopTimer = undefined;
|
||||
function onFocusOrGamepadAttach(e) {
|
||||
/* eslint-disable-next-line compat/compat */
|
||||
if (isGamepadConnected() && document.hasFocus()) {
|
||||
console.log('Gamepad connected! Starting input loop');
|
||||
startInputLoop();
|
||||
}
|
||||
}
|
||||
|
||||
function isGamepadConnected() {
|
||||
var gamepads = navigator.getGamepads(); /* eslint-disable-line compat/compat */
|
||||
for (var i = 0, len = gamepads.length; i < len; i++) {
|
||||
var gamepad = gamepads[i];
|
||||
if (gamepad && gamepad.connected) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
function onFocusOrGamepadDetach(e) {
|
||||
/* eslint-disable-next-line compat/compat */
|
||||
if (!isGamepadConnected() || !document.hasFocus()) {
|
||||
console.log('Gamepad disconnected! No other gamepads are connected, stopping input loop');
|
||||
stopInputLoop();
|
||||
} else {
|
||||
console.log('Gamepad disconnected! There are gamepads still connected.');
|
||||
}
|
||||
}
|
||||
|
||||
function onFocusOrGamepadAttach(e) {
|
||||
/* eslint-disable-next-line compat/compat */
|
||||
if (isGamepadConnected() && document.hasFocus()) {
|
||||
console.log('Gamepad connected! Starting input loop');
|
||||
startInputLoop();
|
||||
}
|
||||
}
|
||||
// Event listeners for any change in gamepads' state.
|
||||
window.addEventListener('gamepaddisconnected', onFocusOrGamepadDetach);
|
||||
window.addEventListener('gamepadconnected', onFocusOrGamepadAttach);
|
||||
window.addEventListener('blur', onFocusOrGamepadDetach);
|
||||
window.addEventListener('focus', onFocusOrGamepadAttach);
|
||||
|
||||
function onFocusOrGamepadDetach(e) {
|
||||
/* eslint-disable-next-line compat/compat */
|
||||
if (!isGamepadConnected() || !document.hasFocus()) {
|
||||
console.log('Gamepad disconnected! No other gamepads are connected, stopping input loop');
|
||||
stopInputLoop();
|
||||
} else {
|
||||
console.log('Gamepad disconnected! There are gamepads still connected.');
|
||||
}
|
||||
}
|
||||
onFocusOrGamepadAttach();
|
||||
|
||||
// Event listeners for any change in gamepads' state.
|
||||
window.addEventListener('gamepaddisconnected', onFocusOrGamepadDetach);
|
||||
window.addEventListener('gamepadconnected', onFocusOrGamepadAttach);
|
||||
window.addEventListener('blur', onFocusOrGamepadDetach);
|
||||
window.addEventListener('focus', onFocusOrGamepadAttach);
|
||||
|
||||
onFocusOrGamepadAttach();
|
||||
|
||||
// The gamepadInputEmulation is a string property that exists in JavaScript UWAs and in WebViews in UWAs.
|
||||
// It won't exist in Win8.1 style apps or browsers.
|
||||
if (window.navigator && typeof window.navigator.gamepadInputEmulation === 'string') {
|
||||
// We want the gamepad to provide gamepad VK keyboard events rather than moving a
|
||||
// mouse like cursor. Set to "keyboard", the gamepad will provide such keyboard events
|
||||
// and provide input to the DOM navigator.getGamepads API.
|
||||
window.navigator.gamepadInputEmulation = 'gamepad';
|
||||
}
|
||||
|
||||
});
|
||||
// The gamepadInputEmulation is a string property that exists in JavaScript UWAs and in WebViews in UWAs.
|
||||
// It won't exist in Win8.1 style apps or browsers.
|
||||
if (window.navigator && typeof window.navigator.gamepadInputEmulation === 'string') {
|
||||
// We want the gamepad to provide gamepad VK keyboard events rather than moving a
|
||||
// mouse like cursor. Set to "keyboard", the gamepad will provide such keyboard events
|
||||
// and provide input to the DOM navigator.getGamepads API.
|
||||
window.navigator.gamepadInputEmulation = 'gamepad';
|
||||
}
|
||||
|
|
|
@ -1,21 +1,24 @@
|
|||
define(['userSettings', 'events'], function (userSettings, events) {
|
||||
'use strict';
|
||||
var fallbackCulture = 'en-us';
|
||||
import * as userSettings from 'userSettings';
|
||||
import events from 'events';
|
||||
|
||||
var allTranslations = {};
|
||||
var currentCulture;
|
||||
var currentDateTimeCulture;
|
||||
/* eslint-disable indent */
|
||||
|
||||
function getCurrentLocale() {
|
||||
const fallbackCulture = 'en-us';
|
||||
|
||||
const allTranslations = {};
|
||||
let currentCulture;
|
||||
let currentDateTimeCulture;
|
||||
|
||||
export function getCurrentLocale() {
|
||||
return currentCulture;
|
||||
}
|
||||
|
||||
function getCurrentDateTimeLocale() {
|
||||
export function getCurrentDateTimeLocale() {
|
||||
return currentDateTimeCulture;
|
||||
}
|
||||
|
||||
function getDefaultLanguage() {
|
||||
var culture = document.documentElement.getAttribute('data-culture');
|
||||
const culture = document.documentElement.getAttribute('data-culture');
|
||||
if (culture) {
|
||||
return culture;
|
||||
}
|
||||
|
@ -33,8 +36,8 @@ define(['userSettings', 'events'], function (userSettings, events) {
|
|||
return fallbackCulture;
|
||||
}
|
||||
|
||||
function updateCurrentCulture() {
|
||||
var culture;
|
||||
export function updateCurrentCulture() {
|
||||
let culture;
|
||||
try {
|
||||
culture = userSettings.language();
|
||||
} catch (err) {
|
||||
|
@ -44,7 +47,7 @@ define(['userSettings', 'events'], function (userSettings, events) {
|
|||
|
||||
currentCulture = normalizeLocaleName(culture);
|
||||
|
||||
var dateTimeCulture;
|
||||
let dateTimeCulture;
|
||||
try {
|
||||
dateTimeCulture = userSettings.dateTimeLocale();
|
||||
} catch (err) {
|
||||
|
@ -60,11 +63,11 @@ define(['userSettings', 'events'], function (userSettings, events) {
|
|||
}
|
||||
|
||||
function ensureTranslations(culture) {
|
||||
for (var i in allTranslations) {
|
||||
for (const i in allTranslations) {
|
||||
ensureTranslation(allTranslations[i], culture);
|
||||
}
|
||||
if (culture !== fallbackCulture) {
|
||||
for (var i in allTranslations) {
|
||||
for (const i in allTranslations) {
|
||||
ensureTranslation(allTranslations[i], fallbackCulture);
|
||||
}
|
||||
}
|
||||
|
@ -85,14 +88,14 @@ define(['userSettings', 'events'], function (userSettings, events) {
|
|||
culture = culture.replace('_', '-');
|
||||
|
||||
// convert de-DE to de
|
||||
var parts = culture.split('-');
|
||||
const parts = culture.split('-');
|
||||
if (parts.length === 2) {
|
||||
if (parts[0].toLowerCase() === parts[1].toLowerCase()) {
|
||||
culture = parts[0].toLowerCase();
|
||||
}
|
||||
}
|
||||
|
||||
var lower = culture.toLowerCase();
|
||||
const lower = culture.toLowerCase();
|
||||
if (lower === 'ca-es') {
|
||||
return 'ca';
|
||||
}
|
||||
|
@ -110,7 +113,7 @@ define(['userSettings', 'events'], function (userSettings, events) {
|
|||
module = defaultModule();
|
||||
}
|
||||
|
||||
var translations = allTranslations[module];
|
||||
const translations = allTranslations[module];
|
||||
if (!translations) {
|
||||
return {};
|
||||
}
|
||||
|
@ -118,17 +121,17 @@ define(['userSettings', 'events'], function (userSettings, events) {
|
|||
return translations.dictionaries[locale];
|
||||
}
|
||||
|
||||
function register(options) {
|
||||
export function register(options) {
|
||||
allTranslations[options.name] = {
|
||||
translations: options.strings || options.translations,
|
||||
dictionaries: {}
|
||||
};
|
||||
}
|
||||
|
||||
function loadStrings(options) {
|
||||
var locale = getCurrentLocale();
|
||||
var promises = [];
|
||||
var optionsName;
|
||||
export function loadStrings(options) {
|
||||
const locale = getCurrentLocale();
|
||||
const promises = [];
|
||||
let optionsName;
|
||||
if (typeof options === 'string') {
|
||||
optionsName = options;
|
||||
} else {
|
||||
|
@ -140,10 +143,10 @@ define(['userSettings', 'events'], function (userSettings, events) {
|
|||
return Promise.all(promises);
|
||||
}
|
||||
|
||||
var cacheParam = new Date().getTime();
|
||||
const cacheParam = new Date().getTime();
|
||||
function loadTranslation(translations, lang) {
|
||||
lang = normalizeLocaleName(lang);
|
||||
var filtered = translations.filter(function (t) {
|
||||
let filtered = translations.filter(function (t) {
|
||||
return normalizeLocaleName(t.lang) === lang;
|
||||
});
|
||||
|
||||
|
@ -159,12 +162,12 @@ define(['userSettings', 'events'], function (userSettings, events) {
|
|||
return;
|
||||
}
|
||||
|
||||
var url = filtered[0].path;
|
||||
let url = filtered[0].path;
|
||||
|
||||
url += url.indexOf('?') === -1 ? '?' : '&';
|
||||
url += 'v=' + cacheParam;
|
||||
|
||||
var xhr = new XMLHttpRequest();
|
||||
const xhr = new XMLHttpRequest();
|
||||
xhr.open('GET', url, true);
|
||||
|
||||
xhr.onload = function (e) {
|
||||
|
@ -183,8 +186,8 @@ define(['userSettings', 'events'], function (userSettings, events) {
|
|||
}
|
||||
|
||||
function translateKey(key) {
|
||||
var parts = key.split('#');
|
||||
var module;
|
||||
const parts = key.split('#');
|
||||
let module;
|
||||
|
||||
if (parts.length > 1) {
|
||||
module = parts[0];
|
||||
|
@ -195,7 +198,7 @@ define(['userSettings', 'events'], function (userSettings, events) {
|
|||
}
|
||||
|
||||
function translateKeyFromModule(key, module) {
|
||||
var dictionary = getDictionary(module, getCurrentLocale());
|
||||
let dictionary = getDictionary(module, getCurrentLocale());
|
||||
if (!dictionary || !dictionary[key]) {
|
||||
dictionary = getDictionary(module, fallbackCulture);
|
||||
}
|
||||
|
@ -209,15 +212,15 @@ define(['userSettings', 'events'], function (userSettings, events) {
|
|||
return str.split(find).join(replace);
|
||||
}
|
||||
|
||||
function translate(key) {
|
||||
var val = translateKey(key);
|
||||
for (var i = 1; i < arguments.length; i++) {
|
||||
export function translate(key) {
|
||||
let val = translateKey(key);
|
||||
for (let i = 1; i < arguments.length; i++) {
|
||||
val = replaceAll(val, '{' + (i - 1) + '}', arguments[i]);
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
function translateHtml(html, module) {
|
||||
export function translateHtml(html, module) {
|
||||
if (!module) {
|
||||
module = defaultModule();
|
||||
}
|
||||
|
@ -225,26 +228,26 @@ define(['userSettings', 'events'], function (userSettings, events) {
|
|||
throw new Error('module cannot be null or empty');
|
||||
}
|
||||
|
||||
var startIndex = html.indexOf('${');
|
||||
let startIndex = html.indexOf('${');
|
||||
if (startIndex === -1) {
|
||||
return html;
|
||||
}
|
||||
|
||||
startIndex += 2;
|
||||
var endIndex = html.indexOf('}', startIndex);
|
||||
const endIndex = html.indexOf('}', startIndex);
|
||||
if (endIndex === -1) {
|
||||
return html;
|
||||
}
|
||||
|
||||
var key = html.substring(startIndex, endIndex);
|
||||
var val = translateKeyFromModule(key, module);
|
||||
const key = html.substring(startIndex, endIndex);
|
||||
const val = translateKeyFromModule(key, module);
|
||||
|
||||
html = html.replace('${' + key + '}', val);
|
||||
return translateHtml(html, module);
|
||||
}
|
||||
|
||||
var _defaultModule;
|
||||
function defaultModule(val) {
|
||||
let _defaultModule;
|
||||
export function defaultModule(val) {
|
||||
if (val) {
|
||||
_defaultModule = val;
|
||||
}
|
||||
|
@ -259,16 +262,15 @@ define(['userSettings', 'events'], function (userSettings, events) {
|
|||
}
|
||||
});
|
||||
|
||||
return {
|
||||
getString: translate,
|
||||
translate: translate,
|
||||
translateDocument: translateHtml,
|
||||
translateHtml: translateHtml,
|
||||
loadStrings: loadStrings,
|
||||
defaultModule: defaultModule,
|
||||
getCurrentLocale: getCurrentLocale,
|
||||
getCurrentDateTimeLocale: getCurrentDateTimeLocale,
|
||||
register: register,
|
||||
updateCurrentCulture: updateCurrentCulture
|
||||
};
|
||||
});
|
||||
export default {
|
||||
translate,
|
||||
translateHtml,
|
||||
loadStrings,
|
||||
defaultModule,
|
||||
getCurrentLocale,
|
||||
getCurrentDateTimeLocale,
|
||||
register,
|
||||
updateCurrentCulture
|
||||
};
|
||||
|
||||
/* eslint-enable indent */
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/* eslint-disable indent */
|
||||
|
||||
import browser from 'browser';
|
||||
/* eslint-disable indent */
|
||||
|
||||
export function getDeviceIcon(device) {
|
||||
var baseUrl = 'assets/img/devices/';
|
||||
|
@ -32,6 +31,11 @@ import browser from 'browser';
|
|||
case 'Safari iPad':
|
||||
case 'Safari iPhone':
|
||||
return baseUrl + 'safari.svg';
|
||||
case 'Edge Chromium':
|
||||
case 'Edge Chromium Android':
|
||||
case 'Edge Chromium iPad':
|
||||
case 'Edge Chromium iPhone':
|
||||
return baseUrl + 'edgechromium.svg';
|
||||
case 'Edge':
|
||||
return baseUrl + 'edge.svg';
|
||||
case 'Internet Explorer':
|
||||
|
|
|
@ -35,13 +35,13 @@ import appHost from 'apphost';
|
|||
if (eventListenerCount) {
|
||||
eventListenerCount--;
|
||||
}
|
||||
|
||||
dom.removeEventListener(scope, 'command', fn, {});
|
||||
}
|
||||
|
||||
let commandTimes = {};
|
||||
const commandTimes = {};
|
||||
|
||||
function checkCommandTime(command) {
|
||||
|
||||
const last = commandTimes[command] || 0;
|
||||
const now = new Date().getTime();
|
||||
|
||||
|
@ -54,7 +54,6 @@ import appHost from 'apphost';
|
|||
}
|
||||
|
||||
export function handleCommand(commandName, options) {
|
||||
|
||||
lastInputTime = new Date().getTime();
|
||||
|
||||
let sourceElement = (options ? options.sourceElement : null);
|
||||
|
@ -66,9 +65,12 @@ import appHost from 'apphost';
|
|||
if (!sourceElement) {
|
||||
sourceElement = document.activeElement || window;
|
||||
|
||||
const dlg = document.querySelector('.dialogContainer .dialog.opened');
|
||||
const dialogs = document.querySelectorAll('.dialogContainer .dialog.opened');
|
||||
|
||||
if (dlg && (!sourceElement || !dlg.contains(sourceElement))) {
|
||||
// Suppose the top open dialog is active
|
||||
const dlg = dialogs.length ? dialogs[dialogs.length - 1] : null;
|
||||
|
||||
if (dlg && !dlg.contains(sourceElement)) {
|
||||
sourceElement = dlg;
|
||||
}
|
||||
}
|
||||
|
@ -183,6 +185,12 @@ import appHost from 'apphost';
|
|||
'changezoom': () => {
|
||||
playbackManager.toggleAspectRatio();
|
||||
},
|
||||
'increaseplaybackrate': () => {
|
||||
playbackManager.increasePlaybackRate();
|
||||
},
|
||||
'decreaseplaybackrate': () => {
|
||||
playbackManager.decreasePlaybackRate();
|
||||
},
|
||||
'changeaudiotrack': () => {
|
||||
playbackManager.changeAudioStream();
|
||||
},
|
||||
|
@ -201,6 +209,9 @@ import appHost from 'apphost';
|
|||
'rewind': () => {
|
||||
playbackManager.rewind();
|
||||
},
|
||||
'seek': () => {
|
||||
playbackManager.seekMs(options);
|
||||
},
|
||||
'togglefullscreen': () => {
|
||||
playbackManager.toggleFullscreen();
|
||||
},
|
||||
|
@ -235,9 +246,6 @@ import appHost from 'apphost';
|
|||
}
|
||||
}
|
||||
|
||||
// Alias for backward compatibility
|
||||
export const trigger = handleCommand;
|
||||
|
||||
dom.addEventListener(document, 'click', notify, {
|
||||
passive: true
|
||||
});
|
||||
|
@ -245,8 +253,7 @@ import appHost from 'apphost';
|
|||
/* eslint-enable indent */
|
||||
|
||||
export default {
|
||||
trigger: handleCommand,
|
||||
handle: handleCommand,
|
||||
handleCommand: handleCommand,
|
||||
notify: notify,
|
||||
notifyMouseMove: notifyMouseMove,
|
||||
idleTime: idleTime,
|
||||
|
|
|
@ -1,369 +1,374 @@
|
|||
define(['connectionManager', 'listView', 'cardBuilder', 'imageLoader', 'libraryBrowser', 'globalize', 'emby-itemscontainer', 'emby-button'], function (connectionManager, listView, cardBuilder, imageLoader, libraryBrowser, globalize) {
|
||||
'use strict';
|
||||
import connectionManager from 'connectionManager';
|
||||
import listView from 'listView';
|
||||
import cardBuilder from 'cardBuilder';
|
||||
import imageLoader from 'imageLoader';
|
||||
import globalize from 'globalize';
|
||||
import 'emby-itemscontainer';
|
||||
import 'emby-button';
|
||||
|
||||
function renderItems(page, item) {
|
||||
var sections = [];
|
||||
function renderItems(page, item) {
|
||||
const sections = [];
|
||||
|
||||
if (item.ArtistCount) {
|
||||
sections.push({
|
||||
name: globalize.translate('TabArtists'),
|
||||
type: 'MusicArtist'
|
||||
});
|
||||
}
|
||||
|
||||
if (item.ProgramCount && 'Person' == item.Type) {
|
||||
sections.push({
|
||||
name: globalize.translate('HeaderUpcomingOnTV'),
|
||||
type: 'Program'
|
||||
});
|
||||
}
|
||||
|
||||
if (item.MovieCount) {
|
||||
sections.push({
|
||||
name: globalize.translate('TabMovies'),
|
||||
type: 'Movie'
|
||||
});
|
||||
}
|
||||
|
||||
if (item.SeriesCount) {
|
||||
sections.push({
|
||||
name: globalize.translate('TabShows'),
|
||||
type: 'Series'
|
||||
});
|
||||
}
|
||||
|
||||
if (item.EpisodeCount) {
|
||||
sections.push({
|
||||
name: globalize.translate('TabEpisodes'),
|
||||
type: 'Episode'
|
||||
});
|
||||
}
|
||||
|
||||
if (item.TrailerCount) {
|
||||
sections.push({
|
||||
name: globalize.translate('TabTrailers'),
|
||||
type: 'Trailer'
|
||||
});
|
||||
}
|
||||
|
||||
if (item.AlbumCount) {
|
||||
sections.push({
|
||||
name: globalize.translate('TabAlbums'),
|
||||
type: 'MusicAlbum'
|
||||
});
|
||||
}
|
||||
|
||||
if (item.MusicVideoCount) {
|
||||
sections.push({
|
||||
name: globalize.translate('TabMusicVideos'),
|
||||
type: 'MusicVideo'
|
||||
});
|
||||
}
|
||||
|
||||
var elem = page.querySelector('#childrenContent');
|
||||
elem.innerHTML = sections.map(function (section) {
|
||||
var html = '';
|
||||
var sectionClass = 'verticalSection';
|
||||
|
||||
if ('Audio' === section.type) {
|
||||
sectionClass += ' verticalSection-extrabottompadding';
|
||||
}
|
||||
|
||||
html += '<div class="' + sectionClass + '" data-type="' + section.type + '">';
|
||||
html += '<div class="sectionTitleContainer sectionTitleContainer-cards">';
|
||||
html += '<h2 class="sectionTitle sectionTitle-cards padded-left">';
|
||||
html += section.name;
|
||||
html += '</h2>';
|
||||
html += '<a is="emby-linkbutton" href="#" class="clearLink hide" style="margin-left:1em;vertical-align:middle;"><button is="emby-button" type="button" class="raised more raised-mini noIcon">' + globalize.translate('ButtonMore') + '</button></a>';
|
||||
html += '</div>';
|
||||
html += '<div is="emby-itemscontainer" class="itemsContainer padded-left padded-right">';
|
||||
html += '</div>';
|
||||
return html += '</div>';
|
||||
}).join('');
|
||||
var sectionElems = elem.querySelectorAll('.verticalSection');
|
||||
|
||||
for (var i = 0, length = sectionElems.length; i < length; i++) {
|
||||
renderSection(page, item, sectionElems[i], sectionElems[i].getAttribute('data-type'));
|
||||
}
|
||||
}
|
||||
|
||||
function renderSection(page, item, element, type) {
|
||||
switch (type) {
|
||||
case 'Program':
|
||||
loadItems(element, item, type, {
|
||||
MediaTypes: '',
|
||||
IncludeItemTypes: 'Program',
|
||||
PersonTypes: '',
|
||||
ArtistIds: '',
|
||||
AlbumArtistIds: '',
|
||||
Limit: 10,
|
||||
SortBy: 'StartDate'
|
||||
}, {
|
||||
shape: 'overflowBackdrop',
|
||||
showTitle: true,
|
||||
centerText: true,
|
||||
overlayMoreButton: true,
|
||||
preferThumb: true,
|
||||
overlayText: false,
|
||||
showAirTime: true,
|
||||
showAirDateTime: true,
|
||||
showChannelName: true
|
||||
});
|
||||
break;
|
||||
|
||||
case 'Movie':
|
||||
loadItems(element, item, type, {
|
||||
MediaTypes: '',
|
||||
IncludeItemTypes: 'Movie',
|
||||
PersonTypes: '',
|
||||
ArtistIds: '',
|
||||
AlbumArtistIds: '',
|
||||
Limit: 10,
|
||||
SortBy: 'SortName'
|
||||
}, {
|
||||
shape: 'overflowPortrait',
|
||||
showTitle: true,
|
||||
centerText: true,
|
||||
overlayMoreButton: true,
|
||||
overlayText: false,
|
||||
showYear: true
|
||||
});
|
||||
break;
|
||||
|
||||
case 'MusicVideo':
|
||||
loadItems(element, item, type, {
|
||||
MediaTypes: '',
|
||||
IncludeItemTypes: 'MusicVideo',
|
||||
PersonTypes: '',
|
||||
ArtistIds: '',
|
||||
AlbumArtistIds: '',
|
||||
Limit: 10,
|
||||
SortBy: 'SortName'
|
||||
}, {
|
||||
shape: 'overflowPortrait',
|
||||
showTitle: true,
|
||||
centerText: true,
|
||||
overlayPlayButton: true
|
||||
});
|
||||
break;
|
||||
|
||||
case 'Trailer':
|
||||
loadItems(element, item, type, {
|
||||
MediaTypes: '',
|
||||
IncludeItemTypes: 'Trailer',
|
||||
PersonTypes: '',
|
||||
ArtistIds: '',
|
||||
AlbumArtistIds: '',
|
||||
Limit: 10,
|
||||
SortBy: 'SortName'
|
||||
}, {
|
||||
shape: 'overflowPortrait',
|
||||
showTitle: true,
|
||||
centerText: true,
|
||||
overlayPlayButton: true
|
||||
});
|
||||
break;
|
||||
|
||||
case 'Series':
|
||||
loadItems(element, item, type, {
|
||||
MediaTypes: '',
|
||||
IncludeItemTypes: 'Series',
|
||||
PersonTypes: '',
|
||||
ArtistIds: '',
|
||||
AlbumArtistIds: '',
|
||||
Limit: 10,
|
||||
SortBy: 'SortName'
|
||||
}, {
|
||||
shape: 'overflowPortrait',
|
||||
showTitle: true,
|
||||
centerText: true,
|
||||
overlayMoreButton: true
|
||||
});
|
||||
break;
|
||||
|
||||
case 'MusicAlbum':
|
||||
loadItems(element, item, type, {
|
||||
MediaTypes: '',
|
||||
IncludeItemTypes: 'MusicAlbum',
|
||||
PersonTypes: '',
|
||||
ArtistIds: '',
|
||||
AlbumArtistIds: '',
|
||||
SortOrder: 'Descending',
|
||||
SortBy: 'ProductionYear,Sortname'
|
||||
}, {
|
||||
shape: 'overflowSquare',
|
||||
playFromHere: true,
|
||||
showTitle: true,
|
||||
showYear: true,
|
||||
coverImage: true,
|
||||
centerText: true,
|
||||
overlayPlayButton: true
|
||||
});
|
||||
break;
|
||||
|
||||
case 'MusicArtist':
|
||||
loadItems(element, item, type, {
|
||||
MediaTypes: '',
|
||||
IncludeItemTypes: 'MusicArtist',
|
||||
PersonTypes: '',
|
||||
ArtistIds: '',
|
||||
AlbumArtistIds: '',
|
||||
Limit: 8,
|
||||
SortBy: 'SortName'
|
||||
}, {
|
||||
shape: 'overflowSquare',
|
||||
playFromHere: true,
|
||||
showTitle: true,
|
||||
showParentTitle: true,
|
||||
coverImage: true,
|
||||
centerText: true,
|
||||
overlayPlayButton: true
|
||||
});
|
||||
break;
|
||||
|
||||
case 'Episode':
|
||||
loadItems(element, item, type, {
|
||||
MediaTypes: '',
|
||||
IncludeItemTypes: 'Episode',
|
||||
PersonTypes: '',
|
||||
ArtistIds: '',
|
||||
AlbumArtistIds: '',
|
||||
Limit: 6,
|
||||
SortBy: 'SortName'
|
||||
}, {
|
||||
shape: 'overflowBackdrop',
|
||||
showTitle: true,
|
||||
showParentTitle: true,
|
||||
centerText: true,
|
||||
overlayPlayButton: true
|
||||
});
|
||||
break;
|
||||
|
||||
case 'Audio':
|
||||
loadItems(element, item, type, {
|
||||
MediaTypes: '',
|
||||
IncludeItemTypes: 'Audio',
|
||||
PersonTypes: '',
|
||||
ArtistIds: '',
|
||||
AlbumArtistIds: '',
|
||||
SortBy: 'AlbumArtist,Album,SortName'
|
||||
}, {
|
||||
playFromHere: true,
|
||||
action: 'playallfromhere',
|
||||
smallIcon: true,
|
||||
artist: true
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function loadItems(element, item, type, query, listOptions) {
|
||||
query = getQuery(query, item);
|
||||
getItemsFunction(query, item)(query.StartIndex, query.Limit, query.Fields).then(function (result) {
|
||||
var html = '';
|
||||
|
||||
if (query.Limit && result.TotalRecordCount > query.Limit) {
|
||||
var link = element.querySelector('a');
|
||||
link.classList.remove('hide');
|
||||
link.setAttribute('href', getMoreItemsHref(item, type));
|
||||
} else {
|
||||
element.querySelector('a').classList.add('hide');
|
||||
}
|
||||
|
||||
listOptions.items = result.Items;
|
||||
var itemsContainer = element.querySelector('.itemsContainer');
|
||||
|
||||
if ('Audio' == type) {
|
||||
html = listView.getListViewHtml(listOptions);
|
||||
itemsContainer.classList.remove('vertical-wrap');
|
||||
itemsContainer.classList.add('vertical-list');
|
||||
} else {
|
||||
html = cardBuilder.getCardsHtml(listOptions);
|
||||
itemsContainer.classList.add('vertical-wrap');
|
||||
itemsContainer.classList.remove('vertical-list');
|
||||
}
|
||||
|
||||
itemsContainer.innerHTML = html;
|
||||
imageLoader.lazyChildren(itemsContainer);
|
||||
if (item.ArtistCount) {
|
||||
sections.push({
|
||||
name: globalize.translate('Artists'),
|
||||
type: 'MusicArtist'
|
||||
});
|
||||
}
|
||||
|
||||
function getMoreItemsHref(item, type) {
|
||||
if ('Genre' == item.Type) {
|
||||
return 'list.html?type=' + type + '&genreId=' + item.Id + '&serverId=' + item.ServerId;
|
||||
}
|
||||
|
||||
if ('MusicGenre' == item.Type) {
|
||||
return 'list.html?type=' + type + '&musicGenreId=' + item.Id + '&serverId=' + item.ServerId;
|
||||
}
|
||||
|
||||
if ('Studio' == item.Type) {
|
||||
return 'list.html?type=' + type + '&studioId=' + item.Id + '&serverId=' + item.ServerId;
|
||||
}
|
||||
|
||||
if ('MusicArtist' == item.Type) {
|
||||
return 'list.html?type=' + type + '&artistId=' + item.Id + '&serverId=' + item.ServerId;
|
||||
}
|
||||
|
||||
if ('Person' == item.Type) {
|
||||
return 'list.html?type=' + type + '&personId=' + item.Id + '&serverId=' + item.ServerId;
|
||||
}
|
||||
|
||||
return 'list.html?type=' + type + '&parentId=' + item.Id + '&serverId=' + item.ServerId;
|
||||
if (item.ProgramCount && item.Type === 'Person') {
|
||||
sections.push({
|
||||
name: globalize.translate('HeaderUpcomingOnTV'),
|
||||
type: 'Program'
|
||||
});
|
||||
}
|
||||
|
||||
function addCurrentItemToQuery(query, item) {
|
||||
if (item.Type == 'Person') {
|
||||
query.PersonIds = item.Id;
|
||||
} else if (item.Type == 'Genre') {
|
||||
query.Genres = item.Name;
|
||||
} else if (item.Type == 'MusicGenre') {
|
||||
query.Genres = item.Name;
|
||||
} else if (item.Type == 'GameGenre') {
|
||||
query.Genres = item.Name;
|
||||
} else if (item.Type == 'Studio') {
|
||||
query.StudioIds = item.Id;
|
||||
} else if (item.Type == 'MusicArtist') {
|
||||
query.AlbumArtistIds = item.Id;
|
||||
if (item.MovieCount) {
|
||||
sections.push({
|
||||
name: globalize.translate('Movies'),
|
||||
type: 'Movie'
|
||||
});
|
||||
}
|
||||
|
||||
if (item.SeriesCount) {
|
||||
sections.push({
|
||||
name: globalize.translate('Shows'),
|
||||
type: 'Series'
|
||||
});
|
||||
}
|
||||
|
||||
if (item.EpisodeCount) {
|
||||
sections.push({
|
||||
name: globalize.translate('Episodes'),
|
||||
type: 'Episode'
|
||||
});
|
||||
}
|
||||
|
||||
if (item.TrailerCount) {
|
||||
sections.push({
|
||||
name: globalize.translate('Trailers'),
|
||||
type: 'Trailer'
|
||||
});
|
||||
}
|
||||
|
||||
if (item.AlbumCount) {
|
||||
sections.push({
|
||||
name: globalize.translate('Albums'),
|
||||
type: 'MusicAlbum'
|
||||
});
|
||||
}
|
||||
|
||||
if (item.MusicVideoCount) {
|
||||
sections.push({
|
||||
name: globalize.translate('HeaderMusicVideos'),
|
||||
type: 'MusicVideo'
|
||||
});
|
||||
}
|
||||
|
||||
const elem = page.querySelector('#childrenContent');
|
||||
elem.innerHTML = sections.map(function (section) {
|
||||
let html = '';
|
||||
let sectionClass = 'verticalSection';
|
||||
|
||||
if (section.type === 'Audio') {
|
||||
sectionClass += ' verticalSection-extrabottompadding';
|
||||
}
|
||||
|
||||
html += '<div class="' + sectionClass + '" data-type="' + section.type + '">';
|
||||
html += '<div class="sectionTitleContainer sectionTitleContainer-cards">';
|
||||
html += '<h2 class="sectionTitle sectionTitle-cards">';
|
||||
html += section.name;
|
||||
html += '</h2>';
|
||||
html += '<a is="emby-linkbutton" href="#" class="clearLink hide" style="margin-left:1em;vertical-align:middle;"><button is="emby-button" type="button" class="raised more raised-mini noIcon">' + globalize.translate('ButtonMore') + '</button></a>';
|
||||
html += '</div>';
|
||||
html += '<div is="emby-itemscontainer" class="itemsContainer padded-right">';
|
||||
html += '</div>';
|
||||
html += '</div>';
|
||||
return html;
|
||||
}).join('');
|
||||
const sectionElems = elem.querySelectorAll('.verticalSection');
|
||||
|
||||
for (let i = 0, length = sectionElems.length; i < length; i++) {
|
||||
renderSection(page, item, sectionElems[i], sectionElems[i].getAttribute('data-type'));
|
||||
}
|
||||
}
|
||||
|
||||
function renderSection(page, item, element, type) {
|
||||
switch (type) {
|
||||
case 'Program':
|
||||
loadItems(element, item, type, {
|
||||
MediaTypes: '',
|
||||
IncludeItemTypes: 'Program',
|
||||
PersonTypes: '',
|
||||
ArtistIds: '',
|
||||
AlbumArtistIds: '',
|
||||
Limit: 10,
|
||||
SortBy: 'StartDate'
|
||||
}, {
|
||||
shape: 'overflowBackdrop',
|
||||
showTitle: true,
|
||||
centerText: true,
|
||||
overlayMoreButton: true,
|
||||
preferThumb: true,
|
||||
overlayText: false,
|
||||
showAirTime: true,
|
||||
showAirDateTime: true,
|
||||
showChannelName: true
|
||||
});
|
||||
break;
|
||||
|
||||
case 'Movie':
|
||||
loadItems(element, item, type, {
|
||||
MediaTypes: '',
|
||||
IncludeItemTypes: 'Movie',
|
||||
PersonTypes: '',
|
||||
ArtistIds: '',
|
||||
AlbumArtistIds: '',
|
||||
Limit: 10,
|
||||
SortBy: 'SortName'
|
||||
}, {
|
||||
shape: 'overflowPortrait',
|
||||
showTitle: true,
|
||||
centerText: true,
|
||||
overlayMoreButton: true,
|
||||
overlayText: false,
|
||||
showYear: true
|
||||
});
|
||||
break;
|
||||
|
||||
case 'MusicVideo':
|
||||
loadItems(element, item, type, {
|
||||
MediaTypes: '',
|
||||
IncludeItemTypes: 'MusicVideo',
|
||||
PersonTypes: '',
|
||||
ArtistIds: '',
|
||||
AlbumArtistIds: '',
|
||||
Limit: 10,
|
||||
SortBy: 'SortName'
|
||||
}, {
|
||||
shape: 'overflowPortrait',
|
||||
showTitle: true,
|
||||
centerText: true,
|
||||
overlayPlayButton: true
|
||||
});
|
||||
break;
|
||||
|
||||
case 'Trailer':
|
||||
loadItems(element, item, type, {
|
||||
MediaTypes: '',
|
||||
IncludeItemTypes: 'Trailer',
|
||||
PersonTypes: '',
|
||||
ArtistIds: '',
|
||||
AlbumArtistIds: '',
|
||||
Limit: 10,
|
||||
SortBy: 'SortName'
|
||||
}, {
|
||||
shape: 'overflowPortrait',
|
||||
showTitle: true,
|
||||
centerText: true,
|
||||
overlayPlayButton: true
|
||||
});
|
||||
break;
|
||||
|
||||
case 'Series':
|
||||
loadItems(element, item, type, {
|
||||
MediaTypes: '',
|
||||
IncludeItemTypes: 'Series',
|
||||
PersonTypes: '',
|
||||
ArtistIds: '',
|
||||
AlbumArtistIds: '',
|
||||
Limit: 10,
|
||||
SortBy: 'SortName'
|
||||
}, {
|
||||
shape: 'overflowPortrait',
|
||||
showTitle: true,
|
||||
centerText: true,
|
||||
overlayMoreButton: true
|
||||
});
|
||||
break;
|
||||
|
||||
case 'MusicAlbum':
|
||||
loadItems(element, item, type, {
|
||||
MediaTypes: '',
|
||||
IncludeItemTypes: 'MusicAlbum',
|
||||
PersonTypes: '',
|
||||
ArtistIds: '',
|
||||
AlbumArtistIds: '',
|
||||
SortOrder: 'Descending',
|
||||
SortBy: 'ProductionYear,Sortname'
|
||||
}, {
|
||||
shape: 'overflowSquare',
|
||||
playFromHere: true,
|
||||
showTitle: true,
|
||||
showYear: true,
|
||||
coverImage: true,
|
||||
centerText: true,
|
||||
overlayPlayButton: true
|
||||
});
|
||||
break;
|
||||
|
||||
case 'MusicArtist':
|
||||
loadItems(element, item, type, {
|
||||
MediaTypes: '',
|
||||
IncludeItemTypes: 'MusicArtist',
|
||||
PersonTypes: '',
|
||||
ArtistIds: '',
|
||||
AlbumArtistIds: '',
|
||||
Limit: 8,
|
||||
SortBy: 'SortName'
|
||||
}, {
|
||||
shape: 'overflowSquare',
|
||||
playFromHere: true,
|
||||
showTitle: true,
|
||||
showParentTitle: true,
|
||||
coverImage: true,
|
||||
centerText: true,
|
||||
overlayPlayButton: true
|
||||
});
|
||||
break;
|
||||
|
||||
case 'Episode':
|
||||
loadItems(element, item, type, {
|
||||
MediaTypes: '',
|
||||
IncludeItemTypes: 'Episode',
|
||||
PersonTypes: '',
|
||||
ArtistIds: '',
|
||||
AlbumArtistIds: '',
|
||||
Limit: 6,
|
||||
SortBy: 'SortName'
|
||||
}, {
|
||||
shape: 'overflowBackdrop',
|
||||
showTitle: true,
|
||||
showParentTitle: true,
|
||||
centerText: true,
|
||||
overlayPlayButton: true
|
||||
});
|
||||
break;
|
||||
|
||||
case 'Audio':
|
||||
loadItems(element, item, type, {
|
||||
MediaTypes: '',
|
||||
IncludeItemTypes: 'Audio',
|
||||
PersonTypes: '',
|
||||
ArtistIds: '',
|
||||
AlbumArtistIds: '',
|
||||
SortBy: 'AlbumArtist,Album,SortName'
|
||||
}, {
|
||||
playFromHere: true,
|
||||
action: 'playallfromhere',
|
||||
smallIcon: true,
|
||||
artist: true
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function loadItems(element, item, type, query, listOptions) {
|
||||
query = getQuery(query, item);
|
||||
getItemsFunction(query, item)(query.StartIndex, query.Limit, query.Fields).then(function (result) {
|
||||
let html = '';
|
||||
|
||||
if (query.Limit && result.TotalRecordCount > query.Limit) {
|
||||
const link = element.querySelector('a');
|
||||
link.classList.remove('hide');
|
||||
link.setAttribute('href', getMoreItemsHref(item, type));
|
||||
} else {
|
||||
element.querySelector('a').classList.add('hide');
|
||||
}
|
||||
|
||||
listOptions.items = result.Items;
|
||||
const itemsContainer = element.querySelector('.itemsContainer');
|
||||
|
||||
if (type === 'Audio') {
|
||||
html = listView.getListViewHtml(listOptions);
|
||||
itemsContainer.classList.remove('vertical-wrap');
|
||||
itemsContainer.classList.add('vertical-list');
|
||||
} else {
|
||||
html = cardBuilder.getCardsHtml(listOptions);
|
||||
itemsContainer.classList.add('vertical-wrap');
|
||||
itemsContainer.classList.remove('vertical-list');
|
||||
}
|
||||
|
||||
itemsContainer.innerHTML = html;
|
||||
imageLoader.lazyChildren(itemsContainer);
|
||||
});
|
||||
}
|
||||
|
||||
function getMoreItemsHref(item, type) {
|
||||
if (item.Type === 'Genre') {
|
||||
return 'list.html?type=' + type + '&genreId=' + item.Id + '&serverId=' + item.ServerId;
|
||||
}
|
||||
|
||||
function getQuery(options, item) {
|
||||
var query = {
|
||||
SortOrder: 'Ascending',
|
||||
IncludeItemTypes: '',
|
||||
Recursive: true,
|
||||
Fields: 'AudioInfo,SeriesInfo,ParentId,PrimaryImageAspectRatio,BasicSyncInfo',
|
||||
Limit: 100,
|
||||
StartIndex: 0,
|
||||
CollapseBoxSetItems: false
|
||||
};
|
||||
query = Object.assign(query, options || {});
|
||||
addCurrentItemToQuery(query, item);
|
||||
return query;
|
||||
if (item.Type === 'MusicGenre') {
|
||||
return 'list.html?type=' + type + '&musicGenreId=' + item.Id + '&serverId=' + item.ServerId;
|
||||
}
|
||||
|
||||
function getItemsFunction(options, item) {
|
||||
var query = getQuery(options, item);
|
||||
return function (index, limit, fields) {
|
||||
query.StartIndex = index;
|
||||
query.Limit = limit;
|
||||
|
||||
if (fields) {
|
||||
query.Fields += ',' + fields;
|
||||
}
|
||||
|
||||
var apiClient = connectionManager.getApiClient(item.ServerId);
|
||||
|
||||
if ('MusicArtist' === query.IncludeItemTypes) {
|
||||
query.IncludeItemTypes = null;
|
||||
return apiClient.getAlbumArtists(apiClient.getCurrentUserId(), query);
|
||||
}
|
||||
|
||||
return apiClient.getItems(apiClient.getCurrentUserId(), query);
|
||||
};
|
||||
if (item.Type === 'Studio') {
|
||||
return 'list.html?type=' + type + '&studioId=' + item.Id + '&serverId=' + item.ServerId;
|
||||
}
|
||||
|
||||
window.ItemsByName = {
|
||||
renderItems: renderItems
|
||||
if (item.Type === 'MusicArtist') {
|
||||
return 'list.html?type=' + type + '&artistId=' + item.Id + '&serverId=' + item.ServerId;
|
||||
}
|
||||
|
||||
if (item.Type === 'Person') {
|
||||
return 'list.html?type=' + type + '&personId=' + item.Id + '&serverId=' + item.ServerId;
|
||||
}
|
||||
|
||||
return 'list.html?type=' + type + '&parentId=' + item.Id + '&serverId=' + item.ServerId;
|
||||
}
|
||||
|
||||
function addCurrentItemToQuery(query, item) {
|
||||
if (item.Type === 'Person') {
|
||||
query.PersonIds = item.Id;
|
||||
} else if (item.Type === 'Genre') {
|
||||
query.Genres = item.Name;
|
||||
} else if (item.Type === 'MusicGenre') {
|
||||
query.Genres = item.Name;
|
||||
} else if (item.Type === 'GameGenre') {
|
||||
query.Genres = item.Name;
|
||||
} else if (item.Type === 'Studio') {
|
||||
query.StudioIds = item.Id;
|
||||
} else if (item.Type === 'MusicArtist') {
|
||||
query.AlbumArtistIds = item.Id;
|
||||
}
|
||||
}
|
||||
|
||||
function getQuery(options, item) {
|
||||
let query = {
|
||||
SortOrder: 'Ascending',
|
||||
IncludeItemTypes: '',
|
||||
Recursive: true,
|
||||
Fields: 'AudioInfo,SeriesInfo,ParentId,PrimaryImageAspectRatio,BasicSyncInfo',
|
||||
Limit: 100,
|
||||
StartIndex: 0,
|
||||
CollapseBoxSetItems: false
|
||||
};
|
||||
});
|
||||
query = Object.assign(query, options || {});
|
||||
addCurrentItemToQuery(query, item);
|
||||
return query;
|
||||
}
|
||||
|
||||
function getItemsFunction(options, item) {
|
||||
const query = getQuery(options, item);
|
||||
return function (index, limit, fields) {
|
||||
query.StartIndex = index;
|
||||
query.Limit = limit;
|
||||
|
||||
if (fields) {
|
||||
query.Fields += ',' + fields;
|
||||
}
|
||||
|
||||
const apiClient = connectionManager.getApiClient(item.ServerId);
|
||||
|
||||
if (query.IncludeItemTypes === 'MusicArtist') {
|
||||
query.IncludeItemTypes = null;
|
||||
return apiClient.getAlbumArtists(apiClient.getCurrentUserId(), query);
|
||||
}
|
||||
|
||||
return apiClient.getItems(apiClient.getCurrentUserId(), query);
|
||||
};
|
||||
}
|
||||
|
||||
window.ItemsByName = {
|
||||
renderItems: renderItems
|
||||
};
|
||||
|
|
|
@ -78,7 +78,7 @@ export function isNavigationKey(key) {
|
|||
}
|
||||
|
||||
export function enable() {
|
||||
document.addEventListener('keydown', function (e) {
|
||||
window.addEventListener('keydown', function (e) {
|
||||
const key = getKeyName(e);
|
||||
|
||||
// Ignore navigation keys for non-TV
|
||||
|
@ -90,53 +90,53 @@ export function enable() {
|
|||
|
||||
switch (key) {
|
||||
case 'ArrowLeft':
|
||||
inputManager.handle('left');
|
||||
inputManager.handleCommand('left');
|
||||
break;
|
||||
case 'ArrowUp':
|
||||
inputManager.handle('up');
|
||||
inputManager.handleCommand('up');
|
||||
break;
|
||||
case 'ArrowRight':
|
||||
inputManager.handle('right');
|
||||
inputManager.handleCommand('right');
|
||||
break;
|
||||
case 'ArrowDown':
|
||||
inputManager.handle('down');
|
||||
inputManager.handleCommand('down');
|
||||
break;
|
||||
|
||||
case 'Back':
|
||||
inputManager.handle('back');
|
||||
inputManager.handleCommand('back');
|
||||
break;
|
||||
|
||||
case 'Escape':
|
||||
if (layoutManager.tv) {
|
||||
inputManager.handle('back');
|
||||
inputManager.handleCommand('back');
|
||||
} else {
|
||||
capture = false;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'MediaPlay':
|
||||
inputManager.handle('play');
|
||||
inputManager.handleCommand('play');
|
||||
break;
|
||||
case 'Pause':
|
||||
inputManager.handle('pause');
|
||||
inputManager.handleCommand('pause');
|
||||
break;
|
||||
case 'MediaPlayPause':
|
||||
inputManager.handle('playpause');
|
||||
inputManager.handleCommand('playpause');
|
||||
break;
|
||||
case 'MediaRewind':
|
||||
inputManager.handle('rewind');
|
||||
inputManager.handleCommand('rewind');
|
||||
break;
|
||||
case 'MediaFastForward':
|
||||
inputManager.handle('fastforward');
|
||||
inputManager.handleCommand('fastforward');
|
||||
break;
|
||||
case 'MediaStop':
|
||||
inputManager.handle('stop');
|
||||
inputManager.handleCommand('stop');
|
||||
break;
|
||||
case 'MediaTrackPrevious':
|
||||
inputManager.handle('previoustrack');
|
||||
inputManager.handleCommand('previoustrack');
|
||||
break;
|
||||
case 'MediaTrackNext':
|
||||
inputManager.handle('nexttrack');
|
||||
inputManager.handleCommand('nexttrack');
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -155,7 +155,8 @@ export function enable() {
|
|||
function attachGamepadScript(e) {
|
||||
console.log('Gamepad connected! Attaching gamepadtokey.js script');
|
||||
window.removeEventListener('gamepadconnected', attachGamepadScript);
|
||||
require(['scripts/gamepadtokey']);
|
||||
/* eslint-disable-next-line @babel/no-unused-expressions */
|
||||
import('scripts/gamepadtokey');
|
||||
}
|
||||
|
||||
// No need to check for gamepads manually at load time, the eventhandler will be fired for that
|
||||
|
|
|
@ -1,199 +1,219 @@
|
|||
define(['userSettings', 'globalize'], function (userSettings, globalize) {
|
||||
'use strict';
|
||||
import * as userSettings from 'userSettings';
|
||||
import globalize from 'globalize';
|
||||
|
||||
var libraryBrowser = {
|
||||
getSavedQueryKey: function (modifier) {
|
||||
return window.location.href.split('#')[0] + (modifier || '');
|
||||
},
|
||||
loadSavedQueryValues: function (key, query) {
|
||||
var values = userSettings.get(key);
|
||||
export function getSavedQueryKey(modifier) {
|
||||
return window.location.href.split('#')[0] + (modifier || '');
|
||||
}
|
||||
|
||||
if (values) {
|
||||
values = JSON.parse(values);
|
||||
return Object.assign(query, values);
|
||||
}
|
||||
export function loadSavedQueryValues(key, query) {
|
||||
var values = userSettings.get(key);
|
||||
|
||||
return query;
|
||||
},
|
||||
saveQueryValues: function (key, query) {
|
||||
var values = {};
|
||||
if (values) {
|
||||
values = JSON.parse(values);
|
||||
return Object.assign(query, values);
|
||||
}
|
||||
|
||||
if (query.SortBy) {
|
||||
values.SortBy = query.SortBy;
|
||||
}
|
||||
return query;
|
||||
}
|
||||
|
||||
if (query.SortOrder) {
|
||||
values.SortOrder = query.SortOrder;
|
||||
}
|
||||
export function saveQueryValues(key, query) {
|
||||
var values = {};
|
||||
|
||||
userSettings.set(key, JSON.stringify(values));
|
||||
},
|
||||
saveViewSetting: function (key, value) {
|
||||
userSettings.set(key + '-_view', value);
|
||||
},
|
||||
getSavedView: function (key) {
|
||||
return userSettings.get(key + '-_view');
|
||||
},
|
||||
showLayoutMenu: function (button, currentLayout, views) {
|
||||
var dispatchEvent = true;
|
||||
if (query.SortBy) {
|
||||
values.SortBy = query.SortBy;
|
||||
}
|
||||
|
||||
if (!views) {
|
||||
dispatchEvent = false;
|
||||
views = button.getAttribute('data-layouts');
|
||||
views = views ? views.split(',') : ['List', 'Poster', 'PosterCard', 'Thumb', 'ThumbCard'];
|
||||
}
|
||||
if (query.SortOrder) {
|
||||
values.SortOrder = query.SortOrder;
|
||||
}
|
||||
|
||||
var menuItems = views.map(function (v) {
|
||||
return {
|
||||
name: globalize.translate('Option' + v),
|
||||
id: v,
|
||||
selected: currentLayout == v
|
||||
};
|
||||
});
|
||||
userSettings.set(key, JSON.stringify(values));
|
||||
}
|
||||
|
||||
require(['actionsheet'], function (actionsheet) {
|
||||
actionsheet.show({
|
||||
items: menuItems,
|
||||
positionTo: button,
|
||||
callback: function (id) {
|
||||
button.dispatchEvent(new CustomEvent('layoutchange', {
|
||||
detail: {
|
||||
viewStyle: id
|
||||
},
|
||||
bubbles: true,
|
||||
cancelable: false
|
||||
}));
|
||||
export function saveViewSetting (key, value) {
|
||||
userSettings.set(key + '-_view', value);
|
||||
}
|
||||
|
||||
if (!dispatchEvent) {
|
||||
if (window.$) {
|
||||
$(button).trigger('layoutchange', [id]);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
getQueryPagingHtml: function (options) {
|
||||
var startIndex = options.startIndex;
|
||||
var limit = options.limit;
|
||||
var totalRecordCount = options.totalRecordCount;
|
||||
var html = '';
|
||||
var recordsEnd = Math.min(startIndex + limit, totalRecordCount);
|
||||
var showControls = limit < totalRecordCount;
|
||||
export function getSavedView (key) {
|
||||
return userSettings.get(key + '-_view');
|
||||
}
|
||||
|
||||
if (html += '<div class="listPaging">', showControls) {
|
||||
html += '<span style="vertical-align:middle;">';
|
||||
html += globalize.translate('ListPaging', (totalRecordCount ? startIndex + 1 : 0), recordsEnd, totalRecordCount);
|
||||
html += '</span>';
|
||||
}
|
||||
export function showLayoutMenu (button, currentLayout, views) {
|
||||
var dispatchEvent = true;
|
||||
|
||||
if (showControls || options.viewButton || options.filterButton || options.sortButton || options.addLayoutButton) {
|
||||
html += '<div style="display:inline-block;">';
|
||||
if (!views) {
|
||||
dispatchEvent = false;
|
||||
views = button.getAttribute('data-layouts');
|
||||
views = views ? views.split(',') : ['List', 'Poster', 'PosterCard', 'Thumb', 'ThumbCard'];
|
||||
}
|
||||
|
||||
if (showControls) {
|
||||
html += '<button is="paper-icon-button-light" class="btnPreviousPage autoSize" ' + (startIndex ? '' : 'disabled') + '><span class="material-icons arrow_back"></span></button>';
|
||||
html += '<button is="paper-icon-button-light" class="btnNextPage autoSize" ' + (startIndex + limit >= totalRecordCount ? 'disabled' : '') + '><span class="material-icons arrow_forward"></span></button>';
|
||||
}
|
||||
var menuItems = views.map(function (v) {
|
||||
return {
|
||||
name: globalize.translate('Option' + v),
|
||||
id: v,
|
||||
selected: currentLayout == v
|
||||
};
|
||||
});
|
||||
|
||||
if (options.addLayoutButton) {
|
||||
html += '<button is="paper-icon-button-light" title="' + globalize.translate('ButtonSelectView') + '" class="btnChangeLayout autoSize" data-layouts="' + (options.layouts || '') + '" onclick="LibraryBrowser.showLayoutMenu(this, \'' + (options.currentLayout || '') + '\');"><span class="material-icons view_comfy"></span></button>';
|
||||
}
|
||||
import('actionsheet').then(({default: actionsheet}) => {
|
||||
actionsheet.show({
|
||||
items: menuItems,
|
||||
positionTo: button,
|
||||
callback: function (id) {
|
||||
button.dispatchEvent(new CustomEvent('layoutchange', {
|
||||
detail: {
|
||||
viewStyle: id
|
||||
},
|
||||
bubbles: true,
|
||||
cancelable: false
|
||||
}));
|
||||
|
||||
if (options.sortButton) {
|
||||
html += '<button is="paper-icon-button-light" class="btnSort autoSize" title="' + globalize.translate('ButtonSort') + '"><span class="material-icons sort_by_alpha"></span></button>';
|
||||
}
|
||||
|
||||
if (options.filterButton) {
|
||||
html += '<button is="paper-icon-button-light" class="btnFilter autoSize" title="' + globalize.translate('ButtonFilter') + '"><span class="material-icons filter_list"></span></button>';
|
||||
}
|
||||
|
||||
html += '</div>';
|
||||
}
|
||||
|
||||
return html += '</div>';
|
||||
},
|
||||
showSortMenu: function (options) {
|
||||
require(['dialogHelper', 'emby-radio'], function (dialogHelper) {
|
||||
function onSortByChange() {
|
||||
var newValue = this.value;
|
||||
|
||||
if (this.checked) {
|
||||
var changed = options.query.SortBy != newValue;
|
||||
options.query.SortBy = newValue.replace('_', ',');
|
||||
options.query.StartIndex = 0;
|
||||
|
||||
if (options.callback && changed) {
|
||||
options.callback();
|
||||
}
|
||||
if (!dispatchEvent) {
|
||||
if (window.$) {
|
||||
$(button).trigger('layoutchange', [id]);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function onSortOrderChange() {
|
||||
var newValue = this.value;
|
||||
export function getQueryPagingHtml (options) {
|
||||
var startIndex = options.startIndex;
|
||||
var limit = options.limit;
|
||||
var totalRecordCount = options.totalRecordCount;
|
||||
var html = '';
|
||||
var recordsEnd = Math.min(startIndex + limit, totalRecordCount);
|
||||
var showControls = limit < totalRecordCount;
|
||||
|
||||
if (this.checked) {
|
||||
var changed = options.query.SortOrder != newValue;
|
||||
options.query.SortOrder = newValue;
|
||||
options.query.StartIndex = 0;
|
||||
if (html += '<div class="listPaging">', showControls) {
|
||||
html += '<span style="vertical-align:middle;">';
|
||||
html += globalize.translate('ListPaging', (totalRecordCount ? startIndex + 1 : 0), recordsEnd, totalRecordCount);
|
||||
html += '</span>';
|
||||
}
|
||||
|
||||
if (options.callback && changed) {
|
||||
options.callback();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (showControls || options.viewButton || options.filterButton || options.sortButton || options.addLayoutButton) {
|
||||
html += '<div style="display:inline-block;">';
|
||||
|
||||
var dlg = dialogHelper.createDialog({
|
||||
removeOnClose: true,
|
||||
modal: false,
|
||||
entryAnimationDuration: 160,
|
||||
exitAnimationDuration: 200
|
||||
});
|
||||
dlg.classList.add('ui-body-a');
|
||||
dlg.classList.add('background-theme-a');
|
||||
dlg.classList.add('formDialog');
|
||||
var html = '';
|
||||
html += '<div style="margin:0;padding:1.25em 1.5em 1.5em;">';
|
||||
html += '<h2 style="margin:0 0 .5em;">';
|
||||
html += globalize.translate('HeaderSortBy');
|
||||
html += '</h2>';
|
||||
var i;
|
||||
var length;
|
||||
var isChecked;
|
||||
html += '<div>';
|
||||
for (i = 0, length = options.items.length; i < length; i++) {
|
||||
var option = options.items[i];
|
||||
var radioValue = option.id.replace(',', '_');
|
||||
isChecked = (options.query.SortBy || '').replace(',', '_') == radioValue ? ' checked' : '';
|
||||
html += '<label class="radio-label-block"><input type="radio" is="emby-radio" name="SortBy" data-id="' + option.id + '" value="' + radioValue + '" class="menuSortBy" ' + isChecked + ' /><span>' + option.name + '</span></label>';
|
||||
}
|
||||
|
||||
html += '</div>';
|
||||
html += '<h2 style="margin: 1em 0 .5em;">';
|
||||
html += globalize.translate('HeaderSortOrder');
|
||||
html += '</h2>';
|
||||
html += '<div>';
|
||||
isChecked = 'Ascending' == options.query.SortOrder ? ' checked' : '';
|
||||
html += '<label class="radio-label-block"><input type="radio" is="emby-radio" name="SortOrder" value="Ascending" class="menuSortOrder" ' + isChecked + ' /><span>' + globalize.translate('OptionAscending') + '</span></label>';
|
||||
isChecked = 'Descending' == options.query.SortOrder ? ' checked' : '';
|
||||
html += '<label class="radio-label-block"><input type="radio" is="emby-radio" name="SortOrder" value="Descending" class="menuSortOrder" ' + isChecked + ' /><span>' + globalize.translate('OptionDescending') + '</span></label>';
|
||||
html += '</div>';
|
||||
html += '</div>';
|
||||
dlg.innerHTML = html;
|
||||
dialogHelper.open(dlg);
|
||||
var sortBys = dlg.querySelectorAll('.menuSortBy');
|
||||
|
||||
for (i = 0, length = sortBys.length; i < length; i++) {
|
||||
sortBys[i].addEventListener('change', onSortByChange);
|
||||
}
|
||||
|
||||
var sortOrders = dlg.querySelectorAll('.menuSortOrder');
|
||||
|
||||
for (i = 0, length = sortOrders.length; i < length; i++) {
|
||||
sortOrders[i].addEventListener('change', onSortOrderChange);
|
||||
}
|
||||
});
|
||||
if (showControls) {
|
||||
html += '<button is="paper-icon-button-light" class="btnPreviousPage autoSize" ' + (startIndex ? '' : 'disabled') + '><span class="material-icons arrow_back"></span></button>';
|
||||
html += '<button is="paper-icon-button-light" class="btnNextPage autoSize" ' + (startIndex + limit >= totalRecordCount ? 'disabled' : '') + '><span class="material-icons arrow_forward"></span></button>';
|
||||
}
|
||||
};
|
||||
window.LibraryBrowser = libraryBrowser;
|
||||
return libraryBrowser;
|
||||
});
|
||||
|
||||
if (options.addLayoutButton) {
|
||||
html += '<button is="paper-icon-button-light" title="' + globalize.translate('ButtonSelectView') + '" class="btnChangeLayout autoSize" data-layouts="' + (options.layouts || '') + '" onclick="LibraryBrowser.showLayoutMenu(this, \'' + (options.currentLayout || '') + '\');"><span class="material-icons view_comfy"></span></button>';
|
||||
}
|
||||
|
||||
if (options.sortButton) {
|
||||
html += '<button is="paper-icon-button-light" class="btnSort autoSize" title="' + globalize.translate('Sort') + '"><span class="material-icons sort_by_alpha"></span></button>';
|
||||
}
|
||||
|
||||
if (options.filterButton) {
|
||||
html += '<button is="paper-icon-button-light" class="btnFilter autoSize" title="' + globalize.translate('Filter') + '"><span class="material-icons filter_list"></span></button>';
|
||||
}
|
||||
|
||||
html += '</div>';
|
||||
}
|
||||
|
||||
return html += '</div>';
|
||||
}
|
||||
|
||||
export function showSortMenu (options) {
|
||||
Promise.all([
|
||||
import('dialogHelper'),
|
||||
import('emby-radio')
|
||||
]).then(([{default: dialogHelper}]) => {
|
||||
function onSortByChange() {
|
||||
var newValue = this.value;
|
||||
|
||||
if (this.checked) {
|
||||
var changed = options.query.SortBy != newValue;
|
||||
options.query.SortBy = newValue.replace('_', ',');
|
||||
options.query.StartIndex = 0;
|
||||
|
||||
if (options.callback && changed) {
|
||||
options.callback();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function onSortOrderChange() {
|
||||
var newValue = this.value;
|
||||
|
||||
if (this.checked) {
|
||||
var changed = options.query.SortOrder != newValue;
|
||||
options.query.SortOrder = newValue;
|
||||
options.query.StartIndex = 0;
|
||||
|
||||
if (options.callback && changed) {
|
||||
options.callback();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var dlg = dialogHelper.createDialog({
|
||||
removeOnClose: true,
|
||||
modal: false,
|
||||
entryAnimationDuration: 160,
|
||||
exitAnimationDuration: 200
|
||||
});
|
||||
dlg.classList.add('ui-body-a');
|
||||
dlg.classList.add('background-theme-a');
|
||||
dlg.classList.add('formDialog');
|
||||
var html = '';
|
||||
html += '<div style="margin:0;padding:1.25em 1.5em 1.5em;">';
|
||||
html += '<h2 style="margin:0 0 .5em;">';
|
||||
html += globalize.translate('HeaderSortBy');
|
||||
html += '</h2>';
|
||||
var i;
|
||||
var length;
|
||||
var isChecked;
|
||||
html += '<div>';
|
||||
for (i = 0, length = options.items.length; i < length; i++) {
|
||||
var option = options.items[i];
|
||||
var radioValue = option.id.replace(',', '_');
|
||||
isChecked = (options.query.SortBy || '').replace(',', '_') == radioValue ? ' checked' : '';
|
||||
html += '<label class="radio-label-block"><input type="radio" is="emby-radio" name="SortBy" data-id="' + option.id + '" value="' + radioValue + '" class="menuSortBy" ' + isChecked + ' /><span>' + option.name + '</span></label>';
|
||||
}
|
||||
|
||||
html += '</div>';
|
||||
html += '<h2 style="margin: 1em 0 .5em;">';
|
||||
html += globalize.translate('HeaderSortOrder');
|
||||
html += '</h2>';
|
||||
html += '<div>';
|
||||
isChecked = options.query.SortOrder == 'Ascending' ? ' checked' : '';
|
||||
html += '<label class="radio-label-block"><input type="radio" is="emby-radio" name="SortOrder" value="Ascending" class="menuSortOrder" ' + isChecked + ' /><span>' + globalize.translate('OptionAscending') + '</span></label>';
|
||||
isChecked = options.query.SortOrder == 'Descending' ? ' checked' : '';
|
||||
html += '<label class="radio-label-block"><input type="radio" is="emby-radio" name="SortOrder" value="Descending" class="menuSortOrder" ' + isChecked + ' /><span>' + globalize.translate('OptionDescending') + '</span></label>';
|
||||
html += '</div>';
|
||||
html += '</div>';
|
||||
dlg.innerHTML = html;
|
||||
dialogHelper.open(dlg);
|
||||
var sortBys = dlg.querySelectorAll('.menuSortBy');
|
||||
|
||||
for (i = 0, length = sortBys.length; i < length; i++) {
|
||||
sortBys[i].addEventListener('change', onSortByChange);
|
||||
}
|
||||
|
||||
var sortOrders = dlg.querySelectorAll('.menuSortOrder');
|
||||
|
||||
for (i = 0, length = sortOrders.length; i < length; i++) {
|
||||
sortOrders[i].addEventListener('change', onSortOrderChange);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
const libraryBrowser = {
|
||||
getSavedQueryKey,
|
||||
loadSavedQueryValues,
|
||||
saveQueryValues,
|
||||
saveViewSetting,
|
||||
getSavedView,
|
||||
showLayoutMenu,
|
||||
getQueryPagingHtml,
|
||||
showSortMenu
|
||||
};
|
||||
|
||||
window.LibraryBrowser = libraryBrowser;
|
||||
|
||||
export default libraryBrowser;
|
||||
|
|
|
@ -1,8 +1,26 @@
|
|||
define(['dom', 'layoutManager', 'inputManager', 'connectionManager', 'events', 'viewManager', 'libraryBrowser', 'appRouter', 'apphost', 'playbackManager', 'syncPlayManager', 'groupSelectionMenu', 'browser', 'globalize', 'scripts/imagehelper', 'paper-icon-button-light', 'material-icons', 'scrollStyles', 'flexStyles'], function (dom, layoutManager, inputManager, connectionManager, events, viewManager, libraryBrowser, appRouter, appHost, playbackManager, syncPlayManager, groupSelectionMenu, browser, globalize, imageHelper) {
|
||||
'use strict';
|
||||
import dom from 'dom';
|
||||
import layoutManager from 'layoutManager';
|
||||
import inputManager from 'inputManager';
|
||||
import connectionManager from 'connectionManager';
|
||||
import events from 'events';
|
||||
import viewManager from 'viewManager';
|
||||
import appRouter from 'appRouter';
|
||||
import appHost from 'apphost';
|
||||
import playbackManager from 'playbackManager';
|
||||
import syncPlayManager from 'syncPlayManager';
|
||||
import * as groupSelectionMenu from 'groupSelectionMenu';
|
||||
import browser from 'browser';
|
||||
import globalize from 'globalize';
|
||||
import imageHelper from 'scripts/imagehelper';
|
||||
import 'paper-icon-button-light';
|
||||
import 'material-icons';
|
||||
import 'scrollStyles';
|
||||
import 'flexStyles';
|
||||
|
||||
/* eslint-disable indent */
|
||||
|
||||
function renderHeader() {
|
||||
var html = '';
|
||||
let html = '';
|
||||
html += '<div class="flex align-items-center flex-grow headerTop">';
|
||||
html += '<div class="headerLeft">';
|
||||
html += '<button type="button" is="paper-icon-button-light" class="headerButton headerButtonLeft headerBackButton hide"><span class="material-icons ' + (browser.safari ? 'chevron_left' : 'arrow_back') + '"></span></button>';
|
||||
|
@ -12,10 +30,10 @@ define(['dom', 'layoutManager', 'inputManager', 'connectionManager', 'events', '
|
|||
html += '</div>';
|
||||
html += '<div class="headerRight">';
|
||||
html += '<span class="headerSelectedPlayer"></span>';
|
||||
html += '<button is="paper-icon-button-light" class="headerSyncButton syncButton headerButton headerButtonRight hide"><span class="material-icons sync_disabled"></span></button>';
|
||||
html += '<button is="paper-icon-button-light" class="headerAudioPlayerButton audioPlayerButton headerButton headerButtonRight hide"><span class="material-icons music_note"></span></button>';
|
||||
html += '<button is="paper-icon-button-light" class="headerCastButton castButton headerButton headerButtonRight hide"><span class="material-icons cast"></span></button>';
|
||||
html += '<button type="button" is="paper-icon-button-light" class="headerButton headerButtonRight headerSearchButton hide"><span class="material-icons search"></span></button>';
|
||||
html += `<button is="paper-icon-button-light" class="headerSyncButton syncButton headerButton headerButtonRight hide" title="${globalize.translate('ButtonSyncPlay')}"><span class="material-icons sync_disabled"></span></button>`;
|
||||
html += `<button is="paper-icon-button-light" class="headerAudioPlayerButton audioPlayerButton headerButton headerButtonRight hide" title="${globalize.translate('ButtonPlayer')}"><span class="material-icons music_note"></span></button>`;
|
||||
html += `<button is="paper-icon-button-light" class="headerCastButton castButton headerButton headerButtonRight hide" title="${globalize.translate('ButtonCast')}"><span class="material-icons cast"></span></button>`;
|
||||
html += `<button type="button" is="paper-icon-button-light" class="headerButton headerButtonRight headerSearchButton hide" title="${globalize.translate('Search')}"><span class="material-icons search"></span></button>`;
|
||||
html += '<button is="paper-icon-button-light" class="headerButton headerButtonRight headerUserButton hide"><span class="material-icons person"></span></button>';
|
||||
html += '</div>';
|
||||
html += '</div>';
|
||||
|
@ -46,7 +64,7 @@ define(['dom', 'layoutManager', 'inputManager', 'connectionManager', 'events', '
|
|||
}
|
||||
|
||||
function lazyLoadViewMenuBarImages() {
|
||||
require(['imageLoader'], function (imageLoader) {
|
||||
import('imageLoader').then(({default: imageLoader}) => {
|
||||
imageLoader.lazyChildren(skinHeader);
|
||||
});
|
||||
}
|
||||
|
@ -56,15 +74,15 @@ define(['dom', 'layoutManager', 'inputManager', 'connectionManager', 'events', '
|
|||
}
|
||||
|
||||
function updateUserInHeader(user) {
|
||||
var hasImage;
|
||||
let hasImage;
|
||||
|
||||
if (user && user.name) {
|
||||
if (user.imageUrl) {
|
||||
var url = user.imageUrl;
|
||||
const url = user.imageUrl;
|
||||
updateHeaderUserButton(url);
|
||||
hasImage = true;
|
||||
}
|
||||
|
||||
headerUserButton.title = user.name;
|
||||
headerUserButton.classList.remove('hide');
|
||||
} else {
|
||||
headerUserButton.classList.add('hide');
|
||||
|
@ -87,9 +105,10 @@ define(['dom', 'layoutManager', 'inputManager', 'connectionManager', 'events', '
|
|||
headerCastButton.classList.remove('hide');
|
||||
}
|
||||
|
||||
var policy = user.Policy ? user.Policy : user.localUser.Policy;
|
||||
const policy = user.Policy ? user.Policy : user.localUser.Policy;
|
||||
|
||||
if (headerSyncButton && policy && policy.SyncPlayAccess !== 'None') {
|
||||
const apiClient = getCurrentApiClient();
|
||||
if (headerSyncButton && policy && policy.SyncPlayAccess !== 'None' && apiClient.isMinServerVersion('10.6.0')) {
|
||||
headerSyncButton.classList.remove('hide');
|
||||
}
|
||||
} else {
|
||||
|
@ -116,7 +135,7 @@ define(['dom', 'layoutManager', 'inputManager', 'connectionManager', 'events', '
|
|||
}
|
||||
|
||||
function showSearch() {
|
||||
inputManager.trigger('search');
|
||||
inputManager.handleCommand('search');
|
||||
}
|
||||
|
||||
function onHeaderUserButtonClick(e) {
|
||||
|
@ -138,7 +157,7 @@ define(['dom', 'layoutManager', 'inputManager', 'connectionManager', 'events', '
|
|||
mainDrawerButton.addEventListener('click', toggleMainDrawer);
|
||||
}
|
||||
|
||||
var headerBackButton = skinHeader.querySelector('.headerBackButton');
|
||||
const headerBackButton = skinHeader.querySelector('.headerBackButton');
|
||||
|
||||
if (headerBackButton) {
|
||||
headerBackButton.addEventListener('click', onBackClick);
|
||||
|
@ -180,20 +199,20 @@ define(['dom', 'layoutManager', 'inputManager', 'connectionManager', 'events', '
|
|||
}
|
||||
|
||||
function onCastButtonClicked() {
|
||||
var btn = this;
|
||||
const btn = this;
|
||||
|
||||
require(['playerSelectionMenu'], function (playerSelectionMenu) {
|
||||
import('playerSelectionMenu').then(({default: playerSelectionMenu}) => {
|
||||
playerSelectionMenu.show(btn);
|
||||
});
|
||||
}
|
||||
|
||||
function onSyncButtonClicked() {
|
||||
var btn = this;
|
||||
const btn = this;
|
||||
groupSelectionMenu.show(btn);
|
||||
}
|
||||
|
||||
function onSyncPlayEnabled(event, enabled) {
|
||||
var icon = headerSyncButton.querySelector('span');
|
||||
const icon = headerSyncButton.querySelector('span');
|
||||
icon.classList.remove('sync', 'sync_disabled', 'sync_problem');
|
||||
if (enabled) {
|
||||
icon.classList.add('sync');
|
||||
|
@ -203,7 +222,7 @@ define(['dom', 'layoutManager', 'inputManager', 'connectionManager', 'events', '
|
|||
}
|
||||
|
||||
function onSyncPlaySyncing(event, is_syncing, syncMethod) {
|
||||
var icon = headerSyncButton.querySelector('span');
|
||||
const icon = headerSyncButton.querySelector('span');
|
||||
icon.classList.remove('sync', 'sync_disabled', 'sync_problem');
|
||||
if (is_syncing) {
|
||||
icon.classList.add('sync_problem');
|
||||
|
@ -228,7 +247,6 @@ define(['dom', 'layoutManager', 'inputManager', 'connectionManager', 'events', '
|
|||
|
||||
function openMainDrawer() {
|
||||
navDrawerInstance.open();
|
||||
lastOpenTime = new Date().getTime();
|
||||
}
|
||||
|
||||
function onMainDrawerOpened() {
|
||||
|
@ -250,9 +268,9 @@ define(['dom', 'layoutManager', 'inputManager', 'connectionManager', 'events', '
|
|||
}
|
||||
|
||||
function refreshLibraryInfoInDrawer(user, drawer) {
|
||||
var html = '';
|
||||
let html = '';
|
||||
html += '<div style="height:.5em;"></div>';
|
||||
html += '<a is="emby-linkbutton" class="navMenuOption lnkMediaFolder" href="home.html"><span class="material-icons navMenuOptionIcon home"></span><span class="navMenuOptionText">' + globalize.translate('ButtonHome') + '</span></a>';
|
||||
html += '<a is="emby-linkbutton" class="navMenuOption lnkMediaFolder" href="home.html"><span class="material-icons navMenuOptionIcon home"></span><span class="navMenuOptionText">' + globalize.translate('Home') + '</span></a>';
|
||||
|
||||
// libraries are added here
|
||||
html += '<div class="libraryMenuOptions">';
|
||||
|
@ -286,12 +304,12 @@ define(['dom', 'layoutManager', 'inputManager', 'connectionManager', 'events', '
|
|||
// add buttons to navigation drawer
|
||||
navDrawerScrollContainer.innerHTML = html;
|
||||
|
||||
var btnSettings = navDrawerScrollContainer.querySelector('.btnSettings');
|
||||
const btnSettings = navDrawerScrollContainer.querySelector('.btnSettings');
|
||||
if (btnSettings) {
|
||||
btnSettings.addEventListener('click', onSettingsClick);
|
||||
}
|
||||
|
||||
var btnLogout = navDrawerScrollContainer.querySelector('.btnLogout');
|
||||
const btnLogout = navDrawerScrollContainer.querySelector('.btnLogout');
|
||||
if (btnLogout) {
|
||||
btnLogout.addEventListener('click', onLogoutClick);
|
||||
}
|
||||
|
@ -309,24 +327,24 @@ define(['dom', 'layoutManager', 'inputManager', 'connectionManager', 'events', '
|
|||
}
|
||||
|
||||
function isUrlInCurrentView(url) {
|
||||
return -1 !== window.location.href.toString().toLowerCase().indexOf(url.toLowerCase());
|
||||
return window.location.href.toString().toLowerCase().indexOf(url.toLowerCase()) !== -1;
|
||||
}
|
||||
|
||||
function updateDashboardMenuSelectedItem() {
|
||||
var links = navDrawerScrollContainer.querySelectorAll('.navMenuOption');
|
||||
var currentViewId = viewManager.currentView().id;
|
||||
const links = navDrawerScrollContainer.querySelectorAll('.navMenuOption');
|
||||
const currentViewId = viewManager.currentView().id;
|
||||
|
||||
for (var i = 0, length = links.length; i < length; i++) {
|
||||
var link = links[i];
|
||||
var selected = false;
|
||||
var pageIds = link.getAttribute('data-pageids');
|
||||
for (let i = 0, length = links.length; i < length; i++) {
|
||||
let link = links[i];
|
||||
let selected = false;
|
||||
let pageIds = link.getAttribute('data-pageids');
|
||||
|
||||
if (pageIds) {
|
||||
pageIds = pageIds.split('|');
|
||||
selected = -1 != pageIds.indexOf(currentViewId);
|
||||
selected = pageIds.indexOf(currentViewId) != -1;
|
||||
}
|
||||
|
||||
var pageUrls = link.getAttribute('data-pageurls');
|
||||
let pageUrls = link.getAttribute('data-pageurls');
|
||||
|
||||
if (pageUrls) {
|
||||
pageUrls = pageUrls.split('|');
|
||||
|
@ -335,7 +353,7 @@ define(['dom', 'layoutManager', 'inputManager', 'connectionManager', 'events', '
|
|||
|
||||
if (selected) {
|
||||
link.classList.add('navMenuOption-selected');
|
||||
var title = '';
|
||||
let title = '';
|
||||
link = link.querySelector('.navMenuOptionText') || link;
|
||||
title += (link.innerText || link.textContent).trim();
|
||||
LibraryMenu.setTitle(title);
|
||||
|
@ -346,7 +364,7 @@ define(['dom', 'layoutManager', 'inputManager', 'connectionManager', 'events', '
|
|||
}
|
||||
|
||||
function createToolsMenuList(pluginItems) {
|
||||
var links = [{
|
||||
const links = [{
|
||||
name: globalize.translate('TabServer')
|
||||
}, {
|
||||
name: globalize.translate('TabDashboard'),
|
||||
|
@ -359,7 +377,7 @@ define(['dom', 'layoutManager', 'inputManager', 'connectionManager', 'events', '
|
|||
pageIds: ['dashboardGeneralPage'],
|
||||
icon: 'settings'
|
||||
}, {
|
||||
name: globalize.translate('TabUsers'),
|
||||
name: globalize.translate('HeaderUsers'),
|
||||
href: 'userprofiles.html',
|
||||
pageIds: ['userProfilesPage', 'newUserPage', 'editUserPage', 'userLibraryAccessPage', 'userParentalControlPage', 'userPasswordPage'],
|
||||
icon: 'people'
|
||||
|
@ -369,7 +387,7 @@ define(['dom', 'layoutManager', 'inputManager', 'connectionManager', 'events', '
|
|||
pageIds: ['mediaLibraryPage', 'librarySettingsPage', 'libraryDisplayPage', 'metadataImagesConfigurationPage', 'metadataNfoPage'],
|
||||
icon: 'folder'
|
||||
}, {
|
||||
name: globalize.translate('TabPlayback'),
|
||||
name: globalize.translate('TitlePlayback'),
|
||||
icon: 'play_arrow',
|
||||
href: 'encodingsettings.html',
|
||||
pageIds: ['encodingSettingsPage', 'playbackConfigurationPage', 'streamingSettingsPage']
|
||||
|
@ -377,10 +395,10 @@ define(['dom', 'layoutManager', 'inputManager', 'connectionManager', 'events', '
|
|||
addPluginPagesToMainMenu(links, pluginItems, 'server');
|
||||
links.push({
|
||||
divider: true,
|
||||
name: globalize.translate('TabDevices')
|
||||
name: globalize.translate('HeaderDevices')
|
||||
});
|
||||
links.push({
|
||||
name: globalize.translate('TabDevices'),
|
||||
name: globalize.translate('HeaderDevices'),
|
||||
href: 'devices.html',
|
||||
pageIds: ['devicesPage', 'devicePage'],
|
||||
icon: 'devices'
|
||||
|
@ -399,16 +417,16 @@ define(['dom', 'layoutManager', 'inputManager', 'connectionManager', 'events', '
|
|||
});
|
||||
links.push({
|
||||
divider: true,
|
||||
name: globalize.translate('TabLiveTV')
|
||||
name: globalize.translate('LiveTV')
|
||||
});
|
||||
links.push({
|
||||
name: globalize.translate('TabLiveTV'),
|
||||
name: globalize.translate('LiveTV'),
|
||||
href: 'livetvstatus.html',
|
||||
pageIds: ['liveTvStatusPage', 'liveTvTunerPage'],
|
||||
icon: 'live_tv'
|
||||
});
|
||||
links.push({
|
||||
name: globalize.translate('TabDVR'),
|
||||
name: globalize.translate('HeaderDVR'),
|
||||
href: 'livetvsettings.html',
|
||||
pageIds: ['liveTvSettingsPage'],
|
||||
icon: 'dvr'
|
||||
|
@ -458,8 +476,8 @@ define(['dom', 'layoutManager', 'inputManager', 'connectionManager', 'events', '
|
|||
}
|
||||
|
||||
function addPluginPagesToMainMenu(links, pluginItems, section) {
|
||||
for (var i = 0, length = pluginItems.length; i < length; i++) {
|
||||
var pluginItem = pluginItems[i];
|
||||
for (let i = 0, length = pluginItems.length; i < length; i++) {
|
||||
const pluginItem = pluginItems[i];
|
||||
|
||||
if (pluginItem.EnableInMainMenu && pluginItem.MenuSection === section) {
|
||||
links.push({
|
||||
|
@ -479,10 +497,10 @@ define(['dom', 'layoutManager', 'inputManager', 'connectionManager', 'events', '
|
|||
}
|
||||
|
||||
function getToolsLinkHtml(item) {
|
||||
var menuHtml = '';
|
||||
var pageIds = item.pageIds ? item.pageIds.join('|') : '';
|
||||
let menuHtml = '';
|
||||
let pageIds = item.pageIds ? item.pageIds.join('|') : '';
|
||||
pageIds = pageIds ? ' data-pageids="' + pageIds + '"' : '';
|
||||
var pageUrls = item.pageUrls ? item.pageUrls.join('|') : '';
|
||||
let pageUrls = item.pageUrls ? item.pageUrls.join('|') : '';
|
||||
pageUrls = pageUrls ? ' data-pageurls="' + pageUrls + '"' : '';
|
||||
menuHtml += '<a is="emby-linkbutton" class="navMenuOption" href="' + item.href + '"' + pageIds + pageUrls + '>';
|
||||
|
||||
|
@ -498,11 +516,11 @@ define(['dom', 'layoutManager', 'inputManager', 'connectionManager', 'events', '
|
|||
|
||||
function getToolsMenuHtml(apiClient) {
|
||||
return getToolsMenuLinks(apiClient).then(function (items) {
|
||||
var item;
|
||||
var menuHtml = '';
|
||||
let item;
|
||||
let menuHtml = '';
|
||||
menuHtml += '<div class="drawerContent">';
|
||||
|
||||
for (var i = 0; i < items.length; i++) {
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
item = items[i];
|
||||
|
||||
if (item.href) {
|
||||
|
@ -520,7 +538,7 @@ define(['dom', 'layoutManager', 'inputManager', 'connectionManager', 'events', '
|
|||
|
||||
function createDashboardMenu(apiClient) {
|
||||
return getToolsMenuHtml(apiClient).then(function (toolsMenuHtml) {
|
||||
var html = '';
|
||||
let html = '';
|
||||
html += '<a class="adminDrawerLogo clearLink" is="emby-linkbutton" href="home.html">';
|
||||
html += '<img src="assets/img/icon-transparent.png" />';
|
||||
html += '</a>';
|
||||
|
@ -531,25 +549,25 @@ define(['dom', 'layoutManager', 'inputManager', 'connectionManager', 'events', '
|
|||
}
|
||||
|
||||
function onSidebarLinkClick() {
|
||||
var section = this.getElementsByClassName('sectionName')[0];
|
||||
var text = section ? section.innerHTML : this.innerHTML;
|
||||
const section = this.getElementsByClassName('sectionName')[0];
|
||||
const text = section ? section.innerHTML : this.innerHTML;
|
||||
LibraryMenu.setTitle(text);
|
||||
}
|
||||
|
||||
function getUserViews(apiClient, userId) {
|
||||
return apiClient.getUserViews({}, userId).then(function (result) {
|
||||
var items = result.Items;
|
||||
var list = [];
|
||||
const items = result.Items;
|
||||
const list = [];
|
||||
|
||||
for (var i = 0, length = items.length; i < length; i++) {
|
||||
var view = items[i];
|
||||
for (let i = 0, length = items.length; i < length; i++) {
|
||||
const view = items[i];
|
||||
list.push(view);
|
||||
|
||||
if ('livetv' == view.CollectionType) {
|
||||
if (view.CollectionType == 'livetv') {
|
||||
view.ImageTags = {};
|
||||
view.icon = 'live_tv';
|
||||
var guideView = Object.assign({}, view);
|
||||
guideView.Name = globalize.translate('ButtonGuide');
|
||||
const guideView = Object.assign({}, view);
|
||||
guideView.Name = globalize.translate('Guide');
|
||||
guideView.ImageTags = {};
|
||||
guideView.icon = 'dvr';
|
||||
guideView.url = 'livetv.html?tab=1';
|
||||
|
@ -562,7 +580,7 @@ define(['dom', 'layoutManager', 'inputManager', 'connectionManager', 'events', '
|
|||
}
|
||||
|
||||
function showBySelector(selector, show) {
|
||||
var elem = document.querySelector(selector);
|
||||
const elem = document.querySelector(selector);
|
||||
|
||||
if (elem) {
|
||||
if (show) {
|
||||
|
@ -574,15 +592,12 @@ define(['dom', 'layoutManager', 'inputManager', 'connectionManager', 'events', '
|
|||
}
|
||||
|
||||
function updateLibraryMenu(user) {
|
||||
// FIXME: Potential equivalent might be
|
||||
// showBySelector(".lnkSyncToOtherDevices", !!user.Policy.EnableContentDownloading);
|
||||
if (!user) {
|
||||
showBySelector('.libraryMenuDownloads', false);
|
||||
showBySelector('.lnkSyncToOtherDevices', false);
|
||||
return void showBySelector('.userMenuOptions', false);
|
||||
}
|
||||
|
||||
// FIXME: Potentially the same as above
|
||||
if (user.Policy.EnableContentDownloading) {
|
||||
showBySelector('.lnkSyncToOtherDevices', true);
|
||||
} else {
|
||||
|
@ -595,34 +610,30 @@ define(['dom', 'layoutManager', 'inputManager', 'connectionManager', 'events', '
|
|||
showBySelector('.libraryMenuDownloads', false);
|
||||
}
|
||||
|
||||
var userId = Dashboard.getCurrentUserId();
|
||||
var apiClient = getCurrentApiClient();
|
||||
var libraryMenuOptions = document.querySelector('.libraryMenuOptions');
|
||||
const userId = Dashboard.getCurrentUserId();
|
||||
const apiClient = getCurrentApiClient();
|
||||
const libraryMenuOptions = document.querySelector('.libraryMenuOptions');
|
||||
|
||||
if (libraryMenuOptions) {
|
||||
getUserViews(apiClient, userId).then(function (result) {
|
||||
var items = result;
|
||||
var html = '';
|
||||
html += '<h3 class="sidebarHeader">';
|
||||
html += globalize.translate('HeaderMedia');
|
||||
html += '</h3>';
|
||||
const items = result;
|
||||
let html = `<h3 class="sidebarHeader">${globalize.translate('HeaderMedia')}</h3>`;
|
||||
html += items.map(function (i) {
|
||||
var icon = i.icon || imageHelper.getLibraryIcon(i.CollectionType);
|
||||
var itemId = i.Id;
|
||||
const icon = i.icon || imageHelper.getLibraryIcon(i.CollectionType);
|
||||
const itemId = i.Id;
|
||||
|
||||
if (i.onclick) {
|
||||
i.onclick;
|
||||
}
|
||||
|
||||
return '<a is="emby-linkbutton" data-itemid="' + itemId + '" class="lnkMediaFolder navMenuOption" href="' + getItemHref(i, i.CollectionType) + '"><span class="material-icons navMenuOptionIcon ' + icon + '"></span><span class="sectionName navMenuOptionText">' + i.Name + '</span></a>';
|
||||
return `<a is="emby-linkbutton" data-itemid="${itemId}" class="lnkMediaFolder navMenuOption" href="${getItemHref(i, i.CollectionType)}">
|
||||
<span class="material-icons navMenuOptionIcon ${icon}"></span>
|
||||
<span class="sectionName navMenuOptionText">${i.Name}</span>
|
||||
</a>`;
|
||||
}).join('');
|
||||
libraryMenuOptions.innerHTML = html;
|
||||
var elem = libraryMenuOptions;
|
||||
var sidebarLinks = elem.querySelectorAll('.navMenuOption');
|
||||
const elem = libraryMenuOptions;
|
||||
const sidebarLinks = elem.querySelectorAll('.navMenuOption');
|
||||
|
||||
for (var i = 0, length = sidebarLinks.length; i < length; i++) {
|
||||
sidebarLinks[i].removeEventListener('click', onSidebarLinkClick);
|
||||
sidebarLinks[i].addEventListener('click', onSidebarLinkClick);
|
||||
for (const sidebarLink of sidebarLinks) {
|
||||
sidebarLink.removeEventListener('click', onSidebarLinkClick);
|
||||
sidebarLink.addEventListener('click', onSidebarLinkClick);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -647,9 +658,9 @@ define(['dom', 'layoutManager', 'inputManager', 'connectionManager', 'events', '
|
|||
}
|
||||
|
||||
function updateCastIcon() {
|
||||
var context = document;
|
||||
var info = playbackManager.getPlayerInfo();
|
||||
var icon = headerCastButton.querySelector('.material-icons');
|
||||
const context = document;
|
||||
const info = playbackManager.getPlayerInfo();
|
||||
const icon = headerCastButton.querySelector('.material-icons');
|
||||
|
||||
icon.classList.remove('cast_connected', 'cast');
|
||||
|
||||
|
@ -665,28 +676,26 @@ define(['dom', 'layoutManager', 'inputManager', 'connectionManager', 'events', '
|
|||
}
|
||||
|
||||
function updateLibraryNavLinks(page) {
|
||||
var i;
|
||||
var length;
|
||||
var isLiveTvPage = page.classList.contains('liveTvPage');
|
||||
var isChannelsPage = page.classList.contains('channelsPage');
|
||||
var isEditorPage = page.classList.contains('metadataEditorPage');
|
||||
var isMySyncPage = page.classList.contains('mySyncPage');
|
||||
var id = isLiveTvPage || isChannelsPage || isEditorPage || isMySyncPage || page.classList.contains('allLibraryPage') ? '' : getTopParentId() || '';
|
||||
var elems = document.getElementsByClassName('lnkMediaFolder');
|
||||
const isLiveTvPage = page.classList.contains('liveTvPage');
|
||||
const isChannelsPage = page.classList.contains('channelsPage');
|
||||
const isEditorPage = page.classList.contains('metadataEditorPage');
|
||||
const isMySyncPage = page.classList.contains('mySyncPage');
|
||||
const id = isLiveTvPage || isChannelsPage || isEditorPage || isMySyncPage || page.classList.contains('allLibraryPage') ? '' : getTopParentId() || '';
|
||||
const elems = document.getElementsByClassName('lnkMediaFolder');
|
||||
|
||||
for (var i = 0, length = elems.length; i < length; i++) {
|
||||
var lnkMediaFolder = elems[i];
|
||||
var itemId = lnkMediaFolder.getAttribute('data-itemid');
|
||||
for (let i = 0, length = elems.length; i < length; i++) {
|
||||
const lnkMediaFolder = elems[i];
|
||||
const itemId = lnkMediaFolder.getAttribute('data-itemid');
|
||||
|
||||
if (isChannelsPage && 'channels' === itemId) {
|
||||
if (isChannelsPage && itemId === 'channels') {
|
||||
lnkMediaFolder.classList.add('navMenuOption-selected');
|
||||
} else if (isLiveTvPage && 'livetv' === itemId) {
|
||||
} else if (isLiveTvPage && itemId === 'livetv') {
|
||||
lnkMediaFolder.classList.add('navMenuOption-selected');
|
||||
} else if (isEditorPage && 'editor' === itemId) {
|
||||
} else if (isEditorPage && itemId === 'editor') {
|
||||
lnkMediaFolder.classList.add('navMenuOption-selected');
|
||||
} else if (isMySyncPage && 'manageoffline' === itemId && -1 != window.location.href.toString().indexOf('mode=download')) {
|
||||
} else if (isMySyncPage && itemId === 'manageoffline' && window.location.href.toString().indexOf('mode=download') != -1) {
|
||||
lnkMediaFolder.classList.add('navMenuOption-selected');
|
||||
} else if (isMySyncPage && 'syncotherdevices' === itemId && -1 == window.location.href.toString().indexOf('mode=download')) {
|
||||
} else if (isMySyncPage && itemId === 'syncotherdevices' && window.location.href.toString().indexOf('mode=download') == -1) {
|
||||
lnkMediaFolder.classList.add('navMenuOption-selected');
|
||||
} else if (id && itemId == id) {
|
||||
lnkMediaFolder.classList.add('navMenuOption-selected');
|
||||
|
@ -697,7 +706,7 @@ define(['dom', 'layoutManager', 'inputManager', 'connectionManager', 'events', '
|
|||
}
|
||||
|
||||
function updateMenuForPageType(isDashboardPage, isLibraryPage) {
|
||||
var newPageType = isDashboardPage ? 2 : isLibraryPage ? 1 : 3;
|
||||
const newPageType = isDashboardPage ? 2 : isLibraryPage ? 1 : 3;
|
||||
|
||||
if (currentPageType !== newPageType) {
|
||||
currentPageType = newPageType;
|
||||
|
@ -708,7 +717,7 @@ define(['dom', 'layoutManager', 'inputManager', 'connectionManager', 'events', '
|
|||
skinHeader.classList.remove('headroomDisabled');
|
||||
}
|
||||
|
||||
var bodyClassList = document.body.classList;
|
||||
const bodyClassList = document.body.classList;
|
||||
|
||||
if (isLibraryPage) {
|
||||
bodyClassList.add('libraryDocument');
|
||||
|
@ -745,7 +754,7 @@ define(['dom', 'layoutManager', 'inputManager', 'connectionManager', 'events', '
|
|||
}
|
||||
|
||||
function updateTitle(page) {
|
||||
var title = page.getAttribute('data-title');
|
||||
const title = page.getAttribute('data-title');
|
||||
|
||||
if (title) {
|
||||
LibraryMenu.setTitle(title);
|
||||
|
@ -760,7 +769,7 @@ define(['dom', 'layoutManager', 'inputManager', 'connectionManager', 'events', '
|
|||
}
|
||||
|
||||
if (headerBackButton) {
|
||||
if ('false' !== page.getAttribute('data-backbutton') && appRouter.canGoBack()) {
|
||||
if (page.getAttribute('data-backbutton') !== 'false' && appRouter.canGoBack()) {
|
||||
headerBackButton.classList.remove('hide');
|
||||
} else {
|
||||
headerBackButton.classList.add('hide');
|
||||
|
@ -769,8 +778,8 @@ define(['dom', 'layoutManager', 'inputManager', 'connectionManager', 'events', '
|
|||
}
|
||||
|
||||
function initHeadRoom(elem) {
|
||||
require(['headroom'], function (Headroom) {
|
||||
var headroom = new Headroom(elem);
|
||||
import('headroom').then(({default: Headroom}) => {
|
||||
const headroom = new Headroom(elem);
|
||||
headroom.init();
|
||||
});
|
||||
}
|
||||
|
@ -790,7 +799,7 @@ define(['dom', 'layoutManager', 'inputManager', 'connectionManager', 'events', '
|
|||
}
|
||||
|
||||
function getNavDrawerOptions() {
|
||||
var drawerWidth = screen.availWidth - 50;
|
||||
let drawerWidth = window.screen.availWidth - 50;
|
||||
drawerWidth = Math.max(drawerWidth, 240);
|
||||
drawerWidth = Math.min(drawerWidth, 320);
|
||||
return {
|
||||
|
@ -809,7 +818,7 @@ define(['dom', 'layoutManager', 'inputManager', 'connectionManager', 'events', '
|
|||
navDrawerScrollContainer = navDrawerElement.querySelector('.scrollContainer');
|
||||
navDrawerScrollContainer.addEventListener('click', onMainDrawerClick);
|
||||
return new Promise(function (resolve, reject) {
|
||||
require(['navdrawer'], function (navdrawer) {
|
||||
import('navdrawer').then(({default: navdrawer}) => {
|
||||
navDrawerInstance = new navdrawer(getNavDrawerOptions());
|
||||
|
||||
if (!layoutManager.tv) {
|
||||
|
@ -821,98 +830,98 @@ define(['dom', 'layoutManager', 'inputManager', 'connectionManager', 'events', '
|
|||
});
|
||||
}
|
||||
|
||||
var navDrawerElement;
|
||||
var navDrawerScrollContainer;
|
||||
var navDrawerInstance;
|
||||
var mainDrawerButton;
|
||||
var headerHomeButton;
|
||||
var currentDrawerType;
|
||||
var pageTitleElement;
|
||||
var headerBackButton;
|
||||
var headerUserButton;
|
||||
var currentUser;
|
||||
var headerCastButton;
|
||||
var headerSearchButton;
|
||||
var headerAudioPlayerButton;
|
||||
var headerSyncButton;
|
||||
var enableLibraryNavDrawer = layoutManager.desktop;
|
||||
var skinHeader = document.querySelector('.skinHeader');
|
||||
var requiresUserRefresh = true;
|
||||
var lastOpenTime = new Date().getTime();
|
||||
window.LibraryMenu = {
|
||||
getTopParentId: getTopParentId,
|
||||
onHardwareMenuButtonClick: function () {
|
||||
toggleMainDrawer();
|
||||
},
|
||||
setTabs: function (type, selectedIndex, builder) {
|
||||
require(['mainTabsManager'], function (mainTabsManager) {
|
||||
if (type) {
|
||||
mainTabsManager.setTabs(viewManager.currentView(), selectedIndex, builder, function () {
|
||||
return [];
|
||||
});
|
||||
} else {
|
||||
mainTabsManager.setTabs(null);
|
||||
}
|
||||
});
|
||||
},
|
||||
setDefaultTitle: function () {
|
||||
if (!pageTitleElement) {
|
||||
pageTitleElement = document.querySelector('.pageTitle');
|
||||
}
|
||||
let navDrawerElement;
|
||||
let navDrawerScrollContainer;
|
||||
let navDrawerInstance;
|
||||
let mainDrawerButton;
|
||||
let headerHomeButton;
|
||||
let currentDrawerType;
|
||||
let pageTitleElement;
|
||||
let headerBackButton;
|
||||
let headerUserButton;
|
||||
let currentUser;
|
||||
let headerCastButton;
|
||||
let headerSearchButton;
|
||||
let headerAudioPlayerButton;
|
||||
let headerSyncButton;
|
||||
const enableLibraryNavDrawer = layoutManager.desktop;
|
||||
const enableLibraryNavDrawerHome = !layoutManager.tv;
|
||||
const skinHeader = document.querySelector('.skinHeader');
|
||||
let requiresUserRefresh = true;
|
||||
|
||||
if (pageTitleElement) {
|
||||
pageTitleElement.classList.add('pageTitleWithLogo');
|
||||
pageTitleElement.classList.add('pageTitleWithDefaultLogo');
|
||||
pageTitleElement.style.backgroundImage = null;
|
||||
pageTitleElement.innerHTML = '';
|
||||
}
|
||||
|
||||
document.title = 'Jellyfin';
|
||||
},
|
||||
setTitle: function (title) {
|
||||
if (null == title) {
|
||||
return void LibraryMenu.setDefaultTitle();
|
||||
}
|
||||
|
||||
if ('-' === title) {
|
||||
title = '';
|
||||
}
|
||||
|
||||
var html = title;
|
||||
|
||||
if (!pageTitleElement) {
|
||||
pageTitleElement = document.querySelector('.pageTitle');
|
||||
}
|
||||
|
||||
if (pageTitleElement) {
|
||||
pageTitleElement.classList.remove('pageTitleWithLogo');
|
||||
pageTitleElement.classList.remove('pageTitleWithDefaultLogo');
|
||||
pageTitleElement.style.backgroundImage = null;
|
||||
pageTitleElement.innerHTML = html || '';
|
||||
}
|
||||
|
||||
document.title = title || 'Jellyfin';
|
||||
},
|
||||
setTransparentMenu: function (transparent) {
|
||||
if (transparent) {
|
||||
skinHeader.classList.add('semiTransparent');
|
||||
function setTabs (type, selectedIndex, builder) {
|
||||
import('mainTabsManager').then((mainTabsManager) => {
|
||||
if (type) {
|
||||
mainTabsManager.setTabs(viewManager.currentView(), selectedIndex, builder, function () {
|
||||
return [];
|
||||
});
|
||||
} else {
|
||||
skinHeader.classList.remove('semiTransparent');
|
||||
mainTabsManager.setTabs(null);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function setDefaultTitle () {
|
||||
if (!pageTitleElement) {
|
||||
pageTitleElement = document.querySelector('.pageTitle');
|
||||
}
|
||||
};
|
||||
var currentPageType;
|
||||
|
||||
if (pageTitleElement) {
|
||||
pageTitleElement.classList.add('pageTitleWithLogo');
|
||||
pageTitleElement.classList.add('pageTitleWithDefaultLogo');
|
||||
pageTitleElement.style.backgroundImage = null;
|
||||
pageTitleElement.innerHTML = '';
|
||||
}
|
||||
|
||||
document.title = 'Jellyfin';
|
||||
}
|
||||
|
||||
function setTitle (title) {
|
||||
if (title == null) {
|
||||
return void LibraryMenu.setDefaultTitle();
|
||||
}
|
||||
|
||||
if (title === '-') {
|
||||
title = '';
|
||||
}
|
||||
|
||||
const html = title;
|
||||
|
||||
if (!pageTitleElement) {
|
||||
pageTitleElement = document.querySelector('.pageTitle');
|
||||
}
|
||||
|
||||
if (pageTitleElement) {
|
||||
pageTitleElement.classList.remove('pageTitleWithLogo');
|
||||
pageTitleElement.classList.remove('pageTitleWithDefaultLogo');
|
||||
pageTitleElement.style.backgroundImage = null;
|
||||
pageTitleElement.innerHTML = html || '';
|
||||
}
|
||||
|
||||
document.title = title || 'Jellyfin';
|
||||
}
|
||||
|
||||
function setTransparentMenu (transparent) {
|
||||
if (transparent) {
|
||||
skinHeader.classList.add('semiTransparent');
|
||||
} else {
|
||||
skinHeader.classList.remove('semiTransparent');
|
||||
}
|
||||
}
|
||||
|
||||
let currentPageType;
|
||||
pageClassOn('pagebeforeshow', 'page', function (e) {
|
||||
if (!this.classList.contains('withTabs')) {
|
||||
LibraryMenu.setTabs(null);
|
||||
}
|
||||
});
|
||||
|
||||
pageClassOn('pageshow', 'page', function (e) {
|
||||
var page = this;
|
||||
var isDashboardPage = page.classList.contains('type-interior');
|
||||
var isHomePage = page.classList.contains('homePage');
|
||||
var isLibraryPage = !isDashboardPage && page.classList.contains('libraryPage');
|
||||
var apiClient = getCurrentApiClient();
|
||||
const page = this;
|
||||
const isDashboardPage = page.classList.contains('type-interior');
|
||||
const isHomePage = page.classList.contains('homePage');
|
||||
const isLibraryPage = !isDashboardPage && page.classList.contains('libraryPage');
|
||||
const apiClient = getCurrentApiClient();
|
||||
|
||||
if (isDashboardPage) {
|
||||
if (mainDrawerButton) {
|
||||
|
@ -922,20 +931,21 @@ define(['dom', 'layoutManager', 'inputManager', 'connectionManager', 'events', '
|
|||
refreshDashboardInfoInDrawer(apiClient);
|
||||
} else {
|
||||
if (mainDrawerButton) {
|
||||
if (enableLibraryNavDrawer || isHomePage) {
|
||||
if (enableLibraryNavDrawer || (isHomePage && enableLibraryNavDrawerHome)) {
|
||||
mainDrawerButton.classList.remove('hide');
|
||||
} else {
|
||||
mainDrawerButton.classList.add('hide');
|
||||
}
|
||||
}
|
||||
|
||||
if ('library' !== currentDrawerType) {
|
||||
if (currentDrawerType !== 'library') {
|
||||
refreshLibraryDrawer();
|
||||
}
|
||||
}
|
||||
|
||||
updateMenuForPageType(isDashboardPage, isLibraryPage);
|
||||
|
||||
// TODO: Seems to do nothing? Check if needed (also in other views).
|
||||
if (!e.detail.isRestored) {
|
||||
window.scrollTo(0, 0);
|
||||
}
|
||||
|
@ -948,7 +958,7 @@ define(['dom', 'layoutManager', 'inputManager', 'connectionManager', 'events', '
|
|||
renderHeader();
|
||||
|
||||
events.on(connectionManager, 'localusersignedin', function (e, user) {
|
||||
var currentApiClient = connectionManager.getApiClient(user.ServerId);
|
||||
const currentApiClient = connectionManager.getApiClient(user.ServerId);
|
||||
|
||||
currentDrawerType = null;
|
||||
currentUser = {
|
||||
|
@ -962,13 +972,32 @@ define(['dom', 'layoutManager', 'inputManager', 'connectionManager', 'events', '
|
|||
updateUserInHeader(user);
|
||||
});
|
||||
});
|
||||
|
||||
events.on(connectionManager, 'localusersignedout', function () {
|
||||
currentUser = {};
|
||||
updateUserInHeader();
|
||||
});
|
||||
|
||||
events.on(playbackManager, 'playerchange', updateCastIcon);
|
||||
|
||||
events.on(syncPlayManager, 'enabled', onSyncPlayEnabled);
|
||||
events.on(syncPlayManager, 'syncing', onSyncPlaySyncing);
|
||||
|
||||
loadNavDrawer();
|
||||
return LibraryMenu;
|
||||
});
|
||||
|
||||
const LibraryMenu = {
|
||||
getTopParentId: getTopParentId,
|
||||
onHardwareMenuButtonClick: function () {
|
||||
toggleMainDrawer();
|
||||
},
|
||||
setTabs: setTabs,
|
||||
setDefaultTitle: setDefaultTitle,
|
||||
setTitle: setTitle,
|
||||
setTransparentMenu: setTransparentMenu
|
||||
};
|
||||
|
||||
window.LibraryMenu = LibraryMenu;
|
||||
|
||||
export default LibraryMenu;
|
||||
|
||||
/* eslint-enable indent */
|
||||
|
|
|
@ -1,118 +1,109 @@
|
|||
define(['layoutManager', 'datetime', 'cardBuilder', 'apphost'], function (layoutManager, datetime, cardBuilder, appHost) {
|
||||
'use strict';
|
||||
import layoutManager from 'layoutManager';
|
||||
import datetime from 'datetime';
|
||||
import cardBuilder from 'cardBuilder';
|
||||
|
||||
function enableScrollX() {
|
||||
return !layoutManager.desktop;
|
||||
function enableScrollX() {
|
||||
return !layoutManager.desktop;
|
||||
}
|
||||
|
||||
function getBackdropShape() {
|
||||
return enableScrollX() ? 'overflowBackdrop' : 'backdrop';
|
||||
}
|
||||
|
||||
function getTimersHtml(timers, options) {
|
||||
options = options || {};
|
||||
|
||||
const items = timers.map(function (t) {
|
||||
t.Type = 'Timer';
|
||||
return t;
|
||||
});
|
||||
|
||||
const groups = [];
|
||||
let currentGroupName = '';
|
||||
let currentGroup = [];
|
||||
|
||||
for (const item of items) {
|
||||
let dateText = '';
|
||||
|
||||
if (options.indexByDate !== false && item.StartDate) {
|
||||
try {
|
||||
const premiereDate = datetime.parseISO8601Date(item.StartDate, true);
|
||||
dateText = datetime.toLocaleDateString(premiereDate, {
|
||||
weekday: 'long',
|
||||
month: 'short',
|
||||
day: 'numeric'
|
||||
});
|
||||
} catch (err) {
|
||||
console.error('error parsing premiereDate:' + item.StartDate + '; error: ' + err);
|
||||
}
|
||||
}
|
||||
|
||||
if (dateText != currentGroupName) {
|
||||
if (currentGroup.length) {
|
||||
groups.push({
|
||||
name: currentGroupName,
|
||||
items: currentGroup
|
||||
});
|
||||
}
|
||||
|
||||
currentGroupName = dateText;
|
||||
currentGroup = [item];
|
||||
} else {
|
||||
currentGroup.push(item);
|
||||
}
|
||||
}
|
||||
|
||||
function getBackdropShape() {
|
||||
return enableScrollX() ? 'overflowBackdrop' : 'backdrop';
|
||||
}
|
||||
|
||||
function getTimersHtml(timers, options) {
|
||||
options = options || {};
|
||||
var i;
|
||||
var length;
|
||||
var items = timers.map(function (t) {
|
||||
t.Type = 'Timer';
|
||||
return t;
|
||||
if (currentGroup.length) {
|
||||
groups.push({
|
||||
name: currentGroupName,
|
||||
items: currentGroup
|
||||
});
|
||||
var groups = [];
|
||||
var currentGroupName = '';
|
||||
var currentGroup = [];
|
||||
|
||||
for (i = 0, length = items.length; i < length; i++) {
|
||||
var item = items[i];
|
||||
var dateText = '';
|
||||
|
||||
if (options.indexByDate !== false && item.StartDate) {
|
||||
try {
|
||||
var premiereDate = datetime.parseISO8601Date(item.StartDate, true);
|
||||
dateText = datetime.toLocaleDateString(premiereDate, {
|
||||
weekday: 'long',
|
||||
month: 'short',
|
||||
day: 'numeric'
|
||||
});
|
||||
} catch (err) {
|
||||
console.error('error parsing premiereDate:' + item.StartDate + '; error: ' + err);
|
||||
}
|
||||
}
|
||||
|
||||
if (dateText != currentGroupName) {
|
||||
if (currentGroup.length) {
|
||||
groups.push({
|
||||
name: currentGroupName,
|
||||
items: currentGroup
|
||||
});
|
||||
}
|
||||
|
||||
currentGroupName = dateText;
|
||||
currentGroup = [item];
|
||||
} else {
|
||||
currentGroup.push(item);
|
||||
}
|
||||
}
|
||||
|
||||
if (currentGroup.length) {
|
||||
groups.push({
|
||||
name: currentGroupName,
|
||||
items: currentGroup
|
||||
});
|
||||
}
|
||||
|
||||
var html = '';
|
||||
|
||||
for (i = 0, length = groups.length; i < length; i++) {
|
||||
var group = groups[i];
|
||||
var supportsImageAnalysis = appHost.supports('imageanalysis');
|
||||
var cardLayout = appHost.preferVisualCards || supportsImageAnalysis;
|
||||
|
||||
cardLayout = true;
|
||||
if (group.name) {
|
||||
html += '<div class="verticalSection">';
|
||||
html += '<h2 class="sectionTitle sectionTitle-cards padded-left">' + group.name + '</h2>';
|
||||
}
|
||||
if (enableScrollX()) {
|
||||
var scrollXClass = 'scrollX hiddenScrollX';
|
||||
|
||||
if (layoutManager.tv) {
|
||||
scrollXClass += ' smoothScrollX';
|
||||
}
|
||||
|
||||
html += '<div is="emby-itemscontainer" class="itemsContainer ' + scrollXClass + ' padded-left padded-right">';
|
||||
} else {
|
||||
html += '<div is="emby-itemscontainer" class="itemsContainer vertical-wrap padded-left padded-right">';
|
||||
}
|
||||
|
||||
html += cardBuilder.getCardsHtml({
|
||||
items: group.items,
|
||||
shape: cardLayout ? getBackdropShape() : enableScrollX() ? 'autoOverflow' : 'autoVertical',
|
||||
showParentTitleOrTitle: true,
|
||||
showAirTime: true,
|
||||
showAirEndTime: true,
|
||||
showChannelName: !cardLayout,
|
||||
cardLayout: cardLayout,
|
||||
centerText: !cardLayout,
|
||||
action: 'edit',
|
||||
cardFooterAside: 'none',
|
||||
preferThumb: !!cardLayout || 'auto',
|
||||
defaultShape: cardLayout ? null : 'portrait',
|
||||
coverImage: true,
|
||||
allowBottomPadding: false,
|
||||
overlayText: false,
|
||||
showChannelLogo: cardLayout
|
||||
});
|
||||
html += '</div>';
|
||||
|
||||
if (group.name) {
|
||||
html += '</div>';
|
||||
}
|
||||
}
|
||||
|
||||
return Promise.resolve(html);
|
||||
}
|
||||
let html = '';
|
||||
for (const group of groups) {
|
||||
if (group.name) {
|
||||
html += '<div class="verticalSection">';
|
||||
html += '<h2 class="sectionTitle sectionTitle-cards padded-left">' + group.name + '</h2>';
|
||||
}
|
||||
|
||||
window.LiveTvHelpers = {
|
||||
getTimersHtml: getTimersHtml
|
||||
};
|
||||
});
|
||||
if (enableScrollX()) {
|
||||
let scrollXClass = 'scrollX hiddenScrollX';
|
||||
if (layoutManager.tv) {
|
||||
scrollXClass += ' smoothScrollX';
|
||||
}
|
||||
html += '<div is="emby-itemscontainer" class="itemsContainer ' + scrollXClass + ' padded-left padded-right">';
|
||||
} else {
|
||||
html += '<div is="emby-itemscontainer" class="itemsContainer vertical-wrap padded-left padded-right">';
|
||||
}
|
||||
|
||||
html += cardBuilder.getCardsHtml({
|
||||
items: group.items,
|
||||
shape: getBackdropShape(),
|
||||
showParentTitleOrTitle: true,
|
||||
showAirTime: true,
|
||||
showAirEndTime: true,
|
||||
showChannelName: false,
|
||||
cardLayout: true,
|
||||
centerText: false,
|
||||
action: 'edit',
|
||||
cardFooterAside: 'none',
|
||||
preferThumb: true,
|
||||
defaultShape: null,
|
||||
coverImage: true,
|
||||
allowBottomPadding: false,
|
||||
overlayText: false,
|
||||
showChannelLogo: true
|
||||
});
|
||||
|
||||
html += '</div>';
|
||||
|
||||
if (group.name) {
|
||||
html += '</div>';
|
||||
}
|
||||
}
|
||||
return Promise.resolve(html);
|
||||
}
|
||||
|
||||
window.LiveTvHelpers = {
|
||||
getTimersHtml: getTimersHtml
|
||||
};
|
||||
|
|
|
@ -1,31 +1,33 @@
|
|||
define(['inputManager', 'focusManager', 'browser', 'layoutManager', 'events', 'dom'], function (inputManager, focusManager, browser, layoutManager, events, dom) {
|
||||
'use strict';
|
||||
import inputManager from 'inputManager';
|
||||
import focusManager from 'focusManager';
|
||||
import browser from 'browser';
|
||||
import layoutManager from 'layoutManager';
|
||||
import events from 'events';
|
||||
import dom from 'dom';
|
||||
/* eslint-disable indent */
|
||||
|
||||
var self = {};
|
||||
const self = {};
|
||||
|
||||
var lastMouseInputTime = new Date().getTime();
|
||||
var isMouseIdle;
|
||||
let lastMouseInputTime = new Date().getTime();
|
||||
let isMouseIdle;
|
||||
|
||||
function mouseIdleTime() {
|
||||
return new Date().getTime() - lastMouseInputTime;
|
||||
}
|
||||
|
||||
function notifyApp() {
|
||||
|
||||
inputManager.notifyMouseMove();
|
||||
}
|
||||
|
||||
function removeIdleClasses() {
|
||||
|
||||
var classList = document.body.classList;
|
||||
const classList = document.body.classList;
|
||||
|
||||
classList.remove('mouseIdle');
|
||||
classList.remove('mouseIdle-tv');
|
||||
}
|
||||
|
||||
function addIdleClasses() {
|
||||
|
||||
var classList = document.body.classList;
|
||||
const classList = document.body.classList;
|
||||
|
||||
classList.add('mouseIdle');
|
||||
|
||||
|
@ -34,18 +36,33 @@ define(['inputManager', 'focusManager', 'browser', 'layoutManager', 'events', 'd
|
|||
}
|
||||
}
|
||||
|
||||
var lastPointerMoveData;
|
||||
function onPointerMove(e) {
|
||||
export function showCursor() {
|
||||
if (isMouseIdle) {
|
||||
isMouseIdle = false;
|
||||
removeIdleClasses();
|
||||
events.trigger(self, 'mouseactive');
|
||||
}
|
||||
}
|
||||
|
||||
var eventX = e.screenX;
|
||||
var eventY = e.screenY;
|
||||
export function hideCursor() {
|
||||
if (!isMouseIdle) {
|
||||
isMouseIdle = true;
|
||||
addIdleClasses();
|
||||
events.trigger(self, 'mouseidle');
|
||||
}
|
||||
}
|
||||
|
||||
let lastPointerMoveData;
|
||||
function onPointerMove(e) {
|
||||
const eventX = e.screenX;
|
||||
const eventY = e.screenY;
|
||||
|
||||
// if coord don't exist how could it move
|
||||
if (typeof eventX === 'undefined' && typeof eventY === 'undefined') {
|
||||
return;
|
||||
}
|
||||
|
||||
var obj = lastPointerMoveData;
|
||||
const obj = lastPointerMoveData;
|
||||
if (!obj) {
|
||||
lastPointerMoveData = {
|
||||
x: eventX,
|
||||
|
@ -65,20 +82,15 @@ define(['inputManager', 'focusManager', 'browser', 'layoutManager', 'events', 'd
|
|||
lastMouseInputTime = new Date().getTime();
|
||||
notifyApp();
|
||||
|
||||
if (isMouseIdle) {
|
||||
isMouseIdle = false;
|
||||
removeIdleClasses();
|
||||
events.trigger(self, 'mouseactive');
|
||||
}
|
||||
showCursor();
|
||||
}
|
||||
|
||||
function onPointerEnter(e) {
|
||||
|
||||
var pointerType = e.pointerType || (layoutManager.mobile ? 'touch' : 'mouse');
|
||||
const pointerType = e.pointerType || (layoutManager.mobile ? 'touch' : 'mouse');
|
||||
|
||||
if (pointerType === 'mouse') {
|
||||
if (!isMouseIdle) {
|
||||
var parent = focusManager.focusableParent(e.target);
|
||||
const parent = focusManager.focusableParent(e.target);
|
||||
if (parent) {
|
||||
focusManager.focus(parent);
|
||||
}
|
||||
|
@ -87,7 +99,6 @@ define(['inputManager', 'focusManager', 'browser', 'layoutManager', 'events', 'd
|
|||
}
|
||||
|
||||
function enableFocusWithMouse() {
|
||||
|
||||
if (!layoutManager.tv) {
|
||||
return false;
|
||||
}
|
||||
|
@ -104,25 +115,20 @@ define(['inputManager', 'focusManager', 'browser', 'layoutManager', 'events', 'd
|
|||
}
|
||||
|
||||
function onMouseInterval() {
|
||||
|
||||
if (!isMouseIdle && mouseIdleTime() >= 5000) {
|
||||
isMouseIdle = true;
|
||||
addIdleClasses();
|
||||
events.trigger(self, 'mouseidle');
|
||||
hideCursor();
|
||||
}
|
||||
}
|
||||
|
||||
var mouseInterval;
|
||||
let mouseInterval;
|
||||
function startMouseInterval() {
|
||||
|
||||
if (!mouseInterval) {
|
||||
mouseInterval = setInterval(onMouseInterval, 5000);
|
||||
}
|
||||
}
|
||||
|
||||
function stopMouseInterval() {
|
||||
|
||||
var interval = mouseInterval;
|
||||
const interval = mouseInterval;
|
||||
|
||||
if (interval) {
|
||||
clearInterval(interval);
|
||||
|
@ -133,9 +139,9 @@ define(['inputManager', 'focusManager', 'browser', 'layoutManager', 'events', 'd
|
|||
}
|
||||
|
||||
function initMouse() {
|
||||
|
||||
stopMouseInterval();
|
||||
|
||||
/* eslint-disable-next-line compat/compat */
|
||||
dom.removeEventListener(document, (window.PointerEvent ? 'pointermove' : 'mousemove'), onPointerMove, {
|
||||
passive: true
|
||||
});
|
||||
|
@ -148,6 +154,7 @@ define(['inputManager', 'focusManager', 'browser', 'layoutManager', 'events', 'd
|
|||
});
|
||||
}
|
||||
|
||||
/* eslint-disable-next-line compat/compat */
|
||||
dom.removeEventListener(document, (window.PointerEvent ? 'pointerenter' : 'mouseenter'), onPointerEnter, {
|
||||
capture: true,
|
||||
passive: true
|
||||
|
@ -165,5 +172,10 @@ define(['inputManager', 'focusManager', 'browser', 'layoutManager', 'events', 'd
|
|||
|
||||
events.on(layoutManager, 'modechange', initMouse);
|
||||
|
||||
return self;
|
||||
});
|
||||
/* eslint-enable indent */
|
||||
|
||||
export default {
|
||||
hideCursor,
|
||||
showCursor
|
||||
};
|
||||
|
||||
|
|
|
@ -1,66 +1,64 @@
|
|||
define(['browser'], function (browser) {
|
||||
'use strict';
|
||||
import browser from 'browser';
|
||||
|
||||
function fallback(urls) {
|
||||
var i = 0;
|
||||
function fallback(urls) {
|
||||
var i = 0;
|
||||
|
||||
(function createIframe() {
|
||||
var frame = document.createElement('iframe');
|
||||
frame.style.display = 'none';
|
||||
frame.src = urls[i++];
|
||||
document.documentElement.appendChild(frame);
|
||||
(function createIframe() {
|
||||
var frame = document.createElement('iframe');
|
||||
frame.style.display = 'none';
|
||||
frame.src = urls[i++];
|
||||
document.documentElement.appendChild(frame);
|
||||
|
||||
// the download init has to be sequential otherwise IE only use the first
|
||||
var interval = setInterval(function () {
|
||||
if (frame.contentWindow.document.readyState === 'complete' || frame.contentWindow.document.readyState === 'interactive') {
|
||||
clearInterval(interval);
|
||||
// the download init has to be sequential otherwise IE only use the first
|
||||
var interval = setInterval(function () {
|
||||
if (frame.contentWindow.document.readyState === 'complete' || frame.contentWindow.document.readyState === 'interactive') {
|
||||
clearInterval(interval);
|
||||
|
||||
// Safari needs a timeout
|
||||
setTimeout(function () {
|
||||
frame.parentNode.removeChild(frame);
|
||||
}, 1000);
|
||||
// Safari needs a timeout
|
||||
setTimeout(function () {
|
||||
frame.parentNode.removeChild(frame);
|
||||
}, 1000);
|
||||
|
||||
if (i < urls.length) {
|
||||
createIframe();
|
||||
}
|
||||
if (i < urls.length) {
|
||||
createIframe();
|
||||
}
|
||||
}, 100);
|
||||
})();
|
||||
}
|
||||
|
||||
function sameDomain(url) {
|
||||
var a = document.createElement('a');
|
||||
a.href = url;
|
||||
|
||||
return location.hostname === a.hostname && location.protocol === a.protocol;
|
||||
}
|
||||
|
||||
function download(url) {
|
||||
var a = document.createElement('a');
|
||||
a.download = '';
|
||||
a.href = url;
|
||||
// firefox doesn't support `a.click()`...
|
||||
a.dispatchEvent(new MouseEvent('click'));
|
||||
}
|
||||
|
||||
return function (urls) {
|
||||
if (!urls) {
|
||||
throw new Error('`urls` required');
|
||||
}
|
||||
|
||||
if (typeof document.createElement('a').download === 'undefined') {
|
||||
return fallback(urls);
|
||||
}
|
||||
|
||||
var delay = 0;
|
||||
|
||||
urls.forEach(function (url) {
|
||||
// the download init has to be sequential for firefox if the urls are not on the same domain
|
||||
if (browser.firefox && !sameDomain(url)) {
|
||||
return setTimeout(download.bind(null, url), 100 * ++delay);
|
||||
}
|
||||
}, 100);
|
||||
})();
|
||||
}
|
||||
|
||||
download(url);
|
||||
});
|
||||
};
|
||||
});
|
||||
function sameDomain(url) {
|
||||
var a = document.createElement('a');
|
||||
a.href = url;
|
||||
|
||||
return window.location.hostname === a.hostname && window.location.protocol === a.protocol;
|
||||
}
|
||||
|
||||
function download(url) {
|
||||
var a = document.createElement('a');
|
||||
a.download = '';
|
||||
a.href = url;
|
||||
// firefox doesn't support `a.click()`...
|
||||
a.dispatchEvent(new MouseEvent('click'));
|
||||
}
|
||||
|
||||
export default function (urls) {
|
||||
if (!urls) {
|
||||
throw new Error('`urls` required');
|
||||
}
|
||||
|
||||
if (typeof document.createElement('a').download === 'undefined') {
|
||||
return fallback(urls);
|
||||
}
|
||||
|
||||
var delay = 0;
|
||||
|
||||
urls.forEach(function (url) {
|
||||
// the download init has to be sequential for firefox if the urls are not on the same domain
|
||||
if (browser.firefox && !sameDomain(url)) {
|
||||
return setTimeout(download.bind(null, url), 100 * ++delay);
|
||||
}
|
||||
|
||||
download(url);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,194 +1,201 @@
|
|||
define(['loading', 'listView', 'cardBuilder', 'libraryMenu', 'libraryBrowser', 'apphost', 'imageLoader', 'userSettings', 'emby-itemscontainer'], function (loading, listView, cardBuilder, libraryMenu, libraryBrowser, appHost, imageLoader, userSettings) {
|
||||
'use strict';
|
||||
import loading from 'loading';
|
||||
import listView from 'listView';
|
||||
import cardBuilder from 'cardBuilder';
|
||||
import libraryMenu from 'libraryMenu';
|
||||
import libraryBrowser from 'libraryBrowser';
|
||||
import imageLoader from 'imageLoader';
|
||||
import userSettings from 'userSettings';
|
||||
import 'emby-itemscontainer';
|
||||
|
||||
return function (view, params) {
|
||||
function getPageData(context) {
|
||||
var key = getSavedQueryKey(context);
|
||||
var pageData = data[key];
|
||||
export default function (view, params) {
|
||||
function getPageData(context) {
|
||||
const key = getSavedQueryKey(context);
|
||||
let pageData = data[key];
|
||||
|
||||
if (!pageData) {
|
||||
pageData = data[key] = {
|
||||
query: {
|
||||
SortBy: 'SortName',
|
||||
SortOrder: 'Ascending',
|
||||
IncludeItemTypes: 'Playlist',
|
||||
Recursive: true,
|
||||
Fields: 'PrimaryImageAspectRatio,SortName,CumulativeRunTimeTicks,CanDelete',
|
||||
StartIndex: 0
|
||||
},
|
||||
view: libraryBrowser.getSavedView(key) || 'Poster'
|
||||
};
|
||||
if (!pageData) {
|
||||
pageData = data[key] = {
|
||||
query: {
|
||||
SortBy: 'SortName',
|
||||
SortOrder: 'Ascending',
|
||||
IncludeItemTypes: 'Playlist',
|
||||
Recursive: true,
|
||||
Fields: 'PrimaryImageAspectRatio,SortName,CumulativeRunTimeTicks,CanDelete',
|
||||
StartIndex: 0
|
||||
},
|
||||
view: libraryBrowser.getSavedView(key) || 'Poster'
|
||||
};
|
||||
|
||||
if (userSettings.libraryPageSize() > 0) {
|
||||
pageData.query['Limit'] = userSettings.libraryPageSize();
|
||||
}
|
||||
|
||||
pageData.query.ParentId = libraryMenu.getTopParentId();
|
||||
libraryBrowser.loadSavedQueryValues(key, pageData.query);
|
||||
if (userSettings.libraryPageSize() > 0) {
|
||||
pageData.query['Limit'] = userSettings.libraryPageSize();
|
||||
}
|
||||
|
||||
return pageData;
|
||||
pageData.query.ParentId = libraryMenu.getTopParentId();
|
||||
libraryBrowser.loadSavedQueryValues(key, pageData.query);
|
||||
}
|
||||
|
||||
function getQuery(context) {
|
||||
return getPageData(context).query;
|
||||
return pageData;
|
||||
}
|
||||
|
||||
function getQuery(context) {
|
||||
return getPageData(context).query;
|
||||
}
|
||||
|
||||
function getSavedQueryKey(context) {
|
||||
if (!context.savedQueryKey) {
|
||||
context.savedQueryKey = libraryBrowser.getSavedQueryKey();
|
||||
}
|
||||
|
||||
function getSavedQueryKey(context) {
|
||||
if (!context.savedQueryKey) {
|
||||
context.savedQueryKey = libraryBrowser.getSavedQueryKey();
|
||||
}
|
||||
return context.savedQueryKey;
|
||||
}
|
||||
|
||||
return context.savedQueryKey;
|
||||
function showLoadingMessage() {
|
||||
loading.show();
|
||||
}
|
||||
|
||||
function hideLoadingMessage() {
|
||||
loading.hide();
|
||||
}
|
||||
|
||||
function onViewStyleChange() {
|
||||
const viewStyle = getPageData(view).view;
|
||||
const itemsContainer = view.querySelector('.itemsContainer');
|
||||
|
||||
if (viewStyle == 'List') {
|
||||
itemsContainer.classList.add('vertical-list');
|
||||
itemsContainer.classList.remove('vertical-wrap');
|
||||
} else {
|
||||
itemsContainer.classList.remove('vertical-list');
|
||||
itemsContainer.classList.add('vertical-wrap');
|
||||
}
|
||||
|
||||
function showLoadingMessage() {
|
||||
loading.show();
|
||||
}
|
||||
itemsContainer.innerHTML = '';
|
||||
}
|
||||
|
||||
function hideLoadingMessage() {
|
||||
loading.hide();
|
||||
}
|
||||
function reloadItems() {
|
||||
showLoadingMessage();
|
||||
const query = getQuery(view);
|
||||
const promise1 = ApiClient.getItems(Dashboard.getCurrentUserId(), query);
|
||||
// TODO: promise2 is unused, check if necessary.
|
||||
const promise2 = Dashboard.getCurrentUser();
|
||||
Promise.all([promise1, promise2]).then(function (responses) {
|
||||
const result = responses[0];
|
||||
// TODO: Is the scroll necessary?
|
||||
window.scrollTo(0, 0);
|
||||
let html = '';
|
||||
const viewStyle = getPageData(view).view;
|
||||
view.querySelector('.listTopPaging').innerHTML = libraryBrowser.getQueryPagingHtml({
|
||||
startIndex: query.StartIndex,
|
||||
limit: query.Limit,
|
||||
totalRecordCount: result.TotalRecordCount,
|
||||
viewButton: false,
|
||||
showLimit: false,
|
||||
updatePageSizeSetting: false,
|
||||
addLayoutButton: true,
|
||||
layouts: 'List,Poster,PosterCard,Thumb,ThumbCard',
|
||||
currentLayout: viewStyle
|
||||
});
|
||||
|
||||
function onViewStyleChange() {
|
||||
var viewStyle = getPageData(view).view;
|
||||
var itemsContainer = view.querySelector('.itemsContainer');
|
||||
|
||||
if ('List' == viewStyle) {
|
||||
itemsContainer.classList.add('vertical-list');
|
||||
itemsContainer.classList.remove('vertical-wrap');
|
||||
} else {
|
||||
itemsContainer.classList.remove('vertical-list');
|
||||
itemsContainer.classList.add('vertical-wrap');
|
||||
}
|
||||
|
||||
itemsContainer.innerHTML = '';
|
||||
}
|
||||
|
||||
function reloadItems() {
|
||||
showLoadingMessage();
|
||||
var query = getQuery(view);
|
||||
var promise1 = ApiClient.getItems(Dashboard.getCurrentUserId(), query);
|
||||
var promise2 = Dashboard.getCurrentUser();
|
||||
Promise.all([promise1, promise2]).then(function (responses) {
|
||||
var result = responses[0];
|
||||
responses[1];
|
||||
window.scrollTo(0, 0);
|
||||
var html = '';
|
||||
var viewStyle = getPageData(view).view;
|
||||
view.querySelector('.listTopPaging').innerHTML = libraryBrowser.getQueryPagingHtml({
|
||||
startIndex: query.StartIndex,
|
||||
limit: query.Limit,
|
||||
totalRecordCount: result.TotalRecordCount,
|
||||
viewButton: false,
|
||||
showLimit: false,
|
||||
updatePageSizeSetting: false,
|
||||
addLayoutButton: true,
|
||||
layouts: 'List,Poster,PosterCard,Thumb,ThumbCard',
|
||||
currentLayout: viewStyle
|
||||
});
|
||||
|
||||
if (result.TotalRecordCount) {
|
||||
if (viewStyle == 'List') {
|
||||
html = listView.getListViewHtml({
|
||||
items: result.Items,
|
||||
sortBy: query.SortBy
|
||||
});
|
||||
} else if (viewStyle == 'PosterCard') {
|
||||
html = cardBuilder.getCardsHtml({
|
||||
items: result.Items,
|
||||
shape: 'square',
|
||||
coverImage: true,
|
||||
showTitle: true,
|
||||
cardLayout: true
|
||||
});
|
||||
} else if (viewStyle == 'Thumb') {
|
||||
html = cardBuilder.getCardsHtml({
|
||||
items: result.Items,
|
||||
shape: 'backdrop',
|
||||
showTitle: true,
|
||||
centerText: true,
|
||||
preferThumb: true,
|
||||
overlayPlayButton: true
|
||||
});
|
||||
} else if (viewStyle == 'ThumbCard') {
|
||||
html = cardBuilder.getCardsHtml({
|
||||
items: result.Items,
|
||||
shape: 'backdrop',
|
||||
showTitle: true,
|
||||
preferThumb: true,
|
||||
cardLayout: true
|
||||
});
|
||||
} else {
|
||||
html = cardBuilder.getCardsHtml({
|
||||
items: result.Items,
|
||||
shape: 'square',
|
||||
showTitle: true,
|
||||
coverImage: true,
|
||||
centerText: true,
|
||||
overlayPlayButton: true
|
||||
});
|
||||
}
|
||||
view.querySelector('.noItemsMessage').classList.add('hide');
|
||||
if (result.TotalRecordCount) {
|
||||
if (viewStyle == 'List') {
|
||||
html = listView.getListViewHtml({
|
||||
items: result.Items,
|
||||
sortBy: query.SortBy
|
||||
});
|
||||
} else if (viewStyle == 'PosterCard') {
|
||||
html = cardBuilder.getCardsHtml({
|
||||
items: result.Items,
|
||||
shape: 'square',
|
||||
coverImage: true,
|
||||
showTitle: true,
|
||||
cardLayout: true
|
||||
});
|
||||
} else if (viewStyle == 'Thumb') {
|
||||
html = cardBuilder.getCardsHtml({
|
||||
items: result.Items,
|
||||
shape: 'backdrop',
|
||||
showTitle: true,
|
||||
centerText: true,
|
||||
preferThumb: true,
|
||||
overlayPlayButton: true
|
||||
});
|
||||
} else if (viewStyle == 'ThumbCard') {
|
||||
html = cardBuilder.getCardsHtml({
|
||||
items: result.Items,
|
||||
shape: 'backdrop',
|
||||
showTitle: true,
|
||||
preferThumb: true,
|
||||
cardLayout: true
|
||||
});
|
||||
} else {
|
||||
view.querySelector('.noItemsMessage').classList.remove('hide');
|
||||
}
|
||||
|
||||
var elem = view.querySelector('.itemsContainer');
|
||||
elem.innerHTML = html;
|
||||
imageLoader.lazyChildren(elem);
|
||||
var btnNextPage = view.querySelector('.btnNextPage');
|
||||
|
||||
if (btnNextPage) {
|
||||
btnNextPage.addEventListener('click', function () {
|
||||
if (userSettings.libraryPageSize() > 0) {
|
||||
query.StartIndex += query.Limit;
|
||||
}
|
||||
reloadItems();
|
||||
html = cardBuilder.getCardsHtml({
|
||||
items: result.Items,
|
||||
shape: 'square',
|
||||
showTitle: true,
|
||||
coverImage: true,
|
||||
centerText: true,
|
||||
overlayPlayButton: true
|
||||
});
|
||||
}
|
||||
view.querySelector('.noItemsMessage').classList.add('hide');
|
||||
} else {
|
||||
view.querySelector('.noItemsMessage').classList.remove('hide');
|
||||
}
|
||||
|
||||
var btnPreviousPage = view.querySelector('.btnPreviousPage');
|
||||
const elem = view.querySelector('.itemsContainer');
|
||||
elem.innerHTML = html;
|
||||
imageLoader.lazyChildren(elem);
|
||||
const btnNextPage = view.querySelector('.btnNextPage');
|
||||
|
||||
if (btnPreviousPage) {
|
||||
btnPreviousPage.addEventListener('click', function () {
|
||||
if (userSettings.libraryPageSize() > 0) {
|
||||
query.StartIndex = Math.max(0, query.StartIndex - query.Limit);
|
||||
}
|
||||
reloadItems();
|
||||
});
|
||||
}
|
||||
|
||||
var btnChangeLayout = view.querySelector('.btnChangeLayout');
|
||||
|
||||
if (btnChangeLayout) {
|
||||
btnChangeLayout.addEventListener('layoutchange', function (e) {
|
||||
var layout = e.detail.viewStyle;
|
||||
getPageData(view).view = layout;
|
||||
libraryBrowser.saveViewSetting(getSavedQueryKey(view), layout);
|
||||
onViewStyleChange();
|
||||
reloadItems();
|
||||
});
|
||||
}
|
||||
|
||||
libraryBrowser.saveQueryValues(getSavedQueryKey(view), query);
|
||||
hideLoadingMessage();
|
||||
});
|
||||
}
|
||||
|
||||
var data = {};
|
||||
view.addEventListener('viewbeforeshow', function () {
|
||||
reloadItems();
|
||||
});
|
||||
view.querySelector('.btnNewPlaylist').addEventListener('click', function () {
|
||||
require(['playlistEditor'], function (playlistEditor) {
|
||||
var serverId = ApiClient.serverInfo().Id;
|
||||
new playlistEditor().show({
|
||||
items: [],
|
||||
serverId: serverId
|
||||
if (btnNextPage) {
|
||||
btnNextPage.addEventListener('click', function () {
|
||||
if (userSettings.libraryPageSize() > 0) {
|
||||
query.StartIndex += query.Limit;
|
||||
}
|
||||
reloadItems();
|
||||
});
|
||||
}
|
||||
|
||||
const btnPreviousPage = view.querySelector('.btnPreviousPage');
|
||||
|
||||
if (btnPreviousPage) {
|
||||
btnPreviousPage.addEventListener('click', function () {
|
||||
if (userSettings.libraryPageSize() > 0) {
|
||||
query.StartIndex = Math.max(0, query.StartIndex - query.Limit);
|
||||
}
|
||||
reloadItems();
|
||||
});
|
||||
}
|
||||
|
||||
const btnChangeLayout = view.querySelector('.btnChangeLayout');
|
||||
|
||||
if (btnChangeLayout) {
|
||||
btnChangeLayout.addEventListener('layoutchange', function (e) {
|
||||
const layout = e.detail.viewStyle;
|
||||
getPageData(view).view = layout;
|
||||
libraryBrowser.saveViewSetting(getSavedQueryKey(view), layout);
|
||||
onViewStyleChange();
|
||||
reloadItems();
|
||||
});
|
||||
}
|
||||
|
||||
libraryBrowser.saveQueryValues(getSavedQueryKey(view), query);
|
||||
hideLoadingMessage();
|
||||
});
|
||||
}
|
||||
|
||||
const data = {};
|
||||
view.addEventListener('viewbeforeshow', function () {
|
||||
reloadItems();
|
||||
});
|
||||
view.querySelector('.btnNewPlaylist').addEventListener('click', function () {
|
||||
import('playlistEditor').then(({default: playlistEditor}) => {
|
||||
const serverId = ApiClient.serverInfo().Id;
|
||||
new playlistEditor({
|
||||
items: [],
|
||||
serverId: serverId
|
||||
});
|
||||
});
|
||||
onViewStyleChange();
|
||||
};
|
||||
});
|
||||
});
|
||||
onViewStyleChange();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,420 +1,533 @@
|
|||
define([
|
||||
'jQuery',
|
||||
'emby-button',
|
||||
'emby-input',
|
||||
'scripts/livetvcomponents',
|
||||
'paper-icon-button-light',
|
||||
'emby-itemscontainer',
|
||||
'emby-collapse',
|
||||
'emby-select',
|
||||
'livetvcss',
|
||||
'emby-checkbox',
|
||||
'emby-slider',
|
||||
'listViewStyle',
|
||||
'dashboardcss',
|
||||
'detailtablecss'], function () {
|
||||
import 'emby-button';
|
||||
import 'emby-input';
|
||||
import 'scripts/livetvcomponents';
|
||||
import 'paper-icon-button-light';
|
||||
import 'emby-itemscontainer';
|
||||
import 'emby-collapse';
|
||||
import 'emby-select';
|
||||
import 'livetvcss';
|
||||
import 'emby-checkbox';
|
||||
import 'emby-slider';
|
||||
import 'listViewStyle';
|
||||
import 'dashboardcss';
|
||||
import 'detailtablecss';
|
||||
|
||||
/* eslint-disable indent */
|
||||
|
||||
console.groupCollapsed('defining core routes');
|
||||
|
||||
function defineRoute(newRoute) {
|
||||
var path = newRoute.path;
|
||||
var path = newRoute.alias ? newRoute.alias : newRoute.path;
|
||||
console.debug('defining route: ' + path);
|
||||
newRoute.dictionary = 'core';
|
||||
Emby.Page.addRoute(path, newRoute);
|
||||
}
|
||||
|
||||
console.debug('defining core routes');
|
||||
defineRoute({
|
||||
alias: '/addserver.html',
|
||||
path: '/controllers/session/addServer/index.html',
|
||||
autoFocus: false,
|
||||
anonymous: true,
|
||||
startup: true,
|
||||
controller: 'session/addServer/index'
|
||||
});
|
||||
|
||||
defineRoute({
|
||||
path: '/addserver.html',
|
||||
alias: '/selectserver.html',
|
||||
path: '/controllers/session/selectServer/index.html',
|
||||
autoFocus: false,
|
||||
anonymous: true,
|
||||
startup: true,
|
||||
controller: 'auth/addserver'
|
||||
});
|
||||
defineRoute({
|
||||
path: '/selectserver.html',
|
||||
autoFocus: false,
|
||||
anonymous: true,
|
||||
startup: true,
|
||||
controller: 'auth/selectserver',
|
||||
controller: 'session/selectServer/index',
|
||||
type: 'selectserver'
|
||||
});
|
||||
|
||||
defineRoute({
|
||||
path: '/login.html',
|
||||
alias: '/login.html',
|
||||
path: '/controllers/session/login/index.html',
|
||||
autoFocus: false,
|
||||
anonymous: true,
|
||||
startup: true,
|
||||
controller: 'auth/login',
|
||||
controller: 'session/login/index',
|
||||
type: 'login'
|
||||
});
|
||||
|
||||
defineRoute({
|
||||
path: '/forgotpassword.html',
|
||||
alias: '/forgotpassword.html',
|
||||
path: '/controllers/session/forgotPassword/index.html',
|
||||
anonymous: true,
|
||||
startup: true,
|
||||
controller: 'auth/forgotpassword'
|
||||
});
|
||||
defineRoute({
|
||||
path: '/forgotpasswordpin.html',
|
||||
autoFocus: false,
|
||||
anonymous: true,
|
||||
startup: true,
|
||||
controller: 'auth/forgotpasswordpin'
|
||||
controller: 'session/forgotPassword/index'
|
||||
});
|
||||
|
||||
defineRoute({
|
||||
path: '/mypreferencesmenu.html',
|
||||
alias: '/forgotpasswordpin.html',
|
||||
path: '/controllers/session/redeemPassword/index.html',
|
||||
autoFocus: false,
|
||||
transition: 'fade',
|
||||
controller: 'user/menu'
|
||||
});
|
||||
defineRoute({
|
||||
path: '/myprofile.html',
|
||||
autoFocus: false,
|
||||
transition: 'fade',
|
||||
controller: 'user/profile'
|
||||
});
|
||||
defineRoute({
|
||||
path: '/mypreferencesdisplay.html',
|
||||
autoFocus: false,
|
||||
transition: 'fade',
|
||||
controller: 'user/display'
|
||||
});
|
||||
defineRoute({
|
||||
path: '/mypreferenceshome.html',
|
||||
autoFocus: false,
|
||||
transition: 'fade',
|
||||
controller: 'user/home'
|
||||
});
|
||||
defineRoute({
|
||||
path: '/mypreferencesplayback.html',
|
||||
autoFocus: false,
|
||||
transition: 'fade',
|
||||
controller: 'user/playback'
|
||||
});
|
||||
defineRoute({
|
||||
path: '/mypreferencessubtitles.html',
|
||||
autoFocus: false,
|
||||
transition: 'fade',
|
||||
controller: 'user/subtitles'
|
||||
anonymous: true,
|
||||
startup: true,
|
||||
controller: 'session/redeemPassword/index'
|
||||
});
|
||||
|
||||
defineRoute({
|
||||
path: '/dashboard.html',
|
||||
alias: '/mypreferencesmenu.html',
|
||||
path: '/controllers/user/menu/index.html',
|
||||
autoFocus: false,
|
||||
controller: 'user/menu/index'
|
||||
});
|
||||
|
||||
defineRoute({
|
||||
alias: '/myprofile.html',
|
||||
path: '/controllers/user/profile/index.html',
|
||||
autoFocus: false,
|
||||
controller: 'user/profile/index'
|
||||
});
|
||||
|
||||
defineRoute({
|
||||
alias: '/mypreferencesdisplay.html',
|
||||
path: '/controllers/user/display/index.html',
|
||||
autoFocus: false,
|
||||
controller: 'user/display/index'
|
||||
});
|
||||
|
||||
defineRoute({
|
||||
alias: '/mypreferenceshome.html',
|
||||
path: '/controllers/user/home/index.html',
|
||||
autoFocus: false,
|
||||
controller: 'user/home/index'
|
||||
});
|
||||
|
||||
defineRoute({
|
||||
alias: '/mypreferencesplayback.html',
|
||||
path: '/controllers/user/playback/index.html',
|
||||
autoFocus: false,
|
||||
controller: 'user/playback/index'
|
||||
});
|
||||
|
||||
defineRoute({
|
||||
alias: '/mypreferencessubtitles.html',
|
||||
path: '/controllers/user/subtitles/index.html',
|
||||
autoFocus: false,
|
||||
controller: 'user/subtitles/index'
|
||||
});
|
||||
|
||||
defineRoute({
|
||||
alias: '/dashboard.html',
|
||||
path: '/controllers/dashboard/dashboard.html',
|
||||
autoFocus: false,
|
||||
roles: 'admin',
|
||||
controller: 'dashboard/dashboard'
|
||||
});
|
||||
|
||||
defineRoute({
|
||||
path: '/dashboardgeneral.html',
|
||||
alias: '/dashboardgeneral.html',
|
||||
path: '/controllers/dashboard/general.html',
|
||||
controller: 'dashboard/general',
|
||||
autoFocus: false,
|
||||
roles: 'admin'
|
||||
});
|
||||
|
||||
defineRoute({
|
||||
path: '/networking.html',
|
||||
alias: '/networking.html',
|
||||
path: '/controllers/dashboard/networking.html',
|
||||
autoFocus: false,
|
||||
roles: 'admin',
|
||||
controller: 'dashboard/networking'
|
||||
});
|
||||
|
||||
defineRoute({
|
||||
path: '/devices.html',
|
||||
alias: '/devices.html',
|
||||
path: '/controllers/dashboard/devices/devices.html',
|
||||
autoFocus: false,
|
||||
roles: 'admin',
|
||||
controller: 'dashboard/devices/devices'
|
||||
});
|
||||
|
||||
defineRoute({
|
||||
path: '/device.html',
|
||||
alias: '/device.html',
|
||||
path: '/controllers/dashboard/devices/device.html',
|
||||
autoFocus: false,
|
||||
roles: 'admin',
|
||||
controller: 'dashboard/devices/device'
|
||||
});
|
||||
|
||||
defineRoute({
|
||||
path: '/dlnaprofile.html',
|
||||
alias: '/dlnaprofile.html',
|
||||
path: '/controllers/dashboard/dlna/profile.html',
|
||||
autoFocus: false,
|
||||
roles: 'admin',
|
||||
controller: 'dashboard/dlna/profile'
|
||||
});
|
||||
|
||||
defineRoute({
|
||||
path: '/dlnaprofiles.html',
|
||||
alias: '/dlnaprofiles.html',
|
||||
path: '/controllers/dashboard/dlna/profiles.html',
|
||||
autoFocus: false,
|
||||
roles: 'admin',
|
||||
controller: 'dashboard/dlna/profiles'
|
||||
});
|
||||
|
||||
defineRoute({
|
||||
path: '/addplugin.html',
|
||||
autoFocus: false,
|
||||
roles: 'admin',
|
||||
controller: 'dashboard/plugins/add'
|
||||
});
|
||||
defineRoute({
|
||||
path: '/library.html',
|
||||
autoFocus: false,
|
||||
roles: 'admin',
|
||||
controller: 'dashboard/mediaLibrary'
|
||||
});
|
||||
defineRoute({
|
||||
path: '/librarydisplay.html',
|
||||
autoFocus: false,
|
||||
roles: 'admin',
|
||||
controller: 'dashboard/librarydisplay'
|
||||
});
|
||||
defineRoute({
|
||||
path: '/dlnasettings.html',
|
||||
alias: '/dlnasettings.html',
|
||||
path: '/controllers/dashboard/dlna/settings.html',
|
||||
autoFocus: false,
|
||||
roles: 'admin',
|
||||
controller: 'dashboard/dlna/settings'
|
||||
});
|
||||
|
||||
defineRoute({
|
||||
path: '/edititemmetadata.html',
|
||||
alias: '/addplugin.html',
|
||||
path: '/controllers/dashboard/plugins/add/index.html',
|
||||
autoFocus: false,
|
||||
roles: 'admin',
|
||||
controller: 'dashboard/plugins/add/index'
|
||||
});
|
||||
|
||||
defineRoute({
|
||||
alias: '/library.html',
|
||||
path: '/controllers/dashboard/library.html',
|
||||
autoFocus: false,
|
||||
roles: 'admin',
|
||||
controller: 'dashboard/library'
|
||||
});
|
||||
|
||||
defineRoute({
|
||||
alias: '/librarydisplay.html',
|
||||
path: '/controllers/dashboard/librarydisplay.html',
|
||||
autoFocus: false,
|
||||
roles: 'admin',
|
||||
controller: 'dashboard/librarydisplay'
|
||||
});
|
||||
|
||||
defineRoute({
|
||||
alias: '/edititemmetadata.html',
|
||||
path: '/controllers/edititemmetadata.html',
|
||||
controller: 'edititemmetadata',
|
||||
autoFocus: false
|
||||
});
|
||||
|
||||
defineRoute({
|
||||
path: '/encodingsettings.html',
|
||||
alias: '/encodingsettings.html',
|
||||
path: '/controllers/dashboard/encodingsettings.html',
|
||||
autoFocus: false,
|
||||
roles: 'admin',
|
||||
controller: 'dashboard/encodingsettings'
|
||||
});
|
||||
|
||||
defineRoute({
|
||||
path: '/log.html',
|
||||
alias: '/log.html',
|
||||
path: '/controllers/dashboard/logs.html',
|
||||
roles: 'admin',
|
||||
controller: 'dashboard/logs'
|
||||
});
|
||||
|
||||
defineRoute({
|
||||
path: '/metadataimages.html',
|
||||
alias: '/metadataimages.html',
|
||||
path: '/controllers/dashboard/metadataimages.html',
|
||||
autoFocus: false,
|
||||
roles: 'admin',
|
||||
controller: 'dashboard/metadataImages'
|
||||
});
|
||||
|
||||
defineRoute({
|
||||
path: '/metadatanfo.html',
|
||||
alias: '/metadatanfo.html',
|
||||
path: '/controllers/dashboard/metadatanfo.html',
|
||||
autoFocus: false,
|
||||
roles: 'admin',
|
||||
controller: 'dashboard/metadatanfo'
|
||||
});
|
||||
|
||||
defineRoute({
|
||||
path: '/notificationsetting.html',
|
||||
alias: '/notificationsetting.html',
|
||||
path: '/controllers/dashboard/notifications/notification/index.html',
|
||||
autoFocus: false,
|
||||
roles: 'admin',
|
||||
controller: 'dashboard/notifications/notification'
|
||||
controller: 'dashboard/notifications/notification/index'
|
||||
});
|
||||
|
||||
defineRoute({
|
||||
path: '/notificationsettings.html',
|
||||
controller: 'dashboard/notifications/notifications',
|
||||
alias: '/notificationsettings.html',
|
||||
path: '/controllers/dashboard/notifications/notifications/index.html',
|
||||
controller: 'dashboard/notifications/notifications/index',
|
||||
autoFocus: false,
|
||||
roles: 'admin'
|
||||
});
|
||||
|
||||
defineRoute({
|
||||
path: '/playbackconfiguration.html',
|
||||
alias: '/playbackconfiguration.html',
|
||||
path: '/controllers/dashboard/playback.html',
|
||||
autoFocus: false,
|
||||
roles: 'admin',
|
||||
controller: 'dashboard/playback'
|
||||
});
|
||||
|
||||
defineRoute({
|
||||
path: '/availableplugins.html',
|
||||
alias: '/availableplugins.html',
|
||||
path: '/controllers/dashboard/plugins/available/index.html',
|
||||
autoFocus: false,
|
||||
roles: 'admin',
|
||||
controller: 'dashboard/plugins/available'
|
||||
controller: 'dashboard/plugins/available/index'
|
||||
});
|
||||
|
||||
defineRoute({
|
||||
path: '/home.html',
|
||||
alias: '/repositories.html',
|
||||
path: '/controllers/dashboard/plugins/repositories/index.html',
|
||||
autoFocus: false,
|
||||
roles: 'admin',
|
||||
controller: 'dashboard/plugins/repositories/index'
|
||||
});
|
||||
|
||||
defineRoute({
|
||||
alias: '/home.html',
|
||||
path: '/controllers/home.html',
|
||||
autoFocus: false,
|
||||
controller: 'home',
|
||||
transition: 'fade',
|
||||
type: 'home'
|
||||
});
|
||||
|
||||
defineRoute({
|
||||
path: '/search.html',
|
||||
alias: '/search.html',
|
||||
path: '/controllers/search.html',
|
||||
controller: 'searchpage'
|
||||
});
|
||||
|
||||
defineRoute({
|
||||
path: '/list.html',
|
||||
alias: '/list.html',
|
||||
path: '/controllers/list.html',
|
||||
autoFocus: false,
|
||||
controller: 'list',
|
||||
transition: 'fade'
|
||||
controller: 'list'
|
||||
});
|
||||
|
||||
defineRoute({
|
||||
path: '/itemdetails.html',
|
||||
controller: 'itemDetails',
|
||||
autoFocus: false,
|
||||
transition: 'fade'
|
||||
alias: '/details',
|
||||
path: '/controllers/itemDetails/index.html',
|
||||
controller: 'itemDetails/index',
|
||||
autoFocus: false
|
||||
});
|
||||
|
||||
defineRoute({
|
||||
path: '/livetv.html',
|
||||
alias: '/livetv.html',
|
||||
path: '/controllers/livetv.html',
|
||||
controller: 'livetv/livetvsuggested',
|
||||
autoFocus: false,
|
||||
transition: 'fade'
|
||||
autoFocus: false
|
||||
});
|
||||
|
||||
defineRoute({
|
||||
path: '/livetvguideprovider.html',
|
||||
alias: '/livetvguideprovider.html',
|
||||
path: '/controllers/livetvguideprovider.html',
|
||||
autoFocus: false,
|
||||
roles: 'admin',
|
||||
controller: 'livetvguideprovider'
|
||||
});
|
||||
|
||||
defineRoute({
|
||||
path: '/livetvsettings.html',
|
||||
alias: '/livetvsettings.html',
|
||||
path: '/controllers/livetvsettings.html',
|
||||
autoFocus: false,
|
||||
controller: 'livetvsettings'
|
||||
});
|
||||
|
||||
defineRoute({
|
||||
path: '/livetvstatus.html',
|
||||
alias: '/livetvstatus.html',
|
||||
path: '/controllers/livetvstatus.html',
|
||||
autoFocus: false,
|
||||
roles: 'admin',
|
||||
controller: 'livetvstatus'
|
||||
});
|
||||
|
||||
defineRoute({
|
||||
path: '/livetvtuner.html',
|
||||
alias: '/livetvtuner.html',
|
||||
path: '/controllers/livetvtuner.html',
|
||||
autoFocus: false,
|
||||
roles: 'admin',
|
||||
controller: 'livetvtuner'
|
||||
});
|
||||
|
||||
defineRoute({
|
||||
path: '/movies.html',
|
||||
alias: '/movies.html',
|
||||
path: '/controllers/movies/movies.html',
|
||||
autoFocus: false,
|
||||
controller: 'movies/moviesrecommended',
|
||||
transition: 'fade'
|
||||
controller: 'movies/moviesrecommended'
|
||||
});
|
||||
|
||||
defineRoute({
|
||||
path: '/music.html',
|
||||
alias: '/music.html',
|
||||
path: '/controllers/music/music.html',
|
||||
controller: 'music/musicrecommended',
|
||||
autoFocus: false,
|
||||
transition: 'fade'
|
||||
autoFocus: false
|
||||
});
|
||||
|
||||
defineRoute({
|
||||
path: '/installedplugins.html',
|
||||
alias: '/installedplugins.html',
|
||||
path: '/controllers/dashboard/plugins/installed/index.html',
|
||||
autoFocus: false,
|
||||
roles: 'admin',
|
||||
controller: 'dashboard/plugins/installed'
|
||||
controller: 'dashboard/plugins/installed/index'
|
||||
});
|
||||
|
||||
defineRoute({
|
||||
path: '/scheduledtask.html',
|
||||
alias: '/scheduledtask.html',
|
||||
path: '/controllers/dashboard/scheduledtasks/scheduledtask.html',
|
||||
autoFocus: false,
|
||||
roles: 'admin',
|
||||
controller: 'dashboard/scheduledtasks/scheduledtask'
|
||||
});
|
||||
|
||||
defineRoute({
|
||||
path: '/scheduledtasks.html',
|
||||
alias: '/scheduledtasks.html',
|
||||
path: '/controllers/dashboard/scheduledtasks/scheduledtasks.html',
|
||||
autoFocus: false,
|
||||
roles: 'admin',
|
||||
controller: 'dashboard/scheduledtasks/scheduledtasks'
|
||||
});
|
||||
|
||||
defineRoute({
|
||||
path: '/serveractivity.html',
|
||||
alias: '/serveractivity.html',
|
||||
path: '/controllers/dashboard/serveractivity.html',
|
||||
autoFocus: false,
|
||||
roles: 'admin',
|
||||
controller: 'dashboard/serveractivity'
|
||||
});
|
||||
|
||||
defineRoute({
|
||||
path: '/apikeys.html',
|
||||
alias: '/apikeys.html',
|
||||
path: '/controllers/dashboard/apikeys.html',
|
||||
autoFocus: false,
|
||||
roles: 'admin',
|
||||
controller: 'dashboard/apikeys'
|
||||
});
|
||||
|
||||
defineRoute({
|
||||
path: '/streamingsettings.html',
|
||||
alias: '/streamingsettings.html',
|
||||
path: '/controllers/dashboard/streaming.html',
|
||||
autoFocus: false,
|
||||
roles: 'admin',
|
||||
controller: 'dashboard/streaming'
|
||||
});
|
||||
|
||||
defineRoute({
|
||||
path: '/tv.html',
|
||||
alias: '/tv.html',
|
||||
path: '/controllers/shows/tvrecommended.html',
|
||||
autoFocus: false,
|
||||
controller: 'shows/tvrecommended',
|
||||
transition: 'fade'
|
||||
controller: 'shows/tvrecommended'
|
||||
});
|
||||
|
||||
defineRoute({
|
||||
path: '/useredit.html',
|
||||
alias: '/useredit.html',
|
||||
path: '/controllers/dashboard/users/useredit.html',
|
||||
autoFocus: false,
|
||||
roles: 'admin',
|
||||
controller: 'dashboard/users/useredit'
|
||||
});
|
||||
|
||||
defineRoute({
|
||||
path: '/userlibraryaccess.html',
|
||||
alias: '/userlibraryaccess.html',
|
||||
path: '/controllers/dashboard/users/userlibraryaccess.html',
|
||||
autoFocus: false,
|
||||
roles: 'admin',
|
||||
controller: 'dashboard/users/userlibraryaccess'
|
||||
});
|
||||
|
||||
defineRoute({
|
||||
path: '/usernew.html',
|
||||
alias: '/usernew.html',
|
||||
path: '/controllers/dashboard/users/usernew.html',
|
||||
autoFocus: false,
|
||||
roles: 'admin',
|
||||
controller: 'dashboard/users/usernew'
|
||||
});
|
||||
|
||||
defineRoute({
|
||||
path: '/userparentalcontrol.html',
|
||||
alias: '/userparentalcontrol.html',
|
||||
path: '/controllers/dashboard/users/userparentalcontrol.html',
|
||||
autoFocus: false,
|
||||
roles: 'admin',
|
||||
controller: 'dashboard/users/userparentalcontrol'
|
||||
});
|
||||
|
||||
defineRoute({
|
||||
path: '/userpassword.html',
|
||||
alias: '/userpassword.html',
|
||||
path: '/controllers/dashboard/users/userpassword.html',
|
||||
autoFocus: false,
|
||||
controller: 'dashboard/users/userpasswordpage'
|
||||
});
|
||||
|
||||
defineRoute({
|
||||
path: '/userprofiles.html',
|
||||
alias: '/userprofiles.html',
|
||||
path: '/controllers/dashboard/users/userprofiles.html',
|
||||
autoFocus: false,
|
||||
roles: 'admin',
|
||||
controller: 'dashboard/users/userprofilespage'
|
||||
});
|
||||
|
||||
defineRoute({
|
||||
path: '/wizardremoteaccess.html',
|
||||
alias: '/wizardremoteaccess.html',
|
||||
path: '/controllers/wizard/remote/index.html',
|
||||
autoFocus: false,
|
||||
anonymous: true,
|
||||
controller: 'wizard/remoteaccess'
|
||||
controller: 'wizard/remote/index'
|
||||
});
|
||||
|
||||
defineRoute({
|
||||
path: '/wizardfinish.html',
|
||||
alias: '/wizardfinish.html',
|
||||
path: '/controllers/wizard/finish/index.html',
|
||||
autoFocus: false,
|
||||
anonymous: true,
|
||||
controller: 'wizard/finish'
|
||||
controller: 'wizard/finish/index'
|
||||
});
|
||||
|
||||
defineRoute({
|
||||
path: '/wizardlibrary.html',
|
||||
alias: '/wizardlibrary.html',
|
||||
path: '/controllers/wizard/library.html',
|
||||
autoFocus: false,
|
||||
anonymous: true,
|
||||
controller: 'dashboard/mediaLibrary'
|
||||
controller: 'dashboard/library'
|
||||
});
|
||||
|
||||
defineRoute({
|
||||
path: '/wizardsettings.html',
|
||||
alias: '/wizardsettings.html',
|
||||
path: '/controllers/wizard/settings/index.html',
|
||||
autoFocus: false,
|
||||
anonymous: true,
|
||||
controller: 'wizard/settings'
|
||||
controller: 'wizard/settings/index'
|
||||
});
|
||||
|
||||
defineRoute({
|
||||
path: '/wizardstart.html',
|
||||
alias: '/wizardstart.html',
|
||||
path: '/controllers/wizard/start/index.html',
|
||||
autoFocus: false,
|
||||
anonymous: true,
|
||||
controller: 'wizard/start'
|
||||
controller: 'wizard/start/index'
|
||||
});
|
||||
|
||||
defineRoute({
|
||||
path: '/wizarduser.html',
|
||||
controller: 'wizard/user',
|
||||
alias: '/wizarduser.html',
|
||||
path: '/controllers/wizard/user/index.html',
|
||||
controller: 'wizard/user/index',
|
||||
autoFocus: false,
|
||||
anonymous: true
|
||||
});
|
||||
|
||||
defineRoute({
|
||||
path: '/videoosd.html',
|
||||
transition: 'fade',
|
||||
controller: 'playback/videoosd',
|
||||
alias: '/video',
|
||||
path: '/controllers/playback/video/index.html',
|
||||
controller: 'playback/video/index',
|
||||
autoFocus: false,
|
||||
type: 'video-osd',
|
||||
supportsThemeMedia: true,
|
||||
fullscreen: true,
|
||||
enableMediaControl: false
|
||||
});
|
||||
|
||||
defineRoute({
|
||||
path: '/nowplaying.html',
|
||||
controller: 'playback/nowplaying',
|
||||
alias: '/queue',
|
||||
path: '/controllers/playback/queue/index.html',
|
||||
controller: 'playback/queue/index',
|
||||
autoFocus: false,
|
||||
transition: 'fade',
|
||||
fullscreen: true,
|
||||
supportsThemeMedia: true,
|
||||
enableMediaControl: false
|
||||
});
|
||||
|
||||
defineRoute({
|
||||
path: '/configurationpage',
|
||||
autoFocus: false,
|
||||
|
@ -428,9 +541,13 @@ define([
|
|||
isDefaultRoute: true,
|
||||
autoFocus: false
|
||||
});
|
||||
|
||||
defineRoute({
|
||||
path: '/index.html',
|
||||
autoFocus: false,
|
||||
isDefaultRoute: true
|
||||
});
|
||||
});
|
||||
|
||||
console.groupEnd('defining core routes');
|
||||
|
||||
/* eslint-enable indent */
|
||||
|
|
|
@ -1,137 +1,138 @@
|
|||
define(['focusManager', 'dom', 'scrollStyles'], function (focusManager, dom) {
|
||||
'use strict';
|
||||
import focusManager from 'focusManager';
|
||||
import dom from 'dom';
|
||||
import 'scrollStyles';
|
||||
|
||||
function getBoundingClientRect(elem) {
|
||||
function getBoundingClientRect(elem) {
|
||||
// Support: BlackBerry 5, iOS 3 (original iPhone)
|
||||
// If we don't have gBCR, just use 0,0 rather than error
|
||||
if (elem.getBoundingClientRect) {
|
||||
return elem.getBoundingClientRect();
|
||||
} else {
|
||||
return { top: 0, left: 0 };
|
||||
}
|
||||
}
|
||||
|
||||
// Support: BlackBerry 5, iOS 3 (original iPhone)
|
||||
// If we don't have gBCR, just use 0,0 rather than error
|
||||
if (elem.getBoundingClientRect) {
|
||||
return elem.getBoundingClientRect();
|
||||
} else {
|
||||
return { top: 0, left: 0 };
|
||||
}
|
||||
export function getPosition(scrollContainer, item, horizontal) {
|
||||
const slideeOffset = getBoundingClientRect(scrollContainer);
|
||||
const itemOffset = getBoundingClientRect(item);
|
||||
|
||||
let offset = horizontal ? itemOffset.left - slideeOffset.left : itemOffset.top - slideeOffset.top;
|
||||
let size = horizontal ? itemOffset.width : itemOffset.height;
|
||||
if (!size && size !== 0) {
|
||||
size = item[horizontal ? 'offsetWidth' : 'offsetHeight'];
|
||||
}
|
||||
|
||||
function getPosition(scrollContainer, item, horizontal) {
|
||||
const currentStart = horizontal ? scrollContainer.scrollLeft : scrollContainer.scrollTop;
|
||||
|
||||
var slideeOffset = getBoundingClientRect(scrollContainer);
|
||||
var itemOffset = getBoundingClientRect(item);
|
||||
offset += currentStart;
|
||||
|
||||
var offset = horizontal ? itemOffset.left - slideeOffset.left : itemOffset.top - slideeOffset.top;
|
||||
var size = horizontal ? itemOffset.width : itemOffset.height;
|
||||
if (!size && size !== 0) {
|
||||
size = item[horizontal ? 'offsetWidth' : 'offsetHeight'];
|
||||
}
|
||||
const frameSize = horizontal ? scrollContainer.offsetWidth : scrollContainer.offsetHeight;
|
||||
|
||||
var currentStart = horizontal ? scrollContainer.scrollLeft : scrollContainer.scrollTop;
|
||||
const currentEnd = currentStart + frameSize;
|
||||
|
||||
offset += currentStart;
|
||||
|
||||
var frameSize = horizontal ? scrollContainer.offsetWidth : scrollContainer.offsetHeight;
|
||||
|
||||
var currentEnd = currentStart + frameSize;
|
||||
|
||||
var isVisible = offset >= currentStart && (offset + size) <= currentEnd;
|
||||
|
||||
return {
|
||||
start: offset,
|
||||
center: (offset - (frameSize / 2) + (size / 2)),
|
||||
end: offset - frameSize + size,
|
||||
size: size,
|
||||
isVisible: isVisible
|
||||
};
|
||||
}
|
||||
|
||||
function toCenter(container, elem, horizontal, skipWhenVisible) {
|
||||
var pos = getPosition(container, elem, horizontal);
|
||||
|
||||
if (skipWhenVisible && pos.isVisible) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (container.scrollTo) {
|
||||
if (horizontal) {
|
||||
container.scrollTo(pos.center, 0);
|
||||
} else {
|
||||
container.scrollTo(0, pos.center);
|
||||
}
|
||||
} else {
|
||||
if (horizontal) {
|
||||
container.scrollLeft = Math.round(pos.center);
|
||||
} else {
|
||||
container.scrollTop = Math.round(pos.center);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function toStart(container, elem, horizontal, skipWhenVisible) {
|
||||
var pos = getPosition(container, elem, horizontal);
|
||||
|
||||
if (skipWhenVisible && pos.isVisible) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (container.scrollTo) {
|
||||
if (horizontal) {
|
||||
container.scrollTo(pos.start, 0);
|
||||
} else {
|
||||
container.scrollTo(0, pos.start);
|
||||
}
|
||||
} else {
|
||||
if (horizontal) {
|
||||
container.scrollLeft = Math.round(pos.start);
|
||||
} else {
|
||||
container.scrollTop = Math.round(pos.start);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function centerOnFocus(e, scrollSlider, horizontal) {
|
||||
var focused = focusManager.focusableParent(e.target);
|
||||
|
||||
if (focused) {
|
||||
toCenter(scrollSlider, focused, horizontal);
|
||||
}
|
||||
}
|
||||
|
||||
function centerOnFocusHorizontal(e) {
|
||||
centerOnFocus(e, this, true);
|
||||
}
|
||||
function centerOnFocusVertical(e) {
|
||||
centerOnFocus(e, this, false);
|
||||
}
|
||||
const isVisible = offset >= currentStart && (offset + size) <= currentEnd;
|
||||
|
||||
return {
|
||||
getPosition: getPosition,
|
||||
centerFocus: {
|
||||
on: function (element, horizontal) {
|
||||
if (horizontal) {
|
||||
dom.addEventListener(element, 'focus', centerOnFocusHorizontal, {
|
||||
capture: true,
|
||||
passive: true
|
||||
});
|
||||
} else {
|
||||
dom.addEventListener(element, 'focus', centerOnFocusVertical, {
|
||||
capture: true,
|
||||
passive: true
|
||||
});
|
||||
}
|
||||
},
|
||||
off: function (element, horizontal) {
|
||||
if (horizontal) {
|
||||
dom.removeEventListener(element, 'focus', centerOnFocusHorizontal, {
|
||||
capture: true,
|
||||
passive: true
|
||||
});
|
||||
} else {
|
||||
dom.removeEventListener(element, 'focus', centerOnFocusVertical, {
|
||||
capture: true,
|
||||
passive: true
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
toCenter: toCenter,
|
||||
toStart: toStart
|
||||
start: offset,
|
||||
center: (offset - (frameSize / 2) + (size / 2)),
|
||||
end: offset - frameSize + size,
|
||||
size: size,
|
||||
isVisible: isVisible
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
export function toCenter(container, elem, horizontal, skipWhenVisible) {
|
||||
const pos = getPosition(container, elem, horizontal);
|
||||
|
||||
if (skipWhenVisible && pos.isVisible) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (container.scrollTo) {
|
||||
if (horizontal) {
|
||||
container.scrollTo(pos.center, 0);
|
||||
} else {
|
||||
container.scrollTo(0, pos.center);
|
||||
}
|
||||
} else {
|
||||
if (horizontal) {
|
||||
container.scrollLeft = Math.round(pos.center);
|
||||
} else {
|
||||
container.scrollTop = Math.round(pos.center);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function toStart(container, elem, horizontal, skipWhenVisible) {
|
||||
const pos = getPosition(container, elem, horizontal);
|
||||
|
||||
if (skipWhenVisible && pos.isVisible) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (container.scrollTo) {
|
||||
if (horizontal) {
|
||||
container.scrollTo(pos.start, 0);
|
||||
} else {
|
||||
container.scrollTo(0, pos.start);
|
||||
}
|
||||
} else {
|
||||
if (horizontal) {
|
||||
container.scrollLeft = Math.round(pos.start);
|
||||
} else {
|
||||
container.scrollTop = Math.round(pos.start);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function centerOnFocus(e, scrollSlider, horizontal) {
|
||||
const focused = focusManager.focusableParent(e.target);
|
||||
|
||||
if (focused) {
|
||||
toCenter(scrollSlider, focused, horizontal);
|
||||
}
|
||||
}
|
||||
|
||||
function centerOnFocusHorizontal(e) {
|
||||
centerOnFocus(e, this, true);
|
||||
}
|
||||
|
||||
function centerOnFocusVertical(e) {
|
||||
centerOnFocus(e, this, false);
|
||||
}
|
||||
|
||||
export const centerFocus = {
|
||||
on: function (element, horizontal) {
|
||||
if (horizontal) {
|
||||
dom.addEventListener(element, 'focus', centerOnFocusHorizontal, {
|
||||
capture: true,
|
||||
passive: true
|
||||
});
|
||||
} else {
|
||||
dom.addEventListener(element, 'focus', centerOnFocusVertical, {
|
||||
capture: true,
|
||||
passive: true
|
||||
});
|
||||
}
|
||||
},
|
||||
off: function (element, horizontal) {
|
||||
if (horizontal) {
|
||||
dom.removeEventListener(element, 'focus', centerOnFocusHorizontal, {
|
||||
capture: true,
|
||||
passive: true
|
||||
});
|
||||
} else {
|
||||
dom.removeEventListener(element, 'focus', centerOnFocusVertical, {
|
||||
capture: true,
|
||||
passive: true
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export default {
|
||||
getPosition: getPosition,
|
||||
centerFocus: centerFocus,
|
||||
toCenter: toCenter,
|
||||
toStart: toStart
|
||||
};
|
||||
|
|
|
@ -1,54 +0,0 @@
|
|||
define(['searchFields', 'searchResults', 'events'], function (SearchFields, SearchResults, events) {
|
||||
'use strict';
|
||||
|
||||
function init(instance, tabContent, options) {
|
||||
tabContent.innerHTML = '<div class="padded-left padded-right searchFields"></div><div class="searchResults padded-top" style="padding-top:1.5em;"></div>';
|
||||
instance.searchFields = new SearchFields({
|
||||
element: tabContent.querySelector('.searchFields')
|
||||
});
|
||||
instance.searchResults = new SearchResults({
|
||||
element: tabContent.querySelector('.searchResults'),
|
||||
serverId: ApiClient.serverId(),
|
||||
parentId: options.parentId,
|
||||
collectionType: options.collectionType
|
||||
});
|
||||
events.on(instance.searchFields, 'search', function (e, value) {
|
||||
instance.searchResults.search(value);
|
||||
});
|
||||
}
|
||||
|
||||
function SearchTab(view, tabContent, options) {
|
||||
var self = this;
|
||||
options = options || {};
|
||||
init(this, tabContent, options);
|
||||
|
||||
self.preRender = function () {};
|
||||
|
||||
self.renderTab = function () {
|
||||
var searchFields = this.searchFields;
|
||||
|
||||
if (searchFields) {
|
||||
searchFields.focus();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
SearchTab.prototype.destroy = function () {
|
||||
var searchFields = this.searchFields;
|
||||
|
||||
if (searchFields) {
|
||||
searchFields.destroy();
|
||||
}
|
||||
|
||||
this.searchFields = null;
|
||||
var searchResults = this.searchResults;
|
||||
|
||||
if (searchResults) {
|
||||
searchResults.destroy();
|
||||
}
|
||||
|
||||
this.searchResults = null;
|
||||
};
|
||||
|
||||
return SearchTab;
|
||||
});
|
|
@ -1,208 +1,216 @@
|
|||
define(['connectionManager', 'playbackManager', 'syncPlayManager', 'events', 'inputManager', 'focusManager', 'appRouter'], function (connectionManager, playbackManager, syncPlayManager, events, inputManager, focusManager, appRouter) {
|
||||
'use strict';
|
||||
import connectionManager from 'connectionManager';
|
||||
import playbackManager from 'playbackManager';
|
||||
import syncPlayManager from 'syncPlayManager';
|
||||
import events from 'events';
|
||||
import inputManager from 'inputManager';
|
||||
import focusManager from 'focusManager';
|
||||
import appRouter from 'appRouter';
|
||||
|
||||
var serverNotifications = {};
|
||||
const serverNotifications = {};
|
||||
|
||||
function notifyApp() {
|
||||
inputManager.notify();
|
||||
}
|
||||
function notifyApp() {
|
||||
inputManager.notify();
|
||||
}
|
||||
|
||||
function displayMessage(cmd) {
|
||||
var args = cmd.Arguments;
|
||||
if (args.TimeoutMs) {
|
||||
require(['toast'], function (toast) {
|
||||
toast({ title: args.Header, text: args.Text });
|
||||
});
|
||||
} else {
|
||||
require(['alert'], function (alert) {
|
||||
alert({ title: args.Header, text: args.Text });
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function displayContent(cmd, apiClient) {
|
||||
if (!playbackManager.isPlayingLocally(['Video', 'Book'])) {
|
||||
appRouter.showItem(cmd.Arguments.ItemId, apiClient.serverId());
|
||||
}
|
||||
}
|
||||
|
||||
function playTrailers(apiClient, itemId) {
|
||||
apiClient.getItem(apiClient.getCurrentUserId(), itemId).then(function (item) {
|
||||
playbackManager.playTrailers(item);
|
||||
function displayMessage(cmd) {
|
||||
const args = cmd.Arguments;
|
||||
if (args.TimeoutMs) {
|
||||
import('toast').then(({default: toast}) => {
|
||||
toast({ title: args.Header, text: args.Text });
|
||||
});
|
||||
} else {
|
||||
import('alert').then(({default: alert}) => {
|
||||
alert({ title: args.Header, text: args.Text });
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function processGeneralCommand(cmd, apiClient) {
|
||||
console.debug('Received command: ' + cmd.Name);
|
||||
switch (cmd.Name) {
|
||||
case 'Select':
|
||||
inputManager.trigger('select');
|
||||
return;
|
||||
case 'Back':
|
||||
inputManager.trigger('back');
|
||||
return;
|
||||
case 'MoveUp':
|
||||
inputManager.trigger('up');
|
||||
return;
|
||||
case 'MoveDown':
|
||||
inputManager.trigger('down');
|
||||
return;
|
||||
case 'MoveLeft':
|
||||
inputManager.trigger('left');
|
||||
return;
|
||||
case 'MoveRight':
|
||||
inputManager.trigger('right');
|
||||
return;
|
||||
case 'PageUp':
|
||||
inputManager.trigger('pageup');
|
||||
return;
|
||||
case 'PageDown':
|
||||
inputManager.trigger('pagedown');
|
||||
return;
|
||||
case 'PlayTrailers':
|
||||
playTrailers(apiClient, cmd.Arguments.ItemId);
|
||||
break;
|
||||
case 'SetRepeatMode':
|
||||
playbackManager.setRepeatMode(cmd.Arguments.RepeatMode);
|
||||
break;
|
||||
case 'VolumeUp':
|
||||
inputManager.trigger('volumeup');
|
||||
return;
|
||||
case 'VolumeDown':
|
||||
inputManager.trigger('volumedown');
|
||||
return;
|
||||
case 'ChannelUp':
|
||||
inputManager.trigger('channelup');
|
||||
return;
|
||||
case 'ChannelDown':
|
||||
inputManager.trigger('channeldown');
|
||||
return;
|
||||
case 'Mute':
|
||||
inputManager.trigger('mute');
|
||||
return;
|
||||
case 'Unmute':
|
||||
inputManager.trigger('unmute');
|
||||
return;
|
||||
case 'ToggleMute':
|
||||
inputManager.trigger('togglemute');
|
||||
return;
|
||||
case 'SetVolume':
|
||||
notifyApp();
|
||||
playbackManager.setVolume(cmd.Arguments.Volume);
|
||||
break;
|
||||
case 'SetAudioStreamIndex':
|
||||
notifyApp();
|
||||
playbackManager.setAudioStreamIndex(parseInt(cmd.Arguments.Index));
|
||||
break;
|
||||
case 'SetSubtitleStreamIndex':
|
||||
notifyApp();
|
||||
playbackManager.setSubtitleStreamIndex(parseInt(cmd.Arguments.Index));
|
||||
break;
|
||||
case 'ToggleFullscreen':
|
||||
inputManager.trigger('togglefullscreen');
|
||||
return;
|
||||
case 'GoHome':
|
||||
inputManager.trigger('home');
|
||||
return;
|
||||
case 'GoToSettings':
|
||||
inputManager.trigger('settings');
|
||||
return;
|
||||
case 'DisplayContent':
|
||||
displayContent(cmd, apiClient);
|
||||
break;
|
||||
case 'GoToSearch':
|
||||
inputManager.trigger('search');
|
||||
return;
|
||||
case 'DisplayMessage':
|
||||
displayMessage(cmd);
|
||||
break;
|
||||
case 'ToggleOsd':
|
||||
// todo
|
||||
break;
|
||||
case 'ToggleContextMenu':
|
||||
// todo
|
||||
break;
|
||||
case 'TakeScreenShot':
|
||||
// todo
|
||||
break;
|
||||
case 'SendKey':
|
||||
// todo
|
||||
break;
|
||||
case 'SendString':
|
||||
// todo
|
||||
focusManager.sendText(cmd.Arguments.String);
|
||||
break;
|
||||
default:
|
||||
console.debug('processGeneralCommand does not recognize: ' + cmd.Name);
|
||||
break;
|
||||
}
|
||||
|
||||
notifyApp();
|
||||
function displayContent(cmd, apiClient) {
|
||||
if (!playbackManager.isPlayingLocally(['Video', 'Book'])) {
|
||||
appRouter.showItem(cmd.Arguments.ItemId, apiClient.serverId());
|
||||
}
|
||||
}
|
||||
|
||||
function onMessageReceived(e, msg) {
|
||||
var apiClient = this;
|
||||
if (msg.MessageType === 'Play') {
|
||||
notifyApp();
|
||||
var serverId = apiClient.serverInfo().Id;
|
||||
if (msg.Data.PlayCommand === 'PlayNext') {
|
||||
playbackManager.queueNext({ ids: msg.Data.ItemIds, serverId: serverId });
|
||||
} else if (msg.Data.PlayCommand === 'PlayLast') {
|
||||
playbackManager.queue({ ids: msg.Data.ItemIds, serverId: serverId });
|
||||
} else {
|
||||
playbackManager.play({
|
||||
ids: msg.Data.ItemIds,
|
||||
startPositionTicks: msg.Data.StartPositionTicks,
|
||||
mediaSourceId: msg.Data.MediaSourceId,
|
||||
audioStreamIndex: msg.Data.AudioStreamIndex,
|
||||
subtitleStreamIndex: msg.Data.SubtitleStreamIndex,
|
||||
startIndex: msg.Data.StartIndex,
|
||||
serverId: serverId
|
||||
});
|
||||
}
|
||||
} else if (msg.MessageType === 'Playstate') {
|
||||
if (msg.Data.Command === 'Stop') {
|
||||
inputManager.trigger('stop');
|
||||
} else if (msg.Data.Command === 'Pause') {
|
||||
inputManager.trigger('pause');
|
||||
} else if (msg.Data.Command === 'Unpause') {
|
||||
inputManager.trigger('play');
|
||||
} else if (msg.Data.Command === 'PlayPause') {
|
||||
inputManager.trigger('playpause');
|
||||
} else if (msg.Data.Command === 'Seek') {
|
||||
playbackManager.seek(msg.Data.SeekPositionTicks);
|
||||
} else if (msg.Data.Command === 'NextTrack') {
|
||||
inputManager.trigger('next');
|
||||
} else if (msg.Data.Command === 'PreviousTrack') {
|
||||
inputManager.trigger('previous');
|
||||
} else {
|
||||
notifyApp();
|
||||
}
|
||||
} else if (msg.MessageType === 'GeneralCommand') {
|
||||
var cmd = msg.Data;
|
||||
processGeneralCommand(cmd, apiClient);
|
||||
} else if (msg.MessageType === 'UserDataChanged') {
|
||||
if (msg.Data.UserId === apiClient.getCurrentUserId()) {
|
||||
for (var i = 0, length = msg.Data.UserDataList.length; i < length; i++) {
|
||||
events.trigger(serverNotifications, 'UserDataChanged', [apiClient, msg.Data.UserDataList[i]]);
|
||||
}
|
||||
}
|
||||
} else if (msg.MessageType === 'SyncPlayCommand') {
|
||||
syncPlayManager.processCommand(msg.Data, apiClient);
|
||||
} else if (msg.MessageType === 'SyncPlayGroupUpdate') {
|
||||
syncPlayManager.processGroupUpdate(msg.Data, apiClient);
|
||||
} else {
|
||||
events.trigger(serverNotifications, msg.MessageType, [apiClient, msg.Data]);
|
||||
}
|
||||
}
|
||||
function bindEvents(apiClient) {
|
||||
events.off(apiClient, 'message', onMessageReceived);
|
||||
events.on(apiClient, 'message', onMessageReceived);
|
||||
}
|
||||
|
||||
connectionManager.getApiClients().forEach(bindEvents);
|
||||
events.on(connectionManager, 'apiclientcreated', function (e, newApiClient) {
|
||||
bindEvents(newApiClient);
|
||||
function playTrailers(apiClient, itemId) {
|
||||
apiClient.getItem(apiClient.getCurrentUserId(), itemId).then(function (item) {
|
||||
playbackManager.playTrailers(item);
|
||||
});
|
||||
return serverNotifications;
|
||||
}
|
||||
|
||||
function processGeneralCommand(cmd, apiClient) {
|
||||
console.debug('Received command: ' + cmd.Name);
|
||||
switch (cmd.Name) {
|
||||
case 'Select':
|
||||
inputManager.handleCommand('select');
|
||||
return;
|
||||
case 'Back':
|
||||
inputManager.handleCommand('back');
|
||||
return;
|
||||
case 'MoveUp':
|
||||
inputManager.handleCommand('up');
|
||||
return;
|
||||
case 'MoveDown':
|
||||
inputManager.handleCommand('down');
|
||||
return;
|
||||
case 'MoveLeft':
|
||||
inputManager.handleCommand('left');
|
||||
return;
|
||||
case 'MoveRight':
|
||||
inputManager.handleCommand('right');
|
||||
return;
|
||||
case 'PageUp':
|
||||
inputManager.handleCommand('pageup');
|
||||
return;
|
||||
case 'PageDown':
|
||||
inputManager.handleCommand('pagedown');
|
||||
return;
|
||||
case 'PlayTrailers':
|
||||
playTrailers(apiClient, cmd.Arguments.ItemId);
|
||||
break;
|
||||
case 'SetRepeatMode':
|
||||
playbackManager.setRepeatMode(cmd.Arguments.RepeatMode);
|
||||
break;
|
||||
case 'SetShuffleQueue':
|
||||
playbackManager.setQueueShuffleMode(cmd.Arguments.ShuffleMode);
|
||||
break;
|
||||
case 'VolumeUp':
|
||||
inputManager.handleCommand('volumeup');
|
||||
return;
|
||||
case 'VolumeDown':
|
||||
inputManager.handleCommand('volumedown');
|
||||
return;
|
||||
case 'ChannelUp':
|
||||
inputManager.handleCommand('channelup');
|
||||
return;
|
||||
case 'ChannelDown':
|
||||
inputManager.handleCommand('channeldown');
|
||||
return;
|
||||
case 'Mute':
|
||||
inputManager.handleCommand('mute');
|
||||
return;
|
||||
case 'Unmute':
|
||||
inputManager.handleCommand('unmute');
|
||||
return;
|
||||
case 'ToggleMute':
|
||||
inputManager.handleCommand('togglemute');
|
||||
return;
|
||||
case 'SetVolume':
|
||||
notifyApp();
|
||||
playbackManager.setVolume(cmd.Arguments.Volume);
|
||||
break;
|
||||
case 'SetAudioStreamIndex':
|
||||
notifyApp();
|
||||
playbackManager.setAudioStreamIndex(parseInt(cmd.Arguments.Index));
|
||||
break;
|
||||
case 'SetSubtitleStreamIndex':
|
||||
notifyApp();
|
||||
playbackManager.setSubtitleStreamIndex(parseInt(cmd.Arguments.Index));
|
||||
break;
|
||||
case 'ToggleFullscreen':
|
||||
inputManager.handleCommand('togglefullscreen');
|
||||
return;
|
||||
case 'GoHome':
|
||||
inputManager.handleCommand('home');
|
||||
return;
|
||||
case 'GoToSettings':
|
||||
inputManager.handleCommand('settings');
|
||||
return;
|
||||
case 'DisplayContent':
|
||||
displayContent(cmd, apiClient);
|
||||
break;
|
||||
case 'GoToSearch':
|
||||
inputManager.handleCommand('search');
|
||||
return;
|
||||
case 'DisplayMessage':
|
||||
displayMessage(cmd);
|
||||
break;
|
||||
case 'ToggleOsd':
|
||||
// todo
|
||||
break;
|
||||
case 'ToggleContextMenu':
|
||||
// todo
|
||||
break;
|
||||
case 'TakeScreenShot':
|
||||
// todo
|
||||
break;
|
||||
case 'SendKey':
|
||||
// todo
|
||||
break;
|
||||
case 'SendString':
|
||||
// todo
|
||||
focusManager.sendText(cmd.Arguments.String);
|
||||
break;
|
||||
default:
|
||||
console.debug('processGeneralCommand does not recognize: ' + cmd.Name);
|
||||
break;
|
||||
}
|
||||
|
||||
notifyApp();
|
||||
}
|
||||
|
||||
function onMessageReceived(e, msg) {
|
||||
const apiClient = this;
|
||||
if (msg.MessageType === 'Play') {
|
||||
notifyApp();
|
||||
const serverId = apiClient.serverInfo().Id;
|
||||
if (msg.Data.PlayCommand === 'PlayNext') {
|
||||
playbackManager.queueNext({ ids: msg.Data.ItemIds, serverId: serverId });
|
||||
} else if (msg.Data.PlayCommand === 'PlayLast') {
|
||||
playbackManager.queue({ ids: msg.Data.ItemIds, serverId: serverId });
|
||||
} else {
|
||||
playbackManager.play({
|
||||
ids: msg.Data.ItemIds,
|
||||
startPositionTicks: msg.Data.StartPositionTicks,
|
||||
mediaSourceId: msg.Data.MediaSourceId,
|
||||
audioStreamIndex: msg.Data.AudioStreamIndex,
|
||||
subtitleStreamIndex: msg.Data.SubtitleStreamIndex,
|
||||
startIndex: msg.Data.StartIndex,
|
||||
serverId: serverId
|
||||
});
|
||||
}
|
||||
} else if (msg.MessageType === 'Playstate') {
|
||||
if (msg.Data.Command === 'Stop') {
|
||||
inputManager.handleCommand('stop');
|
||||
} else if (msg.Data.Command === 'Pause') {
|
||||
inputManager.handleCommand('pause');
|
||||
} else if (msg.Data.Command === 'Unpause') {
|
||||
inputManager.handleCommand('play');
|
||||
} else if (msg.Data.Command === 'PlayPause') {
|
||||
inputManager.handleCommand('playpause');
|
||||
} else if (msg.Data.Command === 'Seek') {
|
||||
playbackManager.seek(msg.Data.SeekPositionTicks);
|
||||
} else if (msg.Data.Command === 'NextTrack') {
|
||||
inputManager.handleCommand('next');
|
||||
} else if (msg.Data.Command === 'PreviousTrack') {
|
||||
inputManager.handleCommand('previous');
|
||||
} else {
|
||||
notifyApp();
|
||||
}
|
||||
} else if (msg.MessageType === 'GeneralCommand') {
|
||||
const cmd = msg.Data;
|
||||
processGeneralCommand(cmd, apiClient);
|
||||
} else if (msg.MessageType === 'UserDataChanged') {
|
||||
if (msg.Data.UserId === apiClient.getCurrentUserId()) {
|
||||
for (let i = 0, length = msg.Data.UserDataList.length; i < length; i++) {
|
||||
events.trigger(serverNotifications, 'UserDataChanged', [apiClient, msg.Data.UserDataList[i]]);
|
||||
}
|
||||
}
|
||||
} else if (msg.MessageType === 'SyncPlayCommand') {
|
||||
syncPlayManager.processCommand(msg.Data, apiClient);
|
||||
} else if (msg.MessageType === 'SyncPlayGroupUpdate') {
|
||||
syncPlayManager.processGroupUpdate(msg.Data, apiClient);
|
||||
} else {
|
||||
events.trigger(serverNotifications, msg.MessageType, [apiClient, msg.Data]);
|
||||
}
|
||||
}
|
||||
function bindEvents(apiClient) {
|
||||
events.off(apiClient, 'message', onMessageReceived);
|
||||
events.on(apiClient, 'message', onMessageReceived);
|
||||
}
|
||||
|
||||
connectionManager.getApiClients().forEach(bindEvents);
|
||||
events.on(connectionManager, 'apiclientcreated', function (e, newApiClient) {
|
||||
bindEvents(newApiClient);
|
||||
});
|
||||
|
||||
export default serverNotifications;
|
||||
|
|
|
@ -28,7 +28,7 @@ import events from 'events';
|
|||
}
|
||||
|
||||
export function enableAutomaticBitrateDetection(isInNetwork, mediaType, val) {
|
||||
var key = 'enableautobitratebitrate-' + mediaType + '-' + isInNetwork;
|
||||
const key = 'enableautobitratebitrate-' + mediaType + '-' + isInNetwork;
|
||||
if (val !== undefined) {
|
||||
if (isInNetwork && mediaType === 'Audio') {
|
||||
val = true;
|
||||
|
@ -45,7 +45,7 @@ import events from 'events';
|
|||
}
|
||||
|
||||
export function maxStreamingBitrate(isInNetwork, mediaType, val) {
|
||||
var key = 'maxbitrate-' + mediaType + '-' + isInNetwork;
|
||||
const key = 'maxbitrate-' + mediaType + '-' + isInNetwork;
|
||||
if (val !== undefined) {
|
||||
if (isInNetwork && mediaType === 'Audio') {
|
||||
// nothing to do, this is always a max value
|
||||
|
@ -67,7 +67,7 @@ import events from 'events';
|
|||
this.set('maxStaticMusicBitrate', val);
|
||||
}
|
||||
|
||||
var defaultValue = 320000;
|
||||
const defaultValue = 320000;
|
||||
return parseInt(this.get('maxStaticMusicBitrate') || defaultValue.toString()) || defaultValue;
|
||||
}
|
||||
|
||||
|
@ -80,45 +80,8 @@ import events from 'events';
|
|||
return val ? parseInt(val) : null;
|
||||
}
|
||||
|
||||
export function syncOnlyOnWifi(val) {
|
||||
if (val !== undefined) {
|
||||
this.set('syncOnlyOnWifi', val.toString());
|
||||
}
|
||||
|
||||
return this.get('syncOnlyOnWifi') !== 'false';
|
||||
}
|
||||
|
||||
export function syncPath(val) {
|
||||
if (val !== undefined) {
|
||||
this.set('syncPath', val);
|
||||
}
|
||||
|
||||
return this.get('syncPath');
|
||||
}
|
||||
|
||||
export function cameraUploadServers(val) {
|
||||
if (val !== undefined) {
|
||||
this.set('cameraUploadServers', val.join(','));
|
||||
}
|
||||
|
||||
val = this.get('cameraUploadServers');
|
||||
if (val) {
|
||||
return val.split(',');
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
export function runAtStartup(val) {
|
||||
if (val !== undefined) {
|
||||
this.set('runatstartup', val.toString());
|
||||
}
|
||||
|
||||
return this.get('runatstartup') === 'true';
|
||||
}
|
||||
|
||||
export function set(name, value, userId) {
|
||||
var currentValue = this.get(name, userId);
|
||||
const currentValue = this.get(name, userId);
|
||||
appStorage.setItem(getKey(name, userId), value);
|
||||
|
||||
if (currentValue !== value) {
|
||||
|
@ -139,10 +102,6 @@ export default {
|
|||
maxStreamingBitrate: maxStreamingBitrate,
|
||||
maxStaticMusicBitrate: maxStaticMusicBitrate,
|
||||
maxChromecastBitrate: maxChromecastBitrate,
|
||||
syncOnlyOnWifi: syncOnlyOnWifi,
|
||||
syncPath: syncPath,
|
||||
cameraUploadServers: cameraUploadServers,
|
||||
runAtStartup: runAtStartup,
|
||||
set: set,
|
||||
get: get
|
||||
};
|
||||
|
|
|
@ -1,23 +1,34 @@
|
|||
/* eslint-disable indent */
|
||||
|
||||
import appSettings from 'appSettings';
|
||||
import events from 'events';
|
||||
|
||||
function onSaveTimeout() {
|
||||
var self = this;
|
||||
self.saveTimeout = null;
|
||||
self.currentApiClient.updateDisplayPreferences('usersettings', self.displayPrefs, self.currentUserId, 'emby');
|
||||
function onSaveTimeout() {
|
||||
const self = this;
|
||||
self.saveTimeout = null;
|
||||
self.currentApiClient.updateDisplayPreferences('usersettings', self.displayPrefs, self.currentUserId, 'emby');
|
||||
}
|
||||
|
||||
function saveServerPreferences(instance) {
|
||||
if (instance.saveTimeout) {
|
||||
clearTimeout(instance.saveTimeout);
|
||||
}
|
||||
|
||||
function saveServerPreferences(instance) {
|
||||
if (instance.saveTimeout) {
|
||||
clearTimeout(instance.saveTimeout);
|
||||
}
|
||||
instance.saveTimeout = setTimeout(onSaveTimeout.bind(instance), 50);
|
||||
}
|
||||
|
||||
instance.saveTimeout = setTimeout(onSaveTimeout.bind(instance), 50);
|
||||
const defaultSubtitleAppearanceSettings = {
|
||||
verticalPosition: -3
|
||||
};
|
||||
|
||||
export class UserSettings {
|
||||
constructor() {
|
||||
}
|
||||
|
||||
export function setUserInfo(userId, apiClient) {
|
||||
/**
|
||||
* Bind UserSettings instance to user.
|
||||
* @param {string} - User identifier.
|
||||
* @param {Object} - ApiClient instance.
|
||||
*/
|
||||
setUserInfo(userId, apiClient) {
|
||||
if (this.saveTimeout) {
|
||||
clearTimeout(this.saveTimeout);
|
||||
}
|
||||
|
@ -30,7 +41,7 @@ import events from 'events';
|
|||
return Promise.resolve();
|
||||
}
|
||||
|
||||
var self = this;
|
||||
const self = this;
|
||||
|
||||
return apiClient.getDisplayPreferences('usersettings', userId, 'emby').then(function (result) {
|
||||
result.CustomPrefs = result.CustomPrefs || {};
|
||||
|
@ -38,18 +49,27 @@ import events from 'events';
|
|||
});
|
||||
}
|
||||
|
||||
export function getData() {
|
||||
// FIXME: Seems unused
|
||||
getData() {
|
||||
return this.displayPrefs;
|
||||
}
|
||||
|
||||
export function importFrom(instance) {
|
||||
// FIXME: Seems unused
|
||||
importFrom(instance) {
|
||||
this.displayPrefs = instance.getData();
|
||||
}
|
||||
|
||||
export function set(name, value, enableOnServer) {
|
||||
var userId = this.currentUserId;
|
||||
var currentValue = this.get(name, enableOnServer);
|
||||
var result = appSettings.set(name, value, userId);
|
||||
// FIXME: 'appSettings.set' doesn't return any value
|
||||
/**
|
||||
* Set value of setting.
|
||||
* @param {string} name - Name of setting.
|
||||
* @param {mixed} value - Value of setting.
|
||||
* @param {boolean} enableOnServer - Flag to save preferences on server.
|
||||
*/
|
||||
set(name, value, enableOnServer) {
|
||||
const userId = this.currentUserId;
|
||||
const currentValue = this.get(name, enableOnServer);
|
||||
const result = appSettings.set(name, value, userId);
|
||||
|
||||
if (enableOnServer !== false && this.displayPrefs) {
|
||||
this.displayPrefs.CustomPrefs[name] = value == null ? value : value.toString();
|
||||
|
@ -63,8 +83,14 @@ import events from 'events';
|
|||
return result;
|
||||
}
|
||||
|
||||
export function get(name, enableOnServer) {
|
||||
var userId = this.currentUserId;
|
||||
/**
|
||||
* Get value of setting.
|
||||
* @param {string} name - Name of setting.
|
||||
* @param {boolean} enableOnServer - Flag to return preferences from server (cached).
|
||||
* @return {string} Value of setting.
|
||||
*/
|
||||
get(name, enableOnServer) {
|
||||
const userId = this.currentUserId;
|
||||
if (enableOnServer !== false && this.displayPrefs) {
|
||||
return this.displayPrefs.CustomPrefs[name];
|
||||
}
|
||||
|
@ -72,8 +98,13 @@ import events from 'events';
|
|||
return appSettings.get(name, userId);
|
||||
}
|
||||
|
||||
export function serverConfig(config) {
|
||||
var apiClient = this.currentApiClient;
|
||||
/**
|
||||
* Get or set user config.
|
||||
* @param {Object|undefined} config - Configuration or undefined.
|
||||
* @return {Object|Promise} Configuration or Promise.
|
||||
*/
|
||||
serverConfig(config) {
|
||||
const apiClient = this.currentApiClient;
|
||||
if (config) {
|
||||
return apiClient.updateUserConfiguration(this.currentUserId, config);
|
||||
}
|
||||
|
@ -83,7 +114,12 @@ import events from 'events';
|
|||
});
|
||||
}
|
||||
|
||||
export function enableCinemaMode(val) {
|
||||
/**
|
||||
* Get or set 'Cinema Mode' state.
|
||||
* @param {boolean|undefined} val - Flag to enable 'Cinema Mode' or undefined.
|
||||
* @return {boolean} 'Cinema Mode' state.
|
||||
*/
|
||||
enableCinemaMode(val) {
|
||||
if (val !== undefined) {
|
||||
return this.set('enableCinemaMode', val.toString(), false);
|
||||
}
|
||||
|
@ -92,7 +128,12 @@ import events from 'events';
|
|||
return val !== 'false';
|
||||
}
|
||||
|
||||
export function enableNextVideoInfoOverlay(val) {
|
||||
/**
|
||||
* Get or set 'Next Video Info Overlay' state.
|
||||
* @param {boolean|undefined} val - Flag to enable 'Next Video Info Overlay' or undefined.
|
||||
* @return {boolean} 'Next Video Info Overlay' state.
|
||||
*/
|
||||
enableNextVideoInfoOverlay(val) {
|
||||
if (val !== undefined) {
|
||||
return this.set('enableNextVideoInfoOverlay', val.toString());
|
||||
}
|
||||
|
@ -101,7 +142,12 @@ import events from 'events';
|
|||
return val !== 'false';
|
||||
}
|
||||
|
||||
export function enableThemeSongs(val) {
|
||||
/**
|
||||
* Get or set 'Theme Songs' state.
|
||||
* @param {boolean|undefined} val - Flag to enable 'Theme Songs' or undefined.
|
||||
* @return {boolean} 'Theme Songs' state.
|
||||
*/
|
||||
enableThemeSongs(val) {
|
||||
if (val !== undefined) {
|
||||
return this.set('enableThemeSongs', val.toString(), false);
|
||||
}
|
||||
|
@ -110,7 +156,12 @@ import events from 'events';
|
|||
return val === 'true';
|
||||
}
|
||||
|
||||
export function enableThemeVideos(val) {
|
||||
/**
|
||||
* Get or set 'Theme Videos' state.
|
||||
* @param {boolean|undefined} val - Flag to enable 'Theme Videos' or undefined.
|
||||
* @return {boolean} 'Theme Videos' state.
|
||||
*/
|
||||
enableThemeVideos(val) {
|
||||
if (val !== undefined) {
|
||||
return this.set('enableThemeVideos', val.toString(), false);
|
||||
}
|
||||
|
@ -119,7 +170,12 @@ import events from 'events';
|
|||
return val === 'true';
|
||||
}
|
||||
|
||||
export function enableFastFadein(val) {
|
||||
/**
|
||||
* Get or set 'Fast Fade-in' state.
|
||||
* @param {boolean|undefined} val - Flag to enable 'Fast Fade-in' or undefined.
|
||||
* @return {boolean} 'Fast Fade-in' state.
|
||||
*/
|
||||
enableFastFadein(val) {
|
||||
if (val !== undefined) {
|
||||
return this.set('fastFadein', val.toString(), false);
|
||||
}
|
||||
|
@ -128,7 +184,26 @@ import events from 'events';
|
|||
return val !== 'false';
|
||||
}
|
||||
|
||||
export function enableBackdrops(val) {
|
||||
/**
|
||||
* Get or set 'Blurhash' state.
|
||||
* @param {boolean|undefined} val - Flag to enable 'Blurhash' or undefined.
|
||||
* @return {boolean} 'Blurhash' state.
|
||||
*/
|
||||
enableBlurhash(val) {
|
||||
if (val !== undefined) {
|
||||
return this.set('blurhash', val.toString(), false);
|
||||
}
|
||||
|
||||
val = this.get('blurhash', false);
|
||||
return val !== 'false';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get or set 'Backdrops' state.
|
||||
* @param {boolean|undefined} val - Flag to enable 'Backdrops' or undefined.
|
||||
* @return {boolean} 'Backdrops' state.
|
||||
*/
|
||||
enableBackdrops(val) {
|
||||
if (val !== undefined) {
|
||||
return this.set('enableBackdrops', val.toString(), false);
|
||||
}
|
||||
|
@ -137,7 +212,12 @@ import events from 'events';
|
|||
return val !== 'false';
|
||||
}
|
||||
|
||||
export function detailsBanner(val) {
|
||||
/**
|
||||
* Get or set 'Details Banner' state.
|
||||
* @param {boolean|undefined} val - Flag to enable 'Details Banner' or undefined.
|
||||
* @return {boolean} 'Details Banner' state.
|
||||
*/
|
||||
detailsBanner(val) {
|
||||
if (val !== undefined) {
|
||||
return this.set('detailsBanner', val.toString(), false);
|
||||
}
|
||||
|
@ -146,7 +226,12 @@ import events from 'events';
|
|||
return val !== 'false';
|
||||
}
|
||||
|
||||
export function language(val) {
|
||||
/**
|
||||
* Get or set language.
|
||||
* @param {string|undefined} val - Language.
|
||||
* @return {string} Language.
|
||||
*/
|
||||
language(val) {
|
||||
if (val !== undefined) {
|
||||
return this.set('language', val.toString(), false);
|
||||
}
|
||||
|
@ -154,7 +239,12 @@ import events from 'events';
|
|||
return this.get('language', false);
|
||||
}
|
||||
|
||||
export function dateTimeLocale(val) {
|
||||
/**
|
||||
* Get or set datetime locale.
|
||||
* @param {string|undefined} val - Datetime locale.
|
||||
* @return {string} Datetime locale.
|
||||
*/
|
||||
dateTimeLocale(val) {
|
||||
if (val !== undefined) {
|
||||
return this.set('datetimelocale', val.toString(), false);
|
||||
}
|
||||
|
@ -162,7 +252,12 @@ import events from 'events';
|
|||
return this.get('datetimelocale', false);
|
||||
}
|
||||
|
||||
export function chromecastVersion(val) {
|
||||
/**
|
||||
* Get or set Chromecast version.
|
||||
* @param {string|undefined} val - Chromecast version.
|
||||
* @return {string} Chromecast version.
|
||||
*/
|
||||
chromecastVersion(val) {
|
||||
if (val !== undefined) {
|
||||
return this.set('chromecastVersion', val.toString());
|
||||
}
|
||||
|
@ -170,7 +265,12 @@ import events from 'events';
|
|||
return this.get('chromecastVersion') || 'stable';
|
||||
}
|
||||
|
||||
export function skipBackLength(val) {
|
||||
/**
|
||||
* Get or set amount of rewind.
|
||||
* @param {number|undefined} val - Amount of rewind.
|
||||
* @return {number} Amount of rewind.
|
||||
*/
|
||||
skipBackLength(val) {
|
||||
if (val !== undefined) {
|
||||
return this.set('skipBackLength', val.toString());
|
||||
}
|
||||
|
@ -178,7 +278,12 @@ import events from 'events';
|
|||
return parseInt(this.get('skipBackLength') || '10000');
|
||||
}
|
||||
|
||||
export function skipForwardLength(val) {
|
||||
/**
|
||||
* Get or set amount of fast forward.
|
||||
* @param {number|undefined} val - Amount of fast forward.
|
||||
* @return {number} Amount of fast forward.
|
||||
*/
|
||||
skipForwardLength(val) {
|
||||
if (val !== undefined) {
|
||||
return this.set('skipForwardLength', val.toString());
|
||||
}
|
||||
|
@ -186,7 +291,12 @@ import events from 'events';
|
|||
return parseInt(this.get('skipForwardLength') || '30000');
|
||||
}
|
||||
|
||||
export function dashboardTheme(val) {
|
||||
/**
|
||||
* Get or set theme for Dashboard.
|
||||
* @param {string|undefined} val - Theme for Dashboard.
|
||||
* @return {string} Theme for Dashboard.
|
||||
*/
|
||||
dashboardTheme(val) {
|
||||
if (val !== undefined) {
|
||||
return this.set('dashboardTheme', val);
|
||||
}
|
||||
|
@ -194,7 +304,12 @@ import events from 'events';
|
|||
return this.get('dashboardTheme');
|
||||
}
|
||||
|
||||
export function skin(val) {
|
||||
/**
|
||||
* Get or set skin.
|
||||
* @param {string|undefined} val - Skin.
|
||||
* @return {string} Skin.
|
||||
*/
|
||||
skin(val) {
|
||||
if (val !== undefined) {
|
||||
return this.set('skin', val, false);
|
||||
}
|
||||
|
@ -202,7 +317,12 @@ import events from 'events';
|
|||
return this.get('skin', false);
|
||||
}
|
||||
|
||||
export function theme(val) {
|
||||
/**
|
||||
* Get or set main theme.
|
||||
* @param {string|undefined} val - Main theme.
|
||||
* @return {string} Main theme.
|
||||
*/
|
||||
theme(val) {
|
||||
if (val !== undefined) {
|
||||
return this.set('appTheme', val, false);
|
||||
}
|
||||
|
@ -210,7 +330,12 @@ import events from 'events';
|
|||
return this.get('appTheme', false);
|
||||
}
|
||||
|
||||
export function screensaver(val) {
|
||||
/**
|
||||
* Get or set screensaver.
|
||||
* @param {string|undefined} val - Screensaver.
|
||||
* @return {string} Screensaver.
|
||||
*/
|
||||
screensaver(val) {
|
||||
if (val !== undefined) {
|
||||
return this.set('screensaver', val, false);
|
||||
}
|
||||
|
@ -218,12 +343,17 @@ import events from 'events';
|
|||
return this.get('screensaver', false);
|
||||
}
|
||||
|
||||
export function libraryPageSize(val) {
|
||||
/**
|
||||
* Get or set library page size.
|
||||
* @param {number|undefined} val - Library page size.
|
||||
* @return {number} Library page size.
|
||||
*/
|
||||
libraryPageSize(val) {
|
||||
if (val !== undefined) {
|
||||
return this.set('libraryPageSize', parseInt(val, 10), false);
|
||||
}
|
||||
|
||||
var libraryPageSize = parseInt(this.get('libraryPageSize', false), 10);
|
||||
const libraryPageSize = parseInt(this.get('libraryPageSize', false), 10);
|
||||
if (libraryPageSize === 0) {
|
||||
// Explicitly return 0 to avoid returning 100 because 0 is falsy.
|
||||
return 0;
|
||||
|
@ -232,7 +362,12 @@ import events from 'events';
|
|||
}
|
||||
}
|
||||
|
||||
export function soundEffects(val) {
|
||||
/**
|
||||
* Get or set sound effects.
|
||||
* @param {string|undefined} val - Sound effects.
|
||||
* @return {string} Sound effects.
|
||||
*/
|
||||
soundEffects(val) {
|
||||
if (val !== undefined) {
|
||||
return this.set('soundeffects', val, false);
|
||||
}
|
||||
|
@ -240,8 +375,14 @@ import events from 'events';
|
|||
return this.get('soundeffects', false);
|
||||
}
|
||||
|
||||
export function loadQuerySettings(key, query) {
|
||||
var values = this.get(key);
|
||||
/**
|
||||
* Load query settings.
|
||||
* @param {string} key - Query key.
|
||||
* @param {Object} query - Query base.
|
||||
* @return {Object} Query.
|
||||
*/
|
||||
loadQuerySettings(key, query) {
|
||||
let values = this.get(key);
|
||||
if (values) {
|
||||
values = JSON.parse(values);
|
||||
return Object.assign(query, values);
|
||||
|
@ -250,8 +391,13 @@ import events from 'events';
|
|||
return query;
|
||||
}
|
||||
|
||||
export function saveQuerySettings(key, query) {
|
||||
var values = {};
|
||||
/**
|
||||
* Save query settings.
|
||||
* @param {string} key - Query key.
|
||||
* @param {Object} query - Query.
|
||||
*/
|
||||
saveQuerySettings(key, query) {
|
||||
const values = {};
|
||||
if (query.SortBy) {
|
||||
values.SortBy = query.SortBy;
|
||||
}
|
||||
|
@ -263,52 +409,76 @@ import events from 'events';
|
|||
return this.set(key, JSON.stringify(values));
|
||||
}
|
||||
|
||||
export function getSubtitleAppearanceSettings(key) {
|
||||
/**
|
||||
* Get subtitle appearance settings.
|
||||
* @param {string|undefined} key - Settings key.
|
||||
* @return {Object} Subtitle appearance settings.
|
||||
*/
|
||||
getSubtitleAppearanceSettings(key) {
|
||||
key = key || 'localplayersubtitleappearance3';
|
||||
return JSON.parse(this.get(key, false) || '{}');
|
||||
return Object.assign(defaultSubtitleAppearanceSettings, JSON.parse(this.get(key, false) || '{}'));
|
||||
}
|
||||
|
||||
export function setSubtitleAppearanceSettings(value, key) {
|
||||
/**
|
||||
* Set subtitle appearance settings.
|
||||
* @param {Object} value - Subtitle appearance settings.
|
||||
* @param {string|undefined} key - Settings key.
|
||||
*/
|
||||
setSubtitleAppearanceSettings(value, key) {
|
||||
key = key || 'localplayersubtitleappearance3';
|
||||
return this.set(key, JSON.stringify(value), false);
|
||||
}
|
||||
|
||||
export function setFilter(key, value) {
|
||||
/**
|
||||
* Set filter.
|
||||
* @param {string} key - Filter key.
|
||||
* @param {string} value - Filter value.
|
||||
*/
|
||||
setFilter(key, value) {
|
||||
return this.set(key, value, true);
|
||||
}
|
||||
|
||||
export function getFilter(key) {
|
||||
/**
|
||||
* Get filter.
|
||||
* @param {string} key - Filter key.
|
||||
* @return {string} Filter value.
|
||||
*/
|
||||
getFilter(key) {
|
||||
return this.get(key, true);
|
||||
}
|
||||
}
|
||||
|
||||
/* eslint-enable indent */
|
||||
export default {
|
||||
setUserInfo: setUserInfo,
|
||||
getData: getData,
|
||||
importFrom: importFrom,
|
||||
set: set,
|
||||
get: get,
|
||||
serverConfig: serverConfig,
|
||||
enableCinemaMode: enableCinemaMode,
|
||||
enableNextVideoInfoOverlay: enableNextVideoInfoOverlay,
|
||||
enableThemeSongs: enableThemeSongs,
|
||||
enableThemeVideos: enableThemeVideos,
|
||||
enableFastFadein: enableFastFadein,
|
||||
enableBackdrops: enableBackdrops,
|
||||
language: language,
|
||||
dateTimeLocale: dateTimeLocale,
|
||||
skipBackLength: skipBackLength,
|
||||
skipForwardLength: skipForwardLength,
|
||||
dashboardTheme: dashboardTheme,
|
||||
skin: skin,
|
||||
theme: theme,
|
||||
screensaver: screensaver,
|
||||
libraryPageSize: libraryPageSize,
|
||||
soundEffects: soundEffects,
|
||||
loadQuerySettings: loadQuerySettings,
|
||||
saveQuerySettings: saveQuerySettings,
|
||||
getSubtitleAppearanceSettings: getSubtitleAppearanceSettings,
|
||||
setSubtitleAppearanceSettings: setSubtitleAppearanceSettings,
|
||||
setFilter: setFilter,
|
||||
getFilter: getFilter
|
||||
};
|
||||
export const currentSettings = new UserSettings;
|
||||
|
||||
// Wrappers for non-ES6 modules and backward compatibility
|
||||
export const setUserInfo = currentSettings.setUserInfo.bind(currentSettings);
|
||||
export const getData = currentSettings.getData.bind(currentSettings);
|
||||
export const importFrom = currentSettings.importFrom.bind(currentSettings);
|
||||
export const set = currentSettings.set.bind(currentSettings);
|
||||
export const get = currentSettings.get.bind(currentSettings);
|
||||
export const serverConfig = currentSettings.serverConfig.bind(currentSettings);
|
||||
export const enableCinemaMode = currentSettings.enableCinemaMode.bind(currentSettings);
|
||||
export const enableNextVideoInfoOverlay = currentSettings.enableNextVideoInfoOverlay.bind(currentSettings);
|
||||
export const enableThemeSongs = currentSettings.enableThemeSongs.bind(currentSettings);
|
||||
export const enableThemeVideos = currentSettings.enableThemeVideos.bind(currentSettings);
|
||||
export const enableFastFadein = currentSettings.enableFastFadein.bind(currentSettings);
|
||||
export const enableBlurhash = currentSettings.enableBlurhash.bind(currentSettings);
|
||||
export const enableBackdrops = currentSettings.enableBackdrops.bind(currentSettings);
|
||||
export const detailsBanner = currentSettings.detailsBanner.bind(currentSettings);
|
||||
export const language = currentSettings.language.bind(currentSettings);
|
||||
export const dateTimeLocale = currentSettings.dateTimeLocale.bind(currentSettings);
|
||||
export const chromecastVersion = currentSettings.chromecastVersion.bind(currentSettings);
|
||||
export const skipBackLength = currentSettings.skipBackLength.bind(currentSettings);
|
||||
export const skipForwardLength = currentSettings.skipForwardLength.bind(currentSettings);
|
||||
export const dashboardTheme = currentSettings.dashboardTheme.bind(currentSettings);
|
||||
export const skin = currentSettings.skin.bind(currentSettings);
|
||||
export const theme = currentSettings.theme.bind(currentSettings);
|
||||
export const screensaver = currentSettings.screensaver.bind(currentSettings);
|
||||
export const libraryPageSize = currentSettings.libraryPageSize.bind(currentSettings);
|
||||
export const soundEffects = currentSettings.soundEffects.bind(currentSettings);
|
||||
export const loadQuerySettings = currentSettings.loadQuerySettings.bind(currentSettings);
|
||||
export const saveQuerySettings = currentSettings.saveQuerySettings.bind(currentSettings);
|
||||
export const getSubtitleAppearanceSettings = currentSettings.getSubtitleAppearanceSettings.bind(currentSettings);
|
||||
export const setSubtitleAppearanceSettings = currentSettings.setSubtitleAppearanceSettings.bind(currentSettings);
|
||||
export const setFilter = currentSettings.setFilter.bind(currentSettings);
|
||||
export const getFilter = currentSettings.getFilter.bind(currentSettings);
|
||||
|
|
|
@ -1,24 +1,43 @@
|
|||
let data;
|
||||
|
||||
function getConfig() {
|
||||
async function getConfig() {
|
||||
if (data) return Promise.resolve(data);
|
||||
return fetch('/config.json?nocache=' + new Date().getUTCMilliseconds()).then(response => {
|
||||
data = response.json();
|
||||
try {
|
||||
const response = await fetch('config.json', {
|
||||
cache: 'no-cache'
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error('network response was not ok');
|
||||
}
|
||||
|
||||
data = await response.json();
|
||||
|
||||
return data;
|
||||
}).catch(error => {
|
||||
console.warn('web config file is missing so the template will be used');
|
||||
} catch (error) {
|
||||
console.warn('failed to fetch the web config file:', error);
|
||||
return getDefaultConfig();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function getDefaultConfig() {
|
||||
return fetch('/config.template.json').then(function (response) {
|
||||
data = response.json();
|
||||
async function getDefaultConfig() {
|
||||
try {
|
||||
const response = await fetch('config.template.json', {
|
||||
cache: 'no-cache'
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error('network response was not ok');
|
||||
}
|
||||
|
||||
data = await response.json();
|
||||
return data;
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('failed to fetch the default web config file:', error);
|
||||
}
|
||||
}
|
||||
|
||||
export function enableMultiServer() {
|
||||
export function getMultiServer() {
|
||||
return getConfig().then(config => {
|
||||
return config.multiserver;
|
||||
}).catch(error => {
|
||||
|
@ -26,3 +45,21 @@ export function enableMultiServer() {
|
|||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
export function getThemes() {
|
||||
return getConfig().then(config => {
|
||||
return config.themes;
|
||||
}).catch(error => {
|
||||
console.log('cannot get web config:', error);
|
||||
return [];
|
||||
});
|
||||
}
|
||||
|
||||
export function getPlugins() {
|
||||
return getConfig().then(config => {
|
||||
return config.plugins;
|
||||
}).catch(error => {
|
||||
console.log('cannot get web config:', error);
|
||||
return [];
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,24 +1,20 @@
|
|||
define([], function () {
|
||||
'use strict';
|
||||
|
||||
return {
|
||||
openUrl: function (url, target) {
|
||||
if (window.NativeShell) {
|
||||
window.NativeShell.openUrl(url, target);
|
||||
} else {
|
||||
window.open(url, target || '_blank');
|
||||
}
|
||||
|
||||
},
|
||||
enableFullscreen: function () {
|
||||
if (window.NativeShell) {
|
||||
window.NativeShell.enableFullscreen();
|
||||
}
|
||||
},
|
||||
disableFullscreen: function () {
|
||||
if (window.NativeShell) {
|
||||
window.NativeShell.disableFullscreen();
|
||||
}
|
||||
// TODO: This seems like a good candidate for deprecation
|
||||
export default {
|
||||
openUrl: function (url, target) {
|
||||
if (window.NativeShell) {
|
||||
window.NativeShell.openUrl(url, target);
|
||||
} else {
|
||||
window.open(url, target || '_blank');
|
||||
}
|
||||
};
|
||||
});
|
||||
},
|
||||
enableFullscreen: function () {
|
||||
if (window.NativeShell) {
|
||||
window.NativeShell.enableFullscreen();
|
||||
}
|
||||
},
|
||||
disableFullscreen: function () {
|
||||
if (window.NativeShell) {
|
||||
window.NativeShell.disableFullscreen();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
function getWindowLocationSearch(win) {
|
||||
window.getWindowLocationSearch = function(win) {
|
||||
'use strict';
|
||||
|
||||
var search = (win || window).location.search;
|
||||
|
@ -6,15 +6,15 @@ function getWindowLocationSearch(win) {
|
|||
if (!search) {
|
||||
var index = window.location.href.indexOf('?');
|
||||
|
||||
if (-1 != index) {
|
||||
if (index != -1) {
|
||||
search = window.location.href.substring(index);
|
||||
}
|
||||
}
|
||||
|
||||
return search || '';
|
||||
}
|
||||
};
|
||||
|
||||
function getParameterByName(name, url) {
|
||||
window.getParameterByName = function(name, url) {
|
||||
'use strict';
|
||||
|
||||
name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
|
||||
|
@ -22,14 +22,14 @@ function getParameterByName(name, url) {
|
|||
var regex = new RegExp(regexS, 'i');
|
||||
var results = regex.exec(url || getWindowLocationSearch());
|
||||
|
||||
if (null == results) {
|
||||
if (results == null) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return decodeURIComponent(results[1].replace(/\+/g, ' '));
|
||||
}
|
||||
};
|
||||
|
||||
function pageClassOn(eventName, className, fn) {
|
||||
window.pageClassOn = function(eventName, className, fn) {
|
||||
'use strict';
|
||||
|
||||
document.addEventListener(eventName, function (event) {
|
||||
|
@ -39,9 +39,9 @@ function pageClassOn(eventName, className, fn) {
|
|||
fn.call(target, event);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
function pageIdOn(eventName, id, fn) {
|
||||
window.pageIdOn = function(eventName, id, fn) {
|
||||
'use strict';
|
||||
|
||||
document.addEventListener(eventName, function (event) {
|
||||
|
@ -51,191 +51,11 @@ function pageIdOn(eventName, id, fn) {
|
|||
fn.call(target, event);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var Dashboard = {
|
||||
getCurrentUser: function () {
|
||||
return window.ApiClient.getCurrentUser(false);
|
||||
},
|
||||
|
||||
//TODO: investigate url prefix support for serverAddress function
|
||||
serverAddress: function () {
|
||||
if (AppInfo.isNativeApp) {
|
||||
var apiClient = window.ApiClient;
|
||||
|
||||
if (apiClient) {
|
||||
return apiClient.serverAddress();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
var urlLower = window.location.href.toLowerCase();
|
||||
var index = urlLower.lastIndexOf('/web');
|
||||
|
||||
if (-1 != index) {
|
||||
return urlLower.substring(0, index);
|
||||
}
|
||||
|
||||
var loc = window.location;
|
||||
var address = loc.protocol + '//' + loc.hostname;
|
||||
|
||||
if (loc.port) {
|
||||
address += ':' + loc.port;
|
||||
}
|
||||
|
||||
return address;
|
||||
},
|
||||
getCurrentUserId: function () {
|
||||
var apiClient = window.ApiClient;
|
||||
|
||||
if (apiClient) {
|
||||
return apiClient.getCurrentUserId();
|
||||
}
|
||||
|
||||
return null;
|
||||
},
|
||||
onServerChanged: function (userId, accessToken, apiClient) {
|
||||
apiClient = apiClient || window.ApiClient;
|
||||
window.ApiClient = apiClient;
|
||||
},
|
||||
logout: function () {
|
||||
ConnectionManager.logout().then(function () {
|
||||
var loginPage;
|
||||
|
||||
if (AppInfo.isNativeApp) {
|
||||
loginPage = 'selectserver.html';
|
||||
window.ApiClient = null;
|
||||
} else {
|
||||
loginPage = 'login.html';
|
||||
}
|
||||
|
||||
Dashboard.navigate(loginPage);
|
||||
});
|
||||
},
|
||||
getConfigurationPageUrl: function (name) {
|
||||
return 'configurationpage?name=' + encodeURIComponent(name);
|
||||
},
|
||||
getConfigurationResourceUrl: function (name) {
|
||||
if (AppInfo.isNativeApp) {
|
||||
return ApiClient.getUrl('web/ConfigurationPage', {
|
||||
name: name
|
||||
});
|
||||
}
|
||||
|
||||
return Dashboard.getConfigurationPageUrl(name);
|
||||
},
|
||||
navigate: function (url, preserveQueryString) {
|
||||
if (!url) {
|
||||
throw new Error('url cannot be null or empty');
|
||||
}
|
||||
|
||||
var queryString = getWindowLocationSearch();
|
||||
|
||||
if (preserveQueryString && queryString) {
|
||||
url += queryString;
|
||||
}
|
||||
|
||||
return new Promise(function (resolve, reject) {
|
||||
require(['appRouter'], function (appRouter) {
|
||||
return appRouter.show(url).then(resolve, reject);
|
||||
});
|
||||
});
|
||||
},
|
||||
navigate_direct: function (path) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
require(['appRouter'], function (appRouter) {
|
||||
return appRouter.showDirect(path).then(resolve, reject);
|
||||
});
|
||||
});
|
||||
},
|
||||
processPluginConfigurationUpdateResult: function () {
|
||||
require(['loading', 'toast'], function (loading, toast) {
|
||||
loading.hide();
|
||||
toast(Globalize.translate('MessageSettingsSaved'));
|
||||
});
|
||||
},
|
||||
processServerConfigurationUpdateResult: function (result) {
|
||||
require(['loading', 'toast'], function (loading, toast) {
|
||||
loading.hide();
|
||||
toast(Globalize.translate('MessageSettingsSaved'));
|
||||
});
|
||||
},
|
||||
processErrorResponse: function (response) {
|
||||
require(['loading'], function (loading) {
|
||||
loading.hide();
|
||||
});
|
||||
|
||||
var status = '' + response.status;
|
||||
|
||||
if (response.statusText) {
|
||||
status = response.statusText;
|
||||
}
|
||||
|
||||
Dashboard.alert({
|
||||
title: status,
|
||||
message: response.headers ? response.headers.get('X-Application-Error-Code') : null
|
||||
});
|
||||
},
|
||||
alert: function (options) {
|
||||
if ('string' == typeof options) {
|
||||
return void require(['toast'], function (toast) {
|
||||
toast({
|
||||
text: options
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
require(['alert'], function (alert) {
|
||||
alert({
|
||||
title: options.title || Globalize.translate('HeaderAlert'),
|
||||
text: options.message
|
||||
}).then(options.callback || function () {});
|
||||
});
|
||||
},
|
||||
restartServer: function () {
|
||||
var apiClient = window.ApiClient;
|
||||
|
||||
if (apiClient) {
|
||||
require(['serverRestartDialog', 'events'], function (ServerRestartDialog, events) {
|
||||
var dialog = new ServerRestartDialog({
|
||||
apiClient: apiClient
|
||||
});
|
||||
events.on(dialog, 'restarted', function () {
|
||||
if (AppInfo.isNativeApp) {
|
||||
apiClient.ensureWebSocket();
|
||||
} else {
|
||||
window.location.reload(true);
|
||||
}
|
||||
});
|
||||
dialog.show();
|
||||
});
|
||||
}
|
||||
},
|
||||
capabilities: function (appHost) {
|
||||
var capabilities = {
|
||||
PlayableMediaTypes: ['Audio', 'Video'],
|
||||
SupportedCommands: ['MoveUp', 'MoveDown', 'MoveLeft', 'MoveRight', 'PageUp', 'PageDown', 'PreviousLetter', 'NextLetter', 'ToggleOsd', 'ToggleContextMenu', 'Select', 'Back', 'SendKey', 'SendString', 'GoHome', 'GoToSettings', 'VolumeUp', 'VolumeDown', 'Mute', 'Unmute', 'ToggleMute', 'SetVolume', 'SetAudioStreamIndex', 'SetSubtitleStreamIndex', 'DisplayContent', 'GoToSearch', 'DisplayMessage', 'SetRepeatMode', 'ChannelUp', 'ChannelDown', 'PlayMediaSource', 'PlayTrailers'],
|
||||
SupportsPersistentIdentifier: 'cordova' === self.appMode || 'android' === self.appMode,
|
||||
SupportsMediaControl: true
|
||||
};
|
||||
appHost.getPushTokenInfo();
|
||||
return capabilities = Object.assign(capabilities, appHost.getPushTokenInfo());
|
||||
},
|
||||
selectServer: function () {
|
||||
if (window.NativeShell && typeof window.NativeShell.selectServer === 'function') {
|
||||
window.NativeShell.selectServer();
|
||||
} else {
|
||||
Dashboard.navigate('selectserver.html');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var AppInfo = {};
|
||||
|
||||
!function () {
|
||||
'use strict';
|
||||
|
||||
function initClient() {
|
||||
function defineConnectionManager(connectionManager) {
|
||||
window.ConnectionManager = connectionManager;
|
||||
define('connectionManager', [], function () {
|
||||
|
@ -270,17 +90,16 @@ var AppInfo = {};
|
|||
}
|
||||
|
||||
function createConnectionManager() {
|
||||
return require(['connectionManagerFactory', 'apphost', 'credentialprovider', 'events', 'userSettings'], function (ConnectionManager, apphost, credentialProvider, events, userSettings) {
|
||||
return require(['connectionManagerFactory', 'apphost', 'credentialprovider', 'events', 'userSettings'], function (ConnectionManager, appHost, credentialProvider, events, userSettings) {
|
||||
appHost = appHost.default || appHost;
|
||||
|
||||
var credentialProviderInstance = new credentialProvider();
|
||||
var promises = [apphost.getSyncProfile(), apphost.init()];
|
||||
var promises = [appHost.init()];
|
||||
|
||||
return Promise.all(promises).then(function (responses) {
|
||||
var deviceProfile = responses[0];
|
||||
var capabilities = Dashboard.capabilities(apphost);
|
||||
var capabilities = Dashboard.capabilities(appHost);
|
||||
|
||||
capabilities.DeviceProfile = deviceProfile;
|
||||
|
||||
var connectionManager = new ConnectionManager(credentialProviderInstance, apphost.appName(), apphost.appVersion(), apphost.deviceName(), apphost.deviceId(), capabilities);
|
||||
var connectionManager = new ConnectionManager(credentialProviderInstance, appHost.appName(), appHost.appVersion(), appHost.deviceName(), appHost.deviceId(), capabilities);
|
||||
|
||||
defineConnectionManager(connectionManager);
|
||||
bindConnectionManagerEvents(connectionManager, events, userSettings);
|
||||
|
@ -288,10 +107,10 @@ var AppInfo = {};
|
|||
if (!AppInfo.isNativeApp) {
|
||||
console.debug('loading ApiClient singleton');
|
||||
|
||||
return require(['apiclient'], function (apiClientFactory) {
|
||||
return require(['apiclient', 'clientUtils'], function (apiClientFactory, clientUtils) {
|
||||
console.debug('creating ApiClient singleton');
|
||||
|
||||
var apiClient = new apiClientFactory(Dashboard.serverAddress(), apphost.appName(), apphost.appVersion(), apphost.deviceName(), apphost.deviceId());
|
||||
var apiClient = new apiClientFactory(Dashboard.serverAddress(), appHost.appName(), appHost.appVersion(), appHost.deviceName(), appHost.deviceId());
|
||||
|
||||
apiClient.enableAutomaticNetworking = false;
|
||||
apiClient.manualAddressOnly = true;
|
||||
|
@ -340,7 +159,7 @@ var AppInfo = {};
|
|||
function getPlaybackManager(playbackManager) {
|
||||
window.addEventListener('beforeunload', function () {
|
||||
try {
|
||||
playbackManager.onAppClose();
|
||||
playbackManager.default.onAppClose();
|
||||
} catch (err) {
|
||||
console.error('error in onAppClose: ' + err);
|
||||
}
|
||||
|
@ -349,6 +168,8 @@ var AppInfo = {};
|
|||
}
|
||||
|
||||
function getLayoutManager(layoutManager, appHost) {
|
||||
layoutManager = layoutManager.default || layoutManager;
|
||||
appHost = appHost.default || appHost;
|
||||
if (appHost.getDefaultLayout) {
|
||||
layoutManager.defaultLayout = appHost.getDefaultLayout();
|
||||
}
|
||||
|
@ -357,7 +178,7 @@ var AppInfo = {};
|
|||
return layoutManager;
|
||||
}
|
||||
|
||||
function createSharedAppFooter(appFooter) {
|
||||
function createSharedAppFooter({default: appFooter}) {
|
||||
return new appFooter({});
|
||||
}
|
||||
|
||||
|
@ -366,54 +187,21 @@ var AppInfo = {};
|
|||
}
|
||||
|
||||
function defineResizeObserver() {
|
||||
if (self.ResizeObserver) {
|
||||
if (window.ResizeObserver) {
|
||||
define('ResizeObserver', [], function () {
|
||||
return self.ResizeObserver;
|
||||
return window.ResizeObserver;
|
||||
});
|
||||
} else {
|
||||
define('ResizeObserver', ['resize-observer-polyfill'], returnFirstDependency);
|
||||
}
|
||||
}
|
||||
|
||||
function initRequireWithBrowser(browser) {
|
||||
var bowerPath = getBowerPath();
|
||||
var componentsPath = getComponentsPath();
|
||||
var scriptsPath = getScriptsPath();
|
||||
|
||||
define('filesystem', [scriptsPath + '/filesystem'], returnFirstDependency);
|
||||
|
||||
define('lazyLoader', [componentsPath + '/lazyLoader/lazyLoaderIntersectionObserver'], returnFirstDependency);
|
||||
define('shell', [scriptsPath + '/shell'], returnFirstDependency);
|
||||
|
||||
if ('registerElement' in document) {
|
||||
define('registerElement', []);
|
||||
} else if (browser.msie) {
|
||||
define('registerElement', ['webcomponents'], returnFirstDependency);
|
||||
} else {
|
||||
define('registerElement', ['document-register-element'], returnFirstDependency);
|
||||
}
|
||||
|
||||
define('alert', [componentsPath + '/alert'], returnFirstDependency);
|
||||
|
||||
defineResizeObserver();
|
||||
|
||||
define('dialog', [componentsPath + '/dialog/dialog'], returnFirstDependency);
|
||||
|
||||
define('confirm', [componentsPath + '/confirm/confirm'], returnFirstDependency);
|
||||
|
||||
define('prompt', [componentsPath + '/prompt/prompt'], returnFirstDependency);
|
||||
|
||||
define('loading', [componentsPath + '/loading/loading'], returnFirstDependency);
|
||||
define('multi-download', [scriptsPath + '/multiDownload'], returnFirstDependency);
|
||||
define('fileDownloader', [scriptsPath + '/fileDownloader'], returnFirstDependency);
|
||||
|
||||
define('castSenderApiLoader', [componentsPath + '/castSenderApi'], returnFirstDependency);
|
||||
}
|
||||
|
||||
function init() {
|
||||
define('livetvcss', ['css!assets/css/livetv.css'], returnFirstDependency);
|
||||
define('detailtablecss', ['css!assets/css/detailtable.css'], returnFirstDependency);
|
||||
|
||||
require(['clientUtils']);
|
||||
|
||||
var promises = [];
|
||||
if (!window.fetch) {
|
||||
promises.push(require(['fetch']));
|
||||
|
@ -426,7 +214,7 @@ var AppInfo = {};
|
|||
require(['globalize', 'browser'], function (globalize, browser) {
|
||||
window.Globalize = globalize;
|
||||
loadCoreDictionary(globalize).then(function () {
|
||||
onGlobalizeInit(browser);
|
||||
onGlobalizeInit(browser, globalize);
|
||||
});
|
||||
});
|
||||
require(['keyboardnavigation'], function(keyboardnavigation) {
|
||||
|
@ -459,14 +247,14 @@ var AppInfo = {};
|
|||
});
|
||||
}
|
||||
|
||||
function onGlobalizeInit(browser) {
|
||||
if ('android' === self.appMode) {
|
||||
if (-1 !== self.location.href.toString().toLowerCase().indexOf('start=backgroundsync')) {
|
||||
function onGlobalizeInit(browser, globalize) {
|
||||
if (window.appMode === 'android') {
|
||||
if (window.location.href.toString().toLowerCase().indexOf('start=backgroundsync') !== -1) {
|
||||
return onAppReady(browser);
|
||||
}
|
||||
}
|
||||
|
||||
document.title = Globalize.translateDocument(document.title, 'core');
|
||||
document.title = globalize.translateHtml(document.title, 'core');
|
||||
|
||||
if (browser.tv && !browser.android) {
|
||||
console.debug('using system fonts with explicit sizes');
|
||||
|
@ -477,6 +265,8 @@ var AppInfo = {};
|
|||
}
|
||||
|
||||
require(['apphost', 'css!assets/css/librarybrowser'], function (appHost) {
|
||||
appHost = appHost.default || appHost;
|
||||
|
||||
loadPlugins(appHost, browser).then(function () {
|
||||
onAppReady(browser);
|
||||
});
|
||||
|
@ -484,44 +274,45 @@ var AppInfo = {};
|
|||
}
|
||||
|
||||
function loadPlugins(appHost, browser, shell) {
|
||||
console.debug('loading installed plugins');
|
||||
var list = [
|
||||
'components/playback/playaccessvalidation',
|
||||
'components/playback/experimentalwarnings',
|
||||
'components/htmlAudioPlayer/plugin',
|
||||
'components/htmlVideoPlayer/plugin',
|
||||
'components/comicsPlayer/plugin',
|
||||
'components/photoPlayer/plugin',
|
||||
'components/youtubeplayer/plugin',
|
||||
'components/backdropScreensaver/plugin',
|
||||
'components/logoScreensaver/plugin'
|
||||
];
|
||||
|
||||
if (appHost.supports('remotecontrol')) {
|
||||
list.push('components/sessionPlayer');
|
||||
|
||||
if (browser.chrome || browser.opera) {
|
||||
list.push('components/chromecast/chromecastplayer');
|
||||
}
|
||||
}
|
||||
|
||||
if (window.NativeShell) {
|
||||
list = list.concat(window.NativeShell.getPlugins());
|
||||
}
|
||||
|
||||
console.groupCollapsed('loading installed plugins');
|
||||
return new Promise(function (resolve, reject) {
|
||||
Promise.all(list.map(loadPlugin)).then(function () {
|
||||
require(['packageManager'], function (packageManager) {
|
||||
packageManager.init().then(resolve, reject);
|
||||
require(['webSettings'], function (webSettings) {
|
||||
webSettings.getPlugins().then(function (list) {
|
||||
// these two plugins are dependent on features
|
||||
if (!appHost.supports('remotecontrol')) {
|
||||
list.splice(list.indexOf('sessionPlayer'), 1);
|
||||
|
||||
if (!browser.chrome && !browser.opera) {
|
||||
list.splice(list.indexOf('chromecastPlayer', 1));
|
||||
}
|
||||
}
|
||||
|
||||
// add any native plugins
|
||||
if (window.NativeShell) {
|
||||
list = list.concat(window.NativeShell.getPlugins());
|
||||
}
|
||||
|
||||
Promise.all(list.map(loadPlugin))
|
||||
.then(function () {
|
||||
console.debug('finished loading plugins');
|
||||
})
|
||||
.catch(() => reject)
|
||||
.finally(() => {
|
||||
console.groupEnd('loading installed plugins');
|
||||
require(['packageManager'], function (packageManager) {
|
||||
packageManager.default.init().then(resolve, reject);
|
||||
});
|
||||
})
|
||||
;
|
||||
});
|
||||
}, reject);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function loadPlugin(url) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
require(['pluginManager'], function (pluginManager) {
|
||||
pluginManager.loadPlugin(url).then(resolve, reject);
|
||||
pluginManager.default.loadPlugin(url).then(resolve, reject);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -531,6 +322,9 @@ var AppInfo = {};
|
|||
|
||||
// ensure that appHost is loaded in this point
|
||||
require(['apphost', 'appRouter'], function (appHost, appRouter) {
|
||||
appRouter = appRouter.default || appRouter;
|
||||
appHost = appHost.default || appHost;
|
||||
|
||||
window.Emby = {};
|
||||
|
||||
console.debug('onAppReady: loading dependencies');
|
||||
|
@ -540,7 +334,7 @@ var AppInfo = {};
|
|||
|
||||
window.Emby.Page = appRouter;
|
||||
|
||||
require(['emby-button', 'scripts/themeLoader', 'libraryMenu', 'scripts/routes'], function () {
|
||||
require(['emby-button', 'scripts/autoThemes', 'libraryMenu', 'scripts/routes'], function () {
|
||||
Emby.Page.start({
|
||||
click: false,
|
||||
hashbang: true
|
||||
|
@ -562,6 +356,7 @@ var AppInfo = {};
|
|||
require(['components/playback/volumeosd']);
|
||||
}
|
||||
|
||||
/* eslint-disable-next-line compat/compat */
|
||||
if (navigator.mediaSession || window.NativeShell) {
|
||||
require(['mediaSession']);
|
||||
}
|
||||
|
@ -589,11 +384,15 @@ var AppInfo = {};
|
|||
return response.text();
|
||||
})
|
||||
.then(function(css) {
|
||||
// Inject the branding css as a dom element in body so it will take
|
||||
// precedence over other stylesheets
|
||||
var style = document.createElement('style');
|
||||
style.appendChild(document.createTextNode(css));
|
||||
document.body.appendChild(style);
|
||||
let style = document.querySelector('#cssBranding');
|
||||
if (!style) {
|
||||
// Inject the branding css as a dom element in body so it will take
|
||||
// precedence over other stylesheets
|
||||
style = document.createElement('style');
|
||||
style.id = 'cssBranding';
|
||||
document.body.appendChild(style);
|
||||
}
|
||||
style.textContent = css;
|
||||
})
|
||||
.catch(function(err) {
|
||||
console.warn('Error applying custom css', err);
|
||||
|
@ -605,7 +404,7 @@ var AppInfo = {};
|
|||
|
||||
function registerServiceWorker() {
|
||||
/* eslint-disable compat/compat */
|
||||
if (navigator.serviceWorker && self.appMode !== 'cordova' && self.appMode !== 'android') {
|
||||
if (navigator.serviceWorker && window.appMode !== 'cordova' && window.appMode !== 'android') {
|
||||
try {
|
||||
navigator.serviceWorker.register('serviceworker.js');
|
||||
} catch (err) {
|
||||
|
@ -617,19 +416,42 @@ var AppInfo = {};
|
|||
/* eslint-enable compat/compat */
|
||||
}
|
||||
|
||||
function onWebComponentsReady(browser) {
|
||||
initRequireWithBrowser(browser);
|
||||
function onWebComponentsReady() {
|
||||
var componentsPath = getComponentsPath();
|
||||
var scriptsPath = getScriptsPath();
|
||||
|
||||
if (self.appMode === 'cordova' || self.appMode === 'android' || self.appMode === 'standalone') {
|
||||
define('filesystem', [scriptsPath + '/filesystem'], returnFirstDependency);
|
||||
|
||||
define('lazyLoader', [componentsPath + '/lazyLoader/lazyLoaderIntersectionObserver'], returnFirstDependency);
|
||||
define('shell', [scriptsPath + '/shell'], returnFirstDependency);
|
||||
|
||||
define('alert', [componentsPath + '/alert'], returnFirstDependency);
|
||||
|
||||
defineResizeObserver();
|
||||
|
||||
define('dialog', [componentsPath + '/dialog/dialog'], returnFirstDependency);
|
||||
|
||||
define('confirm', [componentsPath + '/confirm/confirm'], returnFirstDependency);
|
||||
|
||||
define('prompt', [componentsPath + '/prompt/prompt'], returnFirstDependency);
|
||||
|
||||
define('loading', [componentsPath + '/loading/loading'], returnFirstDependency);
|
||||
define('multi-download', [scriptsPath + '/multiDownload'], returnFirstDependency);
|
||||
define('fileDownloader', [scriptsPath + '/fileDownloader'], returnFirstDependency);
|
||||
|
||||
define('castSenderApiLoader', [componentsPath + '/castSenderApi'], returnFirstDependency);
|
||||
|
||||
if (window.appMode === 'cordova' || window.appMode === 'android' || window.appMode === 'standalone') {
|
||||
AppInfo.isNativeApp = true;
|
||||
}
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
var promise;
|
||||
var localApiClient;
|
||||
|
||||
(function () {
|
||||
function initRequireJs() {
|
||||
var urlArgs = 'v=' + (window.dashboardVersion || new Date().getDate());
|
||||
|
||||
var bowerPath = getBowerPath();
|
||||
|
@ -659,8 +481,10 @@ var AppInfo = {};
|
|||
playQueueManager: componentsPath + '/playback/playqueuemanager',
|
||||
nowPlayingHelper: componentsPath + '/playback/nowplayinghelper',
|
||||
pluginManager: componentsPath + '/pluginManager',
|
||||
packageManager: componentsPath + '/packagemanager',
|
||||
screensaverManager: componentsPath + '/screensavermanager'
|
||||
packageManager: componentsPath + '/packageManager',
|
||||
screensaverManager: componentsPath + '/screensavermanager',
|
||||
clientUtils: scriptsPath + '/clientUtils',
|
||||
appRouter: 'components/appRouter'
|
||||
};
|
||||
|
||||
requirejs.onError = onRequireJsError;
|
||||
|
@ -674,16 +498,15 @@ var AppInfo = {};
|
|||
},
|
||||
bundles: {
|
||||
bundle: [
|
||||
'document-register-element',
|
||||
'fetch',
|
||||
'flvjs',
|
||||
'jstree',
|
||||
'epubjs',
|
||||
'jQuery',
|
||||
'hlsjs',
|
||||
'howler',
|
||||
'native-promise-only',
|
||||
'resize-observer-polyfill',
|
||||
'shaka',
|
||||
'swiper',
|
||||
'queryString',
|
||||
'sortable',
|
||||
|
@ -711,20 +534,12 @@ var AppInfo = {};
|
|||
onError: onRequireJsError
|
||||
});
|
||||
|
||||
require(['fetch']);
|
||||
require(['polyfill']);
|
||||
require(['fast-text-encoding']);
|
||||
require(['intersection-observer']);
|
||||
require(['classlist-polyfill']);
|
||||
|
||||
// Expose jQuery globally
|
||||
require(['jQuery'], function(jQuery) {
|
||||
window.$ = jQuery;
|
||||
window.jQuery = jQuery;
|
||||
});
|
||||
|
||||
require(['css!assets/css/site']);
|
||||
require(['jellyfin-noto']);
|
||||
promise = require(['fetch'])
|
||||
.then(() => require(['jQuery', 'polyfill', 'fast-text-encoding', 'intersection-observer', 'classlist-polyfill', 'css!assets/css/site', 'jellyfin-noto'], (jQuery) => {
|
||||
// Expose jQuery globally
|
||||
window.$ = jQuery;
|
||||
window.jQuery = jQuery;
|
||||
}));
|
||||
|
||||
// define styles
|
||||
// TODO determine which of these files can be moved to the components themselves
|
||||
|
@ -739,12 +554,6 @@ var AppInfo = {};
|
|||
define('cardStyle', ['css!' + componentsPath + '/cardbuilder/card'], returnFirstDependency);
|
||||
define('flexStyles', ['css!assets/css/flexstyles'], returnFirstDependency);
|
||||
|
||||
// define legacy features
|
||||
// TODO delete the rest of these
|
||||
define('fnchecked', ['legacy/fnchecked'], returnFirstDependency);
|
||||
define('legacyDashboard', ['legacy/dashboard'], returnFirstDependency);
|
||||
define('legacySelectMenu', ['legacy/selectmenu'], returnFirstDependency);
|
||||
|
||||
// there are several objects that need to be instantiated
|
||||
// TODO find a better way to do this
|
||||
define('appFooter', [componentsPath + '/appFooter/appFooter'], returnFirstDependency);
|
||||
|
@ -780,7 +589,6 @@ var AppInfo = {};
|
|||
define('appSettings', [scriptsPath + '/settings/appSettings'], returnFirstDependency);
|
||||
define('userSettings', [scriptsPath + '/settings/userSettings'], returnFirstDependency);
|
||||
|
||||
define('chromecastHelper', [componentsPath + '/chromecast/chromecasthelpers'], returnFirstDependency);
|
||||
define('mediaSession', [componentsPath + '/playback/mediasession'], returnFirstDependency);
|
||||
define('actionsheet', [componentsPath + '/actionSheet/actionSheet'], returnFirstDependency);
|
||||
define('tunerPicker', [componentsPath + '/tunerPicker'], returnFirstDependency);
|
||||
|
@ -797,9 +605,7 @@ var AppInfo = {};
|
|||
define('multiSelect', [componentsPath + '/multiSelect/multiSelect'], returnFirstDependency);
|
||||
define('alphaPicker', [componentsPath + '/alphaPicker/alphaPicker'], returnFirstDependency);
|
||||
define('tabbedView', [componentsPath + '/tabbedview/tabbedview'], returnFirstDependency);
|
||||
define('itemsTab', [componentsPath + '/tabbedview/itemstab'], returnFirstDependency);
|
||||
define('collectionEditor', [componentsPath + '/collectionEditor/collectionEditor'], returnFirstDependency);
|
||||
define('serverRestartDialog', [componentsPath + '/serverRestartDialog'], returnFirstDependency);
|
||||
define('playlistEditor', [componentsPath + '/playlisteditor/playlisteditor'], returnFirstDependency);
|
||||
define('recordingCreator', [componentsPath + '/recordingcreator/recordingcreator'], returnFirstDependency);
|
||||
define('recordingEditor', [componentsPath + '/recordingcreator/recordingeditor'], returnFirstDependency);
|
||||
|
@ -822,14 +628,15 @@ var AppInfo = {};
|
|||
define('upNextDialog', [componentsPath + '/upnextdialog/upnextdialog'], returnFirstDependency);
|
||||
define('subtitleAppearanceHelper', [componentsPath + '/subtitlesettings/subtitleappearancehelper'], returnFirstDependency);
|
||||
define('subtitleSettings', [componentsPath + '/subtitlesettings/subtitlesettings'], returnFirstDependency);
|
||||
define('settingsHelper', [componentsPath + '/settingshelper'], returnFirstDependency);
|
||||
define('displaySettings', [componentsPath + '/displaySettings/displaySettings'], returnFirstDependency);
|
||||
define('playbackSettings', [componentsPath + '/playbackSettings/playbackSettings'], returnFirstDependency);
|
||||
define('homescreenSettings', [componentsPath + '/homeScreenSettings/homeScreenSettings'], returnFirstDependency);
|
||||
define('playbackManager', [componentsPath + '/playback/playbackmanager'], getPlaybackManager);
|
||||
define('timeSyncManager', [componentsPath + '/syncplay/timeSyncManager'], returnDefault);
|
||||
define('groupSelectionMenu', [componentsPath + '/syncplay/groupSelectionMenu'], returnFirstDependency);
|
||||
define('syncPlayManager', [componentsPath + '/syncplay/syncPlayManager'], returnDefault);
|
||||
define('playbackPermissionManager', [componentsPath + '/syncplay/playbackPermissionManager'], returnDefault);
|
||||
define('timeSyncManager', [componentsPath + '/syncPlay/timeSyncManager'], returnDefault);
|
||||
define('groupSelectionMenu', [componentsPath + '/syncPlay/groupSelectionMenu'], returnFirstDependency);
|
||||
define('syncPlayManager', [componentsPath + '/syncPlay/syncPlayManager'], returnDefault);
|
||||
define('playbackPermissionManager', [componentsPath + '/syncPlay/playbackPermissionManager'], returnDefault);
|
||||
define('layoutManager', [componentsPath + '/layoutManager', 'apphost'], getLayoutManager);
|
||||
define('homeSections', [componentsPath + '/homesections/homesections'], returnFirstDependency);
|
||||
define('playMenu', [componentsPath + '/playmenu'], returnFirstDependency);
|
||||
|
@ -842,10 +649,9 @@ var AppInfo = {};
|
|||
define('deleteHelper', [scriptsPath + '/deleteHelper'], returnFirstDependency);
|
||||
define('tvguide', [componentsPath + '/guide/guide'], returnFirstDependency);
|
||||
define('guide-settings-dialog', [componentsPath + '/guide/guide-settings'], returnFirstDependency);
|
||||
define('loadingDialog', [componentsPath + '/loadingDialog/loadingDialog'], returnFirstDependency);
|
||||
define('viewManager', [componentsPath + '/viewManager/viewManager'], function (viewManager) {
|
||||
window.ViewManager = viewManager;
|
||||
viewManager.dispatchPageEvents(true);
|
||||
window.ViewManager = viewManager.default;
|
||||
viewManager.default.dispatchPageEvents(true);
|
||||
return viewManager;
|
||||
});
|
||||
define('slideshow', [componentsPath + '/slideshow/slideshow'], returnFirstDependency);
|
||||
|
@ -853,7 +659,7 @@ var AppInfo = {};
|
|||
define('userdataButtons', [componentsPath + '/userdatabuttons/userdatabuttons'], returnFirstDependency);
|
||||
define('listView', [componentsPath + '/listview/listview'], returnFirstDependency);
|
||||
define('indicators', [componentsPath + '/indicators/indicators'], returnFirstDependency);
|
||||
define('viewSettings', [componentsPath + '/viewsettings/viewsettings'], returnFirstDependency);
|
||||
define('viewSettings', [componentsPath + '/viewSettings/viewSettings'], returnFirstDependency);
|
||||
define('filterMenu', [componentsPath + '/filtermenu/filtermenu'], returnFirstDependency);
|
||||
define('sortMenu', [componentsPath + '/sortmenu/sortmenu'], returnFirstDependency);
|
||||
define('sanitizefilename', [componentsPath + '/sanitizeFilename'], returnFirstDependency);
|
||||
|
@ -865,7 +671,7 @@ var AppInfo = {};
|
|||
define('viewContainer', [componentsPath + '/viewContainer'], returnFirstDependency);
|
||||
define('dialogHelper', [componentsPath + '/dialogHelper/dialogHelper'], returnFirstDependency);
|
||||
define('serverNotifications', [scriptsPath + '/serverNotifications'], returnFirstDependency);
|
||||
define('skinManager', [componentsPath + '/skinManager'], returnFirstDependency);
|
||||
define('skinManager', [scriptsPath + '/themeManager'], returnFirstDependency);
|
||||
define('keyboardnavigation', [scriptsPath + '/keyboardNavigation'], returnFirstDependency);
|
||||
define('mouseManager', [scriptsPath + '/mouseManager'], returnFirstDependency);
|
||||
define('scrollManager', [componentsPath + '/scrollManager'], returnFirstDependency);
|
||||
|
@ -878,269 +684,13 @@ var AppInfo = {};
|
|||
return window.ApiClient;
|
||||
};
|
||||
});
|
||||
define('appRouter', [componentsPath + '/appRouter', 'itemHelper'], function (appRouter, itemHelper) {
|
||||
function showItem(item, serverId, options) {
|
||||
if ('string' == typeof item) {
|
||||
require(['connectionManager'], function (connectionManager) {
|
||||
var apiClient = connectionManager.currentApiClient();
|
||||
apiClient.getItem(apiClient.getCurrentUserId(), item).then(function (item) {
|
||||
appRouter.showItem(item, options);
|
||||
});
|
||||
});
|
||||
} else {
|
||||
if (2 == arguments.length) {
|
||||
options = arguments[1];
|
||||
}
|
||||
}
|
||||
|
||||
appRouter.show('/' + appRouter.getRouteUrl(item, options), {
|
||||
item: item
|
||||
});
|
||||
}
|
||||
}
|
||||
initRequireJs();
|
||||
promise.then(onWebComponentsReady);
|
||||
}
|
||||
|
||||
appRouter.showLocalLogin = function (serverId, manualLogin) {
|
||||
Dashboard.navigate('login.html?serverid=' + serverId);
|
||||
};
|
||||
|
||||
appRouter.showVideoOsd = function () {
|
||||
return Dashboard.navigate('videoosd.html');
|
||||
};
|
||||
|
||||
appRouter.showSelectServer = function () {
|
||||
Dashboard.navigate(AppInfo.isNativeApp ? 'selectserver.html' : 'login.html');
|
||||
};
|
||||
|
||||
appRouter.showWelcome = function () {
|
||||
Dashboard.navigate(AppInfo.isNativeApp ? 'selectserver.html' : 'login.html');
|
||||
};
|
||||
|
||||
appRouter.showSettings = function () {
|
||||
Dashboard.navigate('mypreferencesmenu.html');
|
||||
};
|
||||
|
||||
appRouter.showGuide = function () {
|
||||
Dashboard.navigate('livetv.html?tab=1');
|
||||
};
|
||||
|
||||
appRouter.goHome = function () {
|
||||
Dashboard.navigate('home.html');
|
||||
};
|
||||
|
||||
appRouter.showSearch = function () {
|
||||
Dashboard.navigate('search.html');
|
||||
};
|
||||
|
||||
appRouter.showLiveTV = function () {
|
||||
Dashboard.navigate('livetv.html');
|
||||
};
|
||||
|
||||
appRouter.showRecordedTV = function () {
|
||||
Dashboard.navigate('livetv.html?tab=3');
|
||||
};
|
||||
|
||||
appRouter.showFavorites = function () {
|
||||
Dashboard.navigate('home.html?tab=1');
|
||||
};
|
||||
|
||||
appRouter.showSettings = function () {
|
||||
Dashboard.navigate('mypreferencesmenu.html');
|
||||
};
|
||||
|
||||
appRouter.setTitle = function (title) {
|
||||
LibraryMenu.setTitle(title);
|
||||
};
|
||||
|
||||
appRouter.getRouteUrl = function (item, options) {
|
||||
if (!item) {
|
||||
throw new Error('item cannot be null');
|
||||
}
|
||||
|
||||
if (item.url) {
|
||||
return item.url;
|
||||
}
|
||||
|
||||
var context = options ? options.context : null;
|
||||
var id = item.Id || item.ItemId;
|
||||
|
||||
if (!options) {
|
||||
options = {};
|
||||
}
|
||||
|
||||
var url;
|
||||
var itemType = item.Type || (options ? options.itemType : null);
|
||||
var serverId = item.ServerId || options.serverId;
|
||||
|
||||
if ('settings' === item) {
|
||||
return 'mypreferencesmenu.html';
|
||||
}
|
||||
|
||||
if ('wizard' === item) {
|
||||
return 'wizardstart.html';
|
||||
}
|
||||
|
||||
if ('manageserver' === item) {
|
||||
return 'dashboard.html';
|
||||
}
|
||||
|
||||
if ('recordedtv' === item) {
|
||||
return 'livetv.html?tab=3&serverId=' + options.serverId;
|
||||
}
|
||||
|
||||
if ('nextup' === item) {
|
||||
return 'list.html?type=nextup&serverId=' + options.serverId;
|
||||
}
|
||||
|
||||
if ('list' === item) {
|
||||
var url = 'list.html?serverId=' + options.serverId + '&type=' + options.itemTypes;
|
||||
|
||||
if (options.isFavorite) {
|
||||
url += '&IsFavorite=true';
|
||||
}
|
||||
|
||||
return url;
|
||||
}
|
||||
|
||||
if ('livetv' === item) {
|
||||
if ('programs' === options.section) {
|
||||
return 'livetv.html?tab=0&serverId=' + options.serverId;
|
||||
}
|
||||
if ('guide' === options.section) {
|
||||
return 'livetv.html?tab=1&serverId=' + options.serverId;
|
||||
}
|
||||
|
||||
if ('movies' === options.section) {
|
||||
return 'list.html?type=Programs&IsMovie=true&serverId=' + options.serverId;
|
||||
}
|
||||
|
||||
if ('shows' === options.section) {
|
||||
return 'list.html?type=Programs&IsSeries=true&IsMovie=false&IsNews=false&serverId=' + options.serverId;
|
||||
}
|
||||
|
||||
if ('sports' === options.section) {
|
||||
return 'list.html?type=Programs&IsSports=true&serverId=' + options.serverId;
|
||||
}
|
||||
|
||||
if ('kids' === options.section) {
|
||||
return 'list.html?type=Programs&IsKids=true&serverId=' + options.serverId;
|
||||
}
|
||||
|
||||
if ('news' === options.section) {
|
||||
return 'list.html?type=Programs&IsNews=true&serverId=' + options.serverId;
|
||||
}
|
||||
|
||||
if ('onnow' === options.section) {
|
||||
return 'list.html?type=Programs&IsAiring=true&serverId=' + options.serverId;
|
||||
}
|
||||
|
||||
if ('dvrschedule' === options.section) {
|
||||
return 'livetv.html?tab=4&serverId=' + options.serverId;
|
||||
}
|
||||
|
||||
if ('seriesrecording' === options.section) {
|
||||
return 'livetv.html?tab=5&serverId=' + options.serverId;
|
||||
}
|
||||
|
||||
return 'livetv.html?serverId=' + options.serverId;
|
||||
}
|
||||
|
||||
if ('SeriesTimer' == itemType) {
|
||||
return 'itemdetails.html?seriesTimerId=' + id + '&serverId=' + serverId;
|
||||
}
|
||||
|
||||
if ('livetv' == item.CollectionType) {
|
||||
return 'livetv.html';
|
||||
}
|
||||
|
||||
if ('Genre' === item.Type) {
|
||||
url = 'list.html?genreId=' + item.Id + '&serverId=' + serverId;
|
||||
|
||||
if ('livetv' === context) {
|
||||
url += '&type=Programs';
|
||||
}
|
||||
|
||||
if (options.parentId) {
|
||||
url += '&parentId=' + options.parentId;
|
||||
}
|
||||
|
||||
return url;
|
||||
}
|
||||
|
||||
if ('MusicGenre' === item.Type) {
|
||||
url = 'list.html?musicGenreId=' + item.Id + '&serverId=' + serverId;
|
||||
|
||||
if (options.parentId) {
|
||||
url += '&parentId=' + options.parentId;
|
||||
}
|
||||
|
||||
return url;
|
||||
}
|
||||
|
||||
if ('Studio' === item.Type) {
|
||||
url = 'list.html?studioId=' + item.Id + '&serverId=' + serverId;
|
||||
|
||||
if (options.parentId) {
|
||||
url += '&parentId=' + options.parentId;
|
||||
}
|
||||
|
||||
return url;
|
||||
}
|
||||
|
||||
if ('folders' !== context && !itemHelper.isLocalItem(item)) {
|
||||
if ('movies' == item.CollectionType) {
|
||||
url = 'movies.html?topParentId=' + item.Id;
|
||||
|
||||
if (options && 'latest' === options.section) {
|
||||
url += '&tab=1';
|
||||
}
|
||||
|
||||
return url;
|
||||
}
|
||||
|
||||
if ('tvshows' == item.CollectionType) {
|
||||
url = 'tv.html?topParentId=' + item.Id;
|
||||
|
||||
if (options && 'latest' === options.section) {
|
||||
url += '&tab=2';
|
||||
}
|
||||
|
||||
return url;
|
||||
}
|
||||
|
||||
if ('music' == item.CollectionType) {
|
||||
return 'music.html?topParentId=' + item.Id;
|
||||
}
|
||||
}
|
||||
|
||||
var itemTypes = ['Playlist', 'TvChannel', 'Program', 'BoxSet', 'MusicAlbum', 'MusicGenre', 'Person', 'Recording', 'MusicArtist'];
|
||||
|
||||
if (itemTypes.indexOf(itemType) >= 0) {
|
||||
return 'itemdetails.html?id=' + id + '&serverId=' + serverId;
|
||||
}
|
||||
|
||||
var contextSuffix = context ? '&context=' + context : '';
|
||||
|
||||
if ('Series' == itemType || 'Season' == itemType || 'Episode' == itemType) {
|
||||
return 'itemdetails.html?id=' + id + contextSuffix + '&serverId=' + serverId;
|
||||
}
|
||||
|
||||
if (item.IsFolder) {
|
||||
if (id) {
|
||||
return 'list.html?parentId=' + id + '&serverId=' + serverId;
|
||||
}
|
||||
|
||||
return '#';
|
||||
}
|
||||
|
||||
return 'itemdetails.html?id=' + id + '&serverId=' + serverId;
|
||||
};
|
||||
|
||||
appRouter.showItem = showItem;
|
||||
return appRouter;
|
||||
});
|
||||
})();
|
||||
|
||||
return require(['browser'], onWebComponentsReady);
|
||||
}();
|
||||
initClient();
|
||||
|
||||
pageClassOn('viewshow', 'standalonePage', function () {
|
||||
document.querySelector('.skinHeader').classList.add('noHeaderRight');
|
||||
|
|
|
@ -1,119 +1,122 @@
|
|||
define(['events', 'userSettings', 'serverNotifications', 'connectionManager', 'globalize', 'emby-button'], function (events, userSettings, serverNotifications, connectionManager, globalize) {
|
||||
'use strict';
|
||||
|
||||
return function (options) {
|
||||
function pollTasks() {
|
||||
connectionManager.getApiClient(serverId).getScheduledTasks({
|
||||
IsEnabled: true
|
||||
}).then(updateTasks);
|
||||
}
|
||||
import events from 'events';
|
||||
import serverNotifications from 'serverNotifications';
|
||||
import connectionManager from 'connectionManager';
|
||||
import globalize from 'globalize';
|
||||
import 'emby-button';
|
||||
|
||||
function updateTasks(tasks) {
|
||||
var task = tasks.filter(function (t) {
|
||||
return t.Key == options.taskKey;
|
||||
})[0];
|
||||
export default function (options) {
|
||||
function pollTasks() {
|
||||
connectionManager.getApiClient(serverId).getScheduledTasks({
|
||||
IsEnabled: true
|
||||
}).then(updateTasks);
|
||||
}
|
||||
|
||||
if (options.panel) {
|
||||
if (task) {
|
||||
options.panel.classList.remove('hide');
|
||||
} else {
|
||||
options.panel.classList.add('hide');
|
||||
}
|
||||
}
|
||||
|
||||
if (!task) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (task.State == 'Idle') {
|
||||
button.removeAttribute('disabled');
|
||||
} else {
|
||||
button.setAttribute('disabled', 'disabled');
|
||||
}
|
||||
|
||||
button.setAttribute('data-taskid', task.Id);
|
||||
var progress = (task.CurrentProgressPercentage || 0).toFixed(1);
|
||||
|
||||
if (options.progressElem) {
|
||||
options.progressElem.value = progress;
|
||||
|
||||
if (task.State == 'Running') {
|
||||
options.progressElem.classList.remove('hide');
|
||||
} else {
|
||||
options.progressElem.classList.add('hide');
|
||||
}
|
||||
}
|
||||
|
||||
if (options.lastResultElem) {
|
||||
var lastResult = task.LastExecutionResult ? task.LastExecutionResult.Status : '';
|
||||
|
||||
if (lastResult == 'Failed') {
|
||||
options.lastResultElem.html('<span style="color:#FF0000;">(' + globalize.translate('LabelFailed') + ')</span>');
|
||||
} else if (lastResult == 'Cancelled') {
|
||||
options.lastResultElem.html('<span style="color:#0026FF;">(' + globalize.translate('LabelCancelled') + ')</span>');
|
||||
} else if (lastResult == 'Aborted') {
|
||||
options.lastResultElem.html('<span style="color:#FF0000;">' + globalize.translate('LabelAbortedByServerShutdown') + '</span>');
|
||||
} else {
|
||||
options.lastResultElem.html(lastResult);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function onScheduledTaskMessageConfirmed(id) {
|
||||
connectionManager.getApiClient(serverId).startScheduledTask(id).then(pollTasks);
|
||||
}
|
||||
|
||||
function onButtonClick() {
|
||||
onScheduledTaskMessageConfirmed(this.getAttribute('data-taskid'));
|
||||
}
|
||||
|
||||
function onScheduledTasksUpdate(e, apiClient, info) {
|
||||
if (apiClient.serverId() === serverId) {
|
||||
updateTasks(info);
|
||||
}
|
||||
}
|
||||
|
||||
var pollInterval;
|
||||
var button = options.button;
|
||||
var serverId = ApiClient.serverId();
|
||||
|
||||
function onPollIntervalFired() {
|
||||
if (!connectionManager.getApiClient(serverId).isMessageChannelOpen()) {
|
||||
pollTasks();
|
||||
}
|
||||
}
|
||||
|
||||
function startInterval() {
|
||||
var apiClient = connectionManager.getApiClient(serverId);
|
||||
|
||||
if (pollInterval) {
|
||||
clearInterval(pollInterval);
|
||||
}
|
||||
apiClient.sendMessage('ScheduledTasksInfoStart', '1000,1000');
|
||||
pollInterval = setInterval(onPollIntervalFired, 5000);
|
||||
}
|
||||
|
||||
function stopInterval() {
|
||||
connectionManager.getApiClient(serverId).sendMessage('ScheduledTasksInfoStop');
|
||||
|
||||
if (pollInterval) {
|
||||
clearInterval(pollInterval);
|
||||
}
|
||||
}
|
||||
function updateTasks(tasks) {
|
||||
const task = tasks.filter(function (t) {
|
||||
return t.Key == options.taskKey;
|
||||
})[0];
|
||||
|
||||
if (options.panel) {
|
||||
options.panel.classList.add('hide');
|
||||
if (task) {
|
||||
options.panel.classList.remove('hide');
|
||||
} else {
|
||||
options.panel.classList.add('hide');
|
||||
}
|
||||
}
|
||||
|
||||
if (options.mode == 'off') {
|
||||
button.removeEventListener('click', onButtonClick);
|
||||
events.off(serverNotifications, 'ScheduledTasksInfo', onScheduledTasksUpdate);
|
||||
stopInterval();
|
||||
} else {
|
||||
button.addEventListener('click', onButtonClick);
|
||||
pollTasks();
|
||||
startInterval();
|
||||
events.on(serverNotifications, 'ScheduledTasksInfo', onScheduledTasksUpdate);
|
||||
if (!task) {
|
||||
return;
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
if (task.State == 'Idle') {
|
||||
button.removeAttribute('disabled');
|
||||
} else {
|
||||
button.setAttribute('disabled', 'disabled');
|
||||
}
|
||||
|
||||
button.setAttribute('data-taskid', task.Id);
|
||||
const progress = (task.CurrentProgressPercentage || 0).toFixed(1);
|
||||
|
||||
if (options.progressElem) {
|
||||
options.progressElem.value = progress;
|
||||
|
||||
if (task.State == 'Running') {
|
||||
options.progressElem.classList.remove('hide');
|
||||
} else {
|
||||
options.progressElem.classList.add('hide');
|
||||
}
|
||||
}
|
||||
|
||||
if (options.lastResultElem) {
|
||||
const lastResult = task.LastExecutionResult ? task.LastExecutionResult.Status : '';
|
||||
|
||||
if (lastResult == 'Failed') {
|
||||
options.lastResultElem.html('<span style="color:#FF0000;">(' + globalize.translate('LabelFailed') + ')</span>');
|
||||
} else if (lastResult == 'Cancelled') {
|
||||
options.lastResultElem.html('<span style="color:#0026FF;">(' + globalize.translate('LabelCancelled') + ')</span>');
|
||||
} else if (lastResult == 'Aborted') {
|
||||
options.lastResultElem.html('<span style="color:#FF0000;">' + globalize.translate('LabelAbortedByServerShutdown') + '</span>');
|
||||
} else {
|
||||
options.lastResultElem.html(lastResult);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function onScheduledTaskMessageConfirmed(id) {
|
||||
connectionManager.getApiClient(serverId).startScheduledTask(id).then(pollTasks);
|
||||
}
|
||||
|
||||
function onButtonClick() {
|
||||
onScheduledTaskMessageConfirmed(this.getAttribute('data-taskid'));
|
||||
}
|
||||
|
||||
function onScheduledTasksUpdate(e, apiClient, info) {
|
||||
if (apiClient.serverId() === serverId) {
|
||||
updateTasks(info);
|
||||
}
|
||||
}
|
||||
|
||||
let pollInterval;
|
||||
const button = options.button;
|
||||
const serverId = ApiClient.serverId();
|
||||
|
||||
function onPollIntervalFired() {
|
||||
if (!connectionManager.getApiClient(serverId).isMessageChannelOpen()) {
|
||||
pollTasks();
|
||||
}
|
||||
}
|
||||
|
||||
function startInterval() {
|
||||
const apiClient = connectionManager.getApiClient(serverId);
|
||||
|
||||
if (pollInterval) {
|
||||
clearInterval(pollInterval);
|
||||
}
|
||||
apiClient.sendMessage('ScheduledTasksInfoStart', '1000,1000');
|
||||
pollInterval = setInterval(onPollIntervalFired, 5000);
|
||||
}
|
||||
|
||||
function stopInterval() {
|
||||
connectionManager.getApiClient(serverId).sendMessage('ScheduledTasksInfoStop');
|
||||
|
||||
if (pollInterval) {
|
||||
clearInterval(pollInterval);
|
||||
}
|
||||
}
|
||||
|
||||
if (options.panel) {
|
||||
options.panel.classList.add('hide');
|
||||
}
|
||||
|
||||
if (options.mode == 'off') {
|
||||
button.removeEventListener('click', onButtonClick);
|
||||
events.off(serverNotifications, 'ScheduledTasksInfo', onScheduledTasksUpdate);
|
||||
stopInterval();
|
||||
} else {
|
||||
button.addEventListener('click', onButtonClick);
|
||||
pollTasks();
|
||||
startInterval();
|
||||
events.on(serverNotifications, 'ScheduledTasksInfo', onScheduledTasksUpdate);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,27 +0,0 @@
|
|||
define(['userSettings', 'skinManager', 'connectionManager', 'events'], function (userSettings, skinManager, connectionManager, events) {
|
||||
'use strict';
|
||||
|
||||
var currentViewType;
|
||||
pageClassOn('viewbeforeshow', 'page', function () {
|
||||
var classList = this.classList;
|
||||
var viewType = classList.contains('type-interior') || classList.contains('wizardPage') ? 'a' : 'b';
|
||||
|
||||
if (viewType !== currentViewType) {
|
||||
currentViewType = viewType;
|
||||
var theme;
|
||||
var context;
|
||||
|
||||
if ('a' === viewType) {
|
||||
theme = userSettings.dashboardTheme();
|
||||
context = 'serverdashboard';
|
||||
} else {
|
||||
theme = userSettings.theme();
|
||||
}
|
||||
|
||||
skinManager.setTheme(theme, context);
|
||||
}
|
||||
});
|
||||
events.on(connectionManager, 'localusersignedin', function (e, user) {
|
||||
currentViewType = null;
|
||||
});
|
||||
});
|
76
src/scripts/themeManager.js
Normal file
76
src/scripts/themeManager.js
Normal file
|
@ -0,0 +1,76 @@
|
|||
import * as webSettings from 'webSettings';
|
||||
|
||||
var themeStyleElement = document.querySelector('#cssTheme');
|
||||
var currentThemeId;
|
||||
|
||||
function unloadTheme() {
|
||||
var elem = themeStyleElement;
|
||||
if (elem) {
|
||||
elem.removeAttribute('href');
|
||||
currentThemeId = null;
|
||||
}
|
||||
}
|
||||
|
||||
function getThemes() {
|
||||
return webSettings.getThemes();
|
||||
}
|
||||
|
||||
function getThemeStylesheetInfo(id) {
|
||||
return getThemes().then(themes => {
|
||||
var theme = themes.find(theme => {
|
||||
return id ? theme.id === id : theme.default;
|
||||
});
|
||||
|
||||
return {
|
||||
stylesheetPath: 'themes/' + theme.id + '/theme.css',
|
||||
themeId: theme.id
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
function setTheme(id) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
if (currentThemeId && currentThemeId === id) {
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
getThemeStylesheetInfo(id).then(function (info) {
|
||||
if (currentThemeId && currentThemeId === info.themeId) {
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
var linkUrl = info.stylesheetPath;
|
||||
unloadTheme();
|
||||
|
||||
let link = themeStyleElement;
|
||||
|
||||
if (!link) {
|
||||
// Inject the theme css as a dom element in body so it will take
|
||||
// precedence over other stylesheets
|
||||
link = document.createElement('link');
|
||||
link.id = 'cssTheme';
|
||||
link.setAttribute('rel', 'stylesheet');
|
||||
link.setAttribute('type', 'text/css');
|
||||
document.body.appendChild(link);
|
||||
}
|
||||
|
||||
const onLoad = function (e) {
|
||||
e.target.removeEventListener('load', onLoad);
|
||||
resolve();
|
||||
};
|
||||
|
||||
link.addEventListener('load', onLoad);
|
||||
|
||||
link.setAttribute('href', linkUrl);
|
||||
themeStyleElement = link;
|
||||
currentThemeId = info.themeId;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export default {
|
||||
getThemes: getThemes,
|
||||
setTheme: setTheme
|
||||
};
|
|
@ -1,31 +1,29 @@
|
|||
define(['dom', 'events'], function (dom, events) {
|
||||
'use strict';
|
||||
import dom from 'dom';
|
||||
import events from 'events';
|
||||
|
||||
function getTouches(e) {
|
||||
|
||||
return e.changedTouches || e.targetTouches || e.touches;
|
||||
}
|
||||
|
||||
function TouchHelper(elem, options) {
|
||||
function getTouches(e) {
|
||||
return e.changedTouches || e.targetTouches || e.touches;
|
||||
}
|
||||
|
||||
class TouchHelper {
|
||||
constructor(elem, options) {
|
||||
options = options || {};
|
||||
var touchTarget;
|
||||
var touchStartX;
|
||||
var touchStartY;
|
||||
var lastDeltaX;
|
||||
var lastDeltaY;
|
||||
var thresholdYMet;
|
||||
var self = this;
|
||||
let touchTarget;
|
||||
let touchStartX;
|
||||
let touchStartY;
|
||||
let lastDeltaX;
|
||||
let lastDeltaY;
|
||||
let thresholdYMet;
|
||||
const self = this;
|
||||
|
||||
var swipeXThreshold = options.swipeXThreshold || 50;
|
||||
var swipeYThreshold = options.swipeYThreshold || 50;
|
||||
var swipeXMaxY = 30;
|
||||
const swipeXThreshold = options.swipeXThreshold || 50;
|
||||
const swipeYThreshold = options.swipeYThreshold || 50;
|
||||
const swipeXMaxY = 30;
|
||||
|
||||
var excludeTagNames = options.ignoreTagNames || [];
|
||||
const excludeTagNames = options.ignoreTagNames || [];
|
||||
|
||||
var touchStart = function (e) {
|
||||
|
||||
var touch = getTouches(e)[0];
|
||||
const touchStart = function (e) {
|
||||
const touch = getTouches(e)[0];
|
||||
touchTarget = null;
|
||||
touchStartX = 0;
|
||||
touchStartY = 0;
|
||||
|
@ -34,8 +32,7 @@ define(['dom', 'events'], function (dom, events) {
|
|||
thresholdYMet = false;
|
||||
|
||||
if (touch) {
|
||||
|
||||
var currentTouchTarget = touch.target;
|
||||
const currentTouchTarget = touch.target;
|
||||
|
||||
if (dom.parentWithTag(currentTouchTarget, excludeTagNames)) {
|
||||
return;
|
||||
|
@ -47,18 +44,17 @@ define(['dom', 'events'], function (dom, events) {
|
|||
}
|
||||
};
|
||||
|
||||
var touchEnd = function (e) {
|
||||
|
||||
var isTouchMove = e.type === 'touchmove';
|
||||
const touchEnd = function (e) {
|
||||
const isTouchMove = e.type === 'touchmove';
|
||||
|
||||
if (touchTarget) {
|
||||
var touch = getTouches(e)[0];
|
||||
const touch = getTouches(e)[0];
|
||||
|
||||
var deltaX;
|
||||
var deltaY;
|
||||
let deltaX;
|
||||
let deltaY;
|
||||
|
||||
var clientX;
|
||||
var clientY;
|
||||
let clientX;
|
||||
let clientY;
|
||||
|
||||
if (touch) {
|
||||
clientX = touch.clientX || 0;
|
||||
|
@ -70,8 +66,8 @@ define(['dom', 'events'], function (dom, events) {
|
|||
deltaY = 0;
|
||||
}
|
||||
|
||||
var currentDeltaX = lastDeltaX == null ? deltaX : (deltaX - lastDeltaX);
|
||||
var currentDeltaY = lastDeltaY == null ? deltaY : (deltaY - lastDeltaY);
|
||||
const currentDeltaX = lastDeltaX == null ? deltaX : (deltaX - lastDeltaX);
|
||||
const currentDeltaY = lastDeltaY == null ? deltaY : (deltaY - lastDeltaY);
|
||||
|
||||
lastDeltaX = deltaX;
|
||||
lastDeltaY = deltaY;
|
||||
|
@ -81,7 +77,6 @@ define(['dom', 'events'], function (dom, events) {
|
|||
} else if (deltaX < (0 - swipeXThreshold) && Math.abs(deltaY) < swipeXMaxY) {
|
||||
events.trigger(self, 'swipeleft', [touchTarget]);
|
||||
} else if ((deltaY < (0 - swipeYThreshold) || thresholdYMet) && Math.abs(deltaX) < swipeXMaxY) {
|
||||
|
||||
thresholdYMet = true;
|
||||
|
||||
events.trigger(self, 'swipeup', [touchTarget, {
|
||||
|
@ -138,14 +133,12 @@ define(['dom', 'events'], function (dom, events) {
|
|||
passive: true
|
||||
});
|
||||
}
|
||||
|
||||
TouchHelper.prototype.destroy = function () {
|
||||
|
||||
var elem = this.elem;
|
||||
destroy() {
|
||||
const elem = this.elem;
|
||||
|
||||
if (elem) {
|
||||
var touchStart = this.touchStart;
|
||||
var touchEnd = this.touchEnd;
|
||||
const touchStart = this.touchStart;
|
||||
const touchEnd = this.touchEnd;
|
||||
|
||||
dom.removeEventListener(elem, 'touchstart', touchStart, {
|
||||
passive: true
|
||||
|
@ -165,7 +158,7 @@ define(['dom', 'events'], function (dom, events) {
|
|||
this.touchEnd = null;
|
||||
|
||||
this.elem = null;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return TouchHelper;
|
||||
});
|
||||
export default TouchHelper;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue