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

2 lines
59 KiB
JavaScript
Raw Normal View History

2018-09-12 19:26:21 +02:00
function getWindowLocationSearch(win){"use strict";var search=(win||window).location.search;if(!search){var index=window.location.href.indexOf("?");-1!=index&&(search=window.location.href.substring(index))}return search||""}function getParameterByName(name,url){"use strict";name=name.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var regexS="[\\?&]"+name+"=([^&#]*)",regex=new RegExp(regexS,"i"),results=regex.exec(url||getWindowLocationSearch());return null==results?"":decodeURIComponent(results[1].replace(/\+/g," "))}function pageClassOn(eventName,className,fn){"use strict";document.addEventListener(eventName,function(e){var target=e.target;target.classList.contains(className)&&fn.call(target,e)})}function pageIdOn(eventName,id,fn){"use strict";document.addEventListener(eventName,function(e){var target=e.target;target.id===id&&fn.call(target,e)})}var Dashboard={isConnectMode:function(){if(AppInfo.isNativeApp)return!0;var url=window.location.href.toLowerCase();return-1!=url.indexOf("mediabrowser.tv")||-1!=url.indexOf("emby.media")},allowPluginPages:function(pluginId){var allowedPluginConfigs=["b0daa30f-2e09-4083-a6ce-459d9fecdd80","de228f12-e43e-4bd9-9fc0-2830819c3b92","899c12c7-5b40-4c4e-9afd-afd74a685eb1","14f5f69e-4c8d-491b-8917-8e90e8317530","02528C96-F727-44D7-BE87-9EEF040758C3","dc372f99-4e0e-4c6b-8c18-2b887ca4530c","830fc68f-b964-4d2f-b139-48e22cd143c","b9f0c474-e9a8-4292-ae41-eb3c1542f4cd","7cfbb821-e8fd-40ab-b64e-a7749386a6b2","4C2FDA1C-FD5E-433A-AD2B-718E0B73E9A9","cd5a19be-7676-48ef-b64f-a17c98f2b889","b2ff6a63-303a-4a84-b937-6e12f87e3eb9","0277E613-3EC0-4360-A3DE-F8AF0AABB5E9","9464BD84-D30D-4404-B2AD-DFF4E12D5FC5","9574ac10-bf23-49bc-949f-924f23cfa48f","66fd72a4-7e8e-4f22-8d1c-022ce4b9b0d5","4DCB591C-0FA2-4C5D-A7E5-DABE37164C8B","8e791e2a-058a-4b12-8493-8bf69d92d685","577f89eb-58a7-4013-be06-9a970ddb1377","6153FDF0-40CC-4457-8730-3B4A19512BAE","de228f12-e43e-4bd9-9fc0-2830819c3b92","6C3B6965-C257-47C2-AA02-64457AE21D91","2FE79C34-C9DC-4D94-9DF2-2F3F36764414","0417264b-5a93-4ad0-a1f0-b87569b7cf80","e711475e-efad-431b-8527-033ba9873a34","AB95885A-1D0E-445E-BDBF-80C1912C98C5","F015EA06-B413-47F1-BF15-F049A799658B","986a7283-205a-4436-862d-23135c067f8a","8abc6789-fde2-4705-8592-4028806fa343","2850d40d-9c66-4525-aa46-968e8ef04e97"].map(function(i){return i.toLowerCase()});return!(AppInfo.isNativeApp&&-1===allowedPluginConfigs.indexOf((pluginId||"").toLowerCase()))},getCurrentUser:function(){return window.ApiClient.getCurrentUser(!1)},serverAddress:function(){if(Dashboard.isConnectMode()){var apiClient=window.ApiClient;return apiClient?apiClient.serverAddress():null}var urlLower=window.location.href.toLowerCase(),index=urlLower.lastIndexOf("/web");if(-1!=index)return urlLower.substring(0,index);var loc=window.location,address=loc.protocol+"//"+loc.hostname;return loc.port&&(address+=":"+loc.port),address},getCurrentUserId:function(){var apiClient=window.ApiClient;return apiClient?apiClient.getCurrentUserId():null},onServerChanged:function(userId,accessToken,apiClient){apiClient=apiClient||window.ApiClient,window.ApiClient=apiClient},logout:function(logoutWithServer){function onLogoutDone(){var loginPage;Dashboard.isConnectMode()?(loginPage="connectlogin.html",window.ApiClient=null):loginPage="login.html",Dashboard.navigate(loginPage)}!1===logoutWithServer?onLogoutDone():ConnectionManager.logout().then(onLogoutDone)},getConfigurationPageUrl:function(name){return Dashboard.isConnectMode()?"configurationpageext?name="+encodeURIComponent(name):"configurationpage?name="+encodeURIComponent(name)},getConfigurationResourceUrl:function(name){return Dashboard.isConnectMode()?ApiClient.getUrl("web/ConfigurationPage",{name:name}):Dashboard.getConfigurationPageUrl(name)},navigate:function(url,preserveQueryString){if(!url)throw new Error("url cannot be null or empty");var queryString=getWindowLocationSearch();return preserveQueryString&&queryString&&(url+=queryString),new Promise(function(resolve,reject){require(["appRouter"],function(appRouter){return appRouter.show(url).then(resolve,reject)})})},processPluginConfigurationUpdateR
if(console.log("Loaded dependencies in onAppReady"),window.Emby={},isBackgroundSync)return void syncNow();window.Emby.Page=pageObjects,defineCoreRoutes(appHost),Emby.Page.start({click:!1,hashbang:!0});var postInitDependencies=[];!enableNativeGamepadKeyMapping()&&isGamepadSupported()&&postInitDependencies.push("bower_components/emby-webcomponents/input/gamepadtokey"),postInitDependencies.push("bower_components/emby-webcomponents/thememediaplayer"),postInitDependencies.push("scripts/autobackdrops"),"cordova"!==self.appMode&&"android"!==self.appMode||(browser.android?(postInitDependencies.push("cordova/mediasession"),postInitDependencies.push("cordova/chromecast"),postInitDependencies.push("cordova/appshortcuts")):browser.safari&&(postInitDependencies.push("cordova/mediasession"),postInitDependencies.push("cordova/volume"),postInitDependencies.push("cordova/statusbar"),postInitDependencies.push("cordova/backgroundfetch"))),browser.tv||browser.xboxOne||browser.ps4||postInitDependencies.push("bower_components/emby-webcomponents/nowplayingbar/nowplayingbar"),appHost.supports("remotecontrol")&&(postInitDependencies.push("playerSelectionMenu"),postInitDependencies.push("bower_components/emby-webcomponents/playback/remotecontrolautoplay")),appHost.supports("physicalvolumecontrol")&&!browser.touch||browser.edge||postInitDependencies.push("bower_components/emby-webcomponents/playback/volumeosd"),navigator.mediaSession&&postInitDependencies.push("mediaSession"),postInitDependencies.push("apiInput"),postInitDependencies.push("mouseManager"),browser.tv||browser.xboxOne||(postInitDependencies.push("bower_components/emby-webcomponents/playback/playbackorientation"),registerServiceWorker(),window.Notification&&postInitDependencies.push("bower_components/emby-webcomponents/notifications/notifications")),postInitDependencies.push("playerSelectionMenu"),appHost.supports("fullscreenchange")&&(browser.edgeUwp||-1!==navigator.userAgent.toLowerCase().indexOf("electron"))&&require(["fullscreen-doubleclick"]),require(postInitDependencies),appHost.supports("sync")&&initLocalSyncEvents(),Dashboard.isConnectMode()||window.ApiClient&&require(["css!"+ApiClient.getUrl("Branding/Css")])})}function registerServiceWorker(){if(navigator.serviceWorker&&"cordova"!==self.appMode&&"android"!==self.appMode)try{navigator.serviceWorker.register("serviceworker.js").then(function(){return navigator.serviceWorker.ready}).then(function(reg){if(reg&&reg.sync)return reg.sync.register("emby-sync").then(function(){window.SyncRegistered=Dashboard.isConnectMode()})})}catch(err){console.log("Error registering serviceWorker: "+err)}}function syncNow(){require(["localsync"],function(localSync){localSync.sync()})}function initLocalSyncEvents(){require(["serverNotifications","events"],function(serverNotifications,events){events.on(serverNotifications,"SyncJobItemReady",syncNow),events.on(serverNotifications,"SyncJobCancelled",syncNow),events.on(serverNotifications,"SyncJobItemCancelled",syncNow)})}function onWebComponentsReady(browser){var initialDependencies=[];window.Promise&&!browser.web0s||initialDependencies.push("bower_components/emby-webcomponents/native-promise-only/lib/npo.src"),initRequireWithBrowser(browser),"cordova"!==self.appMode&&"android"!==self.appMode||(AppInfo.isNativeApp=!0),require(initialDependencies,init)}var localApiClient;!function(){var urlArgs="v="+(window.dashboardVersion||(new Date).getDate()),bowerPath=getBowerPath(),apiClientBowerPath=bowerPath+"/emby-apiclient",embyWebComponentsBowerPath=bowerPath+"/emby-webcomponents",paths={velocity:bowerPath+"/velocity/velocity.min",vibrant:bowerPath+"/vibrant/dist/vibrant",staticBackdrops:embyWebComponentsBowerPath+"/staticbackdrops",ironCardList:"components/ironcardlist/ironcardlist",scrollThreshold:"components/scrollthreshold",playlisteditor:"components/playlisteditor/playlisteditor",medialibrarycreator:"components/medialibrarycreator/medialibrarycreator",medialibraryeditor:"components/medialibraryeditor/medialibraryeditor",imageoptionseditor:"components/imageoptionseditor/imageoptionseditor",howler:bowerP