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

hls updates

This commit is contained in:
Luke Pulverenti 2015-05-20 12:28:55 -04:00
parent bbdbdf346e
commit 9fc4c86111
19 changed files with 255 additions and 246 deletions

View file

@ -1,18 +1,13 @@
(function () {
function onLoggedIn() {
Dashboard.hideModalLoadingMsg();
Dashboard.navigate('selectserver.html');
}
function login(page, username, password) {
Dashboard.showModalLoadingMsg();
ConnectionManager.loginToConnect(username, password).done(function () {
onLoggedIn();
Dashboard.hideModalLoadingMsg();
Dashboard.navigate('selectserver.html');
}).fail(function () {
@ -39,7 +34,7 @@
{
var apiClient = result.ApiClient;
Dashboard.onServerChanged(apiClient.serverAddress(), apiClient.getCurrentUserId(), apiClient.accessToken(), apiClient);
Dashboard.onServerChanged(apiClient.getCurrentUserId(), apiClient.accessToken(), apiClient);
Dashboard.navigate('index.html');
}
break;
@ -50,7 +45,7 @@
break;
case MediaBrowser.ConnectionState.ServerSelection:
{
onLoggedIn();
Dashboard.navigate('selectserver.html');
}
break;
case MediaBrowser.ConnectionState.ConnectSignIn:

View file

@ -50,8 +50,10 @@
var apiClient = ApiClient;
$(apiClient).off("websocketmessage", DashboardPage.onWebSocketMessage).off("websocketopen", DashboardPage.onWebSocketConnectionChange).off("websocketerror", DashboardPage.onWebSocketConnectionChange).off("websocketclose", DashboardPage.onWebSocketConnectionChange);
DashboardPage.stopInterval(apiClient);
if (apiClient) {
$(apiClient).off("websocketmessage", DashboardPage.onWebSocketMessage).off("websocketopen", DashboardPage.onWebSocketConnectionChange).off("websocketerror", DashboardPage.onWebSocketConnectionChange).off("websocketclose", DashboardPage.onWebSocketConnectionChange);
DashboardPage.stopInterval(apiClient);
}
if (DashboardPage.sessionUpdateTimer) {
clearInterval(DashboardPage.sessionUpdateTimer);
@ -1280,7 +1282,11 @@ $(document).on('pagebeforeshowready', "#dashboardPage", DashboardPage.onPageShow
createList(this);
}
startListening(ApiClient);
var apiClient = ApiClient;
if (apiClient) {
startListening(apiClient);
}
return this;
};

View file

@ -807,7 +807,7 @@
var innerElem = $('.cardOverlayTarget', elem);
var dataElement = elem;
while (!dataElement.getAttribute('data-itemid')) {
while (dataElement && !dataElement.getAttribute('data-itemid')) {
dataElement = dataElement.parentNode;
}

View file

@ -257,6 +257,7 @@
}
var requiresLibraryMenuRefresh = false;
var requiresViewMenuRefresh = false;
function getLibraryMenu(user) {
@ -460,7 +461,7 @@
function updateContextText(page) {
var name = page.getAttribute('data-contextname');
var name = $(page)[0].getAttribute('data-contextname');
if (name) {
@ -490,21 +491,17 @@
}
}
$(document).on('pageinit', ".page", function () {
function buildViewMenuBar(page) {
var page = this;
if ($(page).hasClass('standalonePage')) {
$('.viewMenuBar').remove();
return;
}
$('.libraryViewNav', page).wrapInner('<div class="libraryViewNavInner"></div>');
if (requiresViewMenuRefresh) {
$('.viewMenuBar').remove();
}
$('.libraryViewNav a', page).each(function () {
this.innerHTML = '<span class="libraryViewNavLinkContent">' + this.innerHTML + '</span>';
});
}).on('pagebeforeshowready', ".page:not(.standalonePage)", function () {
var page = this;
var viewMenuBar = $('.viewMenuBar');
if (!$('.viewMenuBar').length) {
@ -517,17 +514,56 @@
updateLibraryNavLinks(page);
updateContextText(page);
requiresViewMenuRefresh = false;
});
} else {
updateContextText(page);
updateLibraryNavLinks(page);
updateViewMenuBarHeadroom(page, viewMenuBar);
requiresViewMenuRefresh = false;
}
}
$(document).on('pageinit', ".page", function () {
var page = this;
$('.libraryViewNav', page).wrapInner('<div class="libraryViewNavInner"></div>');
$('.libraryViewNav a', page).each(function () {
this.innerHTML = '<span class="libraryViewNavLinkContent">' + this.innerHTML + '</span>';
});
}).on('pagebeforeshowready', ".page", function () {
var page = this;
buildViewMenuBar(page);
var jpage = $(page);
if (jpage.hasClass('libraryPage')) {
var isLibraryPage = jpage.hasClass('libraryPage');
if (isLibraryPage) {
$(document.body).addClass('libraryDocument').removeClass('dashboardDocument');
if (AppInfo.enableBottomTabs) {
$(page).addClass('noSecondaryNavPage');
$(function () {
$('.footer').addClass('footerOverBottomTabs');
});
} else {
$('.libraryViewNav', page).each(function () {
initHeadRoom(this);
});
}
}
else if (jpage.hasClass('type-interior')) {
$(document.body).addClass('dashboardDocument').removeClass('libraryDocument');
@ -535,27 +571,6 @@
$(document.body).removeClass('dashboardDocument').removeClass('libraryDocument');
}
}).on('pagebeforeshowready', ".libraryPage", function () {
var page = this;
if (AppInfo.enableBottomTabs) {
$('.libraryViewNav', page).addClass('bottomLibraryViewNav');
$(page).addClass('noSecondaryNavPage');
$(function () {
$('.footer').addClass('footerOverBottomTabs');
});
} else {
$('.libraryViewNav', page).each(function () {
initHeadRoom(this);
});
}
}).on('pageshow', ".libraryPage", function () {
var page = this;
@ -601,8 +616,8 @@
initializeApiClient(apiClient);
}).on('localusersignedin localusersignedout', function () {
$('.viewMenuBar').remove();
requiresLibraryMenuRefresh = true;
requiresViewMenuRefresh = true;
});
});

View file

@ -105,12 +105,12 @@
var newUrl;
if (user.Policy.IsAdministrator && !serverId) {
newUrl = "dashboard.html?u=" + user.Id + '&t=' + result.AccessToken;
newUrl = "dashboard.html";
} else {
newUrl = "index.html?u=" + user.Id + '&t=' + result.AccessToken;
newUrl = "index.html";
}
Dashboard.onServerChanged(apiClient.serverAddress(), user.Id, result.AccessToken, apiClient);
Dashboard.onServerChanged(user.Id, result.AccessToken, apiClient);
Dashboard.navigate(newUrl);
}).fail(function () {

View file

@ -14,7 +14,7 @@
case MediaBrowser.ConnectionState.SignedIn:
{
Dashboard.onServerChanged(apiClient.serverAddress(), apiClient.getCurrentUserId(), apiClient.accessToken(), apiClient);
Dashboard.onServerChanged(apiClient.getCurrentUserId(), apiClient.accessToken(), apiClient);
Dashboard.navigate('index.html');
}
break;
@ -22,7 +22,7 @@
{
if (Dashboard.isRunningInCordova()) {
Dashboard.onServerChanged(apiClient.serverAddress(), null, null, apiClient);
Dashboard.onServerChanged(null, null, apiClient);
Dashboard.navigate('login.html?serverid=' + result.Servers[0].Id);
} else {
showServerConnectionFailure();

View file

@ -104,13 +104,6 @@ var Dashboard = {
}
},
onApiClientServerAddressChanged: function () {
var apiClient = this;
Dashboard.serverAddress(apiClient.serverAddress());
},
getCurrentUser: function () {
if (!Dashboard.getUserPromise) {
@ -130,45 +123,37 @@ var Dashboard = {
}
},
getAccessToken: function () {
serverAddress: function () {
return store.getItem('token');
},
if (Dashboard.isConnectMode()) {
var apiClient = window.ApiClient;
serverAddress: function (val) {
if (apiClient) {
return apiClient.serverAddress();
}
if (val != null) {
console.log('Setting server address to: ' + val);
store.setItem('serverAddress', val);
return null;
}
var address = store.getItem('serverAddress');
// Try to get the server address from the browser url
// This will preserve protocol, hostname, port and subdirectory
var urlLower = getWindowUrl().toLowerCase();
var index = urlLower.indexOf('/web');
if (index == -1) {
index = urlLower.indexOf('/dashboard');
}
if (!address && !Dashboard.isConnectMode()) {
if (index != -1) {
return urlLower.substring(0, index);
}
// Try to get the server address from the browser url
// This will preserve protocol, hostname, port and subdirectory
var urlLower = getWindowUrl().toLowerCase();
var index = urlLower.indexOf('/web');
if (index == -1) {
index = urlLower.indexOf('/dashboard');
}
// If the above failed, just piece it together manually
var loc = window.location;
if (index != -1) {
address = urlLower.substring(0, index);
return address;
}
var address = loc.protocol + '//' + loc.hostname;
// If the above failed, just piece it together manually
var loc = window.location;
address = loc.protocol + '//' + loc.hostname;
if (loc.port) {
address += ':' + loc.port;
}
if (loc.port) {
address += ':' + loc.port;
}
return address;
@ -176,38 +161,26 @@ var Dashboard = {
getCurrentUserId: function () {
var autoLoginUserId = getParameterByName('u');
var storedUserId = store.getItem("userId");
if (autoLoginUserId && autoLoginUserId != storedUserId) {
var token = getParameterByName('t');
Dashboard.setCurrentUser(autoLoginUserId, token);
}
return autoLoginUserId || storedUserId;
},
setCurrentUser: function (userId, token) {
store.setItem("userId", userId);
store.setItem("token", token);
var apiClient = window.ApiClient;
if (apiClient) {
apiClient.setCurrentUserId(userId, token);
return apiClient.getCurrentUserId();
}
return null;
},
onServerChanged: function (userId, accessToken, apiClient) {
apiClient = apiClient || window.ApiClient;
window.ApiClient = apiClient;
Dashboard.getUserPromise = null;
},
logout: function (logoutWithServer, forceReload) {
store.removeItem("userId");
store.removeItem("token");
store.removeItem("serverAddress");
function onLogoutDone() {
var loginPage;
@ -594,9 +567,11 @@ var Dashboard = {
refreshSystemInfoFromServer: function () {
if (Dashboard.getAccessToken()) {
if (AppInfo.enableFooterNotifications) {
ApiClient.getSystemInfo().done(function (info) {
var apiClient = ApiClient;
if (apiClient.accessToken()) {
if (apiClient.enableFooterNotifications) {
apiClient.getSystemInfo().done(function (info) {
Dashboard.updateSystemInfo(info);
});
@ -1040,14 +1015,14 @@ var Dashboard = {
Dashboard.updateSystemInfo(msg.Data);
}
else if (msg.MessageType === "UserUpdated" || msg.MessageType === "UserConfigurationUpdated") {
Dashboard.validateCurrentUser();
var user = msg.Data;
if (user.Id == Dashboard.getCurrentUserId()) {
Dashboard.validateCurrentUser();
$('.currentUsername').html(user.Name);
}
}
else if (msg.MessageType === "PackageInstallationCompleted") {
Dashboard.getCurrentUser().done(function (currentUser) {
@ -1076,7 +1051,7 @@ var Dashboard = {
}
});
}
else if (msg.MessageType === "PackageInstalling") {
else if (msg.MessaapiclientcgeType === "PackageInstalling") {
Dashboard.getCurrentUser().done(function (currentUser) {
if (currentUser.Policy.IsAdministrator) {
@ -1492,18 +1467,8 @@ var Dashboard = {
return deferred.promise();
},
onServerChanged: function (serverAddress, userId, accessToken, apiClient) {
ready: function (fn) {
window.ApiClient = apiClient;
if (Dashboard.isConnectMode()) {
Dashboard.serverAddress(serverAddress);
}
Dashboard.setCurrentUser(userId, accessToken);
},
ready: function(fn) {
if (Dashboard.initPromiseDone) {
fn();
return;
@ -1593,8 +1558,7 @@ var AppInfo = {};
$(apiClient).off('.dashboard')
.on("websocketmessage.dashboard", Dashboard.onWebSocketMessageReceived)
.on('requestfail.dashboard', Dashboard.onRequestFail)
.on('serveraddresschanged.dashboard', Dashboard.onApiClientServerAddressChanged);
.on('requestfail.dashboard', Dashboard.onRequestFail);
}
function createConnectionManager(appInfo) {
@ -1605,41 +1569,36 @@ var AppInfo = {};
window.ConnectionManager = new MediaBrowser.ConnectionManager(Logger, credentialProvider, appInfo.appName, appInfo.appVersion, appInfo.deviceName, appInfo.deviceId, capabilities);
$(ConnectionManager).on('apiclientcreated', function (e, apiClient) {
initializeApiClient(apiClient);
});
var lastApiClient = ConnectionManager.getLastUsedApiClient();
if (Dashboard.isConnectMode()) {
$(ConnectionManager).on('apiclientcreated', function (e, apiClient) {
initializeApiClient(apiClient);
});
if (!Dashboard.isServerlessPage()) {
if (Dashboard.serverAddress() && Dashboard.getCurrentUserId() && Dashboard.getAccessToken()) {
if (lastApiClient && lastApiClient.serverAddress() && lastApiClient.getCurrentUserId() && lastApiClient.accessToken()) {
window.ApiClient = new MediaBrowser.ApiClient(Logger, Dashboard.serverAddress(), appInfo.appName, appInfo.appVersion, appInfo.deviceName, appInfo.deviceId);
window.ApiClient = lastApiClient;
ApiClient.setCurrentUserId(Dashboard.getCurrentUserId(), Dashboard.getAccessToken());
initializeApiClient(lastApiClient);
initializeApiClient(ApiClient);
//ConnectionManager.addApiClient(lastApiClient, true).fail(Dashboard.logout);
ConnectionManager.addApiClient(ApiClient, true).fail(Dashboard.logout);
} else {
Dashboard.logout();
return;
}
}
} else {
window.ApiClient = new MediaBrowser.ApiClient(Logger, Dashboard.serverAddress(), appInfo.appName, appInfo.appVersion, appInfo.deviceName, appInfo.deviceId);
if (!lastApiClient) {
lastApiClient = new MediaBrowser.ApiClient(Logger, Dashboard.serverAddress(), appInfo.appName, appInfo.appVersion, appInfo.deviceName, appInfo.deviceId);
ConnectionManager.addApiClient(lastApiClient);
}
ApiClient.setCurrentUserId(Dashboard.getCurrentUserId(), Dashboard.getAccessToken());
initializeApiClient(ApiClient);
ConnectionManager.addApiClient(ApiClient);
window.ApiClient = lastApiClient;
}
if (window.ApiClient) {
@ -1835,7 +1794,7 @@ var AppInfo = {};
}
}
function init(deferred, appName, deviceId, deviceName) {
function init(deferred, appName, deviceId, deviceName, resolveOnReady) {
requirejs.config({
map: {
@ -1857,9 +1816,17 @@ var AppInfo = {};
createConnectionManager(appInfo);
Dashboard.initPromiseDone = true;
deferred.resolve();
$(onDocumentReady);
if (!resolveOnReady) {
Dashboard.initPromiseDone = true;
deferred.resolve();
}
$(function () {
onDocumentReady();
if (resolveOnReady) {
Dashboard.initPromiseDone = true;
deferred.resolve();
}
});
}
function initCordovaWithDeviceId(deferred, deviceId) {
@ -1867,7 +1834,7 @@ var AppInfo = {};
requirejs(['thirdparty/cordova/imagestore.js']);
}
init(deferred, "Emby Mobile", deviceId, device.model);
init(deferred, "Emby Mobile", deviceId, device.model, true);
}
function initCordova(deferred) {
@ -1974,29 +1941,27 @@ $(document).on('pagecreate', ".page", function () {
Dashboard.firePageEvent(page, 'pagebeforeshowready');
}
}).on('pagebeforeshow', ".page", function () {
}).on('pagebeforeshowready', ".page", function () {
var page = $(this);
var apiClient = window.ApiClient;
if (Dashboard.getAccessToken() && Dashboard.getCurrentUserId()) {
if (apiClient && apiClient.accessToken() && Dashboard.getCurrentUserId()) {
if (apiClient) {
Dashboard.getCurrentUser().done(function (user) {
Dashboard.getCurrentUser().done(function (user) {
var isSettingsPage = page.hasClass('type-interior');
var isSettingsPage = page.hasClass('type-interior');
if (!user.Policy.IsAdministrator && isSettingsPage) {
window.location.replace("index.html");
return;
}
if (!user.Policy.IsAdministrator && isSettingsPage) {
window.location.replace("index.html");
return;
}
if (isSettingsPage) {
Dashboard.ensureToolsMenu(page, user);
}
});
}
if (isSettingsPage) {
Dashboard.ensureToolsMenu(page, user);
}
});
Dashboard.ensureHeader(page);
Dashboard.ensurePageTitle(page);

View file

@ -120,7 +120,7 @@
};
$(document).on('pageshow', "#supporterKeyPage", SupporterKeyPage.onPageShow);
$(document).on('pageshowready', "#supporterKeyPage", SupporterKeyPage.onPageShow);
(function () {
@ -255,14 +255,19 @@ $(document).on('pageshow', "#supporterKeyPage", SupporterKeyPage.onPageShow);
}
$(document).on('pageinit', "#supporterKeyPage", function () {
$(document).on('pageinitdepends', "#supporterKeyPage", function () {
var page = this;
$('#btnAddConnectUser', page).on('click', function () {
showAddUserForm(page);
});
}).on('pageshow', "#supporterKeyPage", function () {
$('#supporterKeyForm').on('submit', SupporterKeyPage.updateSupporterKey);
$('#lostKeyForm').on('submit', SupporterKeyPage.retrieveSupporterKey);
$('#linkKeysForm').on('submit', SupporterKeyPage.linkSupporterKeys);
$('.popupAddUserForm').on('submit', SupporterKeyPage.onAddConnectUserSubmit).on('submit', SupporterKeyPage.onAddConnectUserSubmit);
}).on('pageshowready', "#supporterKeyPage", function () {
var page = this;
loadConnectSupporters(page);

View file

@ -387,7 +387,7 @@
});
}
$(document).on('pageinit', ".libraryPage", function () {
$(document).on('pageinitdepends', ".libraryPage", function () {
var page = this;
@ -396,7 +396,7 @@
onCategorySyncButtonClick(page, this);
});
}).on('pagebeforeshow', ".libraryPage", function () {
}).on('pagebeforeshowready', ".libraryPage", function () {
var page = this;