2013-02-22 05:56:46 +00:00
|
|
|
//try to add ajax data as query string to DELETE calls.
|
2013-06-22 06:24:24 +00:00
|
|
|
'use strict';
|
2013-06-21 05:35:56 +00:00
|
|
|
define(function () {
|
2013-02-15 23:38:53 +00:00
|
|
|
|
2013-06-21 05:35:56 +00:00
|
|
|
return function () {
|
2013-02-15 23:38:53 +00:00
|
|
|
|
2013-06-21 05:35:56 +00:00
|
|
|
var original = this.ajax;
|
|
|
|
this.ajax = function () {
|
2013-02-15 23:38:53 +00:00
|
|
|
|
2013-06-21 05:35:56 +00:00
|
|
|
var xhr = arguments[0];
|
2013-02-15 23:38:53 +00:00
|
|
|
|
2013-06-21 05:35:56 +00:00
|
|
|
//check if ajax call was made with data option
|
|
|
|
if (xhr && xhr.data && xhr.type === 'DELETE') {
|
2013-09-11 21:38:35 +00:00
|
|
|
if (!xhr.url.contains('?')) {
|
2013-06-21 05:35:56 +00:00
|
|
|
xhr.url = xhr.url + '?' + $.param(xhr.data);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
xhr.url = xhr.url + '&' + $.param(xhr.data);
|
|
|
|
}
|
2013-07-11 22:38:15 +00:00
|
|
|
|
|
|
|
delete xhr.data;
|
2013-02-15 23:38:53 +00:00
|
|
|
}
|
2013-09-20 07:31:02 +00:00
|
|
|
if (xhr) {
|
2013-09-20 22:19:48 +00:00
|
|
|
xhr.headers = xhr.headers || {};
|
|
|
|
xhr.headers['Authorization'] = window.NzbDrone.ApiKey;
|
2013-09-20 07:31:02 +00:00
|
|
|
}
|
2013-02-15 23:38:53 +00:00
|
|
|
|
2013-06-21 05:35:56 +00:00
|
|
|
return original.apply(this, arguments);
|
|
|
|
};
|
2013-02-15 23:38:53 +00:00
|
|
|
};
|
2013-06-14 23:18:37 +00:00
|
|
|
});
|