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

update path fields

This commit is contained in:
Luke Pulverenti 2015-09-06 00:53:37 -04:00
parent 8c248c229a
commit 03b5e48d4f
45 changed files with 153 additions and 198 deletions

View file

@ -43,10 +43,8 @@
function sendRequest(request) {
var method = request.type || "GET";
// For now, we can only handle json responses
if (request.dataType || method == "GET") {
if (request.dataType) {
if (request.dataType != 'json') {
return baseAjaxMethod(request);
}
@ -69,6 +67,8 @@
request.headers.accept = 'application/json';
}
var method = request.type || "GET";
var javaRequest = {
Method: method,
Url: request.url,
@ -131,11 +131,54 @@
return error;
}
function getDownloadSpeed(bytes, url) {
var deferred = DeferredBuilder.Deferred();
ApiClientBridge.getDownloadSpeed(bytes, url);
Events.on(AndroidAjax, 'downloadspeedresponse', function (e, response) {
Events.off(AndroidAjax, 'downloadspeedresponse');
if (response) {
deferred.resolveWith(null, [response]);
}
else {
// Need to mimic the jquery ajax error response
deferred.reject();
}
});
return deferred.promise();
}
function initApiClient(newApiClient) {
newApiClient.getDownloadSpeed = function (bytes) {
return getDownloadSpeed(bytes, newApiClient.getUrl('Playback/BitrateTest', {
api_key: newApiClient.accessToken(),
Size: bytes
}));
};
}
Events.on(ConnectionManager, 'apiclientcreated', function (e, newApiClient) {
initApiClient(newApiClient);
});
Events.on(ConnectionManager.credentialProvider(), 'credentialsupdated', updateCredentials);
updateCredentials();
initNativeConnectionManager();
if (window.ApiClient) {
initApiClient(window.ApiClient);
}
window.AndroidAjax = {
onResponse: function (id, response) {
@ -145,6 +188,10 @@
onError: function (id, response) {
Events.trigger(AndroidAjax, 'response' + id, [false, response]);
},
onDownloadSpeedResponse: function (response) {
Events.trigger(AndroidAjax, 'downloadspeedresponse', [response]);
}
};