namibia
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
APE.Transport.JSONP = new Class({
Implements: APE.Transport.SSE,
initialize: function(ape) {
this.ape = ape;
this.requestFailObserver = [];
this.requests = [];
//If browser support servent sent event, switch to SSE / JSONP transport (not yet supported by APE server)
//if (this.SSESupport) this.ape.options.transport = 3;
window.parent.onkeyup = function(ev) {
if (ev.keyCode == 27) {
this.cancel();//Escape key
if (this.ape.status > 0) {
//if (!this.SSESupport)
//this.ape.request('CLOSE');
this.ape.check();
}
}
}.bind(this);
},
send: function(queryString, options) {
//Opera has some trouble with JSONP, so opera use mix of SSE & JSONP
/*if (this.SSESupport && !this.eventSource) { //SSE not yet supported by APE server
this.initSSE(queryString, options, this.readSSE.bind(this));
} else { */
this.callback = options.requestCallback;
var request = document.createElement('script');
request.src = this.ape.serverUri + queryString;
document.head.appendChild(request);
this.requests.push(request);
//Detect timeout
this.requestFailObserver.push(this.ape.requestFail.delay(this.ape.options.pollTime + 10000, this.ape, [-1, request]));
if (Browser.Engine.gecko) {
//Firefox hack to avoid status bar always show a loading message
//Ok this hack is little bit weird but it works!
(function() {
var tmp = document.createElement('iframe');
document.body.appendChild(tmp);
document.body.removeChild(tmp);
}).delay(200);
}
//}
},
clearRequest: function(request) {
request.parentNode.removeChild(request);
//Avoid memory leaks
if (request.clearAttributes) {
request.clearAttributes();
} else {
for (var prop in request) delete request[prop];
}
$clear(this.requestFailObserver.shift());
},
readSSE: function(data) {
this.ape.parseResponse(data, this.callback);
this.callback = null;
},
read: function(resp) {
$clear(this.requestFailObserver.shift());
this.clearRequest(this.requests.shift());
this.ape.parseResponse(resp, this.callback);
this.callback = null;
},
cancel: function() {
if (this.requests.length > 0) {
this.clearRequest(this.requests.shift());
}
},
running: function() {
/* if (this.SSESupport) {
return this.eventSource ? true : false;
} else { */
return this.requests.length > 0 ? true : false;
//}
}
});
APE.Transport.JSONP.browserSupport = function() { return true };
|
Revision |
Author |
Commited |
Message |
df0489 ...
|
Mark |
Fri 14 Oct, 2016 10:01:00 +0000 |
|