-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathxdrwrapper.js
More file actions
63 lines (60 loc) · 1.79 KB
/
Copy pathxdrwrapper.js
File metadata and controls
63 lines (60 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// Generated by CoffeeScript 1.3.1
(function() {
var statii;
statii = {
200: "OK",
201: "CREATED",
202: "ACCEPTED",
204: "NO CONTENT",
401: "UNAUTHORIZED",
403: "FORBIDDEN",
404: "NOT FOUND",
409: "CONFLICT",
422: "PRECONDITION FAILED",
500: "INTERNAL SERVER ERROR"
};
window.XDRWrapper = function(settings, original, xhr) {
var sep, url, xdr;
xdr = new XDomainRequest;
sep = settings.url.indexOf("?") === -1 ? "?" : "&";
url = [settings.url, "xdr"].join(sep);
xdr.open("POST", url);
return {
abort: function() {
return xdr.abort();
},
send: function(headers, complete) {
xdr.onerror = function() {
return console.log("FIX: xdr onerror");
};
xdr.onload = function() {
var body, description, responses, status, _ref;
_ref = (function() {
try {
return $.parseJSON(xdr.responseText);
} catch (err) {
headers = {
"Content-Type": "application/json;charset=UTF-8"
};
body = JSON.stringify({
request: ["Unexpected platform error."],
original: xdr.responseText
});
return [503, headers, body];
}
})(), status = _ref[0], headers = _ref[1], body = _ref[2];
description = statii[status] || "UNKNOWN";
responses = {
text: body
};
return complete(status, description, responses, headers);
};
xdr.onprogress = function() {};
xdr.ontimeout = function() {
return console.log("FIX: xdr ontimeout");
};
return xdr.send(JSON.stringify([settings.type, headers, settings.data]));
}
};
};
}).call(this);