diff --git a/dashboard-ui/apiclient/ajax.js b/dashboard-ui/apiclient/ajax.js deleted file mode 100644 index c0c191ad04..0000000000 --- a/dashboard-ui/apiclient/ajax.js +++ /dev/null @@ -1,24 +0,0 @@ -(function (globalScope) { - - globalScope.HttpClient = { - - param: function (params) { - return jQuery.param(params); - }, - - send: function (request) { - - request.timeout = request.timeout || 30000; - - try { - return jQuery.ajax(request); - } catch (err) { - var deferred = DeferredBuilder.Deferred(); - deferred.reject(); - return deferred.promise(); - } - } - - }; - -})(window); \ No newline at end of file diff --git a/dashboard-ui/apiclient/apiclient.js b/dashboard-ui/apiclient/apiclient.js index db1f86f56b..f8910e7094 100644 --- a/dashboard-ui/apiclient/apiclient.js +++ b/dashboard-ui/apiclient/apiclient.js @@ -68,8 +68,9 @@ if (promise == null) { - promise = self.getUser(self.getCurrentUserId()).fail(function () { + promise = self.getUser(self.getCurrentUserId()).catch(function (err) { currentUserPromise = null; + throw err; }); currentUserPromise = promise; @@ -123,7 +124,7 @@ name = name.split('&').join('-'); name = name.split('?').join('-'); - var val = HttpClient.param({ name: name }); + var val = paramsToString({ name: name }); return val.substring(val.indexOf('=') + 1).replace("'", '%27'); }; @@ -188,27 +189,35 @@ throw new Error("Request cannot be null"); } - if (includeAuthorization !== false) { - - request.headers = request.headers || {}; - self.setRequestHeaders(request.headers); - } - - if (self.enableAutomaticNetworking === false || request.type != "GET") { - logger.log('Requesting url without automatic networking: ' + request.url); - return HttpClient.send(request).fail(onRequestFail); - } - - var deferred = DeferredBuilder.Deferred(); - self.ajaxWithFailover(request, deferred, true); - return deferred.promise(); + return self.fetch(request, includeAuthorization); }; function getFetchPromise(request) { - return fetch(request.url, { - headers: request.headers, + + var headers = request.headers || {}; + + if (request.dataType == 'json') { + headers.accept = 'application/json'; + } + + var fetchRequest = { + headers: headers, method: request.type - }); + }; + + if (request.data) { + + if (typeof request.data === 'string') { + fetchRequest.body = request.data; + } + } + + if (request.contentType) { + + headers['Content-Type'] = request.contentType; + } + + return fetch(request.url, fetchRequest); } /** @@ -220,52 +229,51 @@ throw new Error("Request cannot be null"); } + request.headers = request.headers || {}; + if (includeAuthorization !== false) { - request.headers = request.headers || {}; self.setRequestHeaders(request.headers); } if (self.enableAutomaticNetworking === false || request.type != "GET") { logger.log('Requesting url without automatic networking: ' + request.url); - return new Promise(function (resolve, reject) { + return getFetchPromise(request).then(function (response) { - getFetchPromise(request).then(function (response) { + if (response.status < 400) { - if (response.status < 400) { - resolve(response); + if (request.dataType == 'json' || request.headers.accept == 'application/json') { + return response.json(); } else { - onFetchFail(request.url, response); - reject(); + return response; } + } else { + onFetchFail(request.url, response); + return Promise.reject(response); + } - }, function () { - onFetchFail(request.url, {}); - reject(); - }); + }, function () { + onFetchFail(request.url, {}); + return Promise.reject({}); }); } - return new Promise(function (resolve, reject) { - - self.fetchWithFailover(request, resolve, reject, true); - }); + return self.fetchWithFailover(request, true); }; - self.fetchJSON = function (url, includeAuthorization) { + self.getJSON = function (url, includeAuthorization) { return self.fetch({ url: url, type: 'GET', + dataType: 'json', headers: { accept: 'application/json' } - }, includeAuthorization).then(function (response) { - return response.json(); - }); + }, includeAuthorization); }; function switchConnectionMode(connectionMode) { @@ -303,15 +311,15 @@ var timeout = connectionMode == MediaBrowser.ConnectionMode.Local ? 7000 : 15000; - HttpClient.send({ + fetch(url + "/system/info/public", { - type: "GET", - url: url + "/system/info/public", - dataType: "json", + method: 'GET', + accept: 'application/json' - timeout: timeout + // Commenting this out since the fetch api doesn't have a timeout option yet + //timeout: timeout - }).done(function () { + }).then(function () { logger.log("Reconnect succeeded to " + url); @@ -320,7 +328,7 @@ deferred.resolve(); - }).fail(function () { + }, function () { logger.log("Reconnect attempt failed to " + url); @@ -347,19 +355,24 @@ return deferred.promise(); } - self.fetchWithFailover = function (request, resolve, reject, enableReconnection) { + self.fetchWithFailover = function (request, enableReconnection) { logger.log("Requesting " + request.url); request.timeout = 30000; - getFetchPromise(request).then(function (response) { + return getFetchPromise(request).then(function (response) { if (response.status < 400) { - resolve(response); + + if (request.dataType == 'json' || request.headers.accept == 'application/json') { + return response.json(); + } else { + return response; + } } else { onFetchFail(request.url, response); - reject(); + return Promise.reject(response); } }, function () { @@ -373,18 +386,18 @@ var previousServerAddress = self.serverAddress(); - tryReconnect().done(function () { + tryReconnect().then(function () { logger.log("Reconnect succeesed"); request.url = request.url.replace(previousServerAddress, self.serverAddress()); - self.fetchWithFailover(request, resolve, reject, false); + self.fetchWithFailover(request, false); - }).fail(function () { + }, function () { logger.log("Reconnect failed"); onFetchFail(request.url, {}); - reject(); + return Promise.reject({}); }); } else { @@ -392,55 +405,7 @@ logger.log("Reporting request failure"); onFetchFail(request.url, {}); - reject(); - } - }); - }; - - self.ajaxWithFailover = function (request, deferred, enableReconnection) { - - logger.log("Requesting " + request.url); - - request.timeout = 30000; - - HttpClient.send(request).done(function (response) { - - deferred.resolve(response, 0); - - }).fail(function (e, textStatus) { - - logger.log("Request failed with textStatus " + textStatus + " to " + request.url); - - var statusCode = parseInt(e.status || '0'); - var isUserErrorCode = statusCode >= 400 && statusCode < 500; - - // http://api.jquery.com/jQuery.ajax/ - if (enableReconnection && !isUserErrorCode) { - - logger.log("Attempting reconnection"); - - var previousServerAddress = self.serverAddress(); - - tryReconnect().done(function () { - - logger.log("Reconnect succeesed"); - request.url = request.url.replace(previousServerAddress, self.serverAddress()); - - self.ajaxWithFailover(request, deferred, false); - - }).fail(function () { - - logger.log("Reconnect failed"); - onRetryRequestFail(request); - deferred.reject(); - - }); - } else { - - logger.log("Reporting request failure"); - - onRetryRequestFail(request); - deferred.reject(); + return Promise.reject({}); } }); }; @@ -453,14 +418,20 @@ }); }; - self.getJSON = function (url) { + function paramsToString(params) { - return self.ajax({ - type: "GET", - url: url, - dataType: "json" - }); - }; + var values = []; + + for (var key in params) { + + var value = params[key]; + + if (value) { + values.push(encodeURIComponent(key) + "=" + encodeURIComponent(value)); + } + } + return values.join('&'); + } /** * Creates an api url based on a handler name and query string parameters @@ -490,7 +461,7 @@ url += name; if (params) { - params = HttpClient.param(params); + params = paramsToString(params); if (params) { url += "?" + params; } @@ -632,7 +603,7 @@ var now = new Date().getTime(); - self.get(url).done(function () { + self.get(url).then(function () { var responseTimeSeconds = (new Date().getTime() - now) / 1000; var bytesPerSecond = byteSize / responseTimeSeconds; @@ -640,7 +611,7 @@ deferred.resolveWith(null, [bitrate]); - }).fail(function () { + }, function () { deferred.reject(); }); @@ -653,24 +624,24 @@ var deferred = DeferredBuilder.Deferred(); // First try a small amount so that we don't hang up their mobile connection - self.getDownloadSpeed(1000000).done(function (bitrate) { + self.getDownloadSpeed(1000000).then(function (bitrate) { if (bitrate < 1000000) { deferred.resolveWith(null, [Math.round(bitrate * .8)]); } else { // If that produced a fairly high speed, try again with a larger size to get a more accurate result - self.getDownloadSpeed(2400000).done(function (bitrate) { + self.getDownloadSpeed(2400000).then(function (bitrate) { deferred.resolveWith(null, [Math.round(bitrate * .8)]); - }).fail(function () { + }, function () { deferred.reject(); }); } - }).fail(function () { + }, function () { deferred.reject(); }); @@ -692,7 +663,7 @@ self.getUrl("Users/" + userId + "/Items/" + itemId) : self.getUrl("Items/" + itemId); - return self.fetchJSON(url); + return self.getJSON(url); }; /** @@ -706,7 +677,7 @@ var url = self.getUrl("Users/" + userId + "/Items/Root"); - return self.fetchJSON(url); + return self.getJSON(url); }; self.getNotificationSummary = function (userId) { @@ -770,7 +741,8 @@ return self.ajax({ type: "POST", url: url - }).always(done); + + }).then(done, done); } var deferred = DeferredBuilder.Deferred(); @@ -1215,7 +1187,7 @@ var url = self.getUrl("System/Info"); - return self.fetchJSON(url); + return self.getJSON(url); }; /** @@ -1225,7 +1197,7 @@ var url = self.getUrl("System/Info/Public"); - return self.fetchJSON(url, false); + return self.getJSON(url, false); }; self.getInstantMixFromItem = function (itemId, options) { @@ -1249,7 +1221,7 @@ client: app }); - return self.fetchJSON(url); + return self.getJSON(url); }; self.updateDisplayPreferences = function (id, obj, userId, app) { @@ -1543,7 +1515,7 @@ var url = self.getUrl("System/Configuration"); - return self.fetchJSON(url); + return self.getJSON(url); }; /** @@ -2027,11 +1999,11 @@ url: url, data: data, contentType: "image/" + file.name.substring(file.name.lastIndexOf('.') + 1) - }).done(function (result) { + }).then(function (result) { deferred.resolveWith(null, [result]); - }).fail(function () { + }, function () { deferred.reject(); }); }; @@ -2087,11 +2059,11 @@ url: url, data: data, contentType: "image/" + file.name.substring(file.name.lastIndexOf('.') + 1) - }).done(function (result) { + }).then(function (result) { deferred.resolveWith(null, [result]); - }).fail(function () { + }, function () { deferred.reject(); }); }; @@ -2185,7 +2157,7 @@ var url = self.getUrl("Genres/" + self.encodeName(name), options); - return self.fetchJSON(url); + return self.getJSON(url); }; self.getMusicGenre = function (name, userId) { @@ -2202,7 +2174,7 @@ var url = self.getUrl("MusicGenres/" + self.encodeName(name), options); - return self.fetchJSON(url); + return self.getJSON(url); }; self.getGameGenre = function (name, userId) { @@ -2219,7 +2191,7 @@ var url = self.getUrl("GameGenres/" + self.encodeName(name), options); - return self.fetchJSON(url); + return self.getJSON(url); }; /** @@ -2239,7 +2211,7 @@ var url = self.getUrl("Artists/" + self.encodeName(name), options); - return self.fetchJSON(url); + return self.getJSON(url); }; /** @@ -2485,7 +2457,7 @@ dataType: "json", contentType: "application/json" - }).done(function (result) { + }).then(function (result) { if (self.onAuthenticated) { self.onAuthenticated(self, result); @@ -2493,7 +2465,7 @@ deferred.resolveWith(null, [result]); - }).fail(function () { + }, function () { deferred.reject(); }); @@ -2528,11 +2500,11 @@ currentPassword: CryptoJS.SHA1(currentPassword).toString(), newPassword: CryptoJS.SHA1(newPassword).toString() } - }).done(function (result) { + }).then(function (result) { deferred.resolveWith(null, [result]); - }).fail(function () { + }, function () { deferred.reject(); }); @@ -2565,11 +2537,11 @@ data: { newPassword: CryptoJS.SHA1(newPassword).toString() } - }).done(function (result) { + }).then(function (result) { deferred.resolveWith(null, [result]); - }).fail(function () { + }, function () { deferred.reject(); }); @@ -2862,7 +2834,7 @@ url = self.getUrl("Items", options); } - return self.fetchJSON(url); + return self.getJSON(url); }; self.getChannels = function (query) { diff --git a/dashboard-ui/apiclient/connectionmanager.js b/dashboard-ui/apiclient/connectionmanager.js index fd8c1a0e69..b771220a07 100644 --- a/dashboard-ui/apiclient/connectionmanager.js +++ b/dashboard-ui/apiclient/connectionmanager.js @@ -83,13 +83,63 @@ return baseUrl + "/emby/" + handler; } + function getFetchPromise(request) { + + var headers = request.headers || {}; + + if (request.dataType == 'json') { + headers.accept = 'application/json'; + } + + var fetchRequest = { + headers: headers, + method: request.type + }; + + if (request.data) { + + if (typeof request.data === 'string') { + fetchRequest.body = request.data; + } + } + + if (request.contentType) { + + headers['Content-Type'] = request.contentType; + } + + return fetch(request.url, fetchRequest); + } + + function ajax(request) { + + return getFetchPromise(request).then(function (response) { + + if (response.status < 400) { + + if (request.dataType == 'json' || request.headers.accept == 'application/json') { + return response.json(); + } else { + return response; + } + } else { + onFetchFail(request.url, response); + return Promise.reject(response); + } + + }, function () { + onFetchFail(request.url, {}); + return Promise.reject({}); + }); + } + function tryConnect(url, timeout) { url = getEmbyServerUrl(url, "system/info/public"); logger.log('tryConnect url: ' + url); - return HttpClient.send({ + return ajax({ type: "GET", url: url, @@ -360,12 +410,12 @@ connectUser = null; - getConnectUser(credentials.ConnectUserId, credentials.ConnectAccessToken).done(function (user) { + getConnectUser(credentials.ConnectUserId, credentials.ConnectAccessToken).then(function (user) { onConnectUserSignIn(user); deferred.resolveWith(null, [[]]); - }).fail(function () { + }, function () { deferred.resolveWith(null, [[]]); }); @@ -387,7 +437,7 @@ var url = "https://connect.emby.media/service/user?id=" + userId; - return HttpClient.send({ + return ajax({ type: "GET", url: url, dataType: "json", @@ -412,7 +462,7 @@ url = getEmbyServerUrl(url, "Connect/Exchange?format=json&ConnectUserId=" + credentials.ConnectUserId); - return HttpClient.send({ + return ajax({ type: "GET", url: url, dataType: "json", @@ -420,15 +470,18 @@ "X-MediaBrowser-Token": server.ExchangeToken } - }).done(function (auth) { + }).then(function (auth) { server.UserId = auth.LocalUserId; server.AccessToken = auth.AccessToken; + return auth; - }).fail(function () { + }, function () { server.UserId = null; server.AccessToken = null; + return Promise.reject(); + }); } @@ -438,7 +491,7 @@ var url = MediaBrowser.ServerInfo.getServerAddress(server, connectionMode); - HttpClient.send({ + ajax({ type: "GET", url: getEmbyServerUrl(url, "System/Info"), @@ -447,13 +500,13 @@ "X-MediaBrowser-Token": server.AccessToken } - }).done(function (systemInfo) { + }).then(function (systemInfo) { updateServerInfo(server, systemInfo); if (server.UserId) { - HttpClient.send({ + ajax({ type: "GET", url: getEmbyServerUrl(url, "users/" + server.UserId), @@ -462,12 +515,12 @@ "X-MediaBrowser-Token": server.AccessToken } - }).done(function (user) { + }).then(function (user) { onLocalUserSignIn(user); deferred.resolveWith(null, [[]]); - }).fail(function () { + }, function () { server.UserId = null; server.AccessToken = null; @@ -475,7 +528,7 @@ }); } - }).fail(function () { + }, function () { server.UserId = null; server.AccessToken = null; @@ -520,7 +573,7 @@ var localUser; - function onLocalUserDone() { + function onLocalUserDone(e) { var image = getImageUrl(localUser); @@ -528,7 +581,7 @@ { localUser: localUser, name: connectUser ? connectUser.Name : (localUser ? localUser.Name : null), - canManageServer: localUser && localUser.Policy.IsAdministrator, + canManageServer: localUser ? localUser.Policy.IsAdministrator : false, imageUrl: image.url, supportsImageParams: image.supportsParams }]); @@ -537,9 +590,11 @@ function onEnsureConnectUserDone() { if (apiClient && apiClient.getCurrentUserId()) { - apiClient.getCurrentUser().done(function (u) { + apiClient.getCurrentUser().then(function (u) { localUser = u; - }).always(onLocalUserDone); + onLocalUserDone(); + + }, onLocalUserDone); } else { onLocalUserDone(); } @@ -548,7 +603,7 @@ var credentials = credentialProvider.credentials(); if (credentials.ConnectUserId && credentials.ConnectAccessToken && !(apiClient && apiClient.getCurrentUserId())) { - ensureConnectUser(credentials).always(onEnsureConnectUserDone); + ensureConnectUser(credentials).then(onEnsureConnectUserDone, onEnsureConnectUserDone); } else { onEnsureConnectUserDone(); } @@ -579,7 +634,7 @@ } } - return DeferredBuilder.when(promises).done(function () { + return DeferredBuilder.when(promises).then(function () { var credentials = credentialProvider.credentials(); @@ -624,7 +679,10 @@ serverId: serverInfo.Id }; - return apiClient.logout().always(function () { + return apiClient.logout().then(function () { + + Events.trigger(self, 'localusersignedout', [logoutInfo]); + }, function () { Events.trigger(self, 'localusersignedout', [logoutInfo]); }); @@ -643,7 +701,7 @@ var url = "https://connect.emby.media/service/servers?userId=" + credentials.ConnectUserId; - HttpClient.send({ + ajax({ type: "GET", url: url, dataType: "json", @@ -652,7 +710,7 @@ "X-Connect-UserToken": credentials.ConnectAccessToken } - }).done(function (servers) { + }).then(function (servers) { servers = servers.map(function (i) { return { @@ -668,7 +726,7 @@ deferred.resolveWith(null, [servers]); - }).fail(function () { + }, function () { deferred.resolveWith(null, [[]]); }); @@ -701,9 +759,9 @@ var connectServersPromise = getConnectServers(credentials); var findServersPromise = findServers(); - connectServersPromise.done(function (connectServers) { + connectServersPromise.then(function (connectServers) { - findServersPromise.done(function (foundServers) { + findServersPromise.then(function (foundServers) { var servers = credentials.Servers.slice(0); mergeServers(servers, foundServers); @@ -748,7 +806,7 @@ var deferred = DeferredBuilder.Deferred(); require(['serverdiscovery'], function () { - ServerDiscovery.findServers(1000).done(function (foundServers) { + ServerDiscovery.findServers(1000).then(function (foundServers) { var servers = foundServers.map(function (foundServer) { @@ -798,9 +856,9 @@ var deferred = DeferredBuilder.Deferred(); - self.getAvailableServers().done(function (servers) { + self.getAvailableServers().then(function (servers) { - self.connectToServers(servers).done(function (result) { + self.connectToServers(servers).then(function (result) { deferred.resolveWith(null, [result]); @@ -823,7 +881,7 @@ if (servers.length == 1) { - self.connectToServer(servers[0]).done(function (result) { + self.connectToServer(servers[0]).then(function (result) { if (result.State == MediaBrowser.ConnectionState.Unavailable) { @@ -842,7 +900,7 @@ var firstServer = servers.length ? servers[0] : null; // See if we have any saved credentials and can auto sign in if (firstServer) { - self.connectToServer(firstServer).done(function (result) { + self.connectToServer(firstServer).then(function (result) { if (result.State == MediaBrowser.ConnectionState.SignedIn) { @@ -948,12 +1006,12 @@ logger.log('testing connection mode ' + mode + ' with server ' + server.Name); - tryConnect(address, timeout).done(function (result) { + tryConnect(address, timeout).then(function (result) { logger.log('calling onSuccessfulConnection with connection mode ' + mode + ' with server ' + server.Name); onSuccessfulConnection(server, result, mode, options, deferred); - }).fail(function () { + }, function () { logger.log('test failed for connection mode ' + mode + ' with server ' + server.Name); @@ -977,10 +1035,14 @@ var credentials = credentialProvider.credentials(); if (credentials.ConnectAccessToken) { - ensureConnectUser(credentials).done(function () { + ensureConnectUser(credentials).then(function () { if (server.ExchangeToken) { - addAuthenticationInfoFromConnect(server, connectionMode, credentials).always(function () { + addAuthenticationInfoFromConnect(server, connectionMode, credentials).then(function () { + + afterConnectValidated(server, credentials, systemInfo, connectionMode, true, options, deferred); + + }, function () { afterConnectValidated(server, credentials, systemInfo, connectionMode, true, options, deferred); }); @@ -1000,7 +1062,7 @@ if (verifyLocalAuthentication && server.AccessToken) { - validateAuthentication(server, connectionMode).done(function () { + validateAuthentication(server, connectionMode).then(function () { afterConnectValidated(server, credentials, systemInfo, connectionMode, false, options, deferred); }); @@ -1075,7 +1137,7 @@ resolveWithFailure(deferred); } - tryConnect(address, defaultTimeout).done(function (publicInfo) { + tryConnect(address, defaultTimeout).then(function (publicInfo) { logger.log('connectToAddress ' + address + ' succeeded'); @@ -1085,13 +1147,13 @@ }; updateServerInfo(server, publicInfo); - self.connectToServer(server).done(function (result) { + self.connectToServer(server).then(function (result) { deferred.resolveWith(null, [result]); - }).fail(onFail); + }, onFail); - }).fail(onFail); + }, onFail); return deferred.promise(); }; @@ -1113,7 +1175,7 @@ var md5 = self.getConnectPasswordHash(password); - HttpClient.send({ + ajax({ type: "POST", url: "https://connect.emby.media/service/user/authenticate", data: { @@ -1126,7 +1188,7 @@ "X-Application": appName + "/" + appVersion } - }).done(function (result) { + }).then(function (result) { var credentials = credentialProvider.credentials(); @@ -1139,7 +1201,7 @@ deferred.resolveWith(null, [result]); - }).fail(function () { + }, function () { deferred.reject(); }); }); @@ -1176,7 +1238,7 @@ var md5 = self.getConnectPasswordHash(password); - HttpClient.send({ + ajax({ type: "POST", url: "https://connect.emby.media/service/register", data: { @@ -1191,11 +1253,11 @@ "X-CONNECT-TOKEN": "CONNECT-REGISTER" } - }).done(function (result) { + }).then(function (result) { deferred.resolve(null, []); - }).fail(function (e) { + }, function (e) { try { @@ -1248,7 +1310,7 @@ var url = "https://connect.emby.media/service/servers?userId=" + self.connectUserId() + "&status=Waiting"; - return HttpClient.send({ + return ajax({ type: "GET", url: url, dataType: "json", @@ -1299,7 +1361,7 @@ var url = "https://connect.emby.media/service/serverAuthorizations?serverId=" + server.ConnectServerId + "&userId=" + connectUserId; - HttpClient.send({ + ajax({ type: "DELETE", url: url, headers: { @@ -1307,7 +1369,7 @@ "X-Application": appName + "/" + appVersion } - }).always(onDone); + }).then(onDone, onDone); return deferred.promise(); }; @@ -1328,14 +1390,12 @@ var url = "https://connect.emby.media/service/serverAuthorizations?serverId=" + serverId + "&userId=" + self.connectUserId(); - return HttpClient.send({ - type: "DELETE", - url: url, + return fetch(url, { + method: "DELETE", headers: { "X-Connect-UserToken": connectToken, "X-Application": appName + "/" + appVersion } - }); }; @@ -1355,7 +1415,7 @@ var url = "https://connect.emby.media/service/ServerAuthorizations/accept?serverId=" + serverId + "&userId=" + self.connectUserId(); - return HttpClient.send({ + return ajax({ type: "GET", url: url, headers: { @@ -1370,7 +1430,7 @@ var deferred = DeferredBuilder.Deferred(); - self.getAvailableServers().done(function (servers) { + self.getAvailableServers().then(function (servers) { var matchedServers = servers.filter(function (s) { return stringEqualsIgnoreCase(s.Id, apiClient.serverInfo().Id); @@ -1385,7 +1445,7 @@ if (!match.DateLastLocalConnection) { - ApiClient.fetchJSON(ApiClient.getUrl('System/Endpoint')).then(function (info) { + ApiClient.getJSON(ApiClient.getUrl('System/Endpoint')).then(function (info) { if (info.IsInNetwork) { @@ -1405,7 +1465,7 @@ onLocalCheckSuccess(feature, apiClient, deferred); - }).fail(function () { + }, function () { deferred.reject(); }); @@ -1431,10 +1491,10 @@ function onLocalCheckSuccess(feature, apiClient, deferred) { - apiClient.getRegistrationInfo(feature).done(function (result) { + apiClient.getRegistrationInfo(feature).then(function (result) { deferred.resolveWith(null, [result]); - }).fail(function () { + }, function () { deferred.reject(); }); diff --git a/dashboard-ui/apiclient/sync/contentuploader.js b/dashboard-ui/apiclient/sync/contentuploader.js index c07aff9f4f..f546e924da 100644 --- a/dashboard-ui/apiclient/sync/contentuploader.js +++ b/dashboard-ui/apiclient/sync/contentuploader.js @@ -8,7 +8,7 @@ var deferred = DeferredBuilder.Deferred(); - LocalAssetManager.getCameraPhotos().done(function (photos) { + LocalAssetManager.getCameraPhotos().then(function (photos) { if (!photos.length) { deferred.resolve(); @@ -17,7 +17,7 @@ var apiClient = connectionManager.getApiClient(server.Id); - apiClient.getContentUploadHistory().done(function (uploadHistory) { + apiClient.getContentUploadHistory().then(function (uploadHistory) { photos = getFilesToUpload(photos, uploadHistory); @@ -25,11 +25,11 @@ uploadNext(photos, 0, server, apiClient, deferred); - }).fail(function () { + }, function () { deferred.reject(); }); - }).fail(function () { + }, function () { deferred.reject(); }); @@ -67,10 +67,10 @@ return; } - uploadFile(files[index], apiClient).done(function () { + uploadFile(files[index], apiClient).then(function () { uploadNext(files, index + 1, server, apiClient, deferred); - }).fail(function () { + }, function () { uploadNext(files, index + 1, server, apiClient, deferred); }); } @@ -93,12 +93,12 @@ Logger.log('Uploading file to ' + url); - new MediaBrowser.FileUpload().upload(file, name, url).done(function () { + new MediaBrowser.FileUpload().upload(file, name, url).then(function () { Logger.log('File upload succeeded'); deferred.resolve(); - }).fail(function () { + }, function () { Logger.log('File upload failed'); deferred.reject(); diff --git a/dashboard-ui/apiclient/sync/mediasync.js b/dashboard-ui/apiclient/sync/mediasync.js index ddde0970b5..10ba774649 100644 --- a/dashboard-ui/apiclient/sync/mediasync.js +++ b/dashboard-ui/apiclient/sync/mediasync.js @@ -8,26 +8,26 @@ var deferred = DeferredBuilder.Deferred(); - reportOfflineActions(apiClient, serverInfo).done(function () { + reportOfflineActions(apiClient, serverInfo).then(function () { // Do the first data sync - syncData(apiClient, serverInfo, false).done(function () { + syncData(apiClient, serverInfo, false).then(function () { // Download new content - getNewMedia(apiClient, serverInfo, options).done(function () { + getNewMedia(apiClient, serverInfo, options).then(function () { // Do the second data sync - syncData(apiClient, serverInfo, false).done(function () { + syncData(apiClient, serverInfo, false).then(function () { deferred.resolve(); - }).fail(getOnFail(deferred)); + }, getOnFail(deferred)); - }).fail(getOnFail(deferred)); + }, getOnFail(deferred)); - }).fail(getOnFail(deferred)); + }, getOnFail(deferred)); - }).fail(getOnFail(deferred)); + }, getOnFail(deferred)); return deferred.promise(); }; @@ -40,24 +40,24 @@ require(['localassetmanager'], function () { - LocalAssetManager.getOfflineActions(serverInfo.Id).done(function (actions) { + LocalAssetManager.getOfflineActions(serverInfo.Id).then(function (actions) { if (!actions.length) { deferred.resolve(); return; } - apiClient.reportOfflineActions(actions).done(function () { + apiClient.reportOfflineActions(actions).then(function () { - LocalAssetManager.deleteOfflineActions(actions).done(function () { + LocalAssetManager.deleteOfflineActions(actions).then(function () { deferred.resolve(); - }).fail(getOnFail(deferred)); + }, getOnFail(deferred)); - }).fail(getOnFail(deferred)); + }, getOnFail(deferred)); - }).fail(getOnFail(deferred)); + }, getOnFail(deferred)); }); return deferred.promise(); @@ -71,7 +71,7 @@ require(['localassetmanager'], function () { - LocalAssetManager.getServerItemIds(serverInfo.Id).done(function (localIds) { + LocalAssetManager.getServerItemIds(serverInfo.Id).then(function (localIds) { var request = { TargetId: apiClient.deviceId(), @@ -79,13 +79,13 @@ OfflineUserIds: (serverInfo.Users || []).map(function (u) { return u.Id; }) }; - apiClient.syncData(request).done(function (result) { + apiClient.syncData(request).then(function (result) { afterSyncData(apiClient, serverInfo, syncUserItemAccess, result, deferred); - }).fail(getOnFail(deferred)); + }, getOnFail(deferred)); - }).fail(getOnFail(deferred)); + }, getOnFail(deferred)); }); return deferred.promise(); @@ -95,20 +95,20 @@ Logger.log('Begin afterSyncData'); - removeLocalItems(syncDataResult, serverInfo.Id).done(function (result) { + removeLocalItems(syncDataResult, serverInfo.Id).then(function (result) { if (enableSyncUserItemAccess) { - syncUserItemAccess(syncDataResult, serverInfo.Id).done(function () { + syncUserItemAccess(syncDataResult, serverInfo.Id).then(function () { deferred.resolve(); - }).fail(getOnFail(deferred)); + }, getOnFail(deferred)); } else { deferred.resolve(); } - }).fail(getOnFail(deferred)); + }, getOnFail(deferred)); deferred.resolve(); } @@ -134,10 +134,10 @@ return; } - removeLocalItem(itemIdsToRemove[index], serverId).done(function () { + removeLocalItem(itemIdsToRemove[index], serverId).then(function () { removeNextLocalItem(itemIdsToRemove, index + 1, serverId, deferred); - }).fail(function () { + }, function () { removeNextLocalItem(itemIdsToRemove, index + 1, serverId, deferred); }); } @@ -150,11 +150,11 @@ require(['localassetmanager'], function () { - LocalAssetManager.removeLocalItem(itemId, serverId).done(function (localIds) { + LocalAssetManager.removeLocalItem(itemId, serverId).then(function (localIds) { deferred.resolve(); - }).fail(getOnFail(deferred)); + }, getOnFail(deferred)); }); return deferred.promise(); @@ -166,11 +166,11 @@ var deferred = DeferredBuilder.Deferred(); - apiClient.getReadySyncItems(apiClient.deviceId()).done(function (jobItems) { + apiClient.getReadySyncItems(apiClient.deviceId()).then(function (jobItems) { getNextNewItem(jobItems, 0, apiClient, serverInfo, options, deferred); - }).fail(getOnFail(deferred)); + }, getOnFail(deferred)); return deferred.promise(); } @@ -194,7 +194,7 @@ } }; - getNewItem(jobItems[index], apiClient, serverInfo, options).done(goNext).fail(goNext); + getNewItem(jobItems[index], apiClient, serverInfo, options).then(goNext, goNext); } function getNewItem(jobItem, apiClient, serverInfo, options) { @@ -206,32 +206,32 @@ require(['localassetmanager'], function () { var libraryItem = jobItem.Item; - LocalAssetManager.createLocalItem(libraryItem, serverInfo, jobItem.OriginalFileName).done(function (localItem) { + LocalAssetManager.createLocalItem(libraryItem, serverInfo, jobItem.OriginalFileName).then(function (localItem) { - downloadMedia(apiClient, jobItem, localItem, options).done(function (isQueued) { + downloadMedia(apiClient, jobItem, localItem, options).then(function (isQueued) { if (isQueued) { deferred.resolve(); return; } - getImages(apiClient, jobItem, localItem).done(function () { + getImages(apiClient, jobItem, localItem).then(function () { - getSubtitles(apiClient, jobItem, localItem).done(function () { + getSubtitles(apiClient, jobItem, localItem).then(function () { - apiClient.reportSyncJobItemTransferred(jobItem.SyncJobItemId).done(function () { + apiClient.reportSyncJobItemTransferred(jobItem.SyncJobItemId).then(function () { deferred.resolve(); - }).fail(getOnFail(deferred)); + }, getOnFail(deferred)); - }).fail(getOnFail(deferred)); + }, getOnFail(deferred)); - }).fail(getOnFail(deferred)); + }, getOnFail(deferred)); - }).fail(getOnFail(deferred)); + }, getOnFail(deferred)); - }).fail(getOnFail(deferred)); + }, getOnFail(deferred)); }); return deferred.promise(); @@ -254,19 +254,19 @@ options = options || {}; - LocalAssetManager.downloadFile(url, localPath, options.enableBackgroundTransfer, options.enableNewDownloads).done(function (path, isQueued) { + LocalAssetManager.downloadFile(url, localPath, options.enableBackgroundTransfer, options.enableNewDownloads).then(function (path, isQueued) { if (isQueued) { deferred.resolveWith(null, [true]); return; } - LocalAssetManager.addOrUpdateLocalItem(localItem).done(function () { + LocalAssetManager.addOrUpdateLocalItem(localItem).then(function () { deferred.resolveWith(null, [false]); - }).fail(getOnFail(deferred)); + }, getOnFail(deferred)); - }).fail(getOnFail(deferred)); + }, getOnFail(deferred)); }); @@ -334,7 +334,7 @@ return; } - downloadImage(apiClient, serverId, itemId, imageTag, imageType).done(function () { + downloadImage(apiClient, serverId, itemId, imageTag, imageType).then(function () { // For the sake of simplicity, limit to one image deferred.resolve(); @@ -342,7 +342,7 @@ getNextImage(index + 1, apiClient, localItem, deferred); - }).fail(getOnFail(deferred)); + }, getOnFail(deferred)); } function downloadImage(apiClient, serverId, itemId, imageTag, imageType) { @@ -352,7 +352,7 @@ require(['localassetmanager'], function () { - LocalAssetManager.hasImage(serverId, itemId, imageTag).done(function (hasImage) { + LocalAssetManager.hasImage(serverId, itemId, imageTag).then(function (hasImage) { if (hasImage) { deferred.resolve(); @@ -365,11 +365,11 @@ api_key: apiClient.accessToken() }); - LocalAssetManager.downloadImage(imageUrl, serverId, itemId, imageTag).done(function () { + LocalAssetManager.downloadImage(imageUrl, serverId, itemId, imageTag).then(function () { deferred.resolve(); - }).fail(getOnFail(deferred)); + }, getOnFail(deferred)); }); }); @@ -412,11 +412,11 @@ return; } - getItemSubtitle(file, apiClient, jobItem, localItem, mediaSource).done(function () { + getItemSubtitle(file, apiClient, jobItem, localItem, mediaSource).then(function () { getNextSubtitle(files, index + 1, apiClient, jobItem, localItem, mediaSource, deferred); - }).fail(function () { + }, function () { getNextSubtitle(files, index + 1, apiClient, jobItem, localItem, mediaSource, deferred); }); } @@ -445,14 +445,14 @@ require(['localassetmanager'], function () { - LocalAssetManager.downloadSubtitles(url, localItem, subtitleStream).done(function (subtitlePath) { + LocalAssetManager.downloadSubtitles(url, localItem, subtitleStream).then(function (subtitlePath) { subtitleStream.Path = subtitlePath; - LocalAssetManager.addOrUpdateLocalItem(localItem).done(function () { + LocalAssetManager.addOrUpdateLocalItem(localItem).then(function () { deferred.resolve(); - }).fail(getOnFail(deferred)); + }, getOnFail(deferred)); - }).fail(getOnFail(deferred)); + }, getOnFail(deferred)); }); return deferred.promise(); @@ -483,10 +483,10 @@ return; } - syncUserAccessForItem(itemIds[index], syncDataResult).done(function () { + syncUserAccessForItem(itemIds[index], syncDataResult).then(function () { syncNextUserAccessForItem(itemIds, index + 1, syncDataResult, serverId, deferred); - }).fail(function () { + }, function () { syncNextUserAccessForItem(itemIds, index + 1, syncDataResult, serverId, deferred); }); } @@ -498,7 +498,7 @@ require(['localassetmanager'], function () { - LocalAssetManager.getUserIdsWithAccess(itemId, serverId).done(function (savedUserIdsWithAccess) { + LocalAssetManager.getUserIdsWithAccess(itemId, serverId).then(function (savedUserIdsWithAccess) { var userIdsWithAccess = syncDataResult.ItemUserAccess[itemId]; @@ -508,12 +508,12 @@ } else { - LocalAssetManager.saveUserIdsWithAccess(itemId, serverId, userIdsWithAccess).done(function () { + LocalAssetManager.saveUserIdsWithAccess(itemId, serverId, userIdsWithAccess).then(function () { deferred.resolve(); - }).fail(getOnFail(deferred)); + }, getOnFail(deferred)); } - }).fail(getOnFail(deferred)); + }, getOnFail(deferred)); }); return deferred.promise(); diff --git a/dashboard-ui/apiclient/sync/multiserversync.js b/dashboard-ui/apiclient/sync/multiserversync.js index 8171b3e482..4521ce898e 100644 --- a/dashboard-ui/apiclient/sync/multiserversync.js +++ b/dashboard-ui/apiclient/sync/multiserversync.js @@ -31,11 +31,11 @@ require(['serversync'], function () { - new MediaBrowser.ServerSync(connectionManager).sync(server, options).done(function () { + new MediaBrowser.ServerSync(connectionManager).sync(server, options).then(function () { syncNext(servers, index + 1, options, deferred); - }).fail(function () { + }, function () { syncNext(servers, index + 1, options, deferred); }); diff --git a/dashboard-ui/apiclient/sync/offlineusersync.js b/dashboard-ui/apiclient/sync/offlineusersync.js index 63ee8e135e..2ae3b810b0 100644 --- a/dashboard-ui/apiclient/sync/offlineusersync.js +++ b/dashboard-ui/apiclient/sync/offlineusersync.js @@ -24,10 +24,10 @@ return; } - syncUser(users[index], apiClient).done(function () { + syncUser(users[index], apiClient).then(function () { syncNext(users, index + 1, deferred, apiClient, server); - }).fail(function () { + }, function () { syncNext(users, index + 1, deferred, apiClient, server); }); } @@ -36,26 +36,26 @@ var deferred = DeferredBuilder.Deferred(); - apiClient.getOfflineUser(user.Id).done(function (result) { + apiClient.getOfflineUser(user.Id).then(function (result) { require(['localassetmanager'], function () { - LocalAssetManager.saveOfflineUser(result).done(function () { + LocalAssetManager.saveOfflineUser(result).then(function () { deferred.resolve(); - }).fail(function () { + }, function () { deferred.resolve(); }); }); - }).fail(function () { + }, function () { // TODO: We should only delete if there's a 401 response require(['localassetmanager'], function () { - LocalAssetManager.deleteOfflineUser(user.Id).done(function () { + LocalAssetManager.deleteOfflineUser(user.Id).then(function () { deferred.resolve(); - }).fail(function () { + }, function () { deferred.resolve(); }); }); diff --git a/dashboard-ui/apiclient/sync/serversync.js b/dashboard-ui/apiclient/sync/serversync.js index 4fbb3f4eb5..ae4234a2f1 100644 --- a/dashboard-ui/apiclient/sync/serversync.js +++ b/dashboard-ui/apiclient/sync/serversync.js @@ -21,7 +21,7 @@ reportCapabilities: false }; - connectionManager.connectToServer(server, connectionOptions).done(function (result) { + connectionManager.connectToServer(server, connectionOptions).then(function (result) { if (result.State == MediaBrowser.ConnectionState.SignedIn) { performSync(server, options, deferred); @@ -30,7 +30,7 @@ deferred.reject(); } - }).fail(function () { + }, function () { Logger.log('Unable to connect to server id: ' + server.Id); deferred.reject(); @@ -62,13 +62,13 @@ require(['contentuploader'], function () { - new MediaBrowser.ContentUploader(connectionManager).uploadImages(server).done(function () { + new MediaBrowser.ContentUploader(connectionManager).uploadImages(server).then(function () { Logger.log("ContentUploaded succeeded to server: " + server.Id); nextAction(); - }).fail(function () { + }, function () { Logger.log("ContentUploaded failed to server: " + server.Id); @@ -88,13 +88,13 @@ var apiClient = connectionManager.getApiClient(server.Id); - new MediaBrowser.OfflineUserSync().sync(apiClient, server).done(function () { + new MediaBrowser.OfflineUserSync().sync(apiClient, server).then(function () { Logger.log("OfflineUserSync succeeded to server: " + server.Id); syncMedia(server, options, deferred); - }).fail(function () { + }, function () { Logger.log("OfflineUserSync failed to server: " + server.Id); @@ -109,13 +109,13 @@ var apiClient = connectionManager.getApiClient(server.Id); - new MediaBrowser.MediaSync().sync(apiClient, server, options).done(function () { + new MediaBrowser.MediaSync().sync(apiClient, server, options).then(function () { Logger.log("MediaSync succeeded to server: " + server.Id); deferred.resolve(); - }).fail(function () { + }, function () { Logger.log("MediaSync failed to server: " + server.Id); diff --git a/dashboard-ui/components/collectioneditor/collectioneditor.js b/dashboard-ui/components/collectioneditor/collectioneditor.js index 42b0126aa4..a5de2a6b46 100644 --- a/dashboard-ui/components/collectioneditor/collectioneditor.js +++ b/dashboard-ui/components/collectioneditor/collectioneditor.js @@ -33,7 +33,7 @@ url: url, dataType: "json" - }).done(function (result) { + }).then(function (result) { Dashboard.hideLoadingMsg(); @@ -67,7 +67,7 @@ type: "POST", url: url - }).done(function () { + }).then(function () { Dashboard.hideLoadingMsg(); diff --git a/dashboard-ui/components/directorybrowser/directorybrowser.js b/dashboard-ui/components/directorybrowser/directorybrowser.js index 35c3cc9900..8ce1057862 100644 --- a/dashboard-ui/components/directorybrowser/directorybrowser.js +++ b/dashboard-ui/components/directorybrowser/directorybrowser.js @@ -53,7 +53,7 @@ parentPathPromise = parentPathPromise.promise(); } - $.when(promise, parentPathPromise).done(function (response1, response2) { + $.when(promise, parentPathPromise).then(function (response1, response2) { var folders = response1[0]; var parentPath = response2 && response2.length ? response2[0] || '' : ''; @@ -84,7 +84,7 @@ Dashboard.hideLoadingMsg(); - }).fail(function () { + }, function () { $('#txtDirectoryPickerPath', page).val(""); $('.results', page).html(''); @@ -211,7 +211,7 @@ fileOptions.includeFiles = options.includeFiles; } - getSystemInfo().done(function (systemInfo) { + getSystemInfo().then(function (systemInfo) { require(['components/paperdialoghelper'], function () { diff --git a/dashboard-ui/components/imagedownloader/imagedownloader.js b/dashboard-ui/components/imagedownloader/imagedownloader.js index 61b46ca8c1..b7239310ae 100644 --- a/dashboard-ui/components/imagedownloader/imagedownloader.js +++ b/dashboard-ui/components/imagedownloader/imagedownloader.js @@ -38,7 +38,7 @@ options.ProviderName = provider; } - ApiClient.getAvailableRemoteImages(options).done(function (result) { + ApiClient.getAvailableRemoteImages(options).then(function (result) { renderRemoteImages(page, result, browsableImageType, options.startIndex, options.limit); @@ -125,7 +125,7 @@ Dashboard.showLoadingMsg(); - ApiClient.downloadRemoteImage(options).done(function () { + ApiClient.downloadRemoteImage(options).then(function () { hasChanges = true; var dlg = $(page).parents('paper-dialog')[0]; @@ -260,13 +260,12 @@ Dashboard.showLoadingMsg(); - HttpClient.send({ + var xhr = new XMLHttpRequest(); + xhr.open('GET', 'components/imagedownloader/imagedownloader.template.html', true); - type: 'GET', - url: 'components/imagedownloader/imagedownloader.template.html' - - }).done(function (template) { + xhr.onload = function (e) { + var template = this.response; currentItemId = itemId; currentItemType = itemType; @@ -299,7 +298,9 @@ }); reloadBrowsableImages(editorContent); - }); + } + + xhr.send(); } function onDialogClosed() { diff --git a/dashboard-ui/components/imageeditor/imageeditor.js b/dashboard-ui/components/imageeditor/imageeditor.js index d2498f6d51..7440601dd2 100644 --- a/dashboard-ui/components/imageeditor/imageeditor.js +++ b/dashboard-ui/components/imageeditor/imageeditor.js @@ -31,7 +31,7 @@ currentItem = item; - ApiClient.getRemoteImageProviders(getBaseRemoteOptions()).done(function (providers) { + ApiClient.getRemoteImageProviders(getBaseRemoteOptions()).then(function (providers) { if (providers.length) { $('.btnBrowseAllImages', page).removeClass('hide'); @@ -39,7 +39,7 @@ $('.btnBrowseAllImages', page).addClass('hide'); } - ApiClient.getItemImageInfos(currentItem.Id).done(function (imageInfos) { + ApiClient.getItemImageInfos(currentItem.Id).then(function (imageInfos) { renderStandardImages(page, item, imageInfos, providers); renderBackdrops(page, item, imageInfos, providers); @@ -122,7 +122,7 @@ Dashboard.confirm(Globalize.translate('DeleteImageConfirmation'), Globalize.translate('HeaderDeleteImage'), function (result) { if (result) { - ApiClient.deleteItemImage(currentItem.Id, type, index).done(function () { + ApiClient.deleteItemImage(currentItem.Id, type, index).then(function () { hasChanges = true; reload(page); @@ -137,7 +137,7 @@ var type = this.getAttribute('data-imagetype'); var index = parseInt(this.getAttribute('data-index')); var newIndex = parseInt(this.getAttribute('data-newindex')); - ApiClient.updateItemImageIndex(currentItem.Id, type, index, newIndex).done(function () { + ApiClient.updateItemImageIndex(currentItem.Id, type, index, newIndex).then(function () { hasChanges = true; reload(page); @@ -192,7 +192,7 @@ function showImageDownloader(page, imageType) { require(['components/imagedownloader/imagedownloader'], function () { - ImageDownloader.show(currentItem.Id, currentItem.Type, imageType).done(function (hasChanged) { + ImageDownloader.show(currentItem.Id, currentItem.Type, imageType).then(function (hasChanged) { if (hasChanged) { hasChanges = true; @@ -212,7 +212,7 @@ theme: options.theme - }).done(function (hasChanged) { + }).then(function (hasChanged) { if (hasChanged) { hasChanges = true; @@ -233,13 +233,12 @@ Dashboard.showLoadingMsg(); - HttpClient.send({ + var xhr = new XMLHttpRequest(); + xhr.open('GET', 'components/imageeditor/imageeditor.template.html', true); - type: 'GET', - url: 'components/imageeditor/imageeditor.template.html' - - }).done(function (template) { + xhr.onload = function (e) { + var template = this.response; ApiClient.getItem(Dashboard.getCurrentUserId(), itemId).then(function (item) { var dlg = PaperDialogHelper.createDialog({ @@ -269,12 +268,14 @@ var editorContent = dlg.querySelector('.editorContent'); reload(editorContent, item); - $('.btnCloseDialog', dlg).on('click', function() { - + $('.btnCloseDialog', dlg).on('click', function () { + PaperDialogHelper.close(dlg); }); }); - }); + } + + xhr.send(); } function onDialogClosed() { diff --git a/dashboard-ui/components/imageuploader/imageuploader.js b/dashboard-ui/components/imageuploader/imageuploader.js index 3a7b584407..24d47f6693 100644 --- a/dashboard-ui/components/imageuploader/imageuploader.js +++ b/dashboard-ui/components/imageuploader/imageuploader.js @@ -85,7 +85,7 @@ var imageType = $('#selectImageType', page).val(); - ApiClient.uploadItemImage(currentItemId, imageType, file).done(function () { + ApiClient.uploadItemImage(currentItemId, imageType, file).then(function () { $('#uploadImage', page).val('').trigger('change'); Dashboard.hideLoadingMsg(); @@ -125,13 +125,12 @@ options = options || {}; - HttpClient.send({ + var xhr = new XMLHttpRequest(); + xhr.open('GET', 'components/imageuploader/imageuploader.template.html', true); - type: 'GET', - url: 'components/imageuploader/imageuploader.template.html' - - }).done(function (template) { + xhr.onload = function (e) { + var template = this.response; currentItemId = itemId; var dlg = PaperDialogHelper.createDialog({ @@ -163,7 +162,9 @@ PaperDialogHelper.close(dlg); }); - }); + } + + xhr.send(); } function onDialogClosed() { diff --git a/dashboard-ui/components/itemidentifier/itemidentifier.js b/dashboard-ui/components/itemidentifier/itemidentifier.js index 1f8a52d65c..399cf85a0a 100644 --- a/dashboard-ui/components/itemidentifier/itemidentifier.js +++ b/dashboard-ui/components/itemidentifier/itemidentifier.js @@ -69,7 +69,7 @@ data: JSON.stringify(lookupInfo), contentType: "application/json" - }).done(function (results) { + }).then(function (results) { Dashboard.hideLoadingMsg(); showIdentificationSearchResults(page, results); @@ -213,14 +213,14 @@ data: JSON.stringify(currentSearchResult), contentType: "application/json" - }).done(function () { + }).then(function () { hasChanges = true; Dashboard.hideLoadingMsg(); PaperDialogHelper.close(document.querySelector('.identifyDialog')); - }).fail(function () { + }, function () { Dashboard.hideLoadingMsg(); @@ -236,7 +236,7 @@ function showIdentificationForm(page, item) { - ApiClient.fetchJSON(ApiClient.getUrl("Items/" + item.Id + "/ExternalIdInfos")).then(function (idList) { + ApiClient.getJSON(ApiClient.getUrl("Items/" + item.Id + "/ExternalIdInfos")).then(function (idList) { var html = ''; @@ -281,13 +281,12 @@ Dashboard.showLoadingMsg(); - HttpClient.send({ + var xhr = new XMLHttpRequest(); + xhr.open('GET', 'components/itemidentifier/itemidentifier.template.html', true); - type: 'GET', - url: 'components/itemidentifier/itemidentifier.template.html' - - }).done(function (template) { + xhr.onload = function (e) { + var template = this.response; ApiClient.getItem(Dashboard.getCurrentUserId(), itemId).then(function (item) { currentItem = item; @@ -325,7 +324,9 @@ showIdentificationForm(dlg, item); Dashboard.hideLoadingMsg(); }); - }); + } + + xhr.send(); } function onDialogClosed() { diff --git a/dashboard-ui/components/medialibrarycreator/medialibrarycreator.js b/dashboard-ui/components/medialibrarycreator/medialibrarycreator.js index 69faa78d4e..93e28b3417 100644 --- a/dashboard-ui/components/medialibrarycreator/medialibrarycreator.js +++ b/dashboard-ui/components/medialibrarycreator/medialibrarycreator.js @@ -24,12 +24,12 @@ type = null; } - ApiClient.addVirtualFolder(name, type, currentOptions.refresh, paths).done(function () { + ApiClient.addVirtualFolder(name, type, currentOptions.refresh, paths).then(function () { hasChanges = true; PaperDialogHelper.close(dlg); - }).fail(function () { + }, function () { Dashboard.alert(Globalize.translate('ErrorAddingMediaPathToVirtualFolder')); }); @@ -188,13 +188,12 @@ require(['components/paperdialoghelper'], function () { - HttpClient.send({ + var xhr = new XMLHttpRequest(); + xhr.open('GET', 'components/medialibrarycreator/medialibrarycreator.template.html', true); - type: 'GET', - url: 'components/medialibrarycreator/medialibrarycreator.template.html' - - }).done(function (template) { + xhr.onload = function (e) { + var template = this.response; var dlg = PaperDialogHelper.createDialog({ size: 'small', theme: 'a', @@ -233,7 +232,9 @@ paths = []; renderPaths(editorContent); - }); + } + + xhr.send(); }); diff --git a/dashboard-ui/components/medialibraryeditor/medialibraryeditor.js b/dashboard-ui/components/medialibraryeditor/medialibraryeditor.js index 1075ab8a0b..60b8a08b05 100644 --- a/dashboard-ui/components/medialibraryeditor/medialibraryeditor.js +++ b/dashboard-ui/components/medialibraryeditor/medialibraryeditor.js @@ -10,12 +10,12 @@ var refreshAfterChange = currentOptions.refresh; - ApiClient.addMediaPath(virtualFolder.Name, path, refreshAfterChange).done(function () { + ApiClient.addMediaPath(virtualFolder.Name, path, refreshAfterChange).then(function () { hasChanges = true; refreshLibraryFromServer(page); - }).fail(function () { + }, function () { Dashboard.alert(Globalize.translate('ErrorAddingMediaPathToVirtualFolder')); }); @@ -36,12 +36,12 @@ var refreshAfterChange = currentOptions.refresh; - ApiClient.removeMediaPath(virtualFolder.Name, location, refreshAfterChange).done(function () { + ApiClient.removeMediaPath(virtualFolder.Name, location, refreshAfterChange).then(function () { hasChanges = true; refreshLibraryFromServer($(button).parents('.editorContent')[0]); - }).fail(function () { + }, function () { Dashboard.alert(Globalize.translate('DefaultErrorMessage')); }); @@ -70,7 +70,7 @@ function refreshLibraryFromServer(page) { - ApiClient.getVirtualFolders().done(function (result) { + ApiClient.getVirtualFolders().then(function (result) { var library = result.filter(function (f) { @@ -142,13 +142,12 @@ require(['components/paperdialoghelper'], function () { - HttpClient.send({ + var xhr = new XMLHttpRequest(); + xhr.open('GET', 'components/medialibraryeditor/medialibraryeditor.template.html', true); - type: 'GET', - url: 'components/medialibraryeditor/medialibraryeditor.template.html' - - }).done(function (template) { + xhr.onload = function (e) { + var template = this.response; var dlg = PaperDialogHelper.createDialog({ size: 'small', theme: 'a', @@ -184,7 +183,9 @@ }); refreshLibraryFromServer(editorContent); - }); + } + + xhr.send(); }); diff --git a/dashboard-ui/components/metadataeditor/metadataeditor.js b/dashboard-ui/components/metadataeditor/metadataeditor.js index fbc9483212..d9f135cb4c 100644 --- a/dashboard-ui/components/metadataeditor/metadataeditor.js +++ b/dashboard-ui/components/metadataeditor/metadataeditor.js @@ -39,13 +39,12 @@ Dashboard.showLoadingMsg(); - HttpClient.send({ + var xhr = new XMLHttpRequest(); + xhr.open('GET', 'components/metadataeditor/metadataeditor.template.html', true); - type: 'GET', - url: 'components/metadataeditor/metadataeditor.template.html' - - }).done(function (template) { + xhr.onload = function (e) { + var template = this.response; ApiClient.getItem(Dashboard.getCurrentUserId(), itemId).then(function (item) { var dlg = document.createElement('paper-dialog'); @@ -88,7 +87,9 @@ PaperDialogHelper.close(dlg); }); }); - }); + } + + xhr.send(); } function onDialogClosed() { diff --git a/dashboard-ui/components/playlisteditor/playlisteditor.js b/dashboard-ui/components/playlisteditor/playlisteditor.js index 003762cd40..07d895f602 100644 --- a/dashboard-ui/components/playlisteditor/playlisteditor.js +++ b/dashboard-ui/components/playlisteditor/playlisteditor.js @@ -46,7 +46,7 @@ url: url, dataType: "json" - }).done(function (result) { + }).then(function (result) { Dashboard.hideLoadingMsg(); @@ -69,7 +69,7 @@ type: "POST", url: url - }).done(function () { + }).then(function () { Dashboard.hideLoadingMsg(); diff --git a/dashboard-ui/components/subtitleeditor/subtitleeditor.js b/dashboard-ui/components/subtitleeditor/subtitleeditor.js index cd88d5750b..381bd2c88c 100644 --- a/dashboard-ui/components/subtitleeditor/subtitleeditor.js +++ b/dashboard-ui/components/subtitleeditor/subtitleeditor.js @@ -35,7 +35,7 @@ var url = 'Providers/Subtitles/Subtitles/' + id; - ApiClient.get(ApiClient.getUrl(url)).done(function (result) { + ApiClient.get(ApiClient.getUrl(url)).then(function (result) { $('.subtitleContent', page).html(result); @@ -54,7 +54,7 @@ type: "POST", url: ApiClient.getUrl(url) - }).done(function () { + }).then(function () { Dashboard.alert(Globalize.translate('MessageDownloadQueued')); }); @@ -78,7 +78,7 @@ type: "DELETE", url: ApiClient.getUrl(url) - }).done(function () { + }).then(function () { reload(page, itemId); }); @@ -291,7 +291,7 @@ var url = ApiClient.getUrl('Items/' + currentItem.Id + '/RemoteSearch/Subtitles/' + language); - ApiClient.fetchJSON(url).then(function (results) { + ApiClient.getJSON(url).then(function (results) { renderSearchResults(page, results); }); @@ -331,13 +331,12 @@ Dashboard.showLoadingMsg(); - HttpClient.send({ + var xhr = new XMLHttpRequest(); + xhr.open('GET', 'components/subtitleeditor/subtitleeditor.template.html', true); - type: 'GET', - url: 'components/subtitleeditor/subtitleeditor.template.html' - - }).done(function (template) { + xhr.onload = function (e) { + var template = this.response; ApiClient.getItem(Dashboard.getCurrentUserId(), itemId).then(function (item) { var dlg = PaperDialogHelper.createDialog(); @@ -365,7 +364,7 @@ var editorContent = dlg.querySelector('.editorContent'); reload(editorContent, item); - ApiClient.getCultures().done(function (languages) { + ApiClient.getCultures().then(function (languages) { fillLanguages(editorContent, languages); }); @@ -375,7 +374,9 @@ PaperDialogHelper.close(dlg); }); }); - }); + } + + xhr.send(); } function onDialogClosed() { diff --git a/dashboard-ui/components/tvguide/tvguide.js b/dashboard-ui/components/tvguide/tvguide.js index 8c1c6eb22c..9429b8de97 100644 --- a/dashboard-ui/components/tvguide/tvguide.js +++ b/dashboard-ui/components/tvguide/tvguide.js @@ -67,7 +67,7 @@ var nextDay = new Date(date.getTime() + msPerDay - 2000); Logger.log(nextDay); - channelsPromise.done(function (channelsResult) { + channelsPromise.then(function (channelsResult) { ApiClient.getLiveTvPrograms({ UserId: Dashboard.getCurrentUserId(), @@ -80,7 +80,7 @@ EnableImages: false, SortBy: "StartDate" - }).done(function (programsResult) { + }).then(function (programsResult) { renderGuide(page, date, channelsResult.Items, programsResult.Items); @@ -424,7 +424,7 @@ channelLimit = limit; - ApiClient.getLiveTvGuideInfo().done(function (guideInfo) { + ApiClient.getLiveTvGuideInfo().then(function (guideInfo) { setDateRange(page, guideInfo); }); @@ -434,11 +434,11 @@ $('.guideRequiresUnlock', page).hide(); - RegistrationServices.validateFeature('livetv').done(function () { + RegistrationServices.validateFeature('livetv').then(function () { Dashboard.showModalLoadingMsg(); reloadPageAfterValidation(page, 1000); - }).fail(function () { + }, function () { Dashboard.showModalLoadingMsg(); @@ -469,13 +469,12 @@ }); } - HttpClient.send({ + var xhr = new XMLHttpRequest(); + xhr.open('GET', 'components/tvguide/tvguide.template.html', true); - type: 'GET', - url: 'components/tvguide/tvguide.template.html' - - }).done(function (template) { + xhr.onload = function (e) { + var template = this.response; var tabContent = options.element; tabContent.innerHTML = Globalize.translateDocument(template); @@ -517,6 +516,8 @@ }); self.refresh(); - }); + } + + xhr.send(); }; }); \ No newline at end of file diff --git a/dashboard-ui/components/tvproviders/schedulesdirect.js b/dashboard-ui/components/tvproviders/schedulesdirect.js index df104d4598..b5a7bf4e63 100644 --- a/dashboard-ui/components/tvproviders/schedulesdirect.js +++ b/dashboard-ui/components/tvproviders/schedulesdirect.js @@ -10,7 +10,7 @@ Dashboard.showLoadingMsg(); - ApiClient.getNamedConfiguration("livetv").done(function (config) { + ApiClient.getNamedConfiguration("livetv").then(function (config) { var info = config.ListingProviders.filter(function (i) { return i.Id == providerId; @@ -35,7 +35,7 @@ function setCountry(info) { - ApiClient.fetchJSON(ApiClient.getUrl('LiveTv/ListingProviders/SchedulesDirect/Countries')).then(function (result) { + ApiClient.getJSON(ApiClient.getUrl('LiveTv/ListingProviders/SchedulesDirect/Countries')).then(function (result) { var countryList = []; var i, length; @@ -108,13 +108,13 @@ data: JSON.stringify(info), contentType: "application/json" - }).done(function (result) { + }).then(function (result) { Dashboard.processServerConfigurationUpdateResult(); providerId = result.Id; reload(); - }).fail(function () { + }, function () { Dashboard.alert({ message: Globalize.translate('ErrorSavingTvProvider') }); @@ -137,7 +137,7 @@ var id = providerId; - ApiClient.getNamedConfiguration("livetv").done(function (config) { + ApiClient.getNamedConfiguration("livetv").then(function (config) { var info = config.ListingProviders.filter(function (i) { return i.Id == id; @@ -155,7 +155,7 @@ data: JSON.stringify(info), contentType: "application/json" - }).done(function (result) { + }).then(function (result) { Dashboard.hideLoadingMsg(); if (options.showConfirmation !== false) { @@ -163,7 +163,7 @@ } $(self).trigger('submitted'); - }).fail(function () { + }, function () { Dashboard.hideLoadingMsg(); Dashboard.alert({ message: Globalize.translate('ErrorAddingListingsToSchedulesDirect') @@ -191,7 +191,7 @@ }), dataType: 'json' - }).done(function (result) { + }).then(function (result) { $('#selectListing', page).html(result.map(function (o) { @@ -205,7 +205,7 @@ Dashboard.hideModalLoadingMsg(); - }).fail(function (result) { + }, function (result) { Dashboard.alert({ message: Globalize.translate('ErrorGettingTvLineups') diff --git a/dashboard-ui/cordova/android/iap.js b/dashboard-ui/cordova/android/iap.js index 9ecdb12d28..731ab707e1 100644 --- a/dashboard-ui/cordova/android/iap.js +++ b/dashboard-ui/cordova/android/iap.js @@ -68,11 +68,11 @@ data: { Parameters: JSON.stringify(result) } - }).done(function () { + }).then(function () { refreshPurchases(); - }).fail(function (e) { + }, function (e) { refreshPurchases(); }); @@ -123,14 +123,14 @@ function isPlaybackUnlockedViaOldApp(deferred) { - testDeviceId(ConnectionManager.deviceId()).done(function (isUnlocked) { + testDeviceId(ConnectionManager.deviceId()).then(function (isUnlocked) { if (isUnlocked) { deferred.resolveWith(null, [true]); return; } - testDeviceId(device.uuid).done(function (isUnlocked) { + testDeviceId(device.uuid).then(function (isUnlocked) { if (isUnlocked) { deferred.resolveWith(null, [true]); @@ -159,11 +159,11 @@ type: 'GET', url: 'https://mb3admin.com/admin/service/statistics/appAccess?application=AndroidV1&deviceId=' + deviceId - }).done(function () { + }).then(function () { appStorage.setItem(cacheKey, 'true'); - }).fail(function (e) { + }, function (e) { if (e.status == 404) { appStorage.setItem(cacheKey, 'false'); diff --git a/dashboard-ui/cordova/android/mediasession.js b/dashboard-ui/cordova/android/mediasession.js index 80b3b508b0..b39267115d 100644 --- a/dashboard-ui/cordova/android/mediasession.js +++ b/dashboard-ui/cordova/android/mediasession.js @@ -156,7 +156,7 @@ Logger.log('binding remotecontrols to ' + player.name); - player.getPlayerState().done(function (state) { + player.getPlayerState().then(function (state) { if (state.NowPlayingItem) { player.beginPlayerUpdates(); diff --git a/dashboard-ui/cordova/chromecast.js b/dashboard-ui/cordova/chromecast.js index 6c745a15b4..c8252df449 100644 --- a/dashboard-ui/cordova/chromecast.js +++ b/dashboard-ui/cordova/chromecast.js @@ -76,7 +76,7 @@ return deferred.promise(); } - return ApiClient.fetchJSON(ApiClient.getUrl('System/Endpoint')).then(function (info) { + return ApiClient.getJSON(ApiClient.getUrl('System/Endpoint')).then(function (info) { endpointInfo = info; }); diff --git a/dashboard-ui/cordova/generaldevice.js b/dashboard-ui/cordova/generaldevice.js index 8060c9fe44..9b2c1c1151 100644 --- a/dashboard-ui/cordova/generaldevice.js +++ b/dashboard-ui/cordova/generaldevice.js @@ -148,7 +148,7 @@ Dashboard.showModalLoadingMsg(); } - MediaController.getPlaybackInfo(item.Id, deviceProfile, startPosition).done(function (playbackInfoResult) { + MediaController.getPlaybackInfo(item.Id, deviceProfile, startPosition).then(function (playbackInfoResult) { if (validatePlaybackInfoResult(playbackInfoResult)) { @@ -158,7 +158,7 @@ if (mediaSource.RequiresOpening) { - getLiveStream(item.Id, playbackInfoResult.PlaySessionId, deviceProfile, startPosition, mediaSource, null, null).done(function (openLiveStreamResult) { + getLiveStream(item.Id, playbackInfoResult.PlaySessionId, deviceProfile, startPosition, mediaSource, null, null).then(function (openLiveStreamResult) { openLiveStreamResult.MediaSource.enableDirectPlay = supportsDirectPlay(openLiveStreamResult.MediaSource); diff --git a/dashboard-ui/cordova/iap.js b/dashboard-ui/cordova/iap.js index 069b20722d..c91fd61190 100644 --- a/dashboard-ui/cordova/iap.js +++ b/dashboard-ui/cordova/iap.js @@ -123,24 +123,24 @@ } else { - promise = HttpClient.send({ - type: "POST", - url: "http://mb3admin.com/admin/service/appstore/register", - data: JSON.stringify(postData), - contentType: "application/json", + promise = fetch("http://mb3admin.com/admin/service/appstore/register", { + + method: 'POST', + body: JSON.stringify(postData), headers: { - "X-Emby-Token": "EMBY-APPLE-VALIDATE" + "X-Emby-Token": "EMBY-APPLE-VALIDATE", + "Content-Type": "application/json" } }); } - promise.done(function () { + promise.then(function () { setCachedResult(cacheKey, true); callback(true, product); - }).fail(function (e) { + }, function (e) { if (e.status == 402) { diff --git a/dashboard-ui/cordova/imagestore.js b/dashboard-ui/cordova/imagestore.js index e20dc71339..85d3137851 100644 --- a/dashboard-ui/cordova/imagestore.js +++ b/dashboard-ui/cordova/imagestore.js @@ -80,7 +80,7 @@ //Logger.log('getImageUrl:' + originalUrl); - getFileSystem().done(function (fileSystem) { + getFileSystem().then(function (fileSystem) { var path = fileSystem.root.toURL() + "/emby/cache/" + key; resolveLocalFileSystemURL(path, function (fileEntry) { @@ -116,11 +116,11 @@ // return; //} - self.getImageUrl(url).done(function (localUrl) { + self.getImageUrl(url).then(function (localUrl) { setImageIntoElement(elem, localUrl); - }).fail(onFail); + }, onFail); }; var imageIdIndex = 1; diff --git a/dashboard-ui/cordova/ios/backgroundfetch.js b/dashboard-ui/cordova/ios/backgroundfetch.js index d7f4c41fdc..4f17d08b3a 100644 --- a/dashboard-ui/cordova/ios/backgroundfetch.js +++ b/dashboard-ui/cordova/ios/backgroundfetch.js @@ -40,7 +40,7 @@ var promise = LocalSync.sync(syncOptions); if (reportToFetcher) { - promise.done(onSyncFinish).fail(onSyncFail); + promise.then(onSyncFinish, onSyncFail); } }); } diff --git a/dashboard-ui/cordova/ios/tabbar.js b/dashboard-ui/cordova/ios/tabbar.js index bfe70a8dd2..20141ab430 100644 --- a/dashboard-ui/cordova/ios/tabbar.js +++ b/dashboard-ui/cordova/ios/tabbar.js @@ -108,11 +108,11 @@ return; } - ApiClient.getUserViews({}, user.Id).done(function (result) { + ApiClient.getUserViews({}, user.Id).then(function (result) { onUserViewResponse(user, result.Items); - }).fail(function (result) { + }, function (result) { onUserViewResponse(user, []); }); diff --git a/dashboard-ui/cordova/localassetmanager.js b/dashboard-ui/cordova/localassetmanager.js index 32f3f8bc21..4b9adfa296 100644 --- a/dashboard-ui/cordova/localassetmanager.js +++ b/dashboard-ui/cordova/localassetmanager.js @@ -17,13 +17,13 @@ return deferred.promise(); } - getLocalItem(itemId, serverId).done(function (localItem) { + getLocalItem(itemId, serverId).then(function (localItem) { if (localItem && localItem.Item.MediaSources.length) { var mediaSource = localItem.Item.MediaSources[0]; - fileExists(mediaSource.Path).done(function (exists) { + fileExists(mediaSource.Path).then(function (exists) { if (exists) { deferred.resolveWith(null, [mediaSource]); @@ -32,13 +32,14 @@ deferred.resolveWith(null, [null]); } - }).fail(getOnFail(deferred)); + }, getOnFail(deferred)); return; } deferred.resolveWith(null, [null]); - }).fail(getOnFail(deferred)); + }, getOnFail(deferred)); + return deferred.promise(); } @@ -348,7 +349,7 @@ var deferred = DeferredBuilder.Deferred(); - getLocalItem(itemId, serverId).done(function (item) { + getLocalItem(itemId, serverId).then(function (item) { getOfflineItemsDb(function (db) { @@ -359,16 +360,16 @@ var files = item.AdditionalFiles || []; files.push(item.LocalPath); - deleteFiles(files).done(function () { + deleteFiles(files).then(function () { deferred.resolve(); - }).fail(getOnFail(deferred)); + }, getOnFail(deferred)); }); }); - }).fail(getOnFail(deferred)); + }, getOnFail(deferred)); return deferred.promise(); } @@ -386,9 +387,9 @@ return; } - deleteFile(file).done(function () { + deleteFile(file).then(function () { deleteNextFile(files, index + 1, deferred); - }).fail(function () { + }, function () { deleteNextFile(files, index + 1, deferred); }); } @@ -420,7 +421,7 @@ function resolveFile(path, options, success, fail) { - getFileSystem().done(function (fileSystem) { + getFileSystem().then(function (fileSystem) { fileSystem.root.getFile(path, options || { create: false }, success, fail); }); @@ -541,7 +542,7 @@ Logger.log('downloading: ' + url + ' to ' + localPath); - createDirectory(getParentDirectoryPath(localPath)).done(function () { + createDirectory(getParentDirectoryPath(localPath)).then(function () { resolveFile(localPath, { create: true }, function (targetFile) { @@ -593,7 +594,7 @@ }); - }).fail(getOnFail(deferred));; + }, getOnFail(deferred)); return deferred.promise(); } @@ -626,7 +627,7 @@ Logger.log('downloading: ' + url + ' to ' + localPath); - createDirectory(getParentDirectoryPath(localPath)).done(function () { + createDirectory(getParentDirectoryPath(localPath)).then(function () { resolveFile(localPath, { create: true }, function (targetFile) { @@ -679,7 +680,7 @@ deferred.reject(); }); - }).fail(getOnFail(deferred)); + }, getOnFail(deferred)); return deferred.promise(); } @@ -702,11 +703,11 @@ parts.length = index + 1; var pathToCreate = parts.join('/'); - createDirectoryInternal(pathToCreate).done(function () { + createDirectoryInternal(pathToCreate).then(function () { createDirectoryPart(path, index + 1, deferred); - }).fail(getOnFail(deferred)); + }, getOnFail(deferred)); } function createDirectoryInternal(path) { @@ -714,7 +715,7 @@ Logger.log('creating directory: ' + path); var deferred = DeferredBuilder.Deferred(); - getFileSystem().done(function (fileSystem) { + getFileSystem().then(function (fileSystem) { fileSystem.root.getDirectory(path, { create: true, exclusive: false }, function (targetFile) { @@ -727,7 +728,7 @@ deferred.reject(); }); - }).fail(getOnFail(deferred)); + }, getOnFail(deferred)); return deferred.promise(); } @@ -796,30 +797,31 @@ function hasImage(serverId, itemId, imageTag) { var deferred = DeferredBuilder.Deferred(); - getImageLocalPath(serverId, itemId, imageTag).done(function (localPath) { + getImageLocalPath(serverId, itemId, imageTag).then(function (localPath) { - fileExists(localPath).done(function (exists) { + fileExists(localPath).then(function (exists) { deferred.resolveWith(null, [exists]); - }).fail(getOnFail(deferred)); + }, getOnFail(deferred)); - }).fail(getOnFail(deferred)); + }, getOnFail(deferred)); return deferred.promise(); } function downloadImage(url, serverId, itemId, imageTag) { var deferred = DeferredBuilder.Deferred(); - getImageLocalPath(serverId, itemId, imageTag).done(function (localPath) { + getImageLocalPath(serverId, itemId, imageTag).then(function (localPath) { - downloadFile(url, localPath).done(function () { + downloadFile(url, localPath).then(function () { deferred.resolve(); - }).fail(getOnFail(deferred)); + }, getOnFail(deferred)); + + }, getOnFail(deferred)); - }).fail(getOnFail(deferred)); return deferred.promise(); } diff --git a/dashboard-ui/cordova/registrationservices.js b/dashboard-ui/cordova/registrationservices.js index 0e165b6875..521d9f5042 100644 --- a/dashboard-ui/cordova/registrationservices.js +++ b/dashboard-ui/cordova/registrationservices.js @@ -24,7 +24,7 @@ var prefix = $.browser.android ? 'android' : 'ios'; - IapManager.isUnlockedOverride(feature).done(function (isUnlocked) { + IapManager.isUnlockedOverride(feature).then(function (isUnlocked) { if (isUnlocked) { deferred.resolve(); @@ -38,7 +38,7 @@ return; } - IapManager.getSubscriptionOptions().done(function (subscriptionOptions) { + IapManager.getSubscriptionOptions().then(function (subscriptionOptions) { if (subscriptionOptions.filter(function (p) { return p.owned; @@ -58,7 +58,7 @@ } // Get supporter status - getRegistrationInfo(prefix + 'appunlock').done(onRegistrationInfoResponse).fail(function () { + getRegistrationInfo(prefix + 'appunlock').then(onRegistrationInfoResponse, function () { onRegistrationInfoResponse({}); }); }); @@ -371,7 +371,7 @@ function validateSync(deferred) { - Dashboard.getPluginSecurityInfo().done(function (pluginSecurityInfo) { + Dashboard.getPluginSecurityInfo().then(function (pluginSecurityInfo) { if (pluginSecurityInfo.IsMBSupporter) { deferred.resolve(); @@ -384,7 +384,7 @@ return; } - IapManager.getSubscriptionOptions().done(function (subscriptionOptions) { + IapManager.getSubscriptionOptions().then(function (subscriptionOptions) { var dialogOptions = { title: Globalize.translate('HeaderUnlockSync'), @@ -396,7 +396,7 @@ } // Get supporter status - getRegistrationInfo('Sync').done(onRegistrationInfoResponse).fail(function () { + getRegistrationInfo('Sync').then(onRegistrationInfoResponse, function () { onRegistrationInfoResponse({}); }); }); diff --git a/dashboard-ui/cordova/remotecontrols.js b/dashboard-ui/cordova/remotecontrols.js index 20cb4309e6..3856d2e159 100644 --- a/dashboard-ui/cordova/remotecontrols.js +++ b/dashboard-ui/cordova/remotecontrols.js @@ -158,7 +158,7 @@ Logger.log('binding remotecontrols to MediaPlayer'); - player.getPlayerState().done(function (state) { + player.getPlayerState().then(function (state) { if (state.NowPlayingItem) { player.beginPlayerUpdates(); diff --git a/dashboard-ui/cordova/serverdiscovery.js b/dashboard-ui/cordova/serverdiscovery.js index 5ca80522cb..d8074e3b5a 100644 --- a/dashboard-ui/cordova/serverdiscovery.js +++ b/dashboard-ui/cordova/serverdiscovery.js @@ -146,17 +146,18 @@ var deferred = DeferredBuilder.Deferred(); - deviceReadyPromise.done(function () { + deviceReadyPromise.then(function () { try { - findServersInternal(timeoutMs).done(function (result) { + findServersInternal(timeoutMs).then(function (result) { deferred.resolveWith(null, [result]); - }).fail(function () { + }, function () { deferred.resolveWith(null, [[]]); }); + } catch (err) { deferred.resolveWith(null, [[]]); } diff --git a/dashboard-ui/scripts/addpluginpage.js b/dashboard-ui/scripts/addpluginpage.js index edf4f97c40..67656d8037 100644 --- a/dashboard-ui/scripts/addpluginpage.js +++ b/dashboard-ui/scripts/addpluginpage.js @@ -58,7 +58,7 @@ function populateReviews(id, page) { - ApiClient.getPackageReviews(id, null, null, 3).done(function (positive) { + ApiClient.getPackageReviews(id, null, null, 3).then(function (positive) { var html = ''; @@ -185,7 +185,7 @@ var promise2 = ApiClient.getInstalledPlugins(); var promise3 = ApiClient.getPluginSecurityInfo(); - $.when(promise1, promise2, promise3).done(function (response1, response2, response3) { + $.when(promise1, promise2, promise3).then(function (response1, response2, response3) { renderPackage(response1[0], response2[0], response3[0], page); @@ -243,7 +243,7 @@ Dashboard.showLoadingMsg(); - ApiClient.installPlugin(packageName, guid, updateClass, version).done(function () { + ApiClient.installPlugin(packageName, guid, updateClass, version).then(function () { Dashboard.hideLoadingMsg(); }); @@ -281,7 +281,7 @@ var name = getParameterByName('name'); var guid = getParameterByName('guid'); - ApiClient.getInstalledPlugins().done(function (plugins) { + ApiClient.getInstalledPlugins().then(function (plugins) { var installedPlugin = plugins.filter(function (ip) { return ip.Name == name; diff --git a/dashboard-ui/scripts/advancedconfigurationpage.js b/dashboard-ui/scripts/advancedconfigurationpage.js index 3d5211db54..1990b71431 100644 --- a/dashboard-ui/scripts/advancedconfigurationpage.js +++ b/dashboard-ui/scripts/advancedconfigurationpage.js @@ -63,7 +63,7 @@ config.EnableDashboardResponseCaching = $('#chkEnableDashboardResponseCache', form).checked(); config.DashboardSourcePath = $('#txtDashboardSourcePath', form).val(); - ApiClient.updateServerConfiguration(config).done(Dashboard.processServerConfigurationUpdateResult); + ApiClient.updateServerConfiguration(config).then(Dashboard.processServerConfigurationUpdateResult); }); // Disable default form submission diff --git a/dashboard-ui/scripts/appservices.js b/dashboard-ui/scripts/appservices.js index c17665ab60..098a3e033b 100644 --- a/dashboard-ui/scripts/appservices.js +++ b/dashboard-ui/scripts/appservices.js @@ -10,7 +10,7 @@ var promise2 = ApiClient.getInstalledPlugins(); - $.when(promise1, promise2).done(function (response1, response2) { + $.when(promise1, promise2).then(function (response1, response2) { renderInstalled(page, response1[0], response2[0]); renderCatalog(page, response1[0], response2[0]); }); diff --git a/dashboard-ui/scripts/autoorganizelog.js b/dashboard-ui/scripts/autoorganizelog.js index 5c864b7e2f..e27ad96bb0 100644 --- a/dashboard-ui/scripts/autoorganizelog.js +++ b/dashboard-ui/scripts/autoorganizelog.js @@ -38,13 +38,13 @@ Dashboard.showLoadingMsg(); - ApiClient.deleteOriginalFileFromOrganizationResult(id).done(function () { + ApiClient.deleteOriginalFileFromOrganizationResult(id).then(function () { Dashboard.hideLoadingMsg(); reloadItems(page); - }).fail(onApiFailure); + }, onApiFailure); } }); @@ -121,13 +121,13 @@ Dashboard.showLoadingMsg(); - ApiClient.performOrganization(id).done(function () { + ApiClient.performOrganization(id).then(function () { Dashboard.hideLoadingMsg(); reloadItems(page); - }).fail(onApiFailure); + }, onApiFailure); } }); @@ -149,7 +149,7 @@ EndingEpisodeNumber: $('#txtEndingEpisode', form).val() }; - ApiClient.performEpisodeOrganization(resultId, options).done(function () { + ApiClient.performEpisodeOrganization(resultId, options).then(function () { Dashboard.hideLoadingMsg(); @@ -157,20 +157,21 @@ reloadItems(page); - }).fail(onApiFailure); + }, onApiFailure); } function reloadItems(page) { Dashboard.showLoadingMsg(); - ApiClient.getFileOrganizationResults(query).done(function (result) { + ApiClient.getFileOrganizationResults(query).then(function (result) { currentResult = result; renderResults(page, result); Dashboard.hideLoadingMsg(); - }).fail(onApiFailure); + + }, onApiFailure); } @@ -351,9 +352,9 @@ $('.btnClearLog', page).on('click', function () { - ApiClient.clearOrganizationLog().done(function () { + ApiClient.clearOrganizationLog().then(function () { reloadItems(page); - }).fail(onApiFailure); + }, onApiFailure); }); diff --git a/dashboard-ui/scripts/autoorganizetv.js b/dashboard-ui/scripts/autoorganizetv.js index 38f5a70005..b49ab05c01 100644 --- a/dashboard-ui/scripts/autoorganizetv.js +++ b/dashboard-ui/scripts/autoorganizetv.js @@ -81,7 +81,7 @@ function onSubmit() { var form = this; - ApiClient.getNamedConfiguration('autoorganize').done(function (config) { + ApiClient.getNamedConfiguration('autoorganize').then(function (config) { var tvOptions = config.TvOptions; @@ -103,7 +103,7 @@ tvOptions.CopyOriginalFile = $('#copyOrMoveFile', form).val(); - ApiClient.updateNamedConfiguration('autoorganize', config).done(Dashboard.processServerConfigurationUpdateResult); + ApiClient.updateNamedConfiguration('autoorganize', config).then(Dashboard.processServerConfigurationUpdateResult); }); return false; @@ -160,7 +160,7 @@ var page = this; - ApiClient.getNamedConfiguration('autoorganize').done(function (config) { + ApiClient.getNamedConfiguration('autoorganize').then(function (config) { loadPage(page, config); }); }); diff --git a/dashboard-ui/scripts/channelitems.js b/dashboard-ui/scripts/channelitems.js index 8d133faadd..301a1ea6f3 100644 --- a/dashboard-ui/scripts/channelitems.js +++ b/dashboard-ui/scripts/channelitems.js @@ -36,7 +36,7 @@ var channelId = getParameterByName('id'); - ApiClient.fetchJSON(ApiClient.getUrl("Channels/" + channelId + "/Features")).then(function (features) { + ApiClient.getJSON(ApiClient.getUrl("Channels/" + channelId + "/Features")).then(function (features) { if (features.CanFilter) { @@ -93,7 +93,7 @@ query.folderId = folderId; - ApiClient.fetchJSON(ApiClient.getUrl("Channels/" + channelId + "/Items", query)).then(function (result) { + ApiClient.getJSON(ApiClient.getUrl("Channels/" + channelId + "/Items", query)).then(function (result) { // Scroll back up so they can see the results from the beginning window.scrollTo(0, 0); @@ -145,7 +145,9 @@ showSortMenu(page); }); - }).always(function () { + Dashboard.hideModalLoadingMsg(); + + }, function () { Dashboard.hideModalLoadingMsg(); }); diff --git a/dashboard-ui/scripts/channels.js b/dashboard-ui/scripts/channels.js index 9494ab92bc..13b6589238 100644 --- a/dashboard-ui/scripts/channels.js +++ b/dashboard-ui/scripts/channels.js @@ -12,7 +12,7 @@ query.UserId = Dashboard.getCurrentUserId(); - ApiClient.fetchJSON(ApiClient.getUrl("Channels", query)).then(function (result) { + ApiClient.getJSON(ApiClient.getUrl("Channels", query)).then(function (result) { // Scroll back up so they can see the results from the beginning window.scrollTo(0, 0); diff --git a/dashboard-ui/scripts/channelsettings.js b/dashboard-ui/scripts/channelsettings.js index 09471416b9..7e39b235f6 100644 --- a/dashboard-ui/scripts/channelsettings.js +++ b/dashboard-ui/scripts/channelsettings.js @@ -13,12 +13,12 @@ var form = this; - ApiClient.getNamedConfiguration("channels").done(function (config) { + ApiClient.getNamedConfiguration("channels").then(function (config) { // This should be null if empty config.PreferredStreamingWidth = $('#selectChannelResolution', form).val() || null; - ApiClient.updateNamedConfiguration("channels", config).done(Dashboard.processServerConfigurationUpdateResult); + ApiClient.updateNamedConfiguration("channels", config).then(Dashboard.processServerConfigurationUpdateResult); }); // Disable default form submission @@ -37,7 +37,7 @@ var page = this; - ApiClient.getNamedConfiguration("channels").done(function (config) { + ApiClient.getNamedConfiguration("channels").then(function (config) { loadPage(page, config); diff --git a/dashboard-ui/scripts/channelslatest.js b/dashboard-ui/scripts/channelslatest.js index 5faeeabade..ef4520580a 100644 --- a/dashboard-ui/scripts/channelslatest.js +++ b/dashboard-ui/scripts/channelslatest.js @@ -4,7 +4,9 @@ Dashboard.showLoadingMsg(); - Sections.loadLatestChannelItems(page.querySelector('.latestItems'), Dashboard.getCurrentUserId()).always(function() { + Sections.loadLatestChannelItems(page.querySelector('.latestItems'), Dashboard.getCurrentUserId()).then(function() { + Dashboard.hideLoadingMsg(); + }, function () { Dashboard.hideLoadingMsg(); }); } diff --git a/dashboard-ui/scripts/chromecast.js b/dashboard-ui/scripts/chromecast.js index a3372c2c24..5169d36ba2 100644 --- a/dashboard-ui/scripts/chromecast.js +++ b/dashboard-ui/scripts/chromecast.js @@ -323,7 +323,7 @@ return deferred.promise(); } - return ApiClient.fetchJSON(ApiClient.getUrl('System/Endpoint')).then(function (info) { + return ApiClient.getJSON(ApiClient.getUrl('System/Endpoint')).then(function (info) { endpointInfo = info; }); diff --git a/dashboard-ui/scripts/cinemamodeconfiguration.js b/dashboard-ui/scripts/cinemamodeconfiguration.js index efe971ddc1..9986818430 100644 --- a/dashboard-ui/scripts/cinemamodeconfiguration.js +++ b/dashboard-ui/scripts/cinemamodeconfiguration.js @@ -28,7 +28,7 @@ var page = $(form).parents('.page'); - ApiClient.getNamedConfiguration("cinemamode").done(function (config) { + ApiClient.getNamedConfiguration("cinemamode").then(function (config) { config.CustomIntroPath = $('#txtCustomIntrosPath', page).val(); config.TrailerLimit = $('#txtNumTrailers', page).val(); @@ -44,7 +44,7 @@ config.EnableIntrosFromUpcomingStreamingMovies = $('.chkUpcomingStreamingTrailers', page).checked(); config.EnableIntrosFromSimilarMovies = $('.chkOtherTrailers', page).checked(); - ApiClient.updateNamedConfiguration("cinemamode", config).done(Dashboard.processServerConfigurationUpdateResult); + ApiClient.updateNamedConfiguration("cinemamode", config).then(Dashboard.processServerConfigurationUpdateResult); }); // Disable default form submission @@ -84,7 +84,7 @@ var page = this; - ApiClient.getNamedConfiguration("cinemamode").done(function (config) { + ApiClient.getNamedConfiguration("cinemamode").then(function (config) { loadPage(page, config); diff --git a/dashboard-ui/scripts/connectlogin.js b/dashboard-ui/scripts/connectlogin.js index ddb06077c2..5ecfa5887d 100644 --- a/dashboard-ui/scripts/connectlogin.js +++ b/dashboard-ui/scripts/connectlogin.js @@ -4,12 +4,12 @@ Dashboard.showModalLoadingMsg(); - ConnectionManager.loginToConnect(username, password).done(function () { + ConnectionManager.loginToConnect(username, password).then(function () { Dashboard.hideModalLoadingMsg(); Dashboard.navigate('selectserver.html'); - }).fail(function () { + }, function () { Dashboard.hideModalLoadingMsg(); @@ -70,7 +70,7 @@ Dashboard.showModalLoadingMsg(); - ConnectionManager.connect().done(function (result) { + ConnectionManager.connect().then(function (result) { handleConnectionResult(page, result); @@ -150,7 +150,7 @@ var page = $(this).parents('.page'); - ConnectionManager.signupForConnect($('#txtSignupEmail', page).val(), $('#txtSignupUsername', page).val(), $('#txtSignupPassword', page).val(), $('#txtSignupPasswordConfirm', page).val()).done(function () { + ConnectionManager.signupForConnect($('#txtSignupEmail', page).val(), $('#txtSignupUsername', page).val(), $('#txtSignupPassword', page).val(), $('#txtSignupPasswordConfirm', page).val()).then(function () { Dashboard.alert({ message: Globalize.translate('MessageThankYouForConnectSignUp'), @@ -159,7 +159,7 @@ } }); - }).fail(function (result) { + }, function (result) { if (result.errorCode == 'passwordmatch') { Dashboard.alert({ @@ -282,11 +282,11 @@ Dashboard.showModalLoadingMsg(); - ConnectionManager.connectToAddress(host).done(function (result) { + ConnectionManager.connectToAddress(host).then(function (result) { handleConnectionResult(page, result); - }).fail(function () { + }, function () { handleConnectionResult(page, { State: MediaBrowser.ConnectionState.Unavailable }); diff --git a/dashboard-ui/scripts/dashboardgeneral.js b/dashboard-ui/scripts/dashboardgeneral.js index 5556b6f3ae..326f046187 100644 --- a/dashboard-ui/scripts/dashboardgeneral.js +++ b/dashboard-ui/scripts/dashboardgeneral.js @@ -52,18 +52,18 @@ Dashboard.showDashboardRefreshNotification(); } - ApiClient.updateServerConfiguration(config).done(function () { + ApiClient.updateServerConfiguration(config).then(function () { refreshPageTitle(page); - ApiClient.getNamedConfiguration(brandingConfigKey).done(function (brandingConfig) { + ApiClient.getNamedConfiguration(brandingConfigKey).then(function (brandingConfig) { brandingConfig.LoginDisclaimer = form.querySelector('#txtLoginDisclaimer').value; brandingConfig.CustomCss = form.querySelector('#txtCustomCss').value; var cssChanged = currentBrandingOptions && brandingConfig.CustomCss != currentBrandingOptions.CustomCss; - ApiClient.updateNamedConfiguration(brandingConfigKey, brandingConfig).done(Dashboard.processServerConfigurationUpdateResult); + ApiClient.updateNamedConfiguration(brandingConfigKey, brandingConfig).then(Dashboard.processServerConfigurationUpdateResult); if (cssChanged) { Dashboard.showDashboardRefreshNotification(); @@ -114,7 +114,7 @@ var promise1 = ApiClient.getServerConfiguration(); - var promise2 = ApiClient.fetchJSON(ApiClient.getUrl("Localization/Options")); + var promise2 = ApiClient.getJSON(ApiClient.getUrl("Localization/Options")); Promise.all([promise1, promise2]).then(function (responses) { @@ -122,7 +122,7 @@ }); - ApiClient.getNamedConfiguration(brandingConfigKey).done(function (config) { + ApiClient.getNamedConfiguration(brandingConfigKey).then(function (config) { currentBrandingOptions = config; diff --git a/dashboard-ui/scripts/dashboardhosting.js b/dashboard-ui/scripts/dashboardhosting.js index 32f6a183ef..180535e1d6 100644 --- a/dashboard-ui/scripts/dashboardhosting.js +++ b/dashboard-ui/scripts/dashboardhosting.js @@ -33,7 +33,7 @@ config.WanDdns = $('#txtDdns', form).val(); config.CertificatePath = $('#txtCertificatePath', form).val(); - ApiClient.updateServerConfiguration(config).done(Dashboard.processServerConfigurationUpdateResult); + ApiClient.updateServerConfiguration(config).then(Dashboard.processServerConfigurationUpdateResult); }); // Disable default form submission diff --git a/dashboard-ui/scripts/dashboardpage.js b/dashboard-ui/scripts/dashboardpage.js index 6aa6497095..04cae66b23 100644 --- a/dashboard-ui/scripts/dashboardpage.js +++ b/dashboard-ui/scripts/dashboardpage.js @@ -28,7 +28,7 @@ DashboardPage.lastAppUpdateCheck = null; DashboardPage.lastPluginUpdateCheck = null; - Dashboard.getPluginSecurityInfo().done(function (pluginSecurityInfo) { + Dashboard.getPluginSecurityInfo().then(function (pluginSecurityInfo) { DashboardPage.renderSupporterIcon(page, pluginSecurityInfo); }); @@ -120,7 +120,7 @@ Limit: 7 }; - ApiClient.getProductNews(query).done(function (result) { + ApiClient.getProductNews(query).then(function (result) { var html = result.Items.map(function (item) { @@ -242,11 +242,11 @@ return; } - apiClient.getSessions().done(function (sessions) { + apiClient.getSessions().then(function (sessions) { DashboardPage.renderInfo(page, sessions, forceUpdate); }); - apiClient.getScheduledTasks().done(function (tasks) { + apiClient.getScheduledTasks().then(function (tasks) { DashboardPage.renderRunningTasks(page, tasks); }); @@ -834,7 +834,7 @@ DashboardPage.lastAppUpdateCheck = new Date().getTime(); - ApiClient.getAvailableApplicationUpdate().done(function (packageInfo) { + ApiClient.getAvailableApplicationUpdate().then(function (packageInfo) { var version = packageInfo[0]; @@ -892,7 +892,7 @@ DashboardPage.lastPluginUpdateCheck = new Date().getTime(); - ApiClient.getAvailablePluginUpdates().done(function (updates) { + ApiClient.getAvailablePluginUpdates().then(function (updates) { var elem = $('#pPluginUpdates', page); @@ -932,7 +932,7 @@ Dashboard.showLoadingMsg(); - ApiClient.installPlugin(name, guid, classification, version).done(function () { + ApiClient.installPlugin(name, guid, classification, version).then(function () { Dashboard.hideLoadingMsg(); }); @@ -945,14 +945,14 @@ Dashboard.showLoadingMsg(); - ApiClient.getScheduledTasks().done(function (tasks) { + ApiClient.getScheduledTasks().then(function (tasks) { var task = tasks.filter(function (t) { return t.Key == DashboardPage.systemUpdateTaskKey; })[0]; - ApiClient.startScheduledTask(task.Id).done(function () { + ApiClient.startScheduledTask(task.Id).then(function () { DashboardPage.pollForInfo(page); @@ -965,7 +965,7 @@ var page = $.mobile.activePage; - ApiClient.stopScheduledTask(id).done(function () { + ApiClient.stopScheduledTask(id).then(function () { DashboardPage.pollForInfo(page); }); @@ -1170,7 +1170,7 @@ $(document).on('pageshow', "#dashboardPage", DashboardPage.onPageShow).on('pageb var minDate = new Date(); minDate.setTime(minDate.getTime() - 86400000); - ApiClient.fetchJSON(ApiClient.getUrl('System/ActivityLog/Entries', { + ApiClient.getJSON(ApiClient.getUrl('System/ActivityLog/Entries', { startIndex: startIndex, limit: limit, @@ -1313,7 +1313,7 @@ $(document).on('pageshow', "#dashboardPage", DashboardPage.onPageShow).on('pageb function takeTour(page, userId) { - Dashboard.loadSwipebox().done(function () { + Dashboard.loadSwipebox().then(function () { $.swipebox([ { href: 'css/images/tour/dashboard/dashboard.png', title: Globalize.translate('DashboardTourDashboard') }, @@ -1366,7 +1366,7 @@ $(document).on('pageshow', "#dashboardPage", DashboardPage.onPageShow).on('pageb var page = this; - Dashboard.getPluginSecurityInfo().done(function (pluginSecurityInfo) { + Dashboard.getPluginSecurityInfo().then(function (pluginSecurityInfo) { if (!$('.customSupporterPromotion', page).length) { $('.supporterPromotion', page).remove(); diff --git a/dashboard-ui/scripts/device.js b/dashboard-ui/scripts/device.js index d9a83af813..8d7233d57a 100644 --- a/dashboard-ui/scripts/device.js +++ b/dashboard-ui/scripts/device.js @@ -22,7 +22,7 @@ var promise1 = ApiClient.getJSON(ApiClient.getUrl('Devices/Info', { Id: id })); var promise2 = ApiClient.getJSON(ApiClient.getUrl('Devices/Capabilities', { Id: id })); - $.when(promise1, promise2).done(function (response1, response2) { + $.when(promise1, promise2).then(function (response1, response2) { load(page, response1[0], response2[0]); @@ -46,7 +46,7 @@ }), contentType: "application/json" - }).done(Dashboard.processServerConfigurationUpdateResult); + }).then(Dashboard.processServerConfigurationUpdateResult); } function onSubmit() { diff --git a/dashboard-ui/scripts/devices.js b/dashboard-ui/scripts/devices.js index 143e570dda..3ab6d970e4 100644 --- a/dashboard-ui/scripts/devices.js +++ b/dashboard-ui/scripts/devices.js @@ -15,7 +15,7 @@ Id: id }) - }).done(function () { + }).then(function () { loadData(page); }); @@ -82,7 +82,7 @@ function loadData(page) { Dashboard.showLoadingMsg(); - ApiClient.fetchJSON(ApiClient.getUrl('Devices', { + ApiClient.getJSON(ApiClient.getUrl('Devices', { SupportsPersistentIdentifier: true diff --git a/dashboard-ui/scripts/devicesupload.js b/dashboard-ui/scripts/devicesupload.js index e43bc999b0..bfb668bec9 100644 --- a/dashboard-ui/scripts/devicesupload.js +++ b/dashboard-ui/scripts/devicesupload.js @@ -74,7 +74,7 @@ })); - $.when(promise1, promise2).done(function (response1, response2) { + $.when(promise1, promise2).then(function (response1, response2) { load(page, response2[0].Items, response1[0]); @@ -85,7 +85,7 @@ function save(page) { - ApiClient.getNamedConfiguration("devices").done(function (config) { + ApiClient.getNamedConfiguration("devices").then(function (config) { config.CameraUploadPath = $('#txtUploadPath', page).val(); @@ -97,7 +97,7 @@ config.EnableCameraUploadSubfolders = $('#chkSubfolder', page).checked(); - ApiClient.updateNamedConfiguration("devices", config).done(Dashboard.processServerConfigurationUpdateResult); + ApiClient.updateNamedConfiguration("devices", config).then(Dashboard.processServerConfigurationUpdateResult); }); } diff --git a/dashboard-ui/scripts/dlnaprofile.js b/dashboard-ui/scripts/dlnaprofile.js index 56d61eaf11..67b1a821cb 100644 --- a/dashboard-ui/scripts/dlnaprofile.js +++ b/dashboard-ui/scripts/dlnaprofile.js @@ -14,7 +14,7 @@ var promise1 = getProfile(); var promise2 = ApiClient.getUsers(); - $.when(promise1, promise2).done(function (response1, response2) { + $.when(promise1, promise2).then(function (response1, response2) { currentProfile = response1[0]; @@ -864,7 +864,7 @@ url: ApiClient.getUrl("Dlna/Profiles/" + id), data: JSON.stringify(profile), contentType: "application/json" - }).done(function () { + }).then(function () { Dashboard.alert('Settings saved.'); }); @@ -876,7 +876,7 @@ url: ApiClient.getUrl("Dlna/Profiles"), data: JSON.stringify(profile), contentType: "application/json" - }).done(function () { + }).then(function () { Dashboard.navigate('dlnaprofiles.html'); diff --git a/dashboard-ui/scripts/dlnaprofiles.js b/dashboard-ui/scripts/dlnaprofiles.js index ee79d95336..b944236ebb 100644 --- a/dashboard-ui/scripts/dlnaprofiles.js +++ b/dashboard-ui/scripts/dlnaprofiles.js @@ -4,7 +4,7 @@ Dashboard.showLoadingMsg(); - ApiClient.fetchJSON(ApiClient.getUrl("Dlna/ProfileInfos")).then(function (result) { + ApiClient.getJSON(ApiClient.getUrl("Dlna/ProfileInfos")).then(function (result) { renderProfiles(page, result); @@ -92,7 +92,7 @@ type: "DELETE", url: ApiClient.getUrl("Dlna/Profiles/" + id) - }).done(function () { + }).then(function () { Dashboard.hideLoadingMsg(); diff --git a/dashboard-ui/scripts/dlnaserversettings.js b/dashboard-ui/scripts/dlnaserversettings.js index f5b2207356..7f081e6f35 100644 --- a/dashboard-ui/scripts/dlnaserversettings.js +++ b/dashboard-ui/scripts/dlnaserversettings.js @@ -23,7 +23,7 @@ var form = this; - ApiClient.getNamedConfiguration("dlna").done(function (config) { + ApiClient.getNamedConfiguration("dlna").then(function (config) { config.EnableServer = $('#chkEnableServer', form).checked(); config.BlastAliveMessages = $('#chkBlastAliveMessages', form).checked(); @@ -32,7 +32,7 @@ config.EnableMovieFolders = $('#chkEnableMovieFolders', form).checked(); - ApiClient.updateNamedConfiguration("dlna", config).done(Dashboard.processServerConfigurationUpdateResult); + ApiClient.updateNamedConfiguration("dlna", config).then(Dashboard.processServerConfigurationUpdateResult); }); // Disable default form submission @@ -52,7 +52,7 @@ var promise1 = ApiClient.getNamedConfiguration("dlna"); var promise2 = ApiClient.getUsers(); - $.when(promise1, promise2).done(function (response1, response2) { + $.when(promise1, promise2).then(function (response1, response2) { loadPage(page, response1[0], response2[0]); diff --git a/dashboard-ui/scripts/dlnasettings.js b/dashboard-ui/scripts/dlnasettings.js index 422ddad580..d922a329c9 100644 --- a/dashboard-ui/scripts/dlnasettings.js +++ b/dashboard-ui/scripts/dlnasettings.js @@ -15,13 +15,13 @@ var form = this; - ApiClient.getNamedConfiguration("dlna").done(function (config) { + ApiClient.getNamedConfiguration("dlna").then(function (config) { config.EnablePlayTo = $('#chkEnablePlayTo', form).checked(); config.EnableDebugLogging = $('#chkEnableDlnaDebugLogging', form).checked(); config.ClientDiscoveryIntervalSeconds = $('#txtClientDiscoveryInterval', form).val(); - ApiClient.updateNamedConfiguration("dlna", config).done(Dashboard.processServerConfigurationUpdateResult); + ApiClient.updateNamedConfiguration("dlna", config).then(Dashboard.processServerConfigurationUpdateResult); }); // Disable default form submission @@ -38,7 +38,7 @@ var page = this; - ApiClient.getNamedConfiguration("dlna").done(function (config) { + ApiClient.getNamedConfiguration("dlna").then(function (config) { loadPage(page, config); diff --git a/dashboard-ui/scripts/edititemmetadata.js b/dashboard-ui/scripts/edititemmetadata.js index d2282bd8a1..5c1a61312b 100644 --- a/dashboard-ui/scripts/edititemmetadata.js +++ b/dashboard-ui/scripts/edititemmetadata.js @@ -13,7 +13,7 @@ var promise1 = MetadataEditor.getItemPromise(); var promise2 = MetadataEditor.getCurrentItemId() ? - ApiClient.fetchJSON(ApiClient.getUrl('Items/' + MetadataEditor.getCurrentItemId() + '/MetadataEditor')) : + ApiClient.getJSON(ApiClient.getUrl('Items/' + MetadataEditor.getCurrentItemId() + '/MetadataEditor')) : {}; Promise.all([promise1, promise2]).then(function (responses) { @@ -901,7 +901,7 @@ }); } - ApiClient.updateItem(item).done(function () { + ApiClient.updateItem(item).then(function () { var newContentType = $('#selectContentType', form).val() || ''; @@ -915,7 +915,7 @@ type: 'POST' - }).done(function () { + }).then(function () { afterContentTypeUpdated(); }); diff --git a/dashboard-ui/scripts/editorsidebar.js b/dashboard-ui/scripts/editorsidebar.js index 56592daf68..eaba575b07 100644 --- a/dashboard-ui/scripts/editorsidebar.js +++ b/dashboard-ui/scripts/editorsidebar.js @@ -106,7 +106,7 @@ var promise2 = ApiClient.getLiveTvChannels({ limit: 0 }); - $.when(promise2).done(function (response2) { + $.when(promise2).then(function (response2) { var result = response2; @@ -155,7 +155,7 @@ function loadLiveTvChannels(service, openItems, callback) { - ApiClient.getLiveTvChannels({ ServiceName: service, AddCurrentProgram: false }).done(function (result) { + ApiClient.getLiveTvChannels({ ServiceName: service, AddCurrentProgram: false }).then(function (result) { var nodes = result.Items.map(function (i) { @@ -173,7 +173,7 @@ function loadMediaFolders(page, scope, openItems, callback) { - ApiClient.fetchJSON(ApiClient.getUrl("Library/MediaFolders")).then(function (result) { + ApiClient.getJSON(ApiClient.getUrl("Library/MediaFolders")).then(function (result) { var nodes = result.Items.map(function (n) { @@ -278,7 +278,7 @@ function initializeTree(page, currentUser, openItems, selectedId) { - loadJsTree().done(function () { + loadJsTree().then(function () { initializeTreeInternal(page, currentUser, openItems, selectedId); }); } @@ -428,7 +428,7 @@ if (id) { - ApiClient.getAncestorItems(id, user.Id).done(function (ancestors) { + ApiClient.getAncestorItems(id, user.Id).then(function (ancestors) { var ids = ancestors.map(function (i) { return i.Id; diff --git a/dashboard-ui/scripts/encodingsettings.js b/dashboard-ui/scripts/encodingsettings.js index eefe989c93..19b225240e 100644 --- a/dashboard-ui/scripts/encodingsettings.js +++ b/dashboard-ui/scripts/encodingsettings.js @@ -24,7 +24,7 @@ var form = this; - ApiClient.getNamedConfiguration("encoding").done(function (config) { + ApiClient.getNamedConfiguration("encoding").then(function (config) { config.EnableDebugLogging = $('#chkEnableDebugEncodingLogging', form).checked(); config.EncodingQuality = $('.radioEncodingQuality:checked', form).val(); @@ -34,7 +34,7 @@ config.EncodingThreadCount = $('#selectThreadCount', form).val(); config.HardwareAccelerationType = $('#selectVideoDecoder', form).val(); - ApiClient.updateNamedConfiguration("encoding", config).done(Dashboard.processServerConfigurationUpdateResult); + ApiClient.updateNamedConfiguration("encoding", config).then(Dashboard.processServerConfigurationUpdateResult); }); // Disable default form submission @@ -77,7 +77,7 @@ var page = this; - ApiClient.getNamedConfiguration("encoding").done(function (config) { + ApiClient.getNamedConfiguration("encoding").then(function (config) { loadPage(page, config); diff --git a/dashboard-ui/scripts/externalplayer.js b/dashboard-ui/scripts/externalplayer.js index 23f04423d8..9f8052d8c4 100644 --- a/dashboard-ui/scripts/externalplayer.js +++ b/dashboard-ui/scripts/externalplayer.js @@ -178,7 +178,7 @@ } }; - MediaPlayer.createStreamInfo('Video', item, mediaSource, startPosition).done(function (streamInfo) { + MediaPlayer.createStreamInfo('Video', item, mediaSource, startPosition).then(function (streamInfo) { var currentSrc = streamInfo.url; @@ -437,7 +437,7 @@ ApiClient.getItem(userId, itemId).then(function (item) { - getVideoStreamInfo(item).done(function (streamInfo) { + getVideoStreamInfo(item).then(function (streamInfo) { setTimeout(function () { ExternalPlayer.showPlayerSelectionMenu(item, streamInfo.url, streamInfo.mimeType); @@ -460,7 +460,7 @@ function showPlayerSelectionMenu(item, url, mimeType) { - ExternalPlayer.getExternalPlayers(url, mimeType).done(function (players) { + ExternalPlayer.getExternalPlayers(url, mimeType).then(function (players) { showMenuForItem(item, players); }); } diff --git a/dashboard-ui/scripts/favorites.js b/dashboard-ui/scripts/favorites.js index ec2fcad96e..a2046460cc 100644 --- a/dashboard-ui/scripts/favorites.js +++ b/dashboard-ui/scripts/favorites.js @@ -160,7 +160,7 @@ promises.push(loadSection(elem, userId, topParentId, section, sections.length == 1)); } - $.when(promises).done(function () { + $.when(promises).then(function () { Dashboard.hideLoadingMsg(); LibraryBrowser.setLastRefreshed(page); diff --git a/dashboard-ui/scripts/forgotpassword.js b/dashboard-ui/scripts/forgotpassword.js index 6af0d8e88d..9ea0fd62db 100644 --- a/dashboard-ui/scripts/forgotpassword.js +++ b/dashboard-ui/scripts/forgotpassword.js @@ -53,7 +53,7 @@ EnteredUsername: $('#txtName', page).val() } - }).done(function (result) { + }).then(function (result) { processForgotPasswordResult(page, result); }); diff --git a/dashboard-ui/scripts/forgotpasswordpin.js b/dashboard-ui/scripts/forgotpasswordpin.js index 81790b8d49..d6c5c6f1d8 100644 --- a/dashboard-ui/scripts/forgotpasswordpin.js +++ b/dashboard-ui/scripts/forgotpasswordpin.js @@ -44,7 +44,7 @@ Pin: $('#txtPin', page).val() } - }).done(function (result) { + }).then(function (result) { processForgotPasswordResult(page, result); }); diff --git a/dashboard-ui/scripts/gamegenrepage.js b/dashboard-ui/scripts/gamegenrepage.js index 01462c6067..5b33d40b91 100644 --- a/dashboard-ui/scripts/gamegenrepage.js +++ b/dashboard-ui/scripts/gamegenrepage.js @@ -19,7 +19,7 @@ Dashboard.showLoadingMsg(); - ApiClient.getGameGenres(Dashboard.getCurrentUserId(), query).done(function (result) { + ApiClient.getGameGenres(Dashboard.getCurrentUserId(), query).then(function (result) { // Scroll back up so they can see the results from the beginning window.scrollTo(0, 0); diff --git a/dashboard-ui/scripts/gamespage.js b/dashboard-ui/scripts/gamespage.js index 7079c24b0e..372a446297 100644 --- a/dashboard-ui/scripts/gamespage.js +++ b/dashboard-ui/scripts/gamespage.js @@ -254,7 +254,7 @@ LibraryBrowser.loadSavedQueryValues(viewkey, query); QueryFilters.onPageShow(page, query); - LibraryBrowser.getSavedViewSetting(viewkey).done(function (val) { + LibraryBrowser.getSavedViewSetting(viewkey).then(function (val) { if (val) { $('#selectView', page).val(val).trigger('change'); diff --git a/dashboard-ui/scripts/gamesrecommendedpage.js b/dashboard-ui/scripts/gamesrecommendedpage.js index 070768a2eb..c991299f81 100644 --- a/dashboard-ui/scripts/gamesrecommendedpage.js +++ b/dashboard-ui/scripts/gamesrecommendedpage.js @@ -17,7 +17,7 @@ EnableImageTypes: "Primary,Backdrop,Banner,Thumb" }; - ApiClient.fetchJSON(ApiClient.getUrl('Users/' + userId + '/Items/Latest', options)).then(function (items) { + ApiClient.getJSON(ApiClient.getUrl('Users/' + userId + '/Items/Latest', options)).then(function (items) { $('#recentlyAddedItems', page).html(LibraryBrowser.getPosterViewHtml({ items: items, diff --git a/dashboard-ui/scripts/gamestudiospage.js b/dashboard-ui/scripts/gamestudiospage.js index 933b62e727..f297413c97 100644 --- a/dashboard-ui/scripts/gamestudiospage.js +++ b/dashboard-ui/scripts/gamestudiospage.js @@ -20,7 +20,7 @@ Dashboard.showLoadingMsg(); - ApiClient.getStudios(Dashboard.getCurrentUserId(), query).done(function (result) { + ApiClient.getStudios(Dashboard.getCurrentUserId(), query).then(function (result) { // Scroll back up so they can see the results from the beginning window.scrollTo(0, 0); diff --git a/dashboard-ui/scripts/homenextup.js b/dashboard-ui/scripts/homenextup.js index 1732e185df..6650c7d285 100644 --- a/dashboard-ui/scripts/homenextup.js +++ b/dashboard-ui/scripts/homenextup.js @@ -22,7 +22,7 @@ EnableImageTypes: "Primary,Backdrop,Banner,Thumb" }; - ApiClient.getNextUpEpisodes(query).done(function (result) { + ApiClient.getNextUpEpisodes(query).then(function (result) { if (result.Items.length) { page.querySelector('.noNextUpItems').classList.add('hide'); diff --git a/dashboard-ui/scripts/homeupcoming.js b/dashboard-ui/scripts/homeupcoming.js index bcba1e4bc8..794bdc4a15 100644 --- a/dashboard-ui/scripts/homeupcoming.js +++ b/dashboard-ui/scripts/homeupcoming.js @@ -16,7 +16,7 @@ EnableImageTypes: "Primary,Backdrop,Banner,Thumb" }; - ApiClient.fetchJSON(ApiClient.getUrl("Shows/Upcoming", query)).then(function (result) { + ApiClient.getJSON(ApiClient.getUrl("Shows/Upcoming", query)).then(function (result) { var items = result.Items; diff --git a/dashboard-ui/scripts/indexpage.js b/dashboard-ui/scripts/indexpage.js index d0c4201182..e6cc6c99c7 100644 --- a/dashboard-ui/scripts/indexpage.js +++ b/dashboard-ui/scripts/indexpage.js @@ -165,7 +165,7 @@ function takeTour(page, userId) { - Dashboard.loadSwipebox().done(function () { + Dashboard.loadSwipebox().then(function () { $.swipebox([ { href: 'css/images/tour/web/tourcontent.jpg', title: Globalize.translate('WebClientTourContent') }, diff --git a/dashboard-ui/scripts/itemdetailpage.js b/dashboard-ui/scripts/itemdetailpage.js index e0948a70f9..a88a1b3b98 100644 --- a/dashboard-ui/scripts/itemdetailpage.js +++ b/dashboard-ui/scripts/itemdetailpage.js @@ -1090,7 +1090,7 @@ type: "DELETE", url: url - }).done(function () { + }).then(function () { renderChildren(page, parentItem, user, context); Dashboard.hideLoadingMsg(); @@ -1873,7 +1873,7 @@ type: "DELETE", url: ApiClient.getUrl("Videos/" + id + "/AlternateSources") - }).done(function () { + }).then(function () { Dashboard.hideLoadingMsg(); @@ -1934,7 +1934,7 @@ Dashboard.showLoadingMsg(); - ApiClient.cancelLiveTvTimer(id).done(function () { + ApiClient.cancelLiveTvTimer(id).then(function () { Dashboard.alert(Globalize.translate('MessageRecordingCancelled')); diff --git a/dashboard-ui/scripts/itemlistpage.js b/dashboard-ui/scripts/itemlistpage.js index 2cd05b5539..70df1527fa 100644 --- a/dashboard-ui/scripts/itemlistpage.js +++ b/dashboard-ui/scripts/itemlistpage.js @@ -53,7 +53,7 @@ var itemsPromise = ApiClient.getItems(userId, query); - Promise.all([parentItemPromise, itemsPromise]).done(function (responses) { + Promise.all([parentItemPromise, itemsPromise]).then(function (responses) { var item = responses[0]; currentItem = item; diff --git a/dashboard-ui/scripts/librarybrowser.js b/dashboard-ui/scripts/librarybrowser.js index 829646cf3d..bbc243fa0c 100644 --- a/dashboard-ui/scripts/librarybrowser.js +++ b/dashboard-ui/scripts/librarybrowser.js @@ -435,7 +435,7 @@ playAllFromHere: function (fn, index) { - fn(index, 100, "MediaSources,Chapters").done(function (result) { + fn(index, 100, "MediaSources,Chapters").then(function (result) { MediaController.play({ items: result.Items @@ -445,7 +445,7 @@ queueAllFromHere: function (query, index) { - fn(index, 100, "MediaSources,Chapters").done(function (result) { + fn(index, 100, "MediaSources,Chapters").then(function (result) { MediaController.queue({ items: result.Items @@ -577,7 +577,7 @@ playInExternalPlayer: function (id) { - Dashboard.loadExternalPlayer().done(function () { + Dashboard.loadExternalPlayer().then(function () { ExternalPlayer.showMenu(id); }); }, diff --git a/dashboard-ui/scripts/librarylist.js b/dashboard-ui/scripts/librarylist.js index d54924e195..dd6690c958 100644 --- a/dashboard-ui/scripts/librarylist.js +++ b/dashboard-ui/scripts/librarylist.js @@ -158,7 +158,7 @@ var id = this.getAttribute('data-itemid'); - ApiClient.getLocalTrailers(Dashboard.getCurrentUserId(), id).done(function (trailers) { + ApiClient.getLocalTrailers(Dashboard.getCurrentUserId(), id).then(function (trailers) { MediaController.play({ items: trailers }); }); @@ -226,7 +226,7 @@ var albumid = card.getAttribute('data-albumid'); var artistid = card.getAttribute('data-artistid'); - Dashboard.getCurrentUser().done(function (user) { + Dashboard.getCurrentUser().then(function (user) { var items = []; @@ -495,7 +495,7 @@ MediaController.queue(itemId); break; case 'trailer': - ApiClient.getLocalTrailers(Dashboard.getCurrentUserId(), itemId).done(function (trailers) { + ApiClient.getLocalTrailers(Dashboard.getCurrentUserId(), itemId).then(function (trailers) { MediaController.play({ items: trailers }); }); break; @@ -645,7 +645,7 @@ return; } - ApiClient.fetchJSON(ApiClient.getUrl('Users/' + userId + '/Items/Latest', options)).then(function (items) { + ApiClient.getJSON(ApiClient.getUrl('Users/' + userId + '/Items/Latest', options)).then(function (items) { if (items.length == 1) { @@ -1160,7 +1160,7 @@ type: "POST", url: ApiClient.getUrl("Videos/MergeVersions", { Ids: selection.join(',') }) - }).done(function () { + }).then(function () { Dashboard.hideLoadingMsg(); hideSelections(); diff --git a/dashboard-ui/scripts/librarymenu.js b/dashboard-ui/scripts/librarymenu.js index b5e369c879..44c4455720 100644 --- a/dashboard-ui/scripts/librarymenu.js +++ b/dashboard-ui/scripts/librarymenu.js @@ -188,7 +188,7 @@ if (requiresDrawerRefresh || requiresDashboardDrawerRefresh) { - ConnectionManager.user(window.ApiClient).done(function (user) { + ConnectionManager.user(window.ApiClient).then(function (user) { var drawer = document.querySelector('.mainDrawerPanel .mainDrawer'); @@ -389,7 +389,7 @@ var deferred = $.Deferred(); - apiClient.getUserViews({}, userId).done(function (result) { + apiClient.getUserViews({}, userId).then(function (result) { var items = result.Items; @@ -445,7 +445,7 @@ var apiClient = window.ApiClient; - getUserViews(apiClient, userId).done(function (result) { + getUserViews(apiClient, userId).then(function (result) { var items = result; @@ -786,7 +786,7 @@ updateLibraryNavLinks(page); requiresViewMenuRefresh = false; - ConnectionManager.user(window.ApiClient).done(addUserToHeader); + ConnectionManager.user(window.ApiClient).then(addUserToHeader); } else { viewMenuBar.classList.remove('hide'); diff --git a/dashboard-ui/scripts/librarypathmapping.js b/dashboard-ui/scripts/librarypathmapping.js index e15e913d6d..0daab1fe75 100644 --- a/dashboard-ui/scripts/librarypathmapping.js +++ b/dashboard-ui/scripts/librarypathmapping.js @@ -12,7 +12,7 @@ config.PathSubstitutions.splice(index, 1); - ApiClient.updateServerConfiguration(config).done(function () { + ApiClient.updateServerConfiguration(config).then(function () { reload(page); }); @@ -103,7 +103,7 @@ ApiClient.getServerConfiguration().then(function (config) { addSubstitution(page, config); - ApiClient.updateServerConfiguration(config).done(function () { + ApiClient.updateServerConfiguration(config).then(function () { reload(page); }); diff --git a/dashboard-ui/scripts/librarysettings.js b/dashboard-ui/scripts/librarysettings.js index ec3080c395..85b949d1dd 100644 --- a/dashboard-ui/scripts/librarysettings.js +++ b/dashboard-ui/scripts/librarysettings.js @@ -32,7 +32,7 @@ config.EnableAudioArchiveFiles = $('#chkEnableAudioArchiveFiles', form).checked(); config.EnableVideoArchiveFiles = $('#chkEnableVideoArchiveFiles', form).checked(); - ApiClient.updateServerConfiguration(config).done(Dashboard.processServerConfigurationUpdateResult); + ApiClient.updateServerConfiguration(config).then(Dashboard.processServerConfigurationUpdateResult); }); // Disable default form submission diff --git a/dashboard-ui/scripts/livetvchannel.js b/dashboard-ui/scripts/livetvchannel.js index eccb077019..c98d57665b 100644 --- a/dashboard-ui/scripts/livetvchannel.js +++ b/dashboard-ui/scripts/livetvchannel.js @@ -108,7 +108,7 @@ HasAired: false, SortBy: "StartDate" - }).done(function (result) { + }).then(function (result) { renderPrograms(page, result); diff --git a/dashboard-ui/scripts/livetvchannels.js b/dashboard-ui/scripts/livetvchannels.js index 14f56fa248..828643cf07 100644 --- a/dashboard-ui/scripts/livetvchannels.js +++ b/dashboard-ui/scripts/livetvchannels.js @@ -83,7 +83,7 @@ query.UserId = Dashboard.getCurrentUserId(); - ApiClient.getLiveTvChannels(query).done(function (result) { + ApiClient.getLiveTvChannels(query).then(function (result) { renderChannels(page, viewPanel, result); diff --git a/dashboard-ui/scripts/livetvcomponents.js b/dashboard-ui/scripts/livetvcomponents.js index 5989679f88..f54243d153 100644 --- a/dashboard-ui/scripts/livetvcomponents.js +++ b/dashboard-ui/scripts/livetvcomponents.js @@ -342,7 +342,7 @@ var id = elem.getAttribute('data-programid'); - ApiClient.getLiveTvProgram(id, Dashboard.getCurrentUserId()).done(function (item) { + ApiClient.getLiveTvProgram(id, Dashboard.getCurrentUserId()).then(function (item) { showOverlay(elem, item); diff --git a/dashboard-ui/scripts/livetvguideprovider.js b/dashboard-ui/scripts/livetvguideprovider.js index 3be8989d0a..26710ab12d 100644 --- a/dashboard-ui/scripts/livetvguideprovider.js +++ b/dashboard-ui/scripts/livetvguideprovider.js @@ -15,19 +15,20 @@ function loadTemplate(page, type, providerId) { - HttpClient.send({ + var xhr = new XMLHttpRequest(); + xhr.open('GET', 'components/tvproviders/' + type + '.template.html', true); - type: 'GET', - url: 'components/tvproviders/' + type + '.template.html' - - }).done(function (html) { + xhr.onload = function (e) { + var html = this.response; var elem = page.querySelector('.providerTemplate'); elem.innerHTML = Globalize.translateDocument(html); $(elem).trigger('create'); init(page, type, providerId); - }); + } + + xhr.send(); } $(document).on('pageshow', "#liveTvGuideProviderPage", function () { diff --git a/dashboard-ui/scripts/livetvitems.js b/dashboard-ui/scripts/livetvitems.js index 54debd31c8..8fa03bb2d6 100644 --- a/dashboard-ui/scripts/livetvitems.js +++ b/dashboard-ui/scripts/livetvitems.js @@ -22,7 +22,7 @@ Dashboard.showLoadingMsg(); - ApiClient.getLiveTvPrograms(query).done(function (result) { + ApiClient.getLiveTvPrograms(query).then(function (result) { // Scroll back up so they can see the results from the beginning window.scrollTo(0, 0); diff --git a/dashboard-ui/scripts/livetvnewrecording.js b/dashboard-ui/scripts/livetvnewrecording.js index 33e6eaa258..3fbede31b8 100644 --- a/dashboard-ui/scripts/livetvnewrecording.js +++ b/dashboard-ui/scripts/livetvnewrecording.js @@ -16,7 +16,7 @@ registrationInfo = null; Dashboard.showLoadingMsg(); - ApiClient.fetchJSON(ApiClient.getUrl('LiveTv/Registration', { + ApiClient.getJSON(ApiClient.getUrl('LiveTv/Registration', { ProgramId: programId, Feature: 'seriesrecordings' @@ -84,7 +84,7 @@ var promise1 = ApiClient.getNewLiveTvTimerDefaults({ programId: programId }); var promise2 = ApiClient.getLiveTvProgram(programId, Dashboard.getCurrentUserId()); - $.when(promise1, promise2).done(function (response1, response2) { + $.when(promise1, promise2).then(function (response1, response2) { var defaults = response1[0]; var program = response2[0]; @@ -142,7 +142,7 @@ var programId = getParameterByName('programid'); - ApiClient.getNewLiveTvTimerDefaults({ programId: programId }).done(function (item) { + ApiClient.getNewLiveTvTimerDefaults({ programId: programId }).then(function (item) { item.PrePaddingSeconds = $('#txtPrePaddingMinutes', form).val() * 60; item.PostPaddingSeconds = $('#txtPostPaddingMinutes', form).val() * 60; @@ -155,7 +155,7 @@ if ($('#chkRecordSeries', form).checked()) { - ApiClient.createLiveTvSeriesTimer(item).done(function () { + ApiClient.createLiveTvSeriesTimer(item).then(function () { Dashboard.hideLoadingMsg(); Dashboard.navigate('livetv.html'); @@ -163,7 +163,7 @@ }); } else { - ApiClient.createLiveTvTimer(item).done(function () { + ApiClient.createLiveTvTimer(item).then(function () { Dashboard.hideLoadingMsg(); Dashboard.navigate('livetv.html'); @@ -187,7 +187,7 @@ $('#seriesFields', page).show(); page.querySelector('.btnSubmitContainer').classList.remove('hide'); - getRegistration(getParameterByName('programid')).done(function (regInfo) { + getRegistration(getParameterByName('programid')).then(function (regInfo) { if (regInfo.IsValid) { page.querySelector('.btnSubmitContainer').classList.remove('hide'); diff --git a/dashboard-ui/scripts/livetvrecordinglist.js b/dashboard-ui/scripts/livetvrecordinglist.js index 2fbbcefce6..4da9215e7a 100644 --- a/dashboard-ui/scripts/livetvrecordinglist.js +++ b/dashboard-ui/scripts/livetvrecordinglist.js @@ -11,7 +11,7 @@ Dashboard.showLoadingMsg(); - ApiClient.getLiveTvRecordings(query).done(function (result) { + ApiClient.getLiveTvRecordings(query).then(function (result) { // Scroll back up so they can see the results from the beginning window.scrollTo(0, 0); @@ -107,7 +107,7 @@ if (query.GroupId) { - ApiClient.getLiveTvRecordingGroup(query.GroupId).done(function (group) { + ApiClient.getLiveTvRecordingGroup(query.GroupId).then(function (group) { $('.listName', page).html(group.Name); }); diff --git a/dashboard-ui/scripts/livetvrecordings.js b/dashboard-ui/scripts/livetvrecordings.js index 3266f891c3..cd8d6be0f1 100644 --- a/dashboard-ui/scripts/livetvrecordings.js +++ b/dashboard-ui/scripts/livetvrecordings.js @@ -86,7 +86,7 @@ userId: Dashboard.getCurrentUserId(), IsInProgress: true - }).done(function (result) { + }).then(function (result) { renderRecordings(page.querySelector('#activeRecordings'), result.Items); @@ -98,7 +98,7 @@ limit: 12, IsInProgress: false - }).done(function (result) { + }).then(function (result) { renderRecordings(page.querySelector('#latestRecordings'), result.Items); }); @@ -107,7 +107,7 @@ userId: Dashboard.getCurrentUserId() - }).done(function (result) { + }).then(function (result) { renderRecordingGroups(page, result.Items); diff --git a/dashboard-ui/scripts/livetvseriestimer.js b/dashboard-ui/scripts/livetvseriestimer.js index 074fe4b202..327657fb98 100644 --- a/dashboard-ui/scripts/livetvseriestimer.js +++ b/dashboard-ui/scripts/livetvseriestimer.js @@ -10,7 +10,7 @@ Dashboard.showLoadingMsg(); - ApiClient.cancelLiveTvTimer(id).done(function () { + ApiClient.cancelLiveTvTimer(id).then(function () { Dashboard.alert(Globalize.translate('MessageRecordingCancelled')); @@ -103,7 +103,7 @@ var form = this; - ApiClient.getLiveTvSeriesTimer(currentItem.Id).done(function (item) { + ApiClient.getLiveTvSeriesTimer(currentItem.Id).then(function (item) { item.PrePaddingSeconds = $('#txtPrePaddingMinutes', form).val() * 60; item.PostPaddingSeconds = $('#txtPostPaddingMinutes', form).val() * 60; @@ -114,7 +114,7 @@ item.Days = getDays(form); - ApiClient.updateLiveTvSeriesTimer(item).done(function () { + ApiClient.updateLiveTvSeriesTimer(item).then(function () { Dashboard.alert(Globalize.translate('MessageRecordingSaved')); }); }); @@ -159,7 +159,7 @@ var id = getParameterByName('id'); - ApiClient.getLiveTvSeriesTimer(id).done(function (result) { + ApiClient.getLiveTvSeriesTimer(id).then(function (result) { renderTimer(page, result); @@ -170,7 +170,7 @@ userId: Dashboard.getCurrentUserId(), seriesTimerId: id - }).done(function (recordingResult) { + }).then(function (recordingResult) { renderRecordings(page, recordingResult); @@ -180,7 +180,7 @@ seriesTimerId: id - }).done(function (timerResult) { + }).then(function (timerResult) { renderSchedule(page, timerResult); diff --git a/dashboard-ui/scripts/livetvseriestimers.js b/dashboard-ui/scripts/livetvseriestimers.js index 3a6736b183..e85f9259b2 100644 --- a/dashboard-ui/scripts/livetvseriestimers.js +++ b/dashboard-ui/scripts/livetvseriestimers.js @@ -14,7 +14,7 @@ Dashboard.showLoadingMsg(); - ApiClient.cancelLiveTvSeriesTimer(id).done(function () { + ApiClient.cancelLiveTvSeriesTimer(id).then(function () { Dashboard.alert(Globalize.translate('MessageSeriesCancelled')); @@ -102,7 +102,7 @@ Dashboard.showLoadingMsg(); - ApiClient.getLiveTvSeriesTimers(query).done(function (result) { + ApiClient.getLiveTvSeriesTimers(query).then(function (result) { renderTimers(page, result.Items); diff --git a/dashboard-ui/scripts/livetvsettings.js b/dashboard-ui/scripts/livetvsettings.js index c7f6473dc7..46ff19d041 100644 --- a/dashboard-ui/scripts/livetvsettings.js +++ b/dashboard-ui/scripts/livetvsettings.js @@ -24,7 +24,7 @@ var form = this; - ApiClient.getNamedConfiguration("livetv").done(function (config) { + ApiClient.getNamedConfiguration("livetv").then(function (config) { config.GuideDays = $('#selectGuideDays', form).val() || null; config.EnableMovieProviders = $('#chkMovies', form).checked(); @@ -34,7 +34,7 @@ config.PrePaddingSeconds = $('#txtPrePaddingMinutes', form).val() * 60; config.PostPaddingSeconds = $('#txtPostPaddingMinutes', form).val() * 60; - ApiClient.updateNamedConfiguration("livetv", config).done(Dashboard.processServerConfigurationUpdateResult); + ApiClient.updateNamedConfiguration("livetv", config).then(Dashboard.processServerConfigurationUpdateResult); }); // Disable default form submission @@ -72,7 +72,7 @@ var page = this; - ApiClient.getNamedConfiguration("livetv").done(function (config) { + ApiClient.getNamedConfiguration("livetv").then(function (config) { loadPage(page, config); diff --git a/dashboard-ui/scripts/livetvstatus.js b/dashboard-ui/scripts/livetvstatus.js index 4372424d16..f8b7328039 100644 --- a/dashboard-ui/scripts/livetvstatus.js +++ b/dashboard-ui/scripts/livetvstatus.js @@ -10,7 +10,7 @@ Dashboard.showLoadingMsg(); - ApiClient.resetLiveTvTuner(id).done(function () { + ApiClient.resetLiveTvTuner(id).then(function () { Dashboard.hideLoadingMsg(); @@ -172,7 +172,7 @@ renderTuners(page, tuners); - ApiClient.getNamedConfiguration("livetv").done(function (config) { + ApiClient.getNamedConfiguration("livetv").then(function (config) { renderDevices(page, config.TunerHosts); renderProviders(page, config.ListingProviders); @@ -243,7 +243,7 @@ Id: id }) - }).done(function () { + }).then(function () { reload(page); }); @@ -255,7 +255,7 @@ Dashboard.showLoadingMsg(); - ApiClient.getLiveTvInfo().done(function (liveTvInfo) { + ApiClient.getLiveTvInfo().then(function (liveTvInfo) { loadPage(page, liveTvInfo); @@ -276,11 +276,11 @@ }), contentType: "application/json" - }).done(function () { + }).then(function () { reload(page); - }).fail(function () { + }, function () { Dashboard.alert({ message: Globalize.translate('ErrorAddingTunerDevice') }); @@ -345,7 +345,11 @@ Id: id }) - }).always(function () { + }).then(function () { + + reload(page); + + }, function () { reload(page); }); diff --git a/dashboard-ui/scripts/livetvsuggested.js b/dashboard-ui/scripts/livetvsuggested.js index 23fd2a3caf..50618de043 100644 --- a/dashboard-ui/scripts/livetvsuggested.js +++ b/dashboard-ui/scripts/livetvsuggested.js @@ -33,7 +33,7 @@ ImageTypeLimit: 1, EnableImageTypes: "Primary" - }).done(function (result) { + }).then(function (result) { renderItems(page, result.Items, 'activeProgramItems', 'play'); LibraryBrowser.setLastRefreshed(page); @@ -56,7 +56,7 @@ IsKids: false, IsSeries: true - }).done(function (result) { + }).then(function (result) { renderItems(page, result.Items, 'upcomingProgramItems'); }); @@ -69,7 +69,7 @@ limit: getLimit(), IsMovie: true - }).done(function (result) { + }).then(function (result) { renderItems(page, result.Items, 'upcomingTvMovieItems', null, getPortraitShape()); }); @@ -82,7 +82,7 @@ limit: getLimit(), IsSports: true - }).done(function (result) { + }).then(function (result) { renderItems(page, result.Items, 'upcomingSportsItems'); }); @@ -95,7 +95,7 @@ limit: getLimit(), IsKids: true - }).done(function (result) { + }).then(function (result) { renderItems(page, result.Items, 'upcomingKidsItems'); }); diff --git a/dashboard-ui/scripts/livetvtimer.js b/dashboard-ui/scripts/livetvtimer.js index 3823bf29c8..7dde49ad32 100644 --- a/dashboard-ui/scripts/livetvtimer.js +++ b/dashboard-ui/scripts/livetvtimer.js @@ -10,7 +10,7 @@ Dashboard.showLoadingMsg(); - ApiClient.cancelLiveTvTimer(id).done(function () { + ApiClient.cancelLiveTvTimer(id).then(function () { Dashboard.alert(Globalize.translate('MessageRecordingCancelled')); @@ -72,12 +72,12 @@ var form = this; - ApiClient.getLiveTvTimer(currentItem.Id).done(function (item) { + ApiClient.getLiveTvTimer(currentItem.Id).then(function (item) { item.PrePaddingSeconds = $('#txtPrePaddingMinutes', form).val() * 60; item.PostPaddingSeconds = $('#txtPostPaddingMinutes', form).val() * 60; - ApiClient.updateLiveTvTimer(item).done(function () { + ApiClient.updateLiveTvTimer(item).then(function () { Dashboard.hideLoadingMsg(); Dashboard.alert(Globalize.translate('MessageRecordingSaved')); }); @@ -94,7 +94,7 @@ var id = getParameterByName('id'); - ApiClient.getLiveTvTimer(id).done(function (result) { + ApiClient.getLiveTvTimer(id).then(function (result) { renderTimer(page, result); diff --git a/dashboard-ui/scripts/livetvtimers.js b/dashboard-ui/scripts/livetvtimers.js index 0809bdcd9d..b54ab26e1f 100644 --- a/dashboard-ui/scripts/livetvtimers.js +++ b/dashboard-ui/scripts/livetvtimers.js @@ -8,7 +8,7 @@ Dashboard.showLoadingMsg(); - ApiClient.cancelLiveTvTimer(id).done(function () { + ApiClient.cancelLiveTvTimer(id).then(function () { Dashboard.alert(Globalize.translate('MessageRecordingCancelled')); @@ -39,7 +39,7 @@ Dashboard.showLoadingMsg(); - ApiClient.getLiveTvTimers().done(function (result) { + ApiClient.getLiveTvTimers().then(function (result) { renderTimers(page, result.Items); }); diff --git a/dashboard-ui/scripts/livetvtunerprovider-hdhomerun.js b/dashboard-ui/scripts/livetvtunerprovider-hdhomerun.js index ae1b9bcc7a..66e26c5705 100644 --- a/dashboard-ui/scripts/livetvtunerprovider-hdhomerun.js +++ b/dashboard-ui/scripts/livetvtunerprovider-hdhomerun.js @@ -6,7 +6,7 @@ page.querySelector('.chkFavorite').checked = false; if (providerId) { - ApiClient.getNamedConfiguration("livetv").done(function (config) { + ApiClient.getNamedConfiguration("livetv").then(function (config) { var info = config.TunerHosts.filter(function (i) { return i.Id == providerId; @@ -45,12 +45,12 @@ data: JSON.stringify(info), contentType: "application/json" - }).done(function (result) { + }).then(function (result) { Dashboard.processServerConfigurationUpdateResult(); Dashboard.navigate('livetvstatus.html'); - }).fail(function () { + }, function () { Dashboard.alert({ message: Globalize.translate('ErrorSavingTvProvider') }); diff --git a/dashboard-ui/scripts/livetvtunerprovider-m3u.js b/dashboard-ui/scripts/livetvtunerprovider-m3u.js index 8470ba00a7..b56f00f819 100644 --- a/dashboard-ui/scripts/livetvtunerprovider-m3u.js +++ b/dashboard-ui/scripts/livetvtunerprovider-m3u.js @@ -5,7 +5,7 @@ page.querySelector('.txtDevicePath').value = ''; if (providerId) { - ApiClient.getNamedConfiguration("livetv").done(function (config) { + ApiClient.getNamedConfiguration("livetv").then(function (config) { var info = config.TunerHosts.filter(function (i) { return i.Id == providerId; @@ -37,12 +37,12 @@ data: JSON.stringify(info), contentType: "application/json" - }).done(function (result) { + }).then(function (result) { Dashboard.processServerConfigurationUpdateResult(); Dashboard.navigate('livetvstatus.html'); - }).fail(function () { + }, function () { Dashboard.hideLoadingMsg(); Dashboard.alert({ message: Globalize.translate('ErrorSavingTvProvider') diff --git a/dashboard-ui/scripts/localsync.js b/dashboard-ui/scripts/localsync.js index 4a2247ee8c..b0b49ea67d 100644 --- a/dashboard-ui/scripts/localsync.js +++ b/dashboard-ui/scripts/localsync.js @@ -24,12 +24,12 @@ options.cameraUploadServers = AppSettings.cameraUploadServers(); - syncPromise = new MediaBrowser.MultiServerSync(ConnectionManager).sync(options).done(function () { + syncPromise = new MediaBrowser.MultiServerSync(ConnectionManager).sync(options).then(function () { syncPromise = null; deferred.resolve(); - }).fail(function () { + }, function () { syncPromise = null; }); diff --git a/dashboard-ui/scripts/loginpage.js b/dashboard-ui/scripts/loginpage.js index 4c738c7f93..b219151ff3 100644 --- a/dashboard-ui/scripts/loginpage.js +++ b/dashboard-ui/scripts/loginpage.js @@ -21,9 +21,9 @@ var page = this; - LoginPage.getApiClient().done(function (apiClient) { + LoginPage.getApiClient().then(function (apiClient) { - apiClient.getPublicUsers().done(function (users) { + apiClient.getPublicUsers().then(function (users) { var showManualForm = !users.length; @@ -40,7 +40,7 @@ Dashboard.hideLoadingMsg(); }); - apiClient.fetchJSON(apiClient.getUrl('Branding/Configuration')).then(function (options) { + apiClient.getJSON(apiClient.getUrl('Branding/Configuration')).then(function (options) { $('.disclaimer', page).html(options.LoginDisclaimer || ''); }); @@ -93,7 +93,7 @@ Dashboard.showLoadingMsg(); - apiClient.authenticateUserByName(username, password).done(function (result) { + apiClient.authenticateUserByName(username, password).then(function (result) { var user = result.User; @@ -112,7 +112,7 @@ Dashboard.onServerChanged(user.Id, result.AccessToken, apiClient); Dashboard.navigate(newUrl); - }).fail(function () { + }, function () { $('#pw', page).val(''); $('#txtManualName', page).val(''); @@ -207,7 +207,7 @@ var page = $(this).parents('.page'); - LoginPage.getApiClient().done(function (apiClient) { + LoginPage.getApiClient().then(function (apiClient) { LoginPage.authenticateUserByName(page, apiClient, $('#txtManualName', page).val(), $('#txtManualPassword', page).val()); }); diff --git a/dashboard-ui/scripts/logpage.js b/dashboard-ui/scripts/logpage.js index 4889cc8014..e1b0584053 100644 --- a/dashboard-ui/scripts/logpage.js +++ b/dashboard-ui/scripts/logpage.js @@ -6,7 +6,7 @@ var apiClient = ApiClient; - apiClient.fetchJSON(apiClient.getUrl('System/Logs')).then(function (logs) { + apiClient.getJSON(apiClient.getUrl('System/Logs')).then(function (logs) { var html = ''; diff --git a/dashboard-ui/scripts/mediacontroller.js b/dashboard-ui/scripts/mediacontroller.js index ba5bc202e9..3bd92dceb1 100644 --- a/dashboard-ui/scripts/mediacontroller.js +++ b/dashboard-ui/scripts/mediacontroller.js @@ -75,7 +75,7 @@ Dashboard.showModalLoadingMsg(); - MediaController.getTargets().done(function (targets) { + MediaController.getTargets().then(function (targets) { var menuItems = targets.map(function (t) { @@ -207,7 +207,7 @@ var player = controller.getCurrentPlayer(); - player.getPlayerState().done(function (result) { + player.getPlayerState().then(function (result) { var state = result; @@ -321,7 +321,7 @@ currentPairingId = targetInfo.id; - player.tryPair(targetInfo).done(function () { + player.tryPair(targetInfo).then(function () { currentPlayer = player; currentTargetInfo = targetInfo; @@ -340,7 +340,7 @@ name = normalizeName(name); - self.getTargets().done(function (result) { + self.getTargets().then(function (result) { var target = result.filter(function (p) { return normalizeName(p.name) == name; @@ -418,7 +418,7 @@ return p.getTargets(); }); - $.when.apply($, promises).done(function () { + $.when.apply($, promises).then(function () { var targets = []; @@ -461,7 +461,7 @@ self.playbackTimeLimitMs = null; - RegistrationServices.validateFeature('playback').done(fn).fail(function () { + RegistrationServices.validateFeature('playback').then(fn, function () { self.playbackTimeLimitMs = lockedTimeLimitMs; startAutoStopTimer(); @@ -801,7 +801,7 @@ var serverInfo = ApiClient.serverInfo(); if (serverInfo.Id) { - LocalAssetManager.getLocalMediaSource(serverInfo.Id, itemId).done(function (localMediaSource) { + LocalAssetManager.getLocalMediaSource(serverInfo.Id, itemId).then(function (localMediaSource) { // Use the local media source if a specific one wasn't requested, or the smae one was requested if (localMediaSource && (!mediaSource || mediaSource.Id == localMediaSource.Id)) { @@ -823,9 +823,9 @@ } function getPlaybackInfoWithoutLocalMediaSource(itemId, deviceProfile, startPosition, mediaSource, audioStreamIndex, subtitleStreamIndex, liveStreamId, deferred) { - self.getPlaybackInfoInternal(itemId, deviceProfile, startPosition, mediaSource, audioStreamIndex, subtitleStreamIndex, liveStreamId).done(function (result) { + self.getPlaybackInfoInternal(itemId, deviceProfile, startPosition, mediaSource, audioStreamIndex, subtitleStreamIndex, liveStreamId).then(function (result) { deferred.resolveWith(null, [result]); - }).fail(function () { + }, function () { deferred.reject(); }); } @@ -916,7 +916,7 @@ require(['localassetmanager'], function () { - LocalAssetManager.fileExists(mediaSource.Path).done(function (exists) { + LocalAssetManager.fileExists(mediaSource.Path).then(function (exists) { Logger.log('LocalAssetManager.fileExists: path: ' + mediaSource.Path + ' result: ' + exists); deferred.resolveWith(null, [exists]); }); diff --git a/dashboard-ui/scripts/medialibrarypage.js b/dashboard-ui/scripts/medialibrarypage.js index ec40cf5f4f..9543266fcb 100644 --- a/dashboard-ui/scripts/medialibrarypage.js +++ b/dashboard-ui/scripts/medialibrarypage.js @@ -17,7 +17,7 @@ collectionTypeOptions: getCollectionTypeOptions(), refresh: shouldRefreshLibraryAfterChanges(page) - }).done(function (hasChanges) { + }).then(function (hasChanges) { if (hasChanges) { reloadLibrary(page); @@ -35,7 +35,7 @@ refresh: shouldRefreshLibraryAfterChanges(page), library: virtualFolder - }).done(function (hasChanges) { + }).then(function (hasChanges) { if (hasChanges) { reloadLibrary(page); @@ -59,7 +59,7 @@ var refreshAfterChange = shouldRefreshLibraryAfterChanges(page); - ApiClient.removeVirtualFolder(virtualFolder.Name, refreshAfterChange).done(function () { + ApiClient.removeVirtualFolder(virtualFolder.Name, refreshAfterChange).then(function () { reloadLibrary(page); }); } @@ -80,7 +80,7 @@ var refreshAfterChange = shouldRefreshLibraryAfterChanges(page); - ApiClient.renameVirtualFolder(virtualFolder.Name, newName, refreshAfterChange).done(function () { + ApiClient.renameVirtualFolder(virtualFolder.Name, newName, refreshAfterChange).then(function () { reloadLibrary(page); }); } @@ -156,7 +156,7 @@ Dashboard.showLoadingMsg(); - ApiClient.getVirtualFolders().done(function (result) { + ApiClient.getVirtualFolders().then(function (result) { reloadVirtualFolders(page, result); }); } @@ -211,7 +211,7 @@ ImageEditor.show(virtualFolder.ItemId, { theme: 'a' - }).done(function (hasChanged) { + }).then(function (hasChanged) { if (hasChanged) { reloadLibrary(page); } @@ -441,7 +441,7 @@ var WizardLibraryPage = { type: "POST", url: apiClient.getUrl('System/Configuration/MetadataPlugins/Autoset') - }).done(function () { + }).then(function () { Dashboard.hideLoadingMsg(); Dashboard.navigate('wizardsettings.html'); diff --git a/dashboard-ui/scripts/mediaplayer-video.js b/dashboard-ui/scripts/mediaplayer-video.js index be15164e38..8f99b7ee75 100644 --- a/dashboard-ui/scripts/mediaplayer-video.js +++ b/dashboard-ui/scripts/mediaplayer-video.js @@ -955,7 +955,7 @@ requirejs(['videorenderer'], function () { - self.createStreamInfo('Video', item, mediaSource, startPosition).done(function (streamInfo) { + self.createStreamInfo('Video', item, mediaSource, startPosition).then(function (streamInfo) { // Huge hack alert. Safari doesn't seem to like if the segments aren't available right away when playback starts // This will start the transcoding process before actually feeding the video url into the player @@ -964,14 +964,15 @@ Dashboard.showLoadingMsg(); ApiClient.ajax({ + type: 'GET', url: streamInfo.url.replace('master.m3u8', 'live.m3u8') - }).always(function () { + }).then(function () { Dashboard.hideLoadingMsg(); - - }).done(function () { self.playVideoInternal(item, mediaSource, startPosition, streamInfo, callback); + }, function () { + Dashboard.hideLoadingMsg(); }); } else { @@ -1135,7 +1136,7 @@ self.updateNowPlayingInfo(item); - mediaRenderer.init().done(function () { + mediaRenderer.init().then(function () { self.onBeforePlaybackStart(mediaRenderer, item, mediaSource); diff --git a/dashboard-ui/scripts/mediaplayer.js b/dashboard-ui/scripts/mediaplayer.js index f43a532f80..90539e5710 100644 --- a/dashboard-ui/scripts/mediaplayer.js +++ b/dashboard-ui/scripts/mediaplayer.js @@ -668,7 +668,7 @@ }); if (self.currentItem.MediaType == "Video") { - ApiClient.stopActiveEncodings(playSessionId).done(function () { + ApiClient.stopActiveEncodings(playSessionId).then(function () { //self.startTimeTicksOffset = newPositionTicks; self.setSrcIntoRenderer(mediaRenderer, streamInfo, self.currentItem, self.currentMediaSource); @@ -862,7 +862,7 @@ return; } - ApiClient.fetchJSON(ApiClient.getUrl('Users/' + user.Id + '/Items/' + firstItem.Id + '/Intros')).then(function (intros) { + ApiClient.getJSON(ApiClient.getUrl('Users/' + user.Id + '/Items/' + firstItem.Id + '/Intros')).then(function (intros) { items = intros.Items.concat(items); self.playInternal(items[0], options.startPositionTicks, function () { @@ -880,7 +880,7 @@ return MediaController.supportsDirectPlay(v); }); - $.when.apply($, promises).done(function () { + $.when.apply($, promises).then(function () { for (var i = 0, length = versions.length; i < length; i++) { versions[i].enableDirectPlay = arguments[i] || false; @@ -1036,7 +1036,7 @@ require(['localassetmanager'], function () { - LocalAssetManager.translateFilePath(resultInfo.url).done(function (path) { + LocalAssetManager.translateFilePath(resultInfo.url).then(function (path) { resultInfo.url = path; Logger.log('LocalAssetManager.translateFilePath: path: ' + resultInfo.url + ' result: ' + path); @@ -1087,7 +1087,8 @@ AppSettings.maxStreamingBitrate(bitrate); playOnDeviceProfileCreated(self.getDeviceProfile(), item, startPosition, callback); - }).fail(function () { + + }, function () { playOnDeviceProfileCreated(self.getDeviceProfile(), item, startPosition, callback); }); @@ -1108,14 +1109,14 @@ if (validatePlaybackInfoResult(playbackInfoResult)) { - getOptimalMediaSource(item.MediaType, playbackInfoResult.MediaSources).done(function (mediaSource) { + getOptimalMediaSource(item.MediaType, playbackInfoResult.MediaSources).then(function (mediaSource) { if (mediaSource) { if (mediaSource.RequiresOpening) { - MediaController.getLiveStream(item.Id, playbackInfoResult.PlaySessionId, deviceProfile, startPosition, mediaSource, null, null).done(function (openLiveStreamResult) { + MediaController.getLiveStream(item.Id, playbackInfoResult.PlaySessionId, deviceProfile, startPosition, mediaSource, null, null).then(function (openLiveStreamResult) { - MediaController.supportsDirectPlay(openLiveStreamResult.MediaSource).done(function (result) { + MediaController.supportsDirectPlay(openLiveStreamResult.MediaSource).then(function (result) { openLiveStreamResult.MediaSource.enableDirectPlay = result; callback(openLiveStreamResult.MediaSource); diff --git a/dashboard-ui/scripts/metadataadvanced.js b/dashboard-ui/scripts/metadataadvanced.js index 19741c3309..c98fa4d7fc 100644 --- a/dashboard-ui/scripts/metadataadvanced.js +++ b/dashboard-ui/scripts/metadataadvanced.js @@ -107,23 +107,23 @@ }); - ApiClient.getNamedConfiguration("metadata").done(function (metadata) { + ApiClient.getNamedConfiguration("metadata").then(function (metadata) { loadMetadataConfig(page, metadata); }); - ApiClient.getNamedConfiguration("fanart").done(function (metadata) { + ApiClient.getNamedConfiguration("fanart").then(function (metadata) { loadFanartConfig(page, metadata); }); - ApiClient.getNamedConfiguration("themoviedb").done(function (metadata) { + ApiClient.getNamedConfiguration("themoviedb").then(function (metadata) { loadTmdbConfig(page, metadata); }); - ApiClient.getNamedConfiguration("tvdb").done(function (metadata) { + ApiClient.getNamedConfiguration("tvdb").then(function (metadata) { loadTvdbConfig(page, metadata); }); @@ -131,7 +131,7 @@ var promise1 = ApiClient.getNamedConfiguration("chapters"); var promise2 = ApiClient.getJSON(ApiClient.getUrl("Providers/Chapters")); - $.when(promise1, promise2).done(function (response1, response2) { + $.when(promise1, promise2).then(function (response1, response2) { loadChapters(page, response1[0], response2[0]); }); @@ -139,7 +139,7 @@ function saveFanart(form) { - ApiClient.getNamedConfiguration("fanart").done(function (config) { + ApiClient.getNamedConfiguration("fanart").then(function (config) { config.EnableAutomaticUpdates = $('#chkEnableFanartUpdates', form).checked(); config.UserApiKey = $('#txtFanartApiKey', form).val(); @@ -150,7 +150,7 @@ function saveTvdb(form) { - ApiClient.getNamedConfiguration("tvdb").done(function (config) { + ApiClient.getNamedConfiguration("tvdb").then(function (config) { config.EnableAutomaticUpdates = $('#chkEnableTvdbUpdates', form).checked(); @@ -160,7 +160,7 @@ function saveTmdb(form) { - ApiClient.getNamedConfiguration("themoviedb").done(function (config) { + ApiClient.getNamedConfiguration("themoviedb").then(function (config) { config.EnableAutomaticUpdates = $('#chkEnableTmdbUpdates', form).checked(); @@ -190,13 +190,13 @@ config.PeopleMetadataOptions.DownloadWriterMetadata = $('#chkPeopleWriters', form).checked(); config.PeopleMetadataOptions.DownloadOtherPeopleMetadata = $('#chkPeopleOthers', form).checked(); - ApiClient.updateServerConfiguration(config).done(Dashboard.processServerConfigurationUpdateResult); + ApiClient.updateServerConfiguration(config).then(Dashboard.processServerConfigurationUpdateResult); }); } function saveMetadata(form) { - ApiClient.getNamedConfiguration("metadata").done(function (config) { + ApiClient.getNamedConfiguration("metadata").then(function (config) { config.UseFileCreationTimeForDateAdded = $('#selectDateAdded', form).val() == '1'; @@ -206,7 +206,7 @@ function saveChapters(form) { - ApiClient.getNamedConfiguration("chapters").done(function (config) { + ApiClient.getNamedConfiguration("chapters").then(function (config) { config.EnableMovieChapterImageExtraction = $('#chkChaptersMovies', form).checked(); config.EnableEpisodeChapterImageExtraction = $('#chkChaptersEpisodes', form).checked(); diff --git a/dashboard-ui/scripts/metadataconfigurationpage.js b/dashboard-ui/scripts/metadataconfigurationpage.js index a0d8524495..8e1a5ddafe 100644 --- a/dashboard-ui/scripts/metadataconfigurationpage.js +++ b/dashboard-ui/scripts/metadataconfigurationpage.js @@ -29,7 +29,7 @@ config.PreferredMetadataLanguage = $('#selectLanguage', form).val(); config.MetadataCountryCode = $('#selectCountry', form).val(); - ApiClient.updateServerConfiguration(config).done(Dashboard.processServerConfigurationUpdateResult); + ApiClient.updateServerConfiguration(config).then(Dashboard.processServerConfigurationUpdateResult); }); // Disable default form submission @@ -58,7 +58,7 @@ load(page, config, allCultures, allCountries); }); - ApiClient.getCultures().done(function (result) { + ApiClient.getCultures().then(function (result) { Dashboard.populateLanguages($('#selectLanguage', page), result); @@ -66,7 +66,7 @@ load(page, config, allCultures, allCountries); }); - ApiClient.getCountries().done(function (result) { + ApiClient.getCountries().then(function (result) { Dashboard.populateCountries($('#selectCountry', page), result); diff --git a/dashboard-ui/scripts/metadataimagespage.js b/dashboard-ui/scripts/metadataimagespage.js index cf9cf3f32d..2e34b1a1d2 100644 --- a/dashboard-ui/scripts/metadataimagespage.js +++ b/dashboard-ui/scripts/metadataimagespage.js @@ -27,7 +27,7 @@ currentType = type; var promise1 = ApiClient.getServerConfiguration(); - var promise2 = ApiClient.fetchJSON(ApiClient.getUrl("System/Configuration/MetadataPlugins")); + var promise2 = ApiClient.getJSON(ApiClient.getUrl("System/Configuration/MetadataPlugins")); Promise.all([promise1, promise2]).then(function (responses) { @@ -46,7 +46,7 @@ } else { - ApiClient.fetchJSON(ApiClient.getUrl("System/Configuration/MetadataOptions/Default")).then(function (defaultConfig) { + ApiClient.getJSON(ApiClient.getUrl("System/Configuration/MetadataOptions/Default")).then(function (defaultConfig) { config = defaultConfig; @@ -501,16 +501,16 @@ if (metadataOptions) { saveSettingsIntoConfig(form, metadataOptions); - ApiClient.updateServerConfiguration(config).done(Dashboard.processServerConfigurationUpdateResult); + ApiClient.updateServerConfiguration(config).then(Dashboard.processServerConfigurationUpdateResult); } else { - ApiClient.fetchJSON(ApiClient.getUrl("System/Configuration/MetadataOptions/Default")).then(function (defaultOptions) { + ApiClient.getJSON(ApiClient.getUrl("System/Configuration/MetadataOptions/Default")).then(function (defaultOptions) { defaultOptions.ItemType = type; config.MetadataOptions.push(defaultOptions); saveSettingsIntoConfig(form, defaultOptions); - ApiClient.updateServerConfiguration(config).done(Dashboard.processServerConfigurationUpdateResult); + ApiClient.updateServerConfiguration(config).then(Dashboard.processServerConfigurationUpdateResult); }); } diff --git a/dashboard-ui/scripts/metadatanfo.js b/dashboard-ui/scripts/metadatanfo.js index 9ff57f5f3f..41a6ce473e 100644 --- a/dashboard-ui/scripts/metadatanfo.js +++ b/dashboard-ui/scripts/metadatanfo.js @@ -24,7 +24,7 @@ var form = this; - ApiClient.getNamedConfiguration(metadataKey).done(function (config) { + ApiClient.getNamedConfiguration(metadataKey).then(function (config) { config.UserId = $('#selectUser', form).val() || null; config.ReleaseDateFormat = $('#selectReleaseDateFormat', form).val(); @@ -32,7 +32,7 @@ config.EnablePathSubstitution = $('#chkEnablePathSubstitution', form).checked(); config.EnableExtraThumbsDuplication = $('#chkEnableExtraThumbs', form).checked(); - ApiClient.updateNamedConfiguration(metadataKey, config).done(Dashboard.processServerConfigurationUpdateResult); + ApiClient.updateNamedConfiguration(metadataKey, config).then(Dashboard.processServerConfigurationUpdateResult); }); // Disable default form submission @@ -52,7 +52,7 @@ var promise1 = ApiClient.getUsers(); var promise2 = ApiClient.getNamedConfiguration(metadataKey); - $.when(promise1, promise2).done(function (response1, response2) { + $.when(promise1, promise2).then(function (response1, response2) { loadPage(page, response2[0], response1[0]); }); diff --git a/dashboard-ui/scripts/metadatasubtitles.js b/dashboard-ui/scripts/metadatasubtitles.js index c6f9bec9b2..903ea19afc 100644 --- a/dashboard-ui/scripts/metadatasubtitles.js +++ b/dashboard-ui/scripts/metadatasubtitles.js @@ -48,7 +48,7 @@ var form = this; - ApiClient.getNamedConfiguration("subtitles").done(function (config) { + ApiClient.getNamedConfiguration("subtitles").then(function (config) { config.DownloadMovieSubtitles = $('#chkSubtitlesMovies', form).checked(); config.DownloadEpisodeSubtitles = $('#chkSubtitlesEpisodes', form).checked(); @@ -70,7 +70,7 @@ }); - ApiClient.updateNamedConfiguration("subtitles", config).done(Dashboard.processServerConfigurationUpdateResult); + ApiClient.updateNamedConfiguration("subtitles", config).then(Dashboard.processServerConfigurationUpdateResult); }); // Disable default form submission @@ -90,7 +90,7 @@ var promise1 = ApiClient.getNamedConfiguration("subtitles"); var promise2 = ApiClient.getCultures(); - $.when(promise1, promise2).done(function (response1, response2) { + $.when(promise1, promise2).then(function (response1, response2) { loadPage(page, response1[0], response2[0]); diff --git a/dashboard-ui/scripts/moviegenres.js b/dashboard-ui/scripts/moviegenres.js index 97efe44f64..270c917ccd 100644 --- a/dashboard-ui/scripts/moviegenres.js +++ b/dashboard-ui/scripts/moviegenres.js @@ -40,7 +40,7 @@ Dashboard.showLoadingMsg(); var query = getQuery(); - ApiClient.getGenres(Dashboard.getCurrentUserId(), query).done(function (result) { + ApiClient.getGenres(Dashboard.getCurrentUserId(), query).then(function (result) { // Scroll back up so they can see the results from the beginning window.scrollTo(0, 0); diff --git a/dashboard-ui/scripts/moviesrecommended.js b/dashboard-ui/scripts/moviesrecommended.js index 4ac5b4abf5..c1c2639bf5 100644 --- a/dashboard-ui/scripts/moviesrecommended.js +++ b/dashboard-ui/scripts/moviesrecommended.js @@ -36,7 +36,7 @@ EnableImageTypes: "Primary,Backdrop,Banner,Thumb" }; - ApiClient.fetchJSON(ApiClient.getUrl('Users/' + userId + '/Items/Latest', options)).then(function (items) { + ApiClient.getJSON(ApiClient.getUrl('Users/' + userId + '/Items/Latest', options)).then(function (items) { var view = getView(); var html = ''; @@ -216,7 +216,7 @@ EnableImageTypes: "Primary,Backdrop,Banner,Thumb" }); - ApiClient.fetchJSON(url).then(function (recommendations) { + ApiClient.getJSON(url).then(function (recommendations) { if (!recommendations.length) { diff --git a/dashboard-ui/scripts/moviestudios.js b/dashboard-ui/scripts/moviestudios.js index c4625c65d6..3930e1c4bd 100644 --- a/dashboard-ui/scripts/moviestudios.js +++ b/dashboard-ui/scripts/moviestudios.js @@ -38,7 +38,7 @@ var query = getQuery(); - ApiClient.getStudios(Dashboard.getCurrentUserId(), query).done(function (result) { + ApiClient.getStudios(Dashboard.getCurrentUserId(), query).then(function (result) { // Scroll back up so they can see the results from the beginning window.scrollTo(0, 0); diff --git a/dashboard-ui/scripts/movietrailers.js b/dashboard-ui/scripts/movietrailers.js index bb0d5df141..81755a1c43 100644 --- a/dashboard-ui/scripts/movietrailers.js +++ b/dashboard-ui/scripts/movietrailers.js @@ -39,7 +39,7 @@ var query = getQuery(); query.UserId = Dashboard.getCurrentUserId(); - ApiClient.fetchJSON(ApiClient.getUrl('Trailers', query)).then(function (result) { + ApiClient.getJSON(ApiClient.getUrl('Trailers', query)).then(function (result) { // Scroll back up so they can see the results from the beginning window.scrollTo(0, 0); diff --git a/dashboard-ui/scripts/musicalbumartists.js b/dashboard-ui/scripts/musicalbumartists.js index df0bd070e4..0e58db2c80 100644 --- a/dashboard-ui/scripts/musicalbumartists.js +++ b/dashboard-ui/scripts/musicalbumartists.js @@ -42,7 +42,7 @@ var query = getQuery(); - ApiClient.getAlbumArtists(Dashboard.getCurrentUserId(), query).done(function (result) { + ApiClient.getAlbumArtists(Dashboard.getCurrentUserId(), query).then(function (result) { // Scroll back up so they can see the results from the beginning window.scrollTo(0, 0); diff --git a/dashboard-ui/scripts/musicartists.js b/dashboard-ui/scripts/musicartists.js index d92612d59c..299ab17131 100644 --- a/dashboard-ui/scripts/musicartists.js +++ b/dashboard-ui/scripts/musicartists.js @@ -42,7 +42,7 @@ var query = getQuery(); - ApiClient.getArtists(Dashboard.getCurrentUserId(), query).done(function (result) { + ApiClient.getArtists(Dashboard.getCurrentUserId(), query).then(function (result) { // Scroll back up so they can see the results from the beginning window.scrollTo(0, 0); diff --git a/dashboard-ui/scripts/musicgenres.js b/dashboard-ui/scripts/musicgenres.js index 43c4deac20..695d01329c 100644 --- a/dashboard-ui/scripts/musicgenres.js +++ b/dashboard-ui/scripts/musicgenres.js @@ -41,7 +41,7 @@ var query = getQuery(); - ApiClient.getMusicGenres(Dashboard.getCurrentUserId(), query).done(function (result) { + ApiClient.getMusicGenres(Dashboard.getCurrentUserId(), query).then(function (result) { // Scroll back up so they can see the results from the beginning window.scrollTo(0, 0); diff --git a/dashboard-ui/scripts/musicrecommended.js b/dashboard-ui/scripts/musicrecommended.js index 70535843d1..636de282ed 100644 --- a/dashboard-ui/scripts/musicrecommended.js +++ b/dashboard-ui/scripts/musicrecommended.js @@ -30,7 +30,7 @@ EnableImageTypes: "Primary,Backdrop,Banner,Thumb" }; - ApiClient.fetchJSON(ApiClient.getUrl('Users/' + userId + '/Items/Latest', options)).then(function (items) { + ApiClient.getJSON(ApiClient.getUrl('Users/' + userId + '/Items/Latest', options)).then(function (items) { var elem = page.querySelector('#recentlyAddedSongs'); elem.innerHTML = LibraryBrowser.getPosterViewHtml({ diff --git a/dashboard-ui/scripts/mypreferencesdisplay.js b/dashboard-ui/scripts/mypreferencesdisplay.js index e9e87046d4..60381f9f15 100644 --- a/dashboard-ui/scripts/mypreferencesdisplay.js +++ b/dashboard-ui/scripts/mypreferencesdisplay.js @@ -28,7 +28,7 @@ appStorage.setItem('enableThemeSongs-' + user.Id, $('#selectThemeSong', page).val()); appStorage.setItem('enableBackdrops-' + user.Id, $('#selectBackdrop', page).val()); - ApiClient.updateUserConfiguration(user.Id, user.Configuration).done(function () { + ApiClient.updateUserConfiguration(user.Id, user.Configuration).then(function () { Dashboard.alert(Globalize.translate('SettingsSaved')); loadForm(page, user); @@ -43,7 +43,7 @@ var userId = getParameterByName('userId') || Dashboard.getCurrentUserId(); - ApiClient.getUser(userId).done(function (user) { + ApiClient.getUser(userId).then(function (user) { saveUser(page, user); @@ -67,7 +67,7 @@ var userId = getParameterByName('userId') || Dashboard.getCurrentUserId(); - ApiClient.getUser(userId).done(function (user) { + ApiClient.getUser(userId).then(function (user) { loadForm(page, user); diff --git a/dashboard-ui/scripts/mypreferenceshome.js b/dashboard-ui/scripts/mypreferenceshome.js index 9473652c2d..b2528efad2 100644 --- a/dashboard-ui/scripts/mypreferenceshome.js +++ b/dashboard-ui/scripts/mypreferenceshome.js @@ -140,8 +140,8 @@ sortBy: "SortName" }); var promise2 = ApiClient.getUserViews({}, user.Id); - var promise3 = ApiClient.fetchJSON(ApiClient.getUrl("Users/" + user.Id + "/SpecialViewOptions")); - var promise4 = ApiClient.fetchJSON(ApiClient.getUrl("Users/" + user.Id + "/GroupingOptions")); + var promise3 = ApiClient.getJSON(ApiClient.getUrl("Users/" + user.Id + "/SpecialViewOptions")); + var promise4 = ApiClient.getJSON(ApiClient.getUrl("Users/" + user.Id + "/GroupingOptions")); Promise.all([promise1, promise2, promise3, promise4]).then(function (responses) { @@ -200,9 +200,9 @@ displayPreferences.CustomPrefs.home2 = $('#selectHomeSection3', page).val(); displayPreferences.CustomPrefs.home3 = $('#selectHomeSection4', page).val(); - ApiClient.updateDisplayPreferences('home', displayPreferences, user.Id, AppSettings.displayPreferencesKey()).done(function () { + ApiClient.updateDisplayPreferences('home', displayPreferences, user.Id, AppSettings.displayPreferencesKey()).then(function () { - ApiClient.updateUserConfiguration(user.Id, user.Configuration).done(function () { + ApiClient.updateUserConfiguration(user.Id, user.Configuration).then(function () { Dashboard.alert(Globalize.translate('SettingsSaved')); loadForm(page, user, displayPreferences); @@ -218,7 +218,7 @@ var userId = getParameterByName('userId') || Dashboard.getCurrentUserId(); - ApiClient.getUser(userId).done(function (user) { + ApiClient.getUser(userId).then(function (user) { ApiClient.getDisplayPreferences('home', user.Id, AppSettings.displayPreferencesKey()).then(function (displayPreferences) { @@ -283,7 +283,7 @@ var userId = getParameterByName('userId') || Dashboard.getCurrentUserId(); - ApiClient.getUser(userId).done(function (user) { + ApiClient.getUser(userId).then(function (user) { ApiClient.getDisplayPreferences('home', user.Id, AppSettings.displayPreferencesKey()).then(function (result) { diff --git a/dashboard-ui/scripts/mypreferenceslanguages.js b/dashboard-ui/scripts/mypreferenceslanguages.js index ba337fb01d..332e7d84f3 100644 --- a/dashboard-ui/scripts/mypreferenceslanguages.js +++ b/dashboard-ui/scripts/mypreferenceslanguages.js @@ -18,7 +18,7 @@ function loadForm(page, user, loggedInUser, allCulturesPromise) { - allCulturesPromise.done(function (allCultures) { + allCulturesPromise.then(function (allCultures) { populateLanguages($('#selectAudioLanguage', page), allCultures); populateLanguages($('#selectSubtitleLanguage', page), allCultures); @@ -67,13 +67,13 @@ var allCulturesPromise = ApiClient.getCultures(); - $.when(promise1, promise2).done(function (response1, response2) { + $.when(promise1, promise2).then(function (response1, response2) { loadForm(page, response1[0] || response1, response2[0], allCulturesPromise); }); - ApiClient.getNamedConfiguration("cinemamode").done(function (cinemaConfig) { + ApiClient.getNamedConfiguration("cinemamode").then(function (cinemaConfig) { if (cinemaConfig.EnableIntrosForMovies || cinemaConfig.EnableIntrosForEpisodes) { $('.cinemaModeOptions', page).show(); @@ -93,10 +93,12 @@ AppSettings.enableCinemaMode(page.querySelector('.chkEnableCinemaMode').checked); - ApiClient.updateUserConfiguration(user.Id, user.Configuration).done(function () { + ApiClient.updateUserConfiguration(user.Id, user.Configuration).then(function () { + + Dashboard.hideLoadingMsg(); Dashboard.alert(Globalize.translate('SettingsSaved')); - }).always(function () { + }, function () { Dashboard.hideLoadingMsg(); }); } @@ -121,7 +123,7 @@ var userId = getParameterByName('userId') || Dashboard.getCurrentUserId(); - ApiClient.getUser(userId).done(function (result) { + ApiClient.getUser(userId).then(function (result) { saveUser(page, result); diff --git a/dashboard-ui/scripts/myprofile.js b/dashboard-ui/scripts/myprofile.js index 8fdd814fa8..3b5ea306e1 100644 --- a/dashboard-ui/scripts/myprofile.js +++ b/dashboard-ui/scripts/myprofile.js @@ -8,7 +8,7 @@ Dashboard.showLoadingMsg(); - ApiClient.getUser(userId).done(function (user) { + ApiClient.getUser(userId).then(function (user) { $('.username', page).html(user.Name); Events.trigger($('#uploadUserImage', page).val('')[0], 'change'); @@ -168,7 +168,7 @@ var userId = getParameterByName("userId"); - ApiClient.uploadUserImage(userId, 'Primary', file).done(processImageChangeResult); + ApiClient.uploadUserImage(userId, 'Primary', file).then(processImageChangeResult); return false; }; @@ -199,7 +199,7 @@ var userId = getParameterByName("userId"); - ApiClient.deleteUserImage(userId, "primary").done(processImageChangeResult); + ApiClient.deleteUserImage(userId, "primary").then(processImageChangeResult); } }); @@ -218,7 +218,7 @@ var userid = getParameterByName("userId"); - ApiClient.getUser(userid).done(function (user) { + ApiClient.getUser(userid).then(function (user) { Dashboard.setPageTitle(user.Name); @@ -262,7 +262,7 @@ if (easyPassword) { - ApiClient.updateEasyPassword(userId, easyPassword).done(function () { + ApiClient.updateEasyPassword(userId, easyPassword).then(function () { onEasyPasswordSaved(page, userId); @@ -275,11 +275,11 @@ function onEasyPasswordSaved(page, userId) { - ApiClient.getUser(userId).done(function (user) { + ApiClient.getUser(userId).then(function (user) { user.Configuration.EnableLocalPassword = page.querySelector('.chkEnableLocalEasyPassword').checked; - ApiClient.updateUserConfiguration(user.Id, user.Configuration).done(function () { + ApiClient.updateUserConfiguration(user.Id, user.Configuration).then(function () { Dashboard.hideLoadingMsg(); @@ -296,7 +296,7 @@ var currentPassword = $('#txtCurrentPassword', page).val(); var newPassword = $('#txtNewPassword', page).val(); - ApiClient.updateUserPassword(userId, currentPassword, newPassword).done(function () { + ApiClient.updateUserPassword(userId, currentPassword, newPassword).then(function () { Dashboard.hideLoadingMsg(); @@ -356,7 +356,7 @@ Dashboard.showLoadingMsg(); - ApiClient.resetUserPassword(userId).done(function () { + ApiClient.resetUserPassword(userId).then(function () { Dashboard.hideLoadingMsg(); @@ -386,7 +386,7 @@ Dashboard.showLoadingMsg(); - ApiClient.resetEasyPassword(userId).done(function () { + ApiClient.resetEasyPassword(userId).then(function () { Dashboard.hideLoadingMsg(); diff --git a/dashboard-ui/scripts/mysyncsettings.js b/dashboard-ui/scripts/mysyncsettings.js index 6f3a0889db..2d8d48b740 100644 --- a/dashboard-ui/scripts/mysyncsettings.js +++ b/dashboard-ui/scripts/mysyncsettings.js @@ -47,7 +47,7 @@ var userId = getParameterByName('userId') || Dashboard.getCurrentUserId(); - ApiClient.getUser(userId).done(function (user) { + ApiClient.getUser(userId).then(function (user) { saveUser(page, user); @@ -66,7 +66,7 @@ $('.btnSelectSyncPath', page).on('click', function () { require(['nativedirectorychooser'], function () { - NativeDirectoryChooser.chooseDirectory().done(function (path) { + NativeDirectoryChooser.chooseDirectory().then(function (path) { $('#txtSyncPath', page).val(path); }); }); @@ -80,7 +80,7 @@ var userId = getParameterByName('userId') || Dashboard.getCurrentUserId(); - ApiClient.getUser(userId).done(function (user) { + ApiClient.getUser(userId).then(function (user) { loadForm(page, user); }); diff --git a/dashboard-ui/scripts/notifications.js b/dashboard-ui/scripts/notifications.js index 3d8c89fb01..4761d82ecc 100644 --- a/dashboard-ui/scripts/notifications.js +++ b/dashboard-ui/scripts/notifications.js @@ -37,7 +37,7 @@ return; } - promise.done(function (summary) { + promise.then(function (summary) { var item = $('.btnNotificationsInner').removeClass('levelNormal').removeClass('levelWarning').removeClass('levelError').html(summary.UnreadCount); @@ -49,7 +49,7 @@ self.markNotificationsRead = function (ids, callback) { - ApiClient.markNotificationsRead(Dashboard.getCurrentUserId(), ids, true).done(function () { + ApiClient.markNotificationsRead(Dashboard.getCurrentUserId(), ids, true).then(function () { self.getNotificationsSummaryPromise = null; @@ -75,7 +75,7 @@ var apiClient = window.ApiClient; if (apiClient) { - return apiClient.getNotifications(Dashboard.getCurrentUserId(), { StartIndex: startIndex, Limit: limit }).done(function (result) { + return apiClient.getNotifications(Dashboard.getCurrentUserId(), { StartIndex: startIndex, Limit: limit }).then(function (result) { listUnreadNotifications(result.Notifications, result.TotalRecordCount, startIndex, limit, elem, showPaging); diff --git a/dashboard-ui/scripts/notificationsetting.js b/dashboard-ui/scripts/notificationsetting.js index 5d8038073a..5017f8fa51 100644 --- a/dashboard-ui/scripts/notificationsetting.js +++ b/dashboard-ui/scripts/notificationsetting.js @@ -32,7 +32,7 @@ var promise3 = ApiClient.getJSON(ApiClient.getUrl("Notifications/Types")); var promise4 = ApiClient.getJSON(ApiClient.getUrl("Notifications/Services")); - $.when(promise1, promise2, promise3, promise4).done(function (response1, response2, response3, response4) { + $.when(promise1, promise2, promise3, promise4).then(function (response1, response2, response3, response4) { var users = response1[0]; var notificationOptions = response2[0]; @@ -102,7 +102,7 @@ var promise1 = ApiClient.getNamedConfiguration(notificationsConfigurationKey); var promise2 = ApiClient.getJSON(ApiClient.getUrl("Notifications/Types")); - $.when(promise1, promise2).done(function (response1, response2) { + $.when(promise1, promise2).then(function (response1, response2) { var notificationOptions = response1[0]; var types = response2[0]; @@ -147,7 +147,7 @@ return c.getAttribute('data-itemid'); }); - ApiClient.updateNamedConfiguration(notificationsConfigurationKey, notificationOptions).done(function (r) { + ApiClient.updateNamedConfiguration(notificationsConfigurationKey, notificationOptions).then(function (r) { Dashboard.navigate('notificationsettings.html'); }); diff --git a/dashboard-ui/scripts/notificationsettings.js b/dashboard-ui/scripts/notificationsettings.js index 7f4801c238..af8917e926 100644 --- a/dashboard-ui/scripts/notificationsettings.js +++ b/dashboard-ui/scripts/notificationsettings.js @@ -4,7 +4,7 @@ Dashboard.showLoadingMsg(); - ApiClient.fetchJSON(ApiClient.getUrl("Notifications/Types")).then(function (list) { + ApiClient.getJSON(ApiClient.getUrl("Notifications/Types")).then(function (list) { var html = ''; diff --git a/dashboard-ui/scripts/nowplayingbar.js b/dashboard-ui/scripts/nowplayingbar.js index 45ee416f7d..9ea1077480 100644 --- a/dashboard-ui/scripts/nowplayingbar.js +++ b/dashboard-ui/scripts/nowplayingbar.js @@ -533,7 +533,7 @@ var player = this; - player.getPlayerState().done(function (state) { + player.getPlayerState().then(function (state) { if (player.isDefaultPlayer && state.NowPlayingItem && state.NowPlayingItem.MediaType == 'Video') { return; @@ -549,7 +549,7 @@ currentPlayer = player; - player.getPlayerState().done(function (state) { + player.getPlayerState().then(function (state) { if (state.NowPlayingItem) { player.beginPlayerUpdates(); diff --git a/dashboard-ui/scripts/nowplayingpage.js b/dashboard-ui/scripts/nowplayingpage.js index 044d81af8a..b732177364 100644 --- a/dashboard-ui/scripts/nowplayingpage.js +++ b/dashboard-ui/scripts/nowplayingpage.js @@ -648,7 +648,7 @@ currentPlayer = player; - player.getPlayerState().done(function (state) { + player.getPlayerState().then(function (state) { if (state.NowPlayingItem) { player.beginPlayerUpdates(); diff --git a/dashboard-ui/scripts/photos.js b/dashboard-ui/scripts/photos.js index 0434d78a40..98c1ecac71 100644 --- a/dashboard-ui/scripts/photos.js +++ b/dashboard-ui/scripts/photos.js @@ -154,7 +154,7 @@ index = 0; } - Dashboard.loadSwipebox().done(function () { + Dashboard.loadSwipebox().then(function () { $.swipebox(slideshowItems, { initialIndexOnArray: index, diff --git a/dashboard-ui/scripts/playbackconfiguration.js b/dashboard-ui/scripts/playbackconfiguration.js index e910f05c46..6d965f126e 100644 --- a/dashboard-ui/scripts/playbackconfiguration.js +++ b/dashboard-ui/scripts/playbackconfiguration.js @@ -20,7 +20,7 @@ config.MaxResumePct = $('#txtMaxResumePct', form).val(); config.MinResumeDurationSeconds = $('#txtMinResumeDuration', form).val(); - ApiClient.updateServerConfiguration(config).done(Dashboard.processServerConfigurationUpdateResult); + ApiClient.updateServerConfiguration(config).then(Dashboard.processServerConfigurationUpdateResult); }); // Disable default form submission diff --git a/dashboard-ui/scripts/playlistedit.js b/dashboard-ui/scripts/playlistedit.js index 5007a40dfe..08d5bc85c6 100644 --- a/dashboard-ui/scripts/playlistedit.js +++ b/dashboard-ui/scripts/playlistedit.js @@ -41,7 +41,7 @@ query.UserId = Dashboard.getCurrentUserId(); - ApiClient.fetchJSON(ApiClient.getUrl('Playlists/' + item.Id + '/Items', query)).then(function (result) { + ApiClient.getJSON(ApiClient.getUrl('Playlists/' + item.Id + '/Items', query)).then(function (result) { // Scroll back up so they can see the results from the beginning window.scrollTo(0, 0); @@ -142,11 +142,11 @@ type: 'POST' - }).done(function () { + }).then(function () { Dashboard.hideLoadingMsg(); - }).fail(function () { + }, function () { Dashboard.hideLoadingMsg(); reloadItems(page, item); @@ -163,7 +163,7 @@ type: 'DELETE' - }).done(function () { + }).then(function () { reloadItems(page, item); }); diff --git a/dashboard-ui/scripts/plugincatalogpage.js b/dashboard-ui/scripts/plugincatalogpage.js index 87e20c4ec8..d3d7e30cc2 100644 --- a/dashboard-ui/scripts/plugincatalogpage.js +++ b/dashboard-ui/scripts/plugincatalogpage.js @@ -22,7 +22,7 @@ var promise2 = ApiClient.getInstalledPlugins(); - $.when(promise1, promise2).done(function (response1, response2) { + $.when(promise1, promise2).then(function (response1, response2) { populateList({ diff --git a/dashboard-ui/scripts/pluginspage.js b/dashboard-ui/scripts/pluginspage.js index 72670f2144..d66ba7e8f8 100644 --- a/dashboard-ui/scripts/pluginspage.js +++ b/dashboard-ui/scripts/pluginspage.js @@ -9,7 +9,7 @@ if (result) { Dashboard.showLoadingMsg(); - ApiClient.uninstallPlugin(uniqueid).done(function () { + ApiClient.uninstallPlugin(uniqueid).then(function () { reloadList(page); }); @@ -110,7 +110,7 @@ function renderPlugins(page, plugins, showNoPluginsMessage) { - ApiClient.fetchJSON(ApiClient.getUrl("dashboard/configurationpages") + "?pageType=PluginConfiguration").then(function (configPages) { + ApiClient.getJSON(ApiClient.getUrl("dashboard/configurationpages") + "?pageType=PluginConfiguration").then(function (configPages) { populateList(page, plugins, configPages, showNoPluginsMessage); @@ -213,7 +213,7 @@ Dashboard.showLoadingMsg(); - ApiClient.getInstalledPlugins().done(function (plugins) { + ApiClient.getInstalledPlugins().then(function (plugins) { renderPlugins(page, plugins, true); }); diff --git a/dashboard-ui/scripts/queryfilters.js b/dashboard-ui/scripts/queryfilters.js index d591cd8ea1..02ee87a553 100644 --- a/dashboard-ui/scripts/queryfilters.js +++ b/dashboard-ui/scripts/queryfilters.js @@ -131,7 +131,7 @@ function loadFilters(page, userId, itemQuery, reloadItemsFn) { - return ApiClient.fetchJSON(ApiClient.getUrl('Items/Filters', { + return ApiClient.getJSON(ApiClient.getUrl('Items/Filters', { UserId: userId, ParentId: itemQuery.ParentId, diff --git a/dashboard-ui/scripts/ratingdialog.js b/dashboard-ui/scripts/ratingdialog.js index a1c621aa83..31f6cd934a 100644 --- a/dashboard-ui/scripts/ratingdialog.js +++ b/dashboard-ui/scripts/ratingdialog.js @@ -101,7 +101,7 @@ Logger.log(review); dialog.close(); - ApiClient.createPackageReview(review).done(function () { + ApiClient.createPackageReview(review).then(function () { Dashboard.alert({ message: Globalize.translate('MessageThankYouForYourReview'), title: Globalize.translate('HeaderThankYou') diff --git a/dashboard-ui/scripts/registrationservices.js b/dashboard-ui/scripts/registrationservices.js index 3b33e0b87a..21808c38d7 100644 --- a/dashboard-ui/scripts/registrationservices.js +++ b/dashboard-ui/scripts/registrationservices.js @@ -4,7 +4,7 @@ function validatePlayback(deferred) { - Dashboard.getPluginSecurityInfo().done(function (pluginSecurityInfo) { + Dashboard.getPluginSecurityInfo().then(function (pluginSecurityInfo) { if (pluginSecurityInfo.IsMBSupporter) { deferred.resolve(); @@ -138,7 +138,7 @@ function validateSync(deferred) { - Dashboard.getPluginSecurityInfo().done(function (pluginSecurityInfo) { + Dashboard.getPluginSecurityInfo().then(function (pluginSecurityInfo) { if (pluginSecurityInfo.IsMBSupporter) { deferred.resolve(); @@ -147,7 +147,7 @@ Dashboard.showLoadingMsg(); - ApiClient.getRegistrationInfo('Sync').done(function (registrationInfo) { + ApiClient.getRegistrationInfo('Sync').then(function (registrationInfo) { Dashboard.hideLoadingMsg(); @@ -161,7 +161,7 @@ title: Globalize.translate('HeaderSync') }); - }).fail(function () { + }, function () { Dashboard.hideLoadingMsg(); diff --git a/dashboard-ui/scripts/remotecontrol.js b/dashboard-ui/scripts/remotecontrol.js index 15e782b3bb..d37fd24501 100644 --- a/dashboard-ui/scripts/remotecontrol.js +++ b/dashboard-ui/scripts/remotecontrol.js @@ -172,7 +172,7 @@ var apiClient = window.ApiClient; if (apiClient) { - apiClient.getSessions().done(function (sessions) { + apiClient.getSessions().then(function (sessions) { var currentTargetId = MediaController.getPlayerInfo().id; @@ -203,7 +203,7 @@ var apiClient = window.ApiClient; if (apiClient) { - apiClient.getSessions().done(processUpdatedSessions); + apiClient.getSessions().then(processUpdatedSessions); } } } @@ -272,7 +272,7 @@ var apiClient = window.ApiClient; if (apiClient) { - apiClient.getSessions(sessionQuery).done(function (sessions) { + apiClient.getSessions(sessionQuery).then(function (sessions) { var targets = sessions.filter(function (s) { @@ -293,10 +293,11 @@ deferred.resolveWith(null, [targets]); - }).fail(function () { + }, function () { deferred.reject(); }); + } else { deferred.resolveWith(null, []); } diff --git a/dashboard-ui/scripts/reports.js b/dashboard-ui/scripts/reports.js index e9b98b1e3b..d570dabf7f 100644 --- a/dashboard-ui/scripts/reports.js +++ b/dashboard-ui/scripts/reports.js @@ -274,7 +274,7 @@ var url = ""; url = ApiClient.getUrl("Reports/Headers", query); - ApiClient.fetchJSON(url).then(function (result) { + ApiClient.getJSON(url).then(function (result) { var selected = "None"; $('#selectReportGroup', page).find('option').remove().end(); @@ -438,7 +438,7 @@ break; } - ApiClient.fetchJSON(url).then(function (result) { + ApiClient.getJSON(url).then(function (result) { updateFilterControls(page); renderItems(page, result); }); @@ -1029,7 +1029,7 @@ function loadFilters(page, userId, itemQuery, reloadItemsFn) { - return ApiClient.fetchJSON(ApiClient.getUrl('Items/Filters', { + return ApiClient.getJSON(ApiClient.getUrl('Items/Filters', { UserId: userId, ParentId: itemQuery.ParentId, @@ -1047,7 +1047,7 @@ function loadColumns(page, userId, itemQuery, reloadItemsFn) { - return ApiClient.fetchJSON(ApiClient.getUrl('Reports/Headers', { + return ApiClient.getJSON(ApiClient.getUrl('Reports/Headers', { UserId: userId, IncludeItemTypes: itemQuery.IncludeItemTypes, diff --git a/dashboard-ui/scripts/scheduledtaskpage.js b/dashboard-ui/scripts/scheduledtaskpage.js index b09a7ff104..6728808da1 100644 --- a/dashboard-ui/scripts/scheduledtaskpage.js +++ b/dashboard-ui/scripts/scheduledtaskpage.js @@ -6,7 +6,7 @@ var id = getParameterByName('id'); - ApiClient.getScheduledTask(id).done(ScheduledTaskPage.loadScheduledTask); + ApiClient.getScheduledTask(id).then(ScheduledTaskPage.loadScheduledTask); }, loadScheduledTask: function (task) { @@ -177,11 +177,11 @@ var id = getParameterByName('id'); - ApiClient.getScheduledTask(id).done(function (task) { + ApiClient.getScheduledTask(id).then(function (task) { task.Triggers.remove(index); - ApiClient.updateScheduledTaskTriggers(task.Id, task.Triggers).done(function () { + ApiClient.updateScheduledTaskTriggers(task.Id, task.Triggers).then(function () { ScheduledTaskPage.refreshScheduledTask(); @@ -293,11 +293,11 @@ var id = getParameterByName('id'); - ApiClient.getScheduledTask(id).done(function (task) { + ApiClient.getScheduledTask(id).then(function (task) { task.Triggers.push(ScheduledTaskPage.getTriggerToAdd()); - ApiClient.updateScheduledTaskTriggers(task.Id, task.Triggers).done(function () { + ApiClient.updateScheduledTaskTriggers(task.Id, task.Triggers).then(function () { $('#popupAddTrigger').popup('close'); diff --git a/dashboard-ui/scripts/scheduledtaskspage.js b/dashboard-ui/scripts/scheduledtaskspage.js index a12a17ff96..5e68b9696d 100644 --- a/dashboard-ui/scripts/scheduledtaskspage.js +++ b/dashboard-ui/scripts/scheduledtaskspage.js @@ -2,7 +2,7 @@ function reloadList(page) { - ApiClient.getScheduledTasks({ isHidden: false }).done(function (tasks) { + ApiClient.getScheduledTasks({ isHidden: false }).then(function (tasks) { populateList(page, tasks); @@ -255,7 +255,7 @@ var button = this; var id = button.getAttribute('data-taskid'); - ApiClient.startScheduledTask(id).done(function () { + ApiClient.startScheduledTask(id).then(function () { updateTaskButton(button, "Running"); reloadList(page); @@ -265,7 +265,7 @@ var button = this; var id = button.getAttribute('data-taskid'); - ApiClient.stopScheduledTask(id).done(function () { + ApiClient.stopScheduledTask(id).then(function () { updateTaskButton(button, ""); reloadList(page); diff --git a/dashboard-ui/scripts/search.js b/dashboard-ui/scripts/search.js index 5143cec7a0..c2e77136e5 100644 --- a/dashboard-ui/scripts/search.js +++ b/dashboard-ui/scripts/search.js @@ -111,14 +111,14 @@ searchTerm: searchTerm, limit: 30 - }).done(function (result) { + }).then(function (result) { if (currentTimeout == searchHintTimeout) { renderSearchResultsInOverlay(elem, result.SearchHints); } Dashboard.hideLoadingMsg(); - }).fail(function () { + }, function () { Dashboard.hideLoadingMsg(); }); } diff --git a/dashboard-ui/scripts/sections.js b/dashboard-ui/scripts/sections.js index f8a700097e..4784ca837b 100644 --- a/dashboard-ui/scripts/sections.js +++ b/dashboard-ui/scripts/sections.js @@ -4,7 +4,7 @@ var deferred = $.Deferred(); - ApiClient.getUserViews({}, userId).done(function (result) { + ApiClient.getUserViews({}, userId).then(function (result) { var items = result.Items; @@ -160,7 +160,7 @@ function loadlibraryButtons(elem, userId, index) { - return getUserViews(userId).done(function (items) { + return getUserViews(userId).then(function (items) { var html = '
'; @@ -191,7 +191,7 @@ EnableImageTypes: "Primary,Backdrop,Thumb" }; - return ApiClient.fetchJSON(ApiClient.getUrl('Users/' + user.Id + '/Items/Latest', options)).then(function (items) { + return ApiClient.getJSON(ApiClient.getUrl('Users/' + user.Id + '/Items/Latest', options)).then(function (items) { var html = ''; @@ -239,7 +239,7 @@ IncludeItemTypes: "Movie" }; - return ApiClient.fetchJSON(ApiClient.getUrl('Users/' + user.Id + '/Items/Latest', options)).then(function (items) { + return ApiClient.getJSON(ApiClient.getUrl('Users/' + user.Id + '/Items/Latest', options)).then(function (items) { var html = ''; @@ -282,7 +282,7 @@ IncludeItemTypes: "Episode" }; - return ApiClient.fetchJSON(ApiClient.getUrl('Users/' + user.Id + '/Items/Latest', options)).then(function (items) { + return ApiClient.getJSON(ApiClient.getUrl('Users/' + user.Id + '/Items/Latest', options)).then(function (items) { var html = ''; @@ -327,7 +327,7 @@ UserId: userId }; - return ApiClient.fetchJSON(ApiClient.getUrl("Channels/Items/Latest", options)).then(function (result) { + return ApiClient.getJSON(ApiClient.getUrl("Channels/Items/Latest", options)).then(function (result) { var html = ''; @@ -355,7 +355,7 @@ function loadLibraryTiles(elem, user, shape, index, autoHideOnMobile, showTitles) { - return getUserViews(user.Id).done(function (items) { + return getUserViews(user.Id).then(function (items) { var html = ''; @@ -474,7 +474,7 @@ EnableImageTypes: "Primary,Backdrop,Banner,Thumb" }; - ApiClient.getNextUpEpisodes(query).done(function (result) { + ApiClient.getNextUpEpisodes(query).then(function (result) { var html = ''; @@ -532,7 +532,7 @@ SupportsLatestItems: true }); - return ApiClient.fetchJSON(ApiClient.getUrl("Channels", options)).then(function (result) { + return ApiClient.getJSON(ApiClient.getUrl("Channels", options)).then(function (result) { var channels = result.Items; @@ -567,7 +567,7 @@ ChannelIds: channel.Id }; - ApiClient.fetchJSON(ApiClient.getUrl("Channels/Items/Latest", options)).then(function (result) { + ApiClient.getJSON(ApiClient.getUrl("Channels/Items/Latest", options)).then(function (result) { var html = ''; @@ -612,7 +612,7 @@ limit: 5, IsInProgress: false - }).done(function (result) { + }).then(function (result) { var html = ''; diff --git a/dashboard-ui/scripts/selectserver.js b/dashboard-ui/scripts/selectserver.js index aa7c1adcab..720c93110e 100644 --- a/dashboard-ui/scripts/selectserver.js +++ b/dashboard-ui/scripts/selectserver.js @@ -4,7 +4,7 @@ Dashboard.showLoadingMsg(); - ConnectionManager.connectToServer(server).done(function (result) { + ConnectionManager.connectToServer(server).then(function (result) { Dashboard.hideLoadingMsg(); @@ -127,12 +127,12 @@ Dashboard.showModalLoadingMsg(); // Add/Update connect info - ConnectionManager.acceptServer(id).done(function () { + ConnectionManager.acceptServer(id).then(function () { Dashboard.hideModalLoadingMsg(); loadPage(page); - }).fail(function () { + }, function () { showGeneralError(); }); @@ -143,13 +143,13 @@ Dashboard.showModalLoadingMsg(); // Add/Update connect info - ConnectionManager.deleteServer(serverId).done(function () { + ConnectionManager.deleteServer(serverId).then(function () { Dashboard.hideModalLoadingMsg(); loadPage(page); - }).fail(function () { + }, function () { showGeneralError(); @@ -161,13 +161,13 @@ Dashboard.showModalLoadingMsg(); // Add/Update connect info - ConnectionManager.rejectServer(id).done(function () { + ConnectionManager.rejectServer(id).then(function () { Dashboard.hideModalLoadingMsg(); loadPage(page); - }).fail(function () { + }, function () { showGeneralError(); @@ -297,7 +297,7 @@ if (ConnectionManager.isLoggedIntoConnect()) { - ConnectionManager.getUserInvitations().done(function (list) { + ConnectionManager.getUserInvitations().then(function (list) { renderInvitations(page, list); @@ -314,7 +314,7 @@ Dashboard.showLoadingMsg(); - ConnectionManager.getAvailableServers().done(function (servers) { + ConnectionManager.getAvailableServers().then(function (servers) { servers = servers.slice(0); diff --git a/dashboard-ui/scripts/shared.js b/dashboard-ui/scripts/shared.js index 9f4c5c862d..c0aafb969a 100644 --- a/dashboard-ui/scripts/shared.js +++ b/dashboard-ui/scripts/shared.js @@ -8,7 +8,7 @@ Dashboard.showLoadingMsg(); - ApiClient.fetchJSON(ApiClient.getUrl('Social/Shares/Public/' + id + '/Item')).then(function (item) { + ApiClient.getJSON(ApiClient.getUrl('Social/Shares/Public/' + id + '/Item')).then(function (item) { reloadFromItem(page, item); }); diff --git a/dashboard-ui/scripts/sharingmanager.js b/dashboard-ui/scripts/sharingmanager.js index 7b6f9330b2..40a4176b1f 100644 --- a/dashboard-ui/scripts/sharingmanager.js +++ b/dashboard-ui/scripts/sharingmanager.js @@ -36,7 +36,7 @@ }), dataType: "json" - }).done(function (share) { + }).then(function (share) { var options = { share: share @@ -45,7 +45,7 @@ Dashboard.hideLoadingMsg(); SharingWidget.showMenu(options, onSharingSuccess, onSharingCancel); - }).fail(function () { + }, function () { Dashboard.hideLoadingMsg(); }); diff --git a/dashboard-ui/scripts/site.js b/dashboard-ui/scripts/site.js index 171b64afda..44eb877a86 100644 --- a/dashboard-ui/scripts/site.js +++ b/dashboard-ui/scripts/site.js @@ -118,23 +118,7 @@ var Dashboard = { getCurrentUser: function () { - if (!Dashboard.getUserPromise) { - - Dashboard.getUserPromise = window.ApiClient.getCurrentUser().fail(function () { - Dashboard.getUserPromise = null; - }); - } - - return Dashboard.getUserPromise; - }, - - validateCurrentUser: function () { - - Dashboard.getUserPromise = null; - - if (Dashboard.getCurrentUserId()) { - Dashboard.getCurrentUser(); - } + return window.ApiClient.getCurrentUser(); }, serverAddress: function () { @@ -189,8 +173,6 @@ var Dashboard = { apiClient = apiClient || window.ApiClient; window.ApiClient = apiClient; - - Dashboard.getUserPromise = null; }, logout: function (logoutWithServer) { @@ -211,7 +193,7 @@ var Dashboard = { if (logoutWithServer === false) { onLogoutDone(); } else { - ConnectionManager.logout().done(onLogoutDone); + ConnectionManager.logout().then(onLogoutDone); } }, @@ -330,7 +312,7 @@ var Dashboard = { cancelInstallation: function (id) { - ApiClient.cancelPackageInstallation(id).always(Dashboard.refreshSystemInfoFromServer); + ApiClient.cancelPackageInstallation(id).then(Dashboard.refreshSystemInfoFromServer, Dashboard.refreshSystemInfoFromServer); }, @@ -742,13 +724,13 @@ var Dashboard = { Dashboard.suppressAjaxErrors = true; Dashboard.showLoadingMsg(); - ApiClient.restartServer().done(function () { + ApiClient.restartServer().then(function () { setTimeout(function () { Dashboard.reloadPageWhenServerAvailable(); }, 250); - }).fail(function () { + }, function () { Dashboard.suppressAjaxErrors = false; }); }, @@ -756,7 +738,7 @@ var Dashboard = { reloadPageWhenServerAvailable: function (retryCount) { // Don't use apiclient method because we don't want it reporting authentication under the old version - ApiClient.fetchJSON(ApiClient.getUrl("System/Info")).then(function (info) { + ApiClient.getJSON(ApiClient.getUrl("System/Info")).then(function (info) { // If this is back to false, the restart completed if (!info.HasPendingRestart) { @@ -765,7 +747,7 @@ var Dashboard = { Dashboard.retryReload(retryCount); } - }).fail(function () { + }, function () { Dashboard.retryReload(retryCount); }); }, @@ -809,7 +791,7 @@ var Dashboard = { $(this).off("panelclose").remove(); }); - ConnectionManager.user(window.ApiClient).done(function (user) { + ConnectionManager.user(window.ApiClient).then(function (user) { Dashboard.updateUserFlyout(elem, user); }); }); @@ -867,7 +849,7 @@ var Dashboard = { // Don't show normal dashboard errors } - }).done(function (result) { + }).then(function (result) { deferred.resolveWith(null, [result]); }); @@ -1161,25 +1143,12 @@ var Dashboard = { else if (msg.MessageType === "ServerRestarting") { Dashboard.hideServerRestartWarning(); } - else if (msg.MessageType === "UserDeleted") { - Dashboard.validateCurrentUser(); - } else if (msg.MessageType === "SystemInfo") { Dashboard.updateSystemInfo(msg.Data); } else if (msg.MessageType === "RestartRequired") { Dashboard.updateSystemInfo(msg.Data); } - else if (msg.MessageType === "UserUpdated" || msg.MessageType === "UserConfigurationUpdated") { - var user = msg.Data; - - if (user.Id == Dashboard.getCurrentUserId()) { - - Dashboard.validateCurrentUser(); - $('.currentUsername').html(user.Name); - } - - } else if (msg.MessageType === "PackageInstallationCompleted") { Dashboard.getCurrentUser().then(function (currentUser) { @@ -1870,7 +1839,7 @@ var AppInfo = {}; if (!Dashboard.isServerlessPage()) { if (server && server.UserId && server.AccessToken) { - ConnectionManager.connectToServer(server).done(function (result) { + ConnectionManager.connectToServer(server).then(function (result) { if (result.State == MediaBrowser.ConnectionState.SignedIn) { window.ApiClient = result.ApiClient; } @@ -2187,6 +2156,7 @@ var AppInfo = {}; } deps.push('scripts/mediacontroller'); + deps.push('scripts/globalize'); require(deps, function () { @@ -2221,7 +2191,6 @@ var AppInfo = {}; } deps.push('scripts/librarybrowser'); - deps.push('scripts/globalize'); deps.push('appstorage'); deps.push('scripts/mediaplayer'); deps.push('scripts/appsettings'); diff --git a/dashboard-ui/scripts/streamingsettings.js b/dashboard-ui/scripts/streamingsettings.js index 9a8c25dd2f..387d9ac54b 100644 --- a/dashboard-ui/scripts/streamingsettings.js +++ b/dashboard-ui/scripts/streamingsettings.js @@ -16,7 +16,7 @@ config.RemoteClientBitrateLimit = parseInt(parseFloat(($('#txtRemoteClientBitrateLimit', form).val() || '0')) * 1000000); - ApiClient.updateServerConfiguration(config).done(Dashboard.processServerConfigurationUpdateResult); + ApiClient.updateServerConfiguration(config).then(Dashboard.processServerConfigurationUpdateResult); }); // Disable default form submission diff --git a/dashboard-ui/scripts/supporterkeypage.js b/dashboard-ui/scripts/supporterkeypage.js index 271e5740ed..2df9925b89 100644 --- a/dashboard-ui/scripts/supporterkeypage.js +++ b/dashboard-ui/scripts/supporterkeypage.js @@ -8,7 +8,7 @@ Dashboard.showLoadingMsg(); - ApiClient.getPluginSecurityInfo().done(function (info) { + ApiClient.getPluginSecurityInfo().then(function (info) { $('#txtSupporterKey', page).val(info.SupporterKey); @@ -35,7 +35,7 @@ SupporterKey: key }; - ApiClient.updatePluginSecurityInfo(info).done(function () { + ApiClient.updatePluginSecurityInfo(info).then(function () { Dashboard.resetPluginSecurityInfo(); Dashboard.hideLoadingMsg(); @@ -79,7 +79,7 @@ var url = "http://mb3admin.com/admin/service/supporter/linkKeys"; Logger.log(url); - $.post(url, info).done(function (res) { + $.post(url, info).then(function (res) { var result = JSON.parse(res); Dashboard.hideLoadingMsg(); if (result.Success) { @@ -103,7 +103,7 @@ var url = "http://mb3admin.com/admin/service/supporter/retrievekey?email=" + email; Logger.log(url); - $.post(url).done(function (res) { + $.post(url).then(function (res) { var result = JSON.parse(res); Dashboard.hideLoadingMsg(); if (result.Success) { @@ -147,7 +147,7 @@ $(document).on('pageshow', "#supporterKeyPage", SupporterKeyPage.onPageShow); Id: id }) - }).done(function () { + }).then(function () { $('.popupAddUser', page).popup('close'); loadConnectSupporters(page); @@ -168,7 +168,7 @@ $(document).on('pageshow', "#supporterKeyPage", SupporterKeyPage.onPageShow); Id: id }) - }).done(function () { + }).then(function () { loadConnectSupporters(page); }); @@ -236,28 +236,25 @@ $(document).on('pageshow', "#supporterKeyPage", SupporterKeyPage.onPageShow); url: ApiClient.getUrl('Connect/Supporters'), dataType: "json" - }).done(function (result) { + }).then(function (result) { connectSupporterInfo = result; renderUsers(page, result); Dashboard.hideLoadingMsg(); + Dashboard.suppressAjaxErrors = false; - }).fail(function () { + }, function () { $('.supporters', page).html('

' + Globalize.translate('MessageErrorLoadingSupporterInfo') + '

'); - - }).always(function () { - Dashboard.suppressAjaxErrors = false; }); - } function loadUserInfo(page) { - ApiClient.fetchJSON(ApiClient.getUrl('System/SupporterInfo')).then(function (info) { + ApiClient.getJSON(ApiClient.getUrl('System/SupporterInfo')).then(function (info) { if (info.IsActiveSupporter) { $('.supporterContainer', page).addClass('hide'); diff --git a/dashboard-ui/scripts/sync.js b/dashboard-ui/scripts/sync.js index e32772d4e2..e7fdafd4b9 100644 --- a/dashboard-ui/scripts/sync.js +++ b/dashboard-ui/scripts/sync.js @@ -49,7 +49,7 @@ contentType: "application/json", dataType: 'json' - }).done(function () { + }).then(function () { panel.panel('close'); $(window.SyncManager).trigger('jobsubmit'); @@ -197,7 +197,7 @@ function showSyncMenu(options) { requirejs(["scripts/registrationservices", "jqmcollapsible", "jqmpanel"], function () { - RegistrationServices.validateFeature('sync').done(function () { + RegistrationServices.validateFeature('sync').then(function () { showSyncMenuInternal(options); }); }); @@ -217,7 +217,7 @@ Category: options.Category }; - ApiClient.fetchJSON(ApiClient.getUrl('Sync/Options', dialogOptionsQuery)).then(function (dialogOptions) { + ApiClient.getJSON(ApiClient.getUrl('Sync/Options', dialogOptionsQuery)).then(function (dialogOptions) { currentDialogOptions = dialogOptions; @@ -314,7 +314,7 @@ function loadQualityOptions(form, targetId, dialogOptionsFn) { - dialogOptionsFn(targetId).done(function (options) { + dialogOptionsFn(targetId).then(function (options) { renderTargetDialogOptions(form, options); }); diff --git a/dashboard-ui/scripts/syncactivity.js b/dashboard-ui/scripts/syncactivity.js index fdf45cbb26..785d90dc9e 100644 --- a/dashboard-ui/scripts/syncactivity.js +++ b/dashboard-ui/scripts/syncactivity.js @@ -14,7 +14,7 @@ url: ApiClient.getUrl('Sync/Jobs/' + id), type: 'DELETE' - }).done(function () { + }).then(function () { reloadData(page); }); @@ -325,7 +325,7 @@ } } - ApiClient.fetchJSON(ApiClient.getUrl('Sync/Jobs', options)).then(function (response) { + ApiClient.getJSON(ApiClient.getUrl('Sync/Jobs', options)).then(function (response) { loadData(page, response.Items); Dashboard.hideLoadingMsg(); @@ -381,7 +381,7 @@ $('.btnSyncSupporter', page).on('click', function () { requirejs(["scripts/registrationservices"], function () { - RegistrationServices.validateFeature('sync').done(function () { + RegistrationServices.validateFeature('sync').then(function () { }); }); }); @@ -391,7 +391,7 @@ var page = this; - Dashboard.getPluginSecurityInfo().done(function (pluginSecurityInfo) { + Dashboard.getPluginSecurityInfo().then(function (pluginSecurityInfo) { if (pluginSecurityInfo.IsMBSupporter) { $('.supporterPromotionContainer', page).hide(); diff --git a/dashboard-ui/scripts/syncjob.js b/dashboard-ui/scripts/syncjob.js index d90621292c..4e50fe0502 100644 --- a/dashboard-ui/scripts/syncjob.js +++ b/dashboard-ui/scripts/syncjob.js @@ -213,7 +213,7 @@ type: "DELETE", url: ApiClient.getUrl('Sync/JobItems/' + jobItemId) - }).done(function () { + }).then(function () { loadJob(page); }); @@ -227,7 +227,7 @@ type: "POST", url: ApiClient.getUrl('Sync/JobItems/' + jobItemId + '/MarkForRemoval') - }).done(function () { + }).then(function () { loadJob(page); }); @@ -240,7 +240,7 @@ type: "POST", url: ApiClient.getUrl('Sync/JobItems/' + jobItemId + '/UnmarkForRemoval') - }).done(function () { + }).then(function () { loadJob(page); }); @@ -253,7 +253,7 @@ type: "POST", url: ApiClient.getUrl('Sync/JobItems/' + jobItemId + '/Enable') - }).done(function () { + }).then(function () { loadJob(page); }); @@ -288,9 +288,9 @@ Dashboard.showLoadingMsg(); var id = getParameterByName('id'); - ApiClient.fetchJSON(ApiClient.getUrl('Sync/Jobs/' + id)).then(function (job) { + ApiClient.getJSON(ApiClient.getUrl('Sync/Jobs/' + id)).then(function (job) { - ApiClient.fetchJSON(ApiClient.getUrl('Sync/Options', { + ApiClient.getJSON(ApiClient.getUrl('Sync/Options', { UserId: job.UserId, ItemIds: (job.RequestedItemIds && job.RequestedItemIds.length ? job.RequestedItemIds.join('') : null), @@ -307,7 +307,7 @@ }); }); - ApiClient.fetchJSON(ApiClient.getUrl('Sync/JobItems', { + ApiClient.getJSON(ApiClient.getUrl('Sync/JobItems', { JobId: id, AddMetadata: true @@ -331,7 +331,7 @@ Dashboard.showLoadingMsg(); var id = getParameterByName('id'); - ApiClient.fetchJSON(ApiClient.getUrl('Sync/Jobs/' + id)).then(function (job) { + ApiClient.getJSON(ApiClient.getUrl('Sync/Jobs/' + id)).then(function (job) { SyncManager.setJobValues(job, page); @@ -342,7 +342,7 @@ data: JSON.stringify(job), contentType: "application/json" - }).done(function () { + }).then(function () { Dashboard.hideLoadingMsg(); Dashboard.alert(Globalize.translate('SettingsSaved')); diff --git a/dashboard-ui/scripts/syncsettings.js b/dashboard-ui/scripts/syncsettings.js index b01e7abed2..9766d5ae80 100644 --- a/dashboard-ui/scripts/syncsettings.js +++ b/dashboard-ui/scripts/syncsettings.js @@ -15,14 +15,14 @@ var form = this; - ApiClient.getNamedConfiguration("sync").done(function (config) { + ApiClient.getNamedConfiguration("sync").then(function (config) { config.TemporaryPath = $('#txtSyncTempPath', form).val(); config.UploadSpeedLimitBytes = parseInt(parseFloat(($('#txtUploadSpeedLimit', form).val() || '0')) * 1000000); config.TranscodingCpuCoreLimit = parseInt($('#txtCpuCoreLimit', form).val()); config.EnableFullSpeedTranscoding = $('#chkEnableFullSpeedConversion', form).checked(); - ApiClient.updateNamedConfiguration("sync", config).done(Dashboard.processServerConfigurationUpdateResult); + ApiClient.updateNamedConfiguration("sync", config).then(Dashboard.processServerConfigurationUpdateResult); }); // Disable default form submission @@ -60,7 +60,7 @@ var page = this; - ApiClient.getNamedConfiguration("sync").done(function (config) { + ApiClient.getNamedConfiguration("sync").then(function (config) { loadPage(page, config); diff --git a/dashboard-ui/scripts/taskbutton.js b/dashboard-ui/scripts/taskbutton.js index a2920f276e..9d2bdd447f 100644 --- a/dashboard-ui/scripts/taskbutton.js +++ b/dashboard-ui/scripts/taskbutton.js @@ -7,7 +7,7 @@ $.fn.taskButton = function (options) { IsEnabled: true - }).done(function (tasks) { + }).then(function (tasks) { updateTasks(button, tasks); }); @@ -66,7 +66,7 @@ $.fn.taskButton = function (options) { } function onScheduledTaskMessageConfirmed(instance, id) { - ApiClient.startScheduledTask(id).done(function () { + ApiClient.startScheduledTask(id).then(function () { pollTasks(instance); }); diff --git a/dashboard-ui/scripts/tvgenres.js b/dashboard-ui/scripts/tvgenres.js index a352a166c4..513235d8cc 100644 --- a/dashboard-ui/scripts/tvgenres.js +++ b/dashboard-ui/scripts/tvgenres.js @@ -40,7 +40,7 @@ Dashboard.showLoadingMsg(); var query = getQuery(); - ApiClient.getGenres(Dashboard.getCurrentUserId(), query).done(function (result) { + ApiClient.getGenres(Dashboard.getCurrentUserId(), query).then(function (result) { // Scroll back up so they can see the results from the beginning window.scrollTo(0, 0); diff --git a/dashboard-ui/scripts/tvlatest.js b/dashboard-ui/scripts/tvlatest.js index 05ecdf7cf0..378db861b9 100644 --- a/dashboard-ui/scripts/tvlatest.js +++ b/dashboard-ui/scripts/tvlatest.js @@ -29,7 +29,7 @@ EnableImageTypes: "Primary,Backdrop,Banner,Thumb" }; - ApiClient.fetchJSON(ApiClient.getUrl('Users/' + userId + '/Items/Latest', options)).then(function (items) { + ApiClient.getJSON(ApiClient.getUrl('Users/' + userId + '/Items/Latest', options)).then(function (items) { var view = getView(); var html = ''; diff --git a/dashboard-ui/scripts/tvrecommended.js b/dashboard-ui/scripts/tvrecommended.js index ea8014f2ec..48b12b0270 100644 --- a/dashboard-ui/scripts/tvrecommended.js +++ b/dashboard-ui/scripts/tvrecommended.js @@ -44,7 +44,7 @@ query.ParentId = LibraryMenu.getTopParentId(); - ApiClient.getNextUpEpisodes(query).done(function (result) { + ApiClient.getNextUpEpisodes(query).then(function (result) { if (result.Items.length) { $('.noNextUpItems', page).hide(); diff --git a/dashboard-ui/scripts/tvstudios.js b/dashboard-ui/scripts/tvstudios.js index 116920178c..0ce5e76ca6 100644 --- a/dashboard-ui/scripts/tvstudios.js +++ b/dashboard-ui/scripts/tvstudios.js @@ -38,7 +38,7 @@ Dashboard.showLoadingMsg(); - ApiClient.getStudios(Dashboard.getCurrentUserId(), query).done(function (result) { + ApiClient.getStudios(Dashboard.getCurrentUserId(), query).then(function (result) { // Scroll back up so they can see the results from the beginning window.scrollTo(0, 0); diff --git a/dashboard-ui/scripts/tvupcoming.js b/dashboard-ui/scripts/tvupcoming.js index 7f176cd539..7d9cb3c859 100644 --- a/dashboard-ui/scripts/tvupcoming.js +++ b/dashboard-ui/scripts/tvupcoming.js @@ -19,7 +19,7 @@ query.ParentId = LibraryMenu.getTopParentId(); - ApiClient.fetchJSON(ApiClient.getUrl("Shows/Upcoming", query)).then(function (result) { + ApiClient.getJSON(ApiClient.getUrl("Shows/Upcoming", query)).then(function (result) { var items = result.Items; diff --git a/dashboard-ui/scripts/useredit.js b/dashboard-ui/scripts/useredit.js index 8d846822bb..76dff622e2 100644 --- a/dashboard-ui/scripts/useredit.js +++ b/dashboard-ui/scripts/useredit.js @@ -68,7 +68,7 @@ type: "DELETE", url: linkUrl - }).done(function () { + }).then(function () { Dashboard.alert({ @@ -78,7 +78,7 @@ callback: actionCallback }); - }).fail(function () { + }, function () { Dashboard.alert({ @@ -99,7 +99,7 @@ }, dataType: 'json' - }).done(function (result) { + }).then(function (result) { var msgKey = result.IsPending ? 'MessagePendingEmbyAccountAdded' : 'MessageEmbyAccountAdded'; @@ -109,15 +109,17 @@ callback: actionCallback - }).fail(function () { + }); - Dashboard.alert({ + }, function () { - message: Globalize.translate('ErrorAddingEmbyConnectAccount') + Dashboard.alert({ + + message: Globalize.translate('ErrorAddingEmbyConnectAccount') - }); }); }); + } else { if (noActionCallback) { noActionCallback(); @@ -168,9 +170,9 @@ user.Policy.EnableSyncTranscoding = $('#chkEnableSyncTranscoding', page).checked(); user.Policy.EnablePublicSharing = $('#chkEnableSharing', page).checked(); - ApiClient.updateUser(user).done(function () { + ApiClient.updateUser(user).then(function () { - ApiClient.updateUserPolicy(user.Id, user.Policy).done(function () { + ApiClient.updateUserPolicy(user.Id, user.Policy).then(function () { onSaveComplete(page, user); }); @@ -182,7 +184,7 @@ Dashboard.showLoadingMsg(); - getUser().done(function (result) { + getUser().then(function (result) { saveUser(result, page); }); @@ -201,7 +203,7 @@ Dashboard.showLoadingMsg(); - getUser().done(function (user) { + getUser().then(function (user) { loadUser(page, user); }); diff --git a/dashboard-ui/scripts/userlibraryaccess.js b/dashboard-ui/scripts/userlibraryaccess.js index dbe30512ee..6209f60044 100644 --- a/dashboard-ui/scripts/userlibraryaccess.js +++ b/dashboard-ui/scripts/userlibraryaccess.js @@ -151,7 +151,7 @@ user.Policy.BlockedChannels = null; user.Policy.BlockedMediaFolders = null; - ApiClient.updateUserPolicy(user.Id, user.Policy).done(function () { + ApiClient.updateUserPolicy(user.Id, user.Policy).then(function () { onSaveComplete(page); }); } @@ -163,7 +163,7 @@ var userId = getParameterByName("userId"); - ApiClient.getUser(userId).done(function (result) { + ApiClient.getUser(userId).then(function (result) { saveUser(result, page); }); @@ -238,7 +238,7 @@ SupportsPersistentIdentifier: true })); - $.when(promise1, promise2, promise4, promise5, promise6).done(function (response1, response2, response4, response5, response6) { + $.when(promise1, promise2, promise4, promise5, promise6).then(function (response1, response2, response4, response5, response6) { loadUser(page, response1[0] || response1, response2[0], response4[0].Items, response5[0].Items, response6[0].Items); diff --git a/dashboard-ui/scripts/usernew.js b/dashboard-ui/scripts/usernew.js index 91a745db13..2fa3b291c9 100644 --- a/dashboard-ui/scripts/usernew.js +++ b/dashboard-ui/scripts/usernew.js @@ -70,7 +70,7 @@ var promise5 = ApiClient.getJSON(ApiClient.getUrl("Channels")); - $.when(promise4, promise5).done(function (response4, response5) { + $.when(promise4, promise5).then(function (response4, response5) { loadMediaFolders(page, response4[0].Items); loadChannels(page, response5[0].Items); @@ -83,7 +83,7 @@ var name = $('#txtUserName', page).val(); - ApiClient.createUser(name).done(function (user) { + ApiClient.createUser(name).then(function (user) { user.Policy.EnableAllFolders = $('#chkEnableAllFolders', page).checked(); user.Policy.EnabledFolders = user.Policy.EnableAllFolders ? @@ -103,11 +103,11 @@ }).get(); - ApiClient.updateUserPolicy(user.Id, user.Policy).done(function () { + ApiClient.updateUserPolicy(user.Id, user.Policy).then(function () { Dashboard.navigate("useredit.html?userId=" + user.Id); }); - }).fail(function() { + }, function () { Dashboard.alert(Globalize.translate('DefaultErrorMessage')); Dashboard.hideLoadingMsg(); diff --git a/dashboard-ui/scripts/userparentalcontrol.js b/dashboard-ui/scripts/userparentalcontrol.js index 5cf0522d20..d0aea6154a 100644 --- a/dashboard-ui/scripts/userparentalcontrol.js +++ b/dashboard-ui/scripts/userparentalcontrol.js @@ -211,7 +211,7 @@ user.Policy.BlockedTags = getBlockedTagsFromPage(page); - ApiClient.updateUserPolicy(user.Id, user.Policy).done(function () { + ApiClient.updateUserPolicy(user.Id, user.Policy).then(function () { onSaveComplete(page); }); } @@ -226,7 +226,7 @@ var userId = getParameterByName("userId"); - ApiClient.getUser(userId).done(function (result) { + ApiClient.getUser(userId).then(function (result) { saveUser(result, page); }); @@ -407,7 +407,7 @@ var promise2 = ApiClient.getParentalRatings(); - $.when(promise1, promise2).done(function (response1, response2) { + $.when(promise1, promise2).then(function (response1, response2) { loadUser(page, response1[0] || response1, response2[0]); diff --git a/dashboard-ui/scripts/userpassword.js b/dashboard-ui/scripts/userpassword.js index 72d44d983f..41b63a6fb7 100644 --- a/dashboard-ui/scripts/userpassword.js +++ b/dashboard-ui/scripts/userpassword.js @@ -21,7 +21,7 @@ var userId = getParameterByName("userId"); - ApiClient.getUser(userId).done(function (user) { + ApiClient.getUser(userId).then(function (user) { loadUser(page, user); diff --git a/dashboard-ui/scripts/userprofilespage.js b/dashboard-ui/scripts/userprofilespage.js index 8f825a1496..1941a6f65c 100644 --- a/dashboard-ui/scripts/userprofilespage.js +++ b/dashboard-ui/scripts/userprofilespage.js @@ -37,7 +37,7 @@ if (result) { Dashboard.showLoadingMsg(); - ApiClient.deleteUser(id).done(function () { + ApiClient.deleteUser(id).then(function () { loadData(page); }); @@ -332,7 +332,7 @@ }) - }).done(function () { + }).then(function () { loadData(page); @@ -343,17 +343,17 @@ Dashboard.showLoadingMsg(); - ApiClient.getUsers().done(function (users) { + ApiClient.getUsers().then(function (users) { renderUsers(page, users); Dashboard.hideLoadingMsg(); }); - ApiClient.fetchJSON(ApiClient.getUrl('Connect/Pending')).then(function (pending) { + ApiClient.getJSON(ApiClient.getUrl('Connect/Pending')).then(function (pending) { renderPendingGuests(page, pending); }); - ApiClient.fetchJSON(ApiClient.getUrl("Library/MediaFolders", { IsHidden: false })).then(function (result) { + ApiClient.getJSON(ApiClient.getUrl("Library/MediaFolders", { IsHidden: false })).then(function (result) { renderLibrarySharingList(page, result); }); @@ -363,7 +363,7 @@ Dashboard.showLoadingMsg(); - ApiClient.fetchJSON(ApiClient.getUrl("Channels", {})).then(function (channelsResult) { + ApiClient.getJSON(ApiClient.getUrl("Channels", {})).then(function (channelsResult) { var shareExcludes = $(".chkShareFolder:checked", page).get().map(function (i) { @@ -384,7 +384,7 @@ EnableLiveTv: false } - }).done(function (result) { + }).then(function (result) { $('#popupInvite').popup('close'); diff --git a/dashboard-ui/scripts/wizardfinishpage.js b/dashboard-ui/scripts/wizardfinishpage.js index cfe20d1015..9a8c009c03 100644 --- a/dashboard-ui/scripts/wizardfinishpage.js +++ b/dashboard-ui/scripts/wizardfinishpage.js @@ -7,7 +7,7 @@ url: ApiClient.getUrl('Startup/Complete'), type: 'POST' - }).done(function () { + }).then(function () { Dashboard.navigate('dashboard.html'); }); diff --git a/dashboard-ui/scripts/wizardlivetvguide.js b/dashboard-ui/scripts/wizardlivetvguide.js index 0bbcd5bdc3..c9609e0440 100644 --- a/dashboard-ui/scripts/wizardlivetvguide.js +++ b/dashboard-ui/scripts/wizardlivetvguide.js @@ -8,7 +8,7 @@ var apiClient = ApiClient; - apiClient.fetchJSON(apiClient.getUrl('Startup/Configuration')).then(function (config) { + apiClient.getJSON(apiClient.getUrl('Startup/Configuration')).then(function (config) { var providerId = null; @@ -46,7 +46,7 @@ type: 'GET', url: 'components/tvproviders/' + type + '.template.html' - }).done(function (html) { + }).then(function (html) { var elem = page.querySelector('.providerTemplate'); elem.innerHTML = Globalize.translateDocument(html); @@ -58,7 +58,7 @@ function skip() { var apiClient = ApiClient; - apiClient.fetchJSON(apiClient.getUrl('Startup/Info')).then(function (info) { + apiClient.getJSON(apiClient.getUrl('Startup/Info')).then(function (info) { if (info.SupportsRunningAsService) { Dashboard.navigate('wizardservice.html'); diff --git a/dashboard-ui/scripts/wizardlivetvtuner.js b/dashboard-ui/scripts/wizardlivetvtuner.js index 39fbe7d867..3d99b19663 100644 --- a/dashboard-ui/scripts/wizardlivetvtuner.js +++ b/dashboard-ui/scripts/wizardlivetvtuner.js @@ -7,7 +7,7 @@ var apiClient = ApiClient; // After saving chapter task, now save server config - apiClient.fetchJSON(apiClient.getUrl('Startup/Configuration')).then(function (config) { + apiClient.getJSON(apiClient.getUrl('Startup/Configuration')).then(function (config) { config.LiveTvTunerType = $('#selectTunerType', page).val(); config.LiveTvTunerPath = $('.txtDevicePath', page).val(); @@ -18,12 +18,12 @@ data: config, url: apiClient.getUrl('Startup/Configuration') - }).done(function () { + }).then(function () { Dashboard.hideLoadingMsg(); navigateToNextPage(config); - }).fail(function () { + }, function () { Dashboard.hideLoadingMsg(); Dashboard.alert({ @@ -41,7 +41,7 @@ var apiClient = ApiClient; - apiClient.fetchJSON(apiClient.getUrl('Startup/Configuration')).then(function (config) { + apiClient.getJSON(apiClient.getUrl('Startup/Configuration')).then(function (config) { $('#selectTunerType', page).val(config.LiveTvTunerType || 'hdhomerun'); page.querySelector('.txtDevicePath').value = config.LiveTvTunerPath || ''; @@ -62,7 +62,7 @@ function skip() { var apiClient = ApiClient; - apiClient.fetchJSON(apiClient.getUrl('Startup/Info')).then(function (info) { + apiClient.getJSON(apiClient.getUrl('Startup/Info')).then(function (info) { if (info.SupportsRunningAsService) { Dashboard.navigate('wizardservice.html'); diff --git a/dashboard-ui/scripts/wizardsettings.js b/dashboard-ui/scripts/wizardsettings.js index 31f74cfa70..fefa55e8f7 100644 --- a/dashboard-ui/scripts/wizardsettings.js +++ b/dashboard-ui/scripts/wizardsettings.js @@ -7,7 +7,7 @@ var apiClient = ApiClient; // After saving chapter task, now save server config - apiClient.fetchJSON(apiClient.getUrl('Startup/Configuration')).then(function (config) { + apiClient.getJSON(apiClient.getUrl('Startup/Configuration')).then(function (config) { config.PreferredMetadataLanguage = $('#selectLanguage', page).val(); config.MetadataCountryCode = $('#selectCountry', page).val(); @@ -20,7 +20,7 @@ data: config, url: apiClient.getUrl('Startup/Configuration') - }).done(function () { + }).then(function () { navigateToNextPage(); @@ -50,7 +50,7 @@ var promise2 = apiClient.getCultures(); var promise3 = apiClient.getCountries(); - $.when(promise1, promise2, promise3).done(function (response1, response2, response3) { + $.when(promise1, promise2, promise3).then(function (response1, response2, response3) { reloadData(page, response1[0], response2[0], response3[0]); diff --git a/dashboard-ui/scripts/wizardstartpage.js b/dashboard-ui/scripts/wizardstartpage.js index eca138ebd7..d896c76598 100644 --- a/dashboard-ui/scripts/wizardstartpage.js +++ b/dashboard-ui/scripts/wizardstartpage.js @@ -17,7 +17,7 @@ var apiClient = ApiClient; - apiClient.fetchJSON(apiClient.getUrl('Startup/Configuration')).then(function (config) { + apiClient.getJSON(apiClient.getUrl('Startup/Configuration')).then(function (config) { config.UICulture = $('#selectLocalizationLanguage', page).val(); @@ -27,7 +27,7 @@ data: config, url: apiClient.getUrl('Startup/Configuration') - }).done(function () { + }).then(function () { Dashboard.navigate('wizarduser.html'); @@ -57,7 +57,7 @@ var promise2 = apiClient.getJSON(apiClient.getUrl("Localization/Options")); - $.when(promise1, promise2).done(function (response1, response2) { + $.when(promise1, promise2).then(function (response1, response2) { loadPage(page, response1[0], response2[0]); diff --git a/dashboard-ui/scripts/wizarduserpage.js b/dashboard-ui/scripts/wizarduserpage.js index 8ddbe28fc5..9d544fb91e 100644 --- a/dashboard-ui/scripts/wizarduserpage.js +++ b/dashboard-ui/scripts/wizarduserpage.js @@ -45,7 +45,7 @@ url: apiClient.getUrl('Startup/User'), dataType: 'json' - }).done(onUpdateUserComplete).fail(function () { + }).then(onUpdateUserComplete, function () { var msgKey = form.querySelector('#txtConnectUserName').value ? 'ErrorAddingEmbyConnectAccount' : 'DefaultErrorMessage'; @@ -77,7 +77,7 @@ var apiClient = getApiClient(); - apiClient.fetchJSON(apiClient.getUrl('Startup/User')).then(function (user) { + apiClient.getJSON(apiClient.getUrl('Startup/User')).then(function (user) { page.querySelector('#txtUsername').value = user.Name; page.querySelector('#txtConnectUserName').value = user.ConnectUserName; diff --git a/dashboard-ui/thirdparty/jquerymobile-1.4.5/jqm.popup.js b/dashboard-ui/thirdparty/jquerymobile-1.4.5/jqm.popup.js index d6a47c187c..601abb9d7a 100644 --- a/dashboard-ui/thirdparty/jquerymobile-1.4.5/jqm.popup.js +++ b/dashboard-ui/thirdparty/jquerymobile-1.4.5/jqm.popup.js @@ -598,7 +598,7 @@ } }); - $.when(prerequisites.screen, prerequisites.container).done(function () { + $.when(prerequisites.screen, prerequisites.container).then(function () { if (prerequisites === self._prerequisites) { self._prerequisites = null; whenDone(); diff --git a/dashboard-ui/thirdparty/jquerymobile-1.4.5/jquery.mobile.custom.js b/dashboard-ui/thirdparty/jquerymobile-1.4.5/jquery.mobile.custom.js index 338113f8e0..4b21f0e164 100644 --- a/dashboard-ui/thirdparty/jquerymobile-1.4.5/jquery.mobile.custom.js +++ b/dashboard-ui/thirdparty/jquerymobile-1.4.5/jquery.mobile.custom.js @@ -2160,7 +2160,7 @@ this.load(to, settings); - settings.deferred.done($.proxy(function (url, options, content) { + settings.deferred.then($.proxy(function (url, options, content) { // store the original absolute url so that it can be provided // to events in the triggerData of the subsequent changePage call diff --git a/dashboard-ui/voice/voice.js b/dashboard-ui/voice/voice.js index 9949063f35..ad94d833e9 100644 --- a/dashboard-ui/voice/voice.js +++ b/dashboard-ui/voice/voice.js @@ -148,7 +148,7 @@ if (result.category == 'nextup') { - ApiClient.getNextUpEpisodes(query).done(function (queryResult) { + ApiClient.getNextUpEpisodes(query).then(function (queryResult) { playItems(queryResult.Items, shuffle); @@ -280,7 +280,7 @@ elem = $('.voiceInputHelp'); - getCommandsPromise.done(function (commands) { + getCommandsPromise.then(function (commands) { renderSampleCommands(elem, commands); }); @@ -324,7 +324,7 @@ $('.blockedMessage').show(); } - processText(text).done(hideVoiceHelp).fail(showUnrecognizedCommandHelp); + processText(text).then(hideVoiceHelp, showUnrecognizedCommandHelp); } function startListening() {