-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstrophejs.easyxdm.js
More file actions
52 lines (48 loc) · 1.8 KB
/
Copy pathstrophejs.easyxdm.js
File metadata and controls
52 lines (48 loc) · 1.8 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
Strophe.addConnectionPlugin('easyxdm', {
init: function (conn) {
var XDMXHR = function() {
var self = this;
this.open = function(method,url,async) {
this._method=method;
this._url=url;
this._async=async;
this.readyState = 1;
};
this.send = function(body) {
this.readyState = 2;
Gt.ApiRpc.strophe_request({
type:self._method,
url:self._url,
async:self._async,
data:body
},function(xdmdata) {
self.responseText = xdmdata.responseText;
self.responseXML = $.parseXML( xdmdata.responseText );
self.status = xdmdata.status;
self.readyState=4;
self.onreadystatechange();
},function(xdmdata) {
self.responseText = xdmdata.responseText;
self.responseXML = $.parseXML( xdmdata.responseText );
self.status = xdmdata.status;
self.readyState=4;
if(self.onreadystatechange!=null) {
self.onreadystatechange();
}
});
};
this.abort = function() {
};
this.onreadystatechange = null;
this.responseText = null;
this.responseXML = null;
this.status = null;
this.readyState = 0;
};
Strophe.Request.prototype._newXHR = function () {
var xhr = new XDMXHR();
xhr.onreadystatechange = this.func.bind(null, this);
return xhr;
};
}
});