mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
get api libs from bower
This commit is contained in:
parent
def418714f
commit
f36e664503
97 changed files with 16860 additions and 197 deletions
|
@ -1,131 +0,0 @@
|
|||
(function (globalScope, JSON) {
|
||||
|
||||
if (!globalScope.MediaBrowser) {
|
||||
globalScope.MediaBrowser = {};
|
||||
}
|
||||
|
||||
globalScope.MediaBrowser.CredentialProvider = function (key) {
|
||||
|
||||
var self = this;
|
||||
var credentials = null;
|
||||
key = key || 'servercredentials3';
|
||||
|
||||
function ensure() {
|
||||
|
||||
if (!credentials) {
|
||||
|
||||
var json = appStorage.getItem(key) || '{}';
|
||||
|
||||
Logger.log('credentials initialized with: ' + json);
|
||||
credentials = JSON.parse(json);
|
||||
credentials.Servers = credentials.Servers || [];
|
||||
}
|
||||
}
|
||||
|
||||
function get() {
|
||||
|
||||
ensure();
|
||||
return credentials;
|
||||
}
|
||||
|
||||
function set(data) {
|
||||
|
||||
if (data) {
|
||||
credentials = data;
|
||||
appStorage.setItem(key, JSON.stringify(data));
|
||||
} else {
|
||||
self.clear();
|
||||
}
|
||||
|
||||
Events.trigger(self, 'credentialsupdated');
|
||||
}
|
||||
|
||||
self.clear = function () {
|
||||
credentials = null;
|
||||
appStorage.removeItem(key);
|
||||
};
|
||||
|
||||
self.credentials = function (data) {
|
||||
|
||||
if (data) {
|
||||
set(data);
|
||||
}
|
||||
|
||||
return get();
|
||||
};
|
||||
|
||||
self.addOrUpdateServer = function (list, server) {
|
||||
|
||||
if (!server.Id) {
|
||||
throw new Error('Server.Id cannot be null or empty');
|
||||
}
|
||||
|
||||
var existing = list.filter(function (s) {
|
||||
return s.Id == server.Id;
|
||||
})[0];
|
||||
|
||||
if (existing) {
|
||||
|
||||
// Merge the data
|
||||
existing.DateLastAccessed = Math.max(existing.DateLastAccessed || 0, server.DateLastAccessed || 0);
|
||||
|
||||
existing.UserLinkType = server.UserLinkType;
|
||||
|
||||
if (server.AccessToken) {
|
||||
existing.AccessToken = server.AccessToken;
|
||||
existing.UserId = server.UserId;
|
||||
}
|
||||
if (server.ExchangeToken) {
|
||||
existing.ExchangeToken = server.ExchangeToken;
|
||||
}
|
||||
if (server.RemoteAddress) {
|
||||
existing.RemoteAddress = server.RemoteAddress;
|
||||
}
|
||||
if (server.ManualAddress) {
|
||||
existing.ManualAddress = server.ManualAddress;
|
||||
}
|
||||
if (server.LocalAddress) {
|
||||
existing.LocalAddress = server.LocalAddress;
|
||||
}
|
||||
if (server.Name) {
|
||||
existing.Name = server.Name;
|
||||
}
|
||||
if (server.WakeOnLanInfos && server.WakeOnLanInfos.length) {
|
||||
existing.WakeOnLanInfos = server.WakeOnLanInfos;
|
||||
}
|
||||
if (server.LastConnectionMode != null) {
|
||||
existing.LastConnectionMode = server.LastConnectionMode;
|
||||
}
|
||||
if (server.ConnectServerId) {
|
||||
existing.ConnectServerId = server.ConnectServerId;
|
||||
}
|
||||
existing.DateLastLocalConnection = Math.max(existing.DateLastLocalConnection || 0, server.DateLastLocalConnection || 0);
|
||||
|
||||
return existing;
|
||||
}
|
||||
else {
|
||||
list.push(server);
|
||||
return server;
|
||||
}
|
||||
};
|
||||
|
||||
self.addOrUpdateUser = function (server, user) {
|
||||
|
||||
server.Users = server.Users || [];
|
||||
|
||||
var existing = server.Users.filter(function (s) {
|
||||
return s.Id == user.Id;
|
||||
})[0];
|
||||
|
||||
if (existing) {
|
||||
|
||||
// Merge the data
|
||||
existing.IsSignedInOffline = true;
|
||||
}
|
||||
else {
|
||||
server.Users.push(user);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
})(window, window.JSON);
|
Loading…
Add table
Add a link
Reference in a new issue