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

update scripts for reuse

This commit is contained in:
Luke Pulverenti 2014-10-26 20:13:47 -04:00
parent 83d7b945d7
commit 42d8ccb0aa
2 changed files with 18 additions and 10 deletions

View file

@ -2,7 +2,7 @@
window.MediaBrowser = {}; window.MediaBrowser = {};
} }
MediaBrowser.ConnectionManager = function (store) { MediaBrowser.ConnectionManager = function ($) {
MediaBrowser.ConnectionState = { MediaBrowser.ConnectionState = {
Unavilable: 0, Unavilable: 0,
@ -67,7 +67,9 @@ MediaBrowser.ConnectionManager = function (store) {
dataType: "json", dataType: "json",
error: function () { error: function () {
} },
timeout: 5000
}); });
} }
@ -126,7 +128,7 @@ MediaBrowser.ConnectionManager = function (store) {
apiClient.serverInfo(server); apiClient.serverInfo(server);
$(apiClient).on('authenticated', function (e, result) { $(apiClient).on('authenticated', function (e, result) {
onLocalAuthenticated(this, result); onLocalAuthenticated(this, result, true);
}); });
$(this).trigger('apiclientcreated', [apiClient]); $(this).trigger('apiclientcreated', [apiClient]);
@ -145,7 +147,7 @@ MediaBrowser.ConnectionManager = function (store) {
return apiClient; return apiClient;
} }
function onLocalAuthenticated(apiClient, result) { function onLocalAuthenticated(apiClient, result, saveCredentials) {
apiClient.getSystemInfo().done(function (systemInfo) { apiClient.getSystemInfo().done(function (systemInfo) {
@ -155,8 +157,14 @@ MediaBrowser.ConnectionManager = function (store) {
var credentials = credentialProvider.credentials(); var credentials = credentialProvider.credentials();
server.DateLastAccessed = new Date().getTime(); server.DateLastAccessed = new Date().getTime();
server.UserId = result.User.Id;
server.AccessToken = result.AccessToken; if (saveCredentials) {
server.UserId = result.User.Id;
server.AccessToken = result.AccessToken;
} else {
server.UserId = null;
server.AccessToken = null;
}
credentials.addOrUpdateServer(credentials.servers, server); credentials.addOrUpdateServer(credentials.servers, server);
credentialProvider.credentials(credentials); credentialProvider.credentials(credentials);
@ -785,4 +793,4 @@ MediaBrowser.ConnectionManager = function (store) {
}; };
}; };
}(window.store); }(jQuery);

View file

@ -2,7 +2,7 @@
window.MediaBrowser = {}; window.MediaBrowser = {};
} }
MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, window, FileReader) { MediaBrowser.ApiClient = function ($, JSON, WebSocket, setTimeout, devicePixelRatio, FileReader) {
/** /**
* Creates a new api client instance * Creates a new api client instance
@ -2119,7 +2119,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi
function normalizeImageOptions(options) { function normalizeImageOptions(options) {
var ratio = window.devicePixelRatio || 1; var ratio = devicePixelRatio || 1;
if (ratio) { if (ratio) {
@ -3194,7 +3194,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi
}; };
}(jQuery, navigator, window.JSON, window.WebSocket, setTimeout, window, window.FileReader); }(jQuery, window.JSON, window.WebSocket, setTimeout, window.devicePixelRatio, window.FileReader);
(function (store) { (function (store) {