Merge pull request #1600 from Camc314/migrate-to-ES6-39
Migration of itemDetails/index, browser and itemHelper to ES6 module
This commit is contained in:
commit
4aaab833a3
5 changed files with 742 additions and 705 deletions
|
@ -119,6 +119,7 @@
|
||||||
"src/components/imageUploader/imageUploader.js",
|
"src/components/imageUploader/imageUploader.js",
|
||||||
"src/components/indicators/indicators.js",
|
"src/components/indicators/indicators.js",
|
||||||
"src/components/itemContextMenu.js",
|
"src/components/itemContextMenu.js",
|
||||||
|
"src/components/itemHelper.js",
|
||||||
"src/components/itemidentifier/itemidentifier.js",
|
"src/components/itemidentifier/itemidentifier.js",
|
||||||
"src/components/itemMediaInfo/itemMediaInfo.js",
|
"src/components/itemMediaInfo/itemMediaInfo.js",
|
||||||
"src/components/lazyLoader/lazyLoaderIntersectionObserver.js",
|
"src/components/lazyLoader/lazyLoaderIntersectionObserver.js",
|
||||||
|
@ -199,6 +200,7 @@
|
||||||
"src/controllers/dashboard/users/userparentalcontrol.js",
|
"src/controllers/dashboard/users/userparentalcontrol.js",
|
||||||
"src/controllers/dashboard/users/userpasswordpage.js",
|
"src/controllers/dashboard/users/userpasswordpage.js",
|
||||||
"src/controllers/dashboard/users/userprofilespage.js",
|
"src/controllers/dashboard/users/userprofilespage.js",
|
||||||
|
"src/controllers/itemDetails/index.js",
|
||||||
"src/controllers/playback/queue/index.js",
|
"src/controllers/playback/queue/index.js",
|
||||||
"src/controllers/playback/video/index.js",
|
"src/controllers/playback/video/index.js",
|
||||||
"src/controllers/searchpage.js",
|
"src/controllers/searchpage.js",
|
||||||
|
@ -248,6 +250,7 @@
|
||||||
"src/plugins/youtubePlayer/plugin.js",
|
"src/plugins/youtubePlayer/plugin.js",
|
||||||
"src/scripts/alphanumericshortcuts.js",
|
"src/scripts/alphanumericshortcuts.js",
|
||||||
"src/scripts/autoBackdrops.js",
|
"src/scripts/autoBackdrops.js",
|
||||||
|
"src/scripts/browser.js",
|
||||||
"src/scripts/datetime.js",
|
"src/scripts/datetime.js",
|
||||||
"src/scripts/deleteHelper.js",
|
"src/scripts/deleteHelper.js",
|
||||||
"src/scripts/dfnshelper.js",
|
"src/scripts/dfnshelper.js",
|
||||||
|
|
|
@ -1,342 +1,350 @@
|
||||||
define(['apphost', 'globalize'], function (appHost, globalize) {
|
import appHost from 'apphost';
|
||||||
'use strict';
|
import globalize from 'globalize';
|
||||||
|
|
||||||
function getDisplayName(item, options = {}) {
|
export function getDisplayName(item, options = {}) {
|
||||||
if (!item) {
|
if (!item) {
|
||||||
throw new Error('null item passed into getDisplayName');
|
throw new Error('null item passed into getDisplayName');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item.Type === 'Timer') {
|
||||||
|
item = item.ProgramInfo || item;
|
||||||
|
}
|
||||||
|
|
||||||
|
let name = ((item.Type === 'Program' || item.Type === 'Recording') && (item.IsSeries || item.EpisodeTitle) ? item.EpisodeTitle : item.Name) || '';
|
||||||
|
|
||||||
|
if (item.Type === 'TvChannel') {
|
||||||
|
if (item.ChannelNumber) {
|
||||||
|
return item.ChannelNumber + ' ' + name;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.Type === 'Timer') {
|
|
||||||
item = item.ProgramInfo || item;
|
|
||||||
}
|
|
||||||
|
|
||||||
var name = ((item.Type === 'Program' || item.Type === 'Recording') && (item.IsSeries || item.EpisodeTitle) ? item.EpisodeTitle : item.Name) || '';
|
|
||||||
|
|
||||||
if (item.Type === 'TvChannel') {
|
|
||||||
if (item.ChannelNumber) {
|
|
||||||
return item.ChannelNumber + ' ' + name;
|
|
||||||
}
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
if (item.Type === 'Episode' && item.ParentIndexNumber === 0) {
|
|
||||||
name = globalize.translate('ValueSpecialEpisodeName', name);
|
|
||||||
} else if ((item.Type === 'Episode' || item.Type === 'Program') && item.IndexNumber != null && item.ParentIndexNumber != null && options.includeIndexNumber !== false) {
|
|
||||||
var displayIndexNumber = item.IndexNumber;
|
|
||||||
|
|
||||||
var number = displayIndexNumber;
|
|
||||||
var nameSeparator = ' - ';
|
|
||||||
|
|
||||||
if (options.includeParentInfo !== false) {
|
|
||||||
number = 'S' + item.ParentIndexNumber + ':E' + number;
|
|
||||||
} else {
|
|
||||||
nameSeparator = '. ';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (item.IndexNumberEnd) {
|
|
||||||
displayIndexNumber = item.IndexNumberEnd;
|
|
||||||
number += '-' + displayIndexNumber;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (number) {
|
|
||||||
name = name ? (number + nameSeparator + name) : number;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
if (item.Type === 'Episode' && item.ParentIndexNumber === 0) {
|
||||||
|
name = globalize.translate('ValueSpecialEpisodeName', name);
|
||||||
|
} else if ((item.Type === 'Episode' || item.Type === 'Program') && item.IndexNumber != null && item.ParentIndexNumber != null && options.includeIndexNumber !== false) {
|
||||||
|
let displayIndexNumber = item.IndexNumber;
|
||||||
|
|
||||||
function supportsAddingToCollection(item) {
|
let number = displayIndexNumber;
|
||||||
var invalidTypes = ['Genre', 'MusicGenre', 'Studio', 'UserView', 'CollectionFolder', 'Audio', 'Program', 'Timer', 'SeriesTimer'];
|
let nameSeparator = ' - ';
|
||||||
|
|
||||||
if (item.Type === 'Recording') {
|
if (options.includeParentInfo !== false) {
|
||||||
if (item.Status !== 'Completed') {
|
number = 'S' + item.ParentIndexNumber + ':E' + number;
|
||||||
return false;
|
} else {
|
||||||
}
|
nameSeparator = '. ';
|
||||||
}
|
}
|
||||||
|
|
||||||
return !item.CollectionType && invalidTypes.indexOf(item.Type) === -1 && item.MediaType !== 'Photo' && !isLocalItem(item);
|
if (item.IndexNumberEnd) {
|
||||||
|
displayIndexNumber = item.IndexNumberEnd;
|
||||||
|
number += '-' + displayIndexNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (number) {
|
||||||
|
name = name ? (number + nameSeparator + name) : number;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function supportsAddingToPlaylist(item) {
|
return name;
|
||||||
if (item.Type === 'Program') {
|
}
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (item.Type === 'TvChannel') {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (item.Type === 'Timer') {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (item.Type === 'SeriesTimer') {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (item.MediaType === 'Photo') {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (item.Type === 'Recording') {
|
export function supportsAddingToCollection(item) {
|
||||||
if (item.Status !== 'Completed') {
|
const invalidTypes = ['Genre', 'MusicGenre', 'Studio', 'UserView', 'CollectionFolder', 'Audio', 'Program', 'Timer', 'SeriesTimer'];
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isLocalItem(item)) {
|
if (item.Type === 'Recording') {
|
||||||
|
if (item.Status !== 'Completed') {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (item.CollectionType === 'livetv') {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return item.MediaType || item.IsFolder || item.Type === 'Genre' || item.Type === 'MusicGenre' || item.Type === 'MusicArtist';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function canEdit(user, item) {
|
return !item.CollectionType && invalidTypes.indexOf(item.Type) === -1 && item.MediaType !== 'Photo' && !isLocalItem(item);
|
||||||
var itemType = item.Type;
|
}
|
||||||
|
|
||||||
if (itemType === 'UserRootFolder' || itemType === 'UserView') {
|
export function supportsAddingToPlaylist(item) {
|
||||||
return false;
|
if (item.Type === 'Program') {
|
||||||
}
|
return false;
|
||||||
|
}
|
||||||
if (itemType === 'Program') {
|
if (item.Type === 'TvChannel') {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (item.Type === 'Timer') {
|
||||||
if (itemType === 'Timer') {
|
return false;
|
||||||
return false;
|
}
|
||||||
}
|
if (item.Type === 'SeriesTimer') {
|
||||||
|
return false;
|
||||||
if (itemType === 'SeriesTimer') {
|
}
|
||||||
return false;
|
if (item.MediaType === 'Photo') {
|
||||||
}
|
return false;
|
||||||
|
|
||||||
if (item.Type === 'Recording') {
|
|
||||||
if (item.Status !== 'Completed') {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isLocalItem(item)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return user.Policy.IsAdministrator;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function isLocalItem(item) {
|
if (item.Type === 'Recording') {
|
||||||
if (item && item.Id && item.Id.indexOf('local') === 0) {
|
if (item.Status !== 'Completed') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isLocalItem(item)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (item.CollectionType === 'livetv') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return item.MediaType || item.IsFolder || item.Type === 'Genre' || item.Type === 'MusicGenre' || item.Type === 'MusicArtist';
|
||||||
|
}
|
||||||
|
|
||||||
|
export function canEdit(user, item) {
|
||||||
|
const itemType = item.Type;
|
||||||
|
|
||||||
|
if (itemType === 'UserRootFolder' || itemType === 'UserView') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (itemType === 'Program') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (itemType === 'Timer') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (itemType === 'SeriesTimer') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item.Type === 'Recording') {
|
||||||
|
if (item.Status !== 'Completed') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isLocalItem(item)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return user.Policy.IsAdministrator;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isLocalItem(item) {
|
||||||
|
if (item && item.Id && item.Id.indexOf('local') === 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function canIdentify (user, item) {
|
||||||
|
const itemType = item.Type;
|
||||||
|
|
||||||
|
if (itemType === 'Movie' ||
|
||||||
|
itemType === 'Trailer' ||
|
||||||
|
itemType === 'Series' ||
|
||||||
|
itemType === 'BoxSet' ||
|
||||||
|
itemType === 'Person' ||
|
||||||
|
itemType === 'Book' ||
|
||||||
|
itemType === 'MusicAlbum' ||
|
||||||
|
itemType === 'MusicArtist' ||
|
||||||
|
itemType === 'MusicVideo') {
|
||||||
|
if (user.Policy.IsAdministrator) {
|
||||||
|
if (!isLocalItem(item)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function canEditImages (user, item) {
|
||||||
|
const itemType = item.Type;
|
||||||
|
|
||||||
|
if (item.MediaType === 'Photo') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (itemType === 'UserView') {
|
||||||
|
if (user.Policy.IsAdministrator) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
if (item.Type === 'Recording') {
|
||||||
getDisplayName: getDisplayName,
|
if (item.Status !== 'Completed') {
|
||||||
supportsAddingToCollection: supportsAddingToCollection,
|
|
||||||
supportsAddingToPlaylist: supportsAddingToPlaylist,
|
|
||||||
isLocalItem: isLocalItem,
|
|
||||||
|
|
||||||
canIdentify: function (user, item) {
|
|
||||||
var itemType = item.Type;
|
|
||||||
|
|
||||||
if (itemType === 'Movie' ||
|
|
||||||
itemType === 'Trailer' ||
|
|
||||||
itemType === 'Series' ||
|
|
||||||
itemType === 'BoxSet' ||
|
|
||||||
itemType === 'Person' ||
|
|
||||||
itemType === 'Book' ||
|
|
||||||
itemType === 'MusicAlbum' ||
|
|
||||||
itemType === 'MusicArtist' ||
|
|
||||||
itemType === 'MusicVideo') {
|
|
||||||
if (user.Policy.IsAdministrator) {
|
|
||||||
if (!isLocalItem(item)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
},
|
}
|
||||||
|
}
|
||||||
|
|
||||||
canEdit: canEdit,
|
return itemType !== 'Timer' && itemType !== 'SeriesTimer' && canEdit(user, item) && !isLocalItem(item);
|
||||||
|
}
|
||||||
|
|
||||||
canEditImages: function (user, item) {
|
export function canSync (user, item) {
|
||||||
var itemType = item.Type;
|
if (user && !user.Policy.EnableContentDownloading) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (item.MediaType === 'Photo') {
|
if (isLocalItem(item)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (itemType === 'UserView') {
|
return item.SupportsSync;
|
||||||
if (user.Policy.IsAdministrator) {
|
}
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (item.Type === 'Recording') {
|
|
||||||
if (item.Status !== 'Completed') {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return itemType !== 'Timer' && itemType !== 'SeriesTimer' && canEdit(user, item) && !isLocalItem(item);
|
|
||||||
},
|
|
||||||
|
|
||||||
canSync: function (user, item) {
|
|
||||||
if (user && !user.Policy.EnableContentDownloading) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isLocalItem(item)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return item.SupportsSync;
|
|
||||||
},
|
|
||||||
|
|
||||||
canShare: function (item, user) {
|
|
||||||
if (item.Type === 'Program') {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (item.Type === 'TvChannel') {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (item.Type === 'Timer') {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (item.Type === 'SeriesTimer') {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (item.Type === 'Recording') {
|
|
||||||
if (item.Status !== 'Completed') {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (isLocalItem(item)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return user.Policy.EnablePublicSharing && appHost.supports('sharing');
|
|
||||||
},
|
|
||||||
|
|
||||||
enableDateAddedDisplay: function (item) {
|
|
||||||
return !item.IsFolder && item.MediaType && item.Type !== 'Program' && item.Type !== 'TvChannel' && item.Type !== 'Trailer';
|
|
||||||
},
|
|
||||||
|
|
||||||
canMarkPlayed: function (item) {
|
|
||||||
if (item.Type === 'Program') {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (item.MediaType === 'Video') {
|
|
||||||
if (item.Type !== 'TvChannel') {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
} else if (item.MediaType === 'Audio') {
|
|
||||||
if (item.Type === 'AudioPodcast') {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (item.Type === 'AudioBook') {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (item.Type === 'Series' ||
|
|
||||||
item.Type === 'Season' ||
|
|
||||||
item.Type === 'BoxSet' ||
|
|
||||||
item.MediaType === 'Book' ||
|
|
||||||
item.MediaType === 'Recording') {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
export function canShare (item, user) {
|
||||||
|
if (item.Type === 'Program') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (item.Type === 'TvChannel') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (item.Type === 'Timer') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (item.Type === 'SeriesTimer') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (item.Type === 'Recording') {
|
||||||
|
if (item.Status !== 'Completed') {
|
||||||
return false;
|
return false;
|
||||||
},
|
}
|
||||||
|
}
|
||||||
|
if (isLocalItem(item)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return user.Policy.EnablePublicSharing && appHost.supports('sharing');
|
||||||
|
}
|
||||||
|
|
||||||
canRate: function (item) {
|
export function enableDateAddedDisplay (item) {
|
||||||
if (item.Type === 'Program'
|
return !item.IsFolder && item.MediaType && item.Type !== 'Program' && item.Type !== 'TvChannel' && item.Type !== 'Trailer';
|
||||||
|| item.Type === 'Timer'
|
}
|
||||||
|| item.Type === 'SeriesTimer'
|
|
||||||
|| item.Type === 'CollectionFolder'
|
|
||||||
|| item.Type === 'UserView'
|
|
||||||
|| item.Type === 'Channel'
|
|
||||||
|| !item.UserData) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
export function canMarkPlayed (item) {
|
||||||
},
|
if (item.Type === 'Program') {
|
||||||
|
return false;
|
||||||
canConvert: function (item, user) {
|
}
|
||||||
if (!user.Policy.EnableMediaConversion) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isLocalItem(item)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
var mediaType = item.MediaType;
|
|
||||||
if (mediaType === 'Book' || mediaType === 'Photo' || mediaType === 'Audio') {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
var collectionType = item.CollectionType;
|
|
||||||
if (collectionType === 'livetv') {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
var type = item.Type;
|
|
||||||
if (type === 'Channel' || type === 'Person' || type === 'Year' || type === 'Program' || type === 'Timer' || type === 'SeriesTimer') {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (item.LocationType === 'Virtual' && !item.IsFolder) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (item.IsPlaceHolder) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
},
|
|
||||||
|
|
||||||
canRefreshMetadata: function (item, user) {
|
|
||||||
if (user.Policy.IsAdministrator) {
|
|
||||||
var collectionType = item.CollectionType;
|
|
||||||
if (collectionType === 'livetv') {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (item.Type !== 'Timer' && item.Type !== 'SeriesTimer' && item.Type !== 'Program' && item.Type !== 'TvChannel' && !(item.Type === 'Recording' && item.Status !== 'Completed')) {
|
|
||||||
if (!isLocalItem(item)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
},
|
|
||||||
|
|
||||||
supportsMediaSourceSelection: function (item) {
|
|
||||||
if (item.MediaType !== 'Video') {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (item.Type === 'TvChannel') {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!item.MediaSources || (item.MediaSources.length === 1 && item.MediaSources[0].Type === 'Placeholder')) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (item.EnableMediaSourceDisplay === false) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (item.EnableMediaSourceDisplay == null && item.SourceType && item.SourceType !== 'Library') {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (item.MediaType === 'Video') {
|
||||||
|
if (item.Type !== 'TvChannel') {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
} else if (item.MediaType === 'Audio') {
|
||||||
});
|
if (item.Type === 'AudioPodcast') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (item.Type === 'AudioBook') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item.Type === 'Series' ||
|
||||||
|
item.Type === 'Season' ||
|
||||||
|
item.Type === 'BoxSet' ||
|
||||||
|
item.MediaType === 'Book' ||
|
||||||
|
item.MediaType === 'Recording') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function canRate (item) {
|
||||||
|
if (item.Type === 'Program'
|
||||||
|
|| item.Type === 'Timer'
|
||||||
|
|| item.Type === 'SeriesTimer'
|
||||||
|
|| item.Type === 'CollectionFolder'
|
||||||
|
|| item.Type === 'UserView'
|
||||||
|
|| item.Type === 'Channel'
|
||||||
|
|| !item.UserData) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function canConvert (item, user) {
|
||||||
|
if (!user.Policy.EnableMediaConversion) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isLocalItem(item)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const mediaType = item.MediaType;
|
||||||
|
if (mediaType === 'Book' || mediaType === 'Photo' || mediaType === 'Audio') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const collectionType = item.CollectionType;
|
||||||
|
if (collectionType === 'livetv') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const type = item.Type;
|
||||||
|
if (type === 'Channel' || type === 'Person' || type === 'Year' || type === 'Program' || type === 'Timer' || type === 'SeriesTimer') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item.LocationType === 'Virtual' && !item.IsFolder) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item.IsPlaceHolder) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function canRefreshMetadata (item, user) {
|
||||||
|
if (user.Policy.IsAdministrator) {
|
||||||
|
const collectionType = item.CollectionType;
|
||||||
|
if (collectionType === 'livetv') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item.Type !== 'Timer' && item.Type !== 'SeriesTimer' && item.Type !== 'Program' && item.Type !== 'TvChannel' && !(item.Type === 'Recording' && item.Status !== 'Completed')) {
|
||||||
|
if (!isLocalItem(item)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function supportsMediaSourceSelection (item) {
|
||||||
|
if (item.MediaType !== 'Video') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (item.Type === 'TvChannel') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!item.MediaSources || (item.MediaSources.length === 1 && item.MediaSources[0].Type === 'Placeholder')) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (item.EnableMediaSourceDisplay === false) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (item.EnableMediaSourceDisplay == null && item.SourceType && item.SourceType !== 'Library') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default {
|
||||||
|
getDisplayName: getDisplayName,
|
||||||
|
supportsAddingToCollection: supportsAddingToCollection,
|
||||||
|
supportsAddingToPlaylist: supportsAddingToPlaylist,
|
||||||
|
isLocalItem: isLocalItem,
|
||||||
|
canIdentify: canIdentify,
|
||||||
|
canEdit: canEdit,
|
||||||
|
canEditImages: canEditImages,
|
||||||
|
canSync: canSync,
|
||||||
|
canShare: canShare,
|
||||||
|
enableDateAddedDisplay: enableDateAddedDisplay,
|
||||||
|
canMarkPlayed: canMarkPlayed,
|
||||||
|
canRate: canRate,
|
||||||
|
canConvert: canConvert,
|
||||||
|
canRefreshMetadata: canRefreshMetadata,
|
||||||
|
supportsMediaSourceSelection: supportsMediaSourceSelection
|
||||||
|
};
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -222,7 +222,7 @@ export class BookPlayer {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
import('epubjs').then(({default: epubjs}) => {
|
import('epubjs').then(({default: epubjs}) => {
|
||||||
let downloadHref = apiClient.getItemDownloadUrl(item.Id);
|
let downloadHref = apiClient.getItemDownloadUrl(item.Id);
|
||||||
let book = epubjs.default(downloadHref, {openAs: 'epub'});
|
let book = epubjs(downloadHref, {openAs: 'epub'});
|
||||||
let rendition = book.renderTo(elem, {width: '100%', height: '97%'});
|
let rendition = book.renderTo(elem, {width: '100%', height: '97%'});
|
||||||
|
|
||||||
this._currentSrc = downloadHref;
|
this._currentSrc = downloadHref;
|
||||||
|
|
|
@ -1,260 +1,256 @@
|
||||||
define([], function () {
|
function isTv() {
|
||||||
'use strict';
|
// This is going to be really difficult to get right
|
||||||
|
const userAgent = navigator.userAgent.toLowerCase();
|
||||||
|
|
||||||
function isTv() {
|
if (userAgent.indexOf('tv') !== -1) {
|
||||||
// This is going to be really difficult to get right
|
return true;
|
||||||
var userAgent = navigator.userAgent.toLowerCase();
|
|
||||||
|
|
||||||
if (userAgent.indexOf('tv') !== -1) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (userAgent.indexOf('samsungbrowser') !== -1) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (userAgent.indexOf('viera') !== -1) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (userAgent.indexOf('web0s') !== -1) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function isMobile(userAgent) {
|
if (userAgent.indexOf('samsungbrowser') !== -1) {
|
||||||
var terms = [
|
return true;
|
||||||
'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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function hasKeyboard(browser) {
|
if (userAgent.indexOf('viera') !== -1) {
|
||||||
if (browser.touch) {
|
return true;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function iOSversion() {
|
if (userAgent.indexOf('web0s') !== -1) {
|
||||||
// MacIntel: Apple iPad Pro 11 iOS 13.1
|
return true;
|
||||||
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 false;
|
||||||
return [parseInt(v[1], 10), parseInt(v[2], 10), parseInt(v[3] || 0, 10)];
|
}
|
||||||
|
|
||||||
|
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;
|
return false;
|
||||||
var _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 {
|
|
||||||
if (_supportsCssAnimation === true || _supportsCssAnimation === false) {
|
|
||||||
return _supportsCssAnimation;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var animation = false;
|
function hasKeyboard(browser) {
|
||||||
var domPrefixes = ['Webkit', 'O', 'Moz'];
|
if (browser.touch) {
|
||||||
var elm = document.createElement('div');
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (elm.style.animationName !== undefined) {
|
if (browser.xboxOne) {
|
||||||
animation = true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (animation === false && allowPrefix) {
|
if (browser.ps4) {
|
||||||
for (var i = 0; i < domPrefixes.length; i++) {
|
return true;
|
||||||
if (elm.style[domPrefixes[i] + 'AnimationName'] !== undefined) {
|
}
|
||||||
animation = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (allowPrefix) {
|
if (browser.edgeUwp) {
|
||||||
_supportsCssAnimationWithPrefix = animation;
|
// 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
return _supportsCssAnimationWithPrefix;
|
||||||
} else {
|
}
|
||||||
_supportsCssAnimation = animation;
|
} else {
|
||||||
|
if (_supportsCssAnimation === true || _supportsCssAnimation === false) {
|
||||||
return _supportsCssAnimation;
|
return _supportsCssAnimation;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var uaMatch = function (ua) {
|
let animation = false;
|
||||||
ua = ua.toLowerCase();
|
const domPrefixes = ['Webkit', 'O', 'Moz'];
|
||||||
|
const elm = document.createElement('div');
|
||||||
|
|
||||||
var match = /(edg)[ \/]([\w.]+)/.exec(ua) ||
|
if (elm.style.animationName !== undefined) {
|
||||||
/(edga)[ \/]([\w.]+)/.exec(ua) ||
|
animation = true;
|
||||||
/(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) ||
|
|
||||||
[];
|
|
||||||
|
|
||||||
var versionMatch = /(version)[ \/]([\w.]+)/.exec(ua);
|
if (animation === false && allowPrefix) {
|
||||||
|
for (let i = 0; i < domPrefixes.length; i++) {
|
||||||
var platform_match = /(ipad)/.exec(ua) ||
|
if (elm.style[domPrefixes[i] + 'AnimationName'] !== undefined) {
|
||||||
/(iphone)/.exec(ua) ||
|
animation = true;
|
||||||
/(windows)/.exec(ua) ||
|
break;
|
||||||
/(android)/.exec(ua) ||
|
}
|
||||||
[];
|
|
||||||
|
|
||||||
var browser = match[1] || '';
|
|
||||||
|
|
||||||
if (browser === 'edge') {
|
|
||||||
platform_match = [''];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
if (allowPrefix) {
|
||||||
browser[matched.platform] = true;
|
_supportsCssAnimationWithPrefix = animation;
|
||||||
}
|
return _supportsCssAnimationWithPrefix;
|
||||||
|
|
||||||
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 || 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;
|
|
||||||
} else {
|
} else {
|
||||||
var v = (navigator.appVersion).match(/Tizen (\d+).(\d+)/);
|
_supportsCssAnimation = animation;
|
||||||
browser.tizenVersion = parseInt(v[1]);
|
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) {
|
if (browser === 'opr') {
|
||||||
browser.edge = true;
|
browser = 'opera';
|
||||||
}
|
}
|
||||||
|
|
||||||
browser.tv = isTv();
|
let version;
|
||||||
browser.operaTv = browser.tv && userAgent.toLowerCase().indexOf('opr/') !== -1;
|
if (versionMatch && versionMatch.length > 2) {
|
||||||
|
version = versionMatch[2];
|
||||||
if (browser.mobile || browser.tv) {
|
|
||||||
browser.slow = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof document !== 'undefined') {
|
version = version || match[2] || '0';
|
||||||
/* eslint-disable-next-line compat/compat */
|
|
||||||
if (('ontouchstart' in window) || (navigator.maxTouchPoints > 0)) {
|
let versionMajor = parseInt(version.split('.')[0]);
|
||||||
browser.touch = true;
|
|
||||||
}
|
if (isNaN(versionMajor)) {
|
||||||
|
versionMajor = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
browser.keyboard = hasKeyboard(browser);
|
return {
|
||||||
browser.supportsCssAnimation = supportsCssAnimation;
|
browser: browser,
|
||||||
|
version: version,
|
||||||
|
platform: platform_match[0] || '',
|
||||||
|
versionMajor: versionMajor
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
browser.osx = userAgent.toLowerCase().indexOf('os x') !== -1;
|
const userAgent = navigator.userAgent;
|
||||||
browser.iOS = browser.ipad || browser.iphone || browser.ipod;
|
|
||||||
|
|
||||||
if (browser.iOS) {
|
const matched = uaMatch(userAgent);
|
||||||
browser.iOSVersion = iOSversion();
|
const browser = {};
|
||||||
|
|
||||||
if (browser.iOSVersion && browser.iOSVersion.length >= 2) {
|
if (matched.browser) {
|
||||||
browser.iOSVersion = browser.iOSVersion[0] + (browser.iOSVersion[1] / 10);
|
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 || 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;
|
||||||
|
} 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;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return browser;
|
browser.keyboard = hasKeyboard(browser);
|
||||||
});
|
browser.supportsCssAnimation = supportsCssAnimation;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue