mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
trim core scripts
This commit is contained in:
parent
d7fb3af903
commit
6acc4bf69d
13 changed files with 267 additions and 454 deletions
|
@ -1340,18 +1340,15 @@
|
|||
$('.hasrefreshtime').removeClass('hasrefreshtime').removeAttr('data-lastrefresh');
|
||||
}
|
||||
|
||||
Dashboard.ready(function () {
|
||||
if (window.ApiClient) {
|
||||
initializeApiClient(window.ApiClient);
|
||||
}
|
||||
|
||||
if (window.ApiClient) {
|
||||
initializeApiClient(window.ApiClient);
|
||||
}
|
||||
|
||||
$(ConnectionManager).on('apiclientcreated', function (e, apiClient) {
|
||||
initializeApiClient(apiClient);
|
||||
});
|
||||
|
||||
Events.on(ConnectionManager, 'localusersignedin', clearRefreshTimes);
|
||||
Events.on(ConnectionManager, 'localusersignedout', clearRefreshTimes);
|
||||
$(ConnectionManager).on('apiclientcreated', function (e, apiClient) {
|
||||
initializeApiClient(apiClient);
|
||||
});
|
||||
|
||||
Events.on(ConnectionManager, 'localusersignedin', clearRefreshTimes);
|
||||
Events.on(ConnectionManager, 'localusersignedout', clearRefreshTimes);
|
||||
|
||||
})(jQuery, document, window);
|
|
@ -133,13 +133,7 @@
|
|||
var mainDrawerButton = document.querySelector('.mainDrawerButton');
|
||||
|
||||
if (mainDrawerButton) {
|
||||
if (AppInfo.isTouchPreferred || $.browser.mobile) {
|
||||
|
||||
mainDrawerButton.addEventListener('click', openMainDrawer);
|
||||
|
||||
} else {
|
||||
$(mainDrawerButton).createHoverTouch().on('hovertouch', openMainDrawer);
|
||||
}
|
||||
mainDrawerButton.addEventListener('click', openMainDrawer);
|
||||
}
|
||||
|
||||
var headerBackButton = document.querySelector('.headerBackButton');
|
||||
|
@ -312,7 +306,6 @@
|
|||
var userHeader = drawer.querySelector('.userheader');
|
||||
|
||||
userHeader.innerHTML = html;
|
||||
|
||||
ImageLoader.fillImages(userHeader.getElementsByClassName('lazy'));
|
||||
}
|
||||
|
||||
|
@ -341,10 +334,6 @@
|
|||
drawer.querySelector('.dashboardDrawerContent').innerHTML = html;
|
||||
}
|
||||
|
||||
function replaceAll(string, find, replace) {
|
||||
return string.replace(new RegExp(escapeRegExp(find), 'g'), replace);
|
||||
}
|
||||
|
||||
function refreshBottomUserInfoInDrawer(user, drawer) {
|
||||
|
||||
var html = '';
|
||||
|
@ -582,7 +571,7 @@
|
|||
} else {
|
||||
Dashboard.navigate(link.href);
|
||||
}
|
||||
}, 400);
|
||||
}, 350);
|
||||
}, 50);
|
||||
}
|
||||
|
||||
|
@ -599,7 +588,7 @@
|
|||
|
||||
setTimeout(function () {
|
||||
Dashboard.logout();
|
||||
}, 400);
|
||||
}, 350);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -807,7 +796,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
pageClassOn('pagebeforeshow', 'page', function () {
|
||||
pageClassOn('pageinit', 'page', function () {
|
||||
|
||||
var page = this;
|
||||
|
||||
|
@ -815,7 +804,7 @@
|
|||
requiresDashboardDrawerRefresh = true;
|
||||
}
|
||||
|
||||
onPageBeforeShowDocumentReady(page);
|
||||
onPageBeforeShow(page);
|
||||
|
||||
});
|
||||
|
||||
|
@ -823,20 +812,15 @@
|
|||
|
||||
var page = this;
|
||||
|
||||
onPageShowDocumentReady(page);
|
||||
if (!NavHelper.isBack()) {
|
||||
// Scroll back up so in case vertical scroll was messed with
|
||||
window.scrollTo(0, 0);
|
||||
}
|
||||
updateTabLinks(page);
|
||||
|
||||
});
|
||||
|
||||
//pageClassOn('pagebeforehide', 'page', function () {
|
||||
|
||||
// var headroomEnabled = document.querySelectorAll('.headroomEnabled');
|
||||
// for (var i = 0, length = headroomEnabled.length; i < length; i++) {
|
||||
// headroomEnabled[i].classList.add('headroomDisabled');
|
||||
// }
|
||||
|
||||
//});
|
||||
|
||||
function onPageBeforeShowDocumentReady(page) {
|
||||
function onPageBeforeShow(page) {
|
||||
|
||||
buildViewMenuBar(page);
|
||||
|
||||
|
@ -934,15 +918,6 @@
|
|||
}
|
||||
}
|
||||
|
||||
function onPageShowDocumentReady(page) {
|
||||
|
||||
if (!NavHelper.isBack()) {
|
||||
// Scroll back up so in case vertical scroll was messed with
|
||||
window.scrollTo(0, 0);
|
||||
}
|
||||
updateTabLinks(page);
|
||||
}
|
||||
|
||||
function initHeadRoom(elem) {
|
||||
|
||||
if (!AppInfo.enableHeadRoom) {
|
||||
|
@ -1006,59 +981,6 @@
|
|||
|
||||
})(window, document, jQuery, window.devicePixelRatio);
|
||||
|
||||
$.fn.createHoverTouch = function () {
|
||||
|
||||
var preventHover = false;
|
||||
var timerId;
|
||||
|
||||
function startTimer(elem) {
|
||||
|
||||
stopTimer();
|
||||
|
||||
timerId = setTimeout(function () {
|
||||
|
||||
Events.trigger(elem, 'hovertouch');
|
||||
}, 300);
|
||||
}
|
||||
|
||||
function stopTimer(elem) {
|
||||
|
||||
if (timerId) {
|
||||
clearTimeout(timerId);
|
||||
timerId = null;
|
||||
}
|
||||
}
|
||||
|
||||
return $(this).on('mouseenter', function () {
|
||||
|
||||
if (preventHover === true) {
|
||||
preventHover = false;
|
||||
return;
|
||||
}
|
||||
|
||||
startTimer(this);
|
||||
|
||||
}).on('mouseleave', function () {
|
||||
|
||||
stopTimer(this);
|
||||
|
||||
}).on('touchstart', function () {
|
||||
|
||||
preventHover = true;
|
||||
|
||||
}).on('click', function () {
|
||||
|
||||
preventHover = true;
|
||||
|
||||
if (preventHover) {
|
||||
Events.trigger(this, 'hovertouch');
|
||||
stopTimer(this);
|
||||
preventHover = false;
|
||||
}
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
(function () {
|
||||
|
||||
var isCurrentNavBack = false;
|
||||
|
|
|
@ -34,6 +34,10 @@
|
|||
|
||||
self.resetEnhancements = function () {
|
||||
|
||||
if (!initComplete) {
|
||||
return;
|
||||
}
|
||||
|
||||
fadeOut(document.querySelector('#mediaPlayer'));
|
||||
$('#videoPlayer').removeClass('fullscreenVideo').removeClass('idlePlayer');
|
||||
$('.hiddenOnIdle').removeClass("inactive");
|
||||
|
@ -676,6 +680,9 @@
|
|||
|
||||
Dashboard.importCss('css/mediaplayer-video.css');
|
||||
|
||||
// TODO: remove dependency on this file
|
||||
Dashboard.importCss('css/nowplayingbar.css');
|
||||
|
||||
var html = '<div id="mediaPlayer" style="display: none;">';
|
||||
|
||||
html += '<div class="videoBackdrop">';
|
||||
|
@ -749,8 +756,15 @@
|
|||
document.body.appendChild(div);
|
||||
}
|
||||
|
||||
Dashboard.ready(function () {
|
||||
var initComplete;
|
||||
|
||||
function initVideoElements() {
|
||||
|
||||
if (initComplete) {
|
||||
return;
|
||||
}
|
||||
|
||||
initComplete = true;
|
||||
ensureVideoPlayerElements();
|
||||
|
||||
var parent = $("#mediaPlayer");
|
||||
|
@ -783,7 +797,7 @@
|
|||
updateVolumeButtons(vol);
|
||||
self.setVolume(vol);
|
||||
})[0];
|
||||
});
|
||||
}
|
||||
|
||||
var idleHandlerTimeout;
|
||||
function idleHandler() {
|
||||
|
@ -924,13 +938,17 @@
|
|||
// Replace audio version
|
||||
self.cleanup = function (mediaRenderer) {
|
||||
|
||||
currentTimeElement.html('--:--');
|
||||
if (currentTimeElement) {
|
||||
currentTimeElement.html('--:--');
|
||||
}
|
||||
|
||||
unbindEventsForPlayback(mediaRenderer);
|
||||
};
|
||||
|
||||
self.playVideo = function (item, mediaSource, startPosition, callback) {
|
||||
|
||||
initVideoElements();
|
||||
|
||||
requirejs(['videorenderer'], function () {
|
||||
|
||||
self.createStreamInfo('Video', item, mediaSource, startPosition).done(function (streamInfo) {
|
||||
|
@ -1127,6 +1145,11 @@
|
|||
};
|
||||
|
||||
self.updatePlaylistUi = function () {
|
||||
|
||||
if (!initComplete) {
|
||||
return;
|
||||
}
|
||||
|
||||
var index = self.currentPlaylistIndex(null);
|
||||
var length = self.playlist.length;
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
var targets = [{
|
||||
name: Globalize.translate('MyDevice'),
|
||||
id: ConnectionManager.deviceId(),
|
||||
id: AppInfo.deviceId,
|
||||
playerName: self.name,
|
||||
playableMediaTypes: ['Audio', 'Video'],
|
||||
isLocalPlayer: true,
|
||||
|
@ -1049,7 +1049,7 @@
|
|||
return deferred.promise();
|
||||
};
|
||||
|
||||
self.lastBitrateDetect = 0;
|
||||
self.lastBitrateDetections = {};
|
||||
|
||||
self.playInternal = function (item, startPosition, callback) {
|
||||
|
||||
|
@ -1071,14 +1071,16 @@
|
|||
return;
|
||||
}
|
||||
|
||||
if (item.MediaType == 'Video' && AppSettings.enableAutomaticBitrateDetection() && (new Date().getTime() - self.lastBitrateDetect) > 300000) {
|
||||
var bitrateDetectionKey = ApiClient.serverAddress();
|
||||
|
||||
if (item.MediaType == 'Video' && AppSettings.enableAutomaticBitrateDetection() && (new Date().getTime() - (self.lastBitrateDetections[bitrateDetectionKey] || 0)) > 300000) {
|
||||
|
||||
Dashboard.showModalLoadingMsg();
|
||||
|
||||
ApiClient.detectBitrate().done(function (bitrate) {
|
||||
|
||||
Logger.log('Max bitrate auto detected to ' + bitrate);
|
||||
self.lastBitrateDetect = new Date().getTime();
|
||||
self.lastBitrateDetections[bitrateDetectionKey] = new Date().getTime();
|
||||
AppSettings.maxStreamingBitrate(bitrate);
|
||||
|
||||
playOnDeviceProfileCreated(self.getDeviceProfile(), item, startPosition, callback);
|
||||
|
@ -1997,17 +1999,8 @@
|
|||
|
||||
window.MediaPlayer = new mediaPlayer();
|
||||
|
||||
function onConnectionChange() {
|
||||
window.MediaPlayer.lastBitrateDetect = 0;
|
||||
}
|
||||
|
||||
Dashboard.ready(function () {
|
||||
window.MediaController.registerPlayer(window.MediaPlayer);
|
||||
window.MediaController.setActivePlayer(window.MediaPlayer, window.MediaPlayer.getTargets()[0]);
|
||||
|
||||
Events.on(ConnectionManager, 'localusersignedin', onConnectionChange);
|
||||
Events.on(ConnectionManager, 'localusersignedout', onConnectionChange);
|
||||
});
|
||||
window.MediaController.registerPlayer(window.MediaPlayer);
|
||||
window.MediaController.setActivePlayer(window.MediaPlayer, window.MediaPlayer.getTargets()[0]);
|
||||
|
||||
|
||||
})(document, setTimeout, clearTimeout, screen, $, setInterval, window);
|
|
@ -184,29 +184,24 @@
|
|||
});
|
||||
});
|
||||
|
||||
Dashboard.ready(function () {
|
||||
if (window.ApiClient) {
|
||||
initializeApiClient(window.ApiClient);
|
||||
}
|
||||
|
||||
if (window.ApiClient) {
|
||||
initializeApiClient(window.ApiClient);
|
||||
}
|
||||
$(ConnectionManager).on('apiclientcreated', function (e, apiClient) {
|
||||
initializeApiClient(apiClient);
|
||||
});
|
||||
|
||||
$(ConnectionManager).on('apiclientcreated', function (e, apiClient) {
|
||||
initializeApiClient(apiClient);
|
||||
});
|
||||
Events.on(ConnectionManager, 'localusersignedin', function () {
|
||||
needsRefresh = true;
|
||||
});
|
||||
|
||||
Events.on(ConnectionManager, 'localusersignedin', function () {
|
||||
needsRefresh = true;
|
||||
});
|
||||
|
||||
Events.on(ConnectionManager, 'localusersignedout', function () {
|
||||
needsRefresh = true;
|
||||
});
|
||||
Events.on(ConnectionManager, 'localusersignedout', function () {
|
||||
needsRefresh = true;
|
||||
});
|
||||
|
||||
pageClassOn('pageshow', "type-interior", function () {
|
||||
|
||||
var page = $(this);
|
||||
|
||||
if (needsRefresh) {
|
||||
Notifications.updateNotificationCount();
|
||||
}
|
||||
|
|
|
@ -201,7 +201,9 @@
|
|||
return elem;
|
||||
}
|
||||
|
||||
elem = $(getNowPlayingBarHtml()).insertBefore('#footerNotifications')[0];
|
||||
Dashboard.importCss('css/nowplayingbar.css');
|
||||
|
||||
elem = $(getNowPlayingBarHtml()).appendTo(document.body)[0];
|
||||
|
||||
if (($.browser.safari || !AppInfo.isNativeApp) && $.browser.mobile) {
|
||||
// Not handled well here. The wrong elements receive events, bar doesn't update quickly enough, etc.
|
||||
|
@ -563,14 +565,11 @@
|
|||
.on('positionchange', onStateChanged);
|
||||
}
|
||||
|
||||
Dashboard.ready(function () {
|
||||
|
||||
Events.on(MediaController, 'playerchange', function () {
|
||||
|
||||
bindToPlayer(MediaController.getCurrentPlayer());
|
||||
});
|
||||
Events.on(MediaController, 'playerchange', function () {
|
||||
|
||||
bindToPlayer(MediaController.getCurrentPlayer());
|
||||
});
|
||||
|
||||
bindToPlayer(MediaController.getCurrentPlayer());
|
||||
|
||||
})(window, document, jQuery, setTimeout, clearTimeout);
|
|
@ -387,15 +387,12 @@
|
|||
$(apiClient).on("websocketmessage", onWebSocketMessageReceived).on("websocketopen", onWebSocketConnectionChange);
|
||||
}
|
||||
|
||||
Dashboard.ready(function () {
|
||||
if (window.ApiClient) {
|
||||
initializeApiClient(window.ApiClient);
|
||||
}
|
||||
|
||||
if (window.ApiClient) {
|
||||
initializeApiClient(window.ApiClient);
|
||||
}
|
||||
|
||||
$(ConnectionManager).on('apiclientcreated', function (e, apiClient) {
|
||||
initializeApiClient(apiClient);
|
||||
});
|
||||
$(ConnectionManager).on('apiclientcreated', function (e, apiClient) {
|
||||
initializeApiClient(apiClient);
|
||||
});
|
||||
|
||||
})(window, document, jQuery);
|
|
@ -435,6 +435,17 @@ var Dashboard = {
|
|||
|
||||
options.id = options.id || "notification" + new Date().getTime() + parseInt(Math.random());
|
||||
|
||||
if (!$(".footer").length) {
|
||||
|
||||
var footerHtml = '<div id="footer" class="footer" data-theme="b" class="ui-bar-b">';
|
||||
|
||||
footerHtml += '<div id="footerNotifications"></div>';
|
||||
footerHtml += '</div>';
|
||||
|
||||
$(document.body).append(footerHtml);
|
||||
|
||||
}
|
||||
|
||||
var footer = $(".footer").css("top", "initial").show();
|
||||
|
||||
var parentElem = $('#footerNotifications', footer);
|
||||
|
@ -1688,12 +1699,7 @@ var Dashboard = {
|
|||
|
||||
ready: function (fn) {
|
||||
|
||||
if (Dashboard.initPromiseDone) {
|
||||
fn();
|
||||
return;
|
||||
}
|
||||
|
||||
Dashboard.initPromise.done(fn);
|
||||
Dashboard.initPromise.then(fn);
|
||||
},
|
||||
|
||||
loadExternalPlayer: function () {
|
||||
|
@ -1884,36 +1890,36 @@ var AppInfo = {};
|
|||
initializeApiClient(newApiClient);
|
||||
});
|
||||
|
||||
var deferred = DeferredBuilder.Deferred();
|
||||
return new Promise(function (resolve, reject) {
|
||||
|
||||
if (Dashboard.isConnectMode()) {
|
||||
if (Dashboard.isConnectMode()) {
|
||||
|
||||
var server = ConnectionManager.getLastUsedServer();
|
||||
var server = ConnectionManager.getLastUsedServer();
|
||||
|
||||
if (!Dashboard.isServerlessPage()) {
|
||||
if (!Dashboard.isServerlessPage()) {
|
||||
|
||||
if (server && server.UserId && server.AccessToken) {
|
||||
ConnectionManager.connectToServer(server).done(function (result) {
|
||||
if (result.State == MediaBrowser.ConnectionState.SignedIn) {
|
||||
window.ApiClient = result.ApiClient;
|
||||
}
|
||||
deferred.resolve();
|
||||
});
|
||||
return deferred.promise();
|
||||
if (server && server.UserId && server.AccessToken) {
|
||||
ConnectionManager.connectToServer(server).done(function (result) {
|
||||
if (result.State == MediaBrowser.ConnectionState.SignedIn) {
|
||||
window.ApiClient = result.ApiClient;
|
||||
}
|
||||
resolve();
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
resolve();
|
||||
|
||||
} else {
|
||||
|
||||
var apiClient = new MediaBrowser.ApiClient(Logger, Dashboard.serverAddress(), AppInfo.appName, AppInfo.appVersion, AppInfo.deviceName, AppInfo.deviceId);
|
||||
apiClient.enableAutomaticNetworking = false;
|
||||
ConnectionManager.addApiClient(apiClient);
|
||||
Dashboard.importCss(apiClient.getUrl('Branding/Css'));
|
||||
window.ApiClient = apiClient;
|
||||
resolve();
|
||||
}
|
||||
deferred.resolve();
|
||||
|
||||
} else {
|
||||
|
||||
var apiClient = new MediaBrowser.ApiClient(Logger, Dashboard.serverAddress(), AppInfo.appName, AppInfo.appVersion, AppInfo.deviceName, AppInfo.deviceId);
|
||||
apiClient.enableAutomaticNetworking = false;
|
||||
ConnectionManager.addApiClient(apiClient);
|
||||
Dashboard.importCss(apiClient.getUrl('Branding/Css'));
|
||||
window.ApiClient = apiClient;
|
||||
deferred.resolve();
|
||||
}
|
||||
return deferred.promise();
|
||||
});
|
||||
}
|
||||
|
||||
function initFastClick() {
|
||||
|
@ -2004,82 +2010,6 @@ var AppInfo = {};
|
|||
}
|
||||
}
|
||||
|
||||
function onDocumentReady() {
|
||||
|
||||
if ($.browser.msie) {
|
||||
require(['devices/ie/ie']);
|
||||
}
|
||||
|
||||
// Do these now to prevent a flash of content
|
||||
if (AppInfo.isNativeApp && $.browser.android) {
|
||||
Dashboard.importCss('devices/android/android.css');
|
||||
} else if (AppInfo.isNativeApp && $.browser.safari) {
|
||||
Dashboard.importCss('devices/ios/ios.css');
|
||||
} else if (!$.browser.android) {
|
||||
Dashboard.importCss('devices/android/android.css');
|
||||
}
|
||||
|
||||
loadTheme();
|
||||
|
||||
if ($.browser.safari && $.browser.mobile) {
|
||||
initFastClick();
|
||||
}
|
||||
|
||||
var footerHtml = '<div id="footer" class="footer" data-theme="b" class="ui-bar-b">';
|
||||
|
||||
footerHtml += '<div id="footerNotifications"></div>';
|
||||
footerHtml += '</div>';
|
||||
|
||||
$(document.body).append(footerHtml);
|
||||
|
||||
window.addEventListener("beforeunload", function () {
|
||||
|
||||
var apiClient = window.ApiClient;
|
||||
|
||||
// Close the connection gracefully when possible
|
||||
if (apiClient && apiClient.isWebSocketOpen()) {
|
||||
|
||||
var localActivePlayers = MediaController.getPlayers().filter(function (p) {
|
||||
|
||||
return p.isLocalPlayer && p.isPlaying();
|
||||
});
|
||||
|
||||
if (!localActivePlayers.length) {
|
||||
Logger.log('Sending close web socket command');
|
||||
apiClient.closeWebSocket();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (Dashboard.isRunningInCordova()) {
|
||||
require(['cordova/connectsdk', 'scripts/registrationservices', 'cordova/back']);
|
||||
|
||||
if ($.browser.android) {
|
||||
require(['cordova/android/androidcredentials', 'cordova/android/immersive', 'cordova/android/mediasession']);
|
||||
} else {
|
||||
require(['cordova/volume']);
|
||||
}
|
||||
|
||||
if ($.browser.safari) {
|
||||
require(['cordova/ios/orientation']);
|
||||
}
|
||||
|
||||
} else {
|
||||
if ($.browser.chrome) {
|
||||
require(['scripts/chromecast']);
|
||||
}
|
||||
}
|
||||
|
||||
if (AppInfo.enableNowPlayingBar) {
|
||||
require(['scripts/nowplayingbar']);
|
||||
Dashboard.importCss('css/nowplayingbar.css');
|
||||
}
|
||||
|
||||
if (navigator.splashscreen) {
|
||||
navigator.splashscreen.hide();
|
||||
}
|
||||
}
|
||||
|
||||
function initRequire() {
|
||||
|
||||
var urlArgs = "v=" + window.dashboardVersion;
|
||||
|
@ -2115,7 +2045,7 @@ var AppInfo = {};
|
|||
|
||||
}
|
||||
|
||||
function init(deferred, capabilities, appName, appVersion, deviceId, deviceName) {
|
||||
function init(promiseResolve, capabilities, appName, appVersion, deviceId, deviceName) {
|
||||
|
||||
// Required since jQuery is loaded before requireJs
|
||||
define('jquery', [], function () {
|
||||
|
@ -2290,11 +2220,11 @@ var AppInfo = {};
|
|||
loadImageCache();
|
||||
$.extend(AppInfo, Dashboard.getAppInfo(appName, appVersion, deviceId, deviceName));
|
||||
|
||||
initAfterDependencies(deferred, capabilities);
|
||||
initAfterDependencies(promiseResolve, capabilities);
|
||||
});
|
||||
}
|
||||
|
||||
function initAfterDependencies(deferred, capabilities) {
|
||||
function initAfterDependencies(promiseResolve, capabilities) {
|
||||
|
||||
var drawer = document.querySelector('.mainDrawerPanel');
|
||||
drawer.classList.remove('mainDrawerPanelPreInit');
|
||||
|
@ -2314,10 +2244,11 @@ var AppInfo = {};
|
|||
var deps = [];
|
||||
|
||||
if (AppInfo.isNativeApp && $.browser.android) {
|
||||
deps.push('cordova/android/logging');
|
||||
require(['cordova/android/logging']);
|
||||
}
|
||||
|
||||
deps.push('appstorage');
|
||||
deps.push('scripts/mediaplayer');
|
||||
|
||||
require(deps, function () {
|
||||
|
||||
|
@ -2342,64 +2273,98 @@ var AppInfo = {};
|
|||
}
|
||||
|
||||
capabilities.DeviceProfile = MediaPlayer.getDeviceProfile(Math.max(screen.height, screen.width));
|
||||
createConnectionManager(capabilities).done(function () { onConnectionManagerCreated(deferred); });
|
||||
|
||||
//$(document.body).append('<div style="background:#00ACC1;position:fixed;z-index:999999;top:1px;left:1px;width:800px;height:450px;display:flex;align-items:center;justify-content:center;"><iron-icon icon="ondemand-video" style="width:320px;height:320px;color:#fff;"></iron-icon></div>');
|
||||
});
|
||||
}
|
||||
var connectionManagerPromise = createConnectionManager(capabilities);
|
||||
|
||||
function onConnectionManagerCreated(deferred) {
|
||||
Promise.all([Globalize.ensure(), connectionManagerPromise]).then(function () {
|
||||
|
||||
Globalize.ensure().then(function () {
|
||||
document.title = Globalize.translateDocument(document.title, 'html');
|
||||
document.title = Globalize.translateDocument(document.title, 'html');
|
||||
|
||||
$(function () {
|
||||
$(function () {
|
||||
|
||||
var mainDrawerPanelContent = document.querySelector('.mainDrawerPanelContent');
|
||||
var mainDrawerPanelContent = document.querySelector('.mainDrawerPanelContent');
|
||||
|
||||
if (mainDrawerPanelContent) {
|
||||
if (mainDrawerPanelContent) {
|
||||
|
||||
var newHtml = mainDrawerPanelContent.innerHTML.substring(4);
|
||||
newHtml = newHtml.substring(0, newHtml.length - 3);
|
||||
var newHtml = mainDrawerPanelContent.innerHTML.substring(4);
|
||||
newHtml = newHtml.substring(0, newHtml.length - 3);
|
||||
|
||||
var srch = 'data-require=';
|
||||
var index = newHtml.indexOf(srch);
|
||||
var depends;
|
||||
var srch = 'data-require=';
|
||||
var index = newHtml.indexOf(srch);
|
||||
var depends;
|
||||
|
||||
if (index != -1) {
|
||||
if (index != -1) {
|
||||
|
||||
var requireAttribute = newHtml.substring(index + srch.length + 1);
|
||||
var requireAttribute = newHtml.substring(index + srch.length + 1);
|
||||
|
||||
requireAttribute = requireAttribute.substring(0, requireAttribute.indexOf('"'));
|
||||
depends = requireAttribute.split(',');
|
||||
requireAttribute = requireAttribute.substring(0, requireAttribute.indexOf('"'));
|
||||
depends = requireAttribute.split(',');
|
||||
}
|
||||
|
||||
depends = depends || [];
|
||||
|
||||
if (newHtml.indexOf('type-interior') != -1) {
|
||||
depends.push('jqmpopup');
|
||||
depends.push('jqmlistview');
|
||||
depends.push('jqmcollapsible');
|
||||
depends.push('jqmcontrolgroup');
|
||||
depends.push('jqmcheckbox');
|
||||
}
|
||||
|
||||
require(depends, function () {
|
||||
|
||||
// Don't like having to use jQuery here, but it takes care of making sure that embedded script executes
|
||||
$(mainDrawerPanelContent).html(Globalize.translateDocument(newHtml, 'html'));
|
||||
onAppReady(promiseResolve);
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
depends = depends || [];
|
||||
|
||||
if (newHtml.indexOf('type-interior') != -1) {
|
||||
depends.push('jqmpopup');
|
||||
depends.push('jqmlistview');
|
||||
depends.push('jqmcollapsible');
|
||||
depends.push('jqmcontrolgroup');
|
||||
depends.push('jqmcheckbox');
|
||||
}
|
||||
|
||||
require(depends, function () {
|
||||
|
||||
// Don't like having to use jQuery here, but it takes care of making sure that embedded script executes
|
||||
$(mainDrawerPanelContent).html(Globalize.translateDocument(newHtml, 'html'));
|
||||
onAppReady(deferred);
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
onAppReady(deferred);
|
||||
onAppReady(promiseResolve);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function onAppReady(deferred) {
|
||||
onDocumentReady();
|
||||
function onAppReady(promiseResolve) {
|
||||
|
||||
if ($.browser.msie) {
|
||||
require(['devices/ie/ie']);
|
||||
}
|
||||
|
||||
// Do these now to prevent a flash of content
|
||||
if (AppInfo.isNativeApp && $.browser.android) {
|
||||
Dashboard.importCss('devices/android/android.css');
|
||||
} else if (AppInfo.isNativeApp && $.browser.safari) {
|
||||
Dashboard.importCss('devices/ios/ios.css');
|
||||
} else if (!$.browser.android) {
|
||||
Dashboard.importCss('devices/android/android.css');
|
||||
}
|
||||
|
||||
loadTheme();
|
||||
|
||||
if ($.browser.safari && $.browser.mobile) {
|
||||
initFastClick();
|
||||
}
|
||||
|
||||
if (Dashboard.isRunningInCordova()) {
|
||||
require(['cordova/connectsdk', 'scripts/registrationservices', 'cordova/back']);
|
||||
|
||||
if ($.browser.android) {
|
||||
require(['cordova/android/androidcredentials', 'cordova/android/immersive', 'cordova/android/mediasession']);
|
||||
} else {
|
||||
require(['cordova/volume']);
|
||||
}
|
||||
|
||||
if ($.browser.safari) {
|
||||
require(['cordova/ios/orientation']);
|
||||
}
|
||||
|
||||
} else {
|
||||
if ($.browser.chrome) {
|
||||
require(['scripts/chromecast']);
|
||||
}
|
||||
}
|
||||
|
||||
var deps = [];
|
||||
|
||||
|
@ -2412,13 +2377,24 @@ var AppInfo = {};
|
|||
deps.push('cordova/ios/tabbar');
|
||||
}
|
||||
|
||||
deps.push('scripts/remotecontrol');
|
||||
deps.push('scripts/search');
|
||||
deps.push('scripts/librarylist');
|
||||
deps.push('scripts/notifications');
|
||||
|
||||
require(deps, function () {
|
||||
|
||||
Dashboard.initPromiseDone = true;
|
||||
$.mobile.initializePage();
|
||||
deferred.resolve();
|
||||
promiseResolve();
|
||||
require(['scripts/mediaplayer-video']);
|
||||
});
|
||||
//require(['localsync']);
|
||||
|
||||
if (AppInfo.enableNowPlayingBar) {
|
||||
require(['scripts/nowplayingbar']);
|
||||
}
|
||||
|
||||
require(['scripts/alphapicker']);
|
||||
require(['scripts/thememediaplayer']);
|
||||
}
|
||||
|
||||
function loadImageCache() {
|
||||
|
@ -2461,33 +2437,33 @@ var AppInfo = {};
|
|||
}, false);
|
||||
}
|
||||
|
||||
var initDeferred = $.Deferred();
|
||||
Dashboard.initPromise = initDeferred.promise();
|
||||
Dashboard.initPromise = new Promise(function (resolve, reject) {
|
||||
|
||||
setAppInfo();
|
||||
setDocumentClasses();
|
||||
setAppInfo();
|
||||
setDocumentClasses();
|
||||
|
||||
function onWebComponentsReady() {
|
||||
if (Dashboard.isRunningInCordova()) {
|
||||
initCordova(initDeferred);
|
||||
} else {
|
||||
init(initDeferred, Dashboard.capabilities());
|
||||
function onWebComponentsReady() {
|
||||
if (Dashboard.isRunningInCordova()) {
|
||||
initCordova(resolve);
|
||||
} else {
|
||||
init(resolve, Dashboard.capabilities());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
initRequire();
|
||||
initRequire();
|
||||
|
||||
if ('registerElement' in document && 'content' in document.createElement('template')) {
|
||||
onWebComponentsReady();
|
||||
} else {
|
||||
if ('registerElement' in document && 'content' in document.createElement('template')) {
|
||||
onWebComponentsReady();
|
||||
} else {
|
||||
|
||||
document.addEventListener('WebComponentsReady', function () {
|
||||
document.addEventListener('WebComponentsReady', function () {
|
||||
|
||||
var delay = $.browser.mobile ? 500 : 300;
|
||||
setTimeout(onWebComponentsReady, delay);
|
||||
});
|
||||
require(['bower_components/webcomponentsjs/webcomponents-lite.min.js']);
|
||||
}
|
||||
var delay = $.browser.mobile ? 500 : 300;
|
||||
setTimeout(onWebComponentsReady, delay);
|
||||
});
|
||||
require(['bower_components/webcomponentsjs/webcomponents-lite.min.js']);
|
||||
}
|
||||
});
|
||||
|
||||
})();
|
||||
|
||||
|
@ -2612,4 +2588,23 @@ pageClassOn('pageshow', "page", function () {
|
|||
|
||||
});
|
||||
|
||||
window.addEventListener("beforeunload", function () {
|
||||
|
||||
var apiClient = window.ApiClient;
|
||||
|
||||
// Close the connection gracefully when possible
|
||||
if (apiClient && apiClient.isWebSocketOpen()) {
|
||||
|
||||
var localActivePlayers = MediaController.getPlayers().filter(function (p) {
|
||||
|
||||
return p.isLocalPlayer && p.isPlaying();
|
||||
});
|
||||
|
||||
if (!localActivePlayers.length) {
|
||||
Logger.log('Sending close web socket command');
|
||||
apiClient.closeWebSocket();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Dashboard.jQueryMobileInit();
|
Loading…
Add table
Add a link
Reference in a new issue