Git Repository Public Repository

namibia

URLs

Copy to Clipboard
 
df0489e1eeeeab5a9bd44e1d84fce49924fe1bac
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
Request = new Class({

	Extends: Request,

	send: function(options) {
		//mootools set onreadystatechange after xhr.open, in webkit, this cause readyState 1 to be never fired
		if (Browser.Engine.webkit) this.xhr.onreadystatechange = this.onStateChange.bind(this);
		return this.parent(options);
	},

	onStateChange: function() {
		if (this.xhr.readyState == 1) this.dataSent = true;
		this.parent();
	}
});

APE.Transport.longPolling = new Class({

	initialize: function(ape) { 
		this.ape = ape;
		this.requestFailObserver = [];
	},

	send: function(queryString, options) {
		var request = new Request({
			url: this.ape.serverUri,
			onFailure: this.ape.requestFail.bind(this.ape, [-2, this]),
			onComplete: function(resp) {
				$clear(this.requestFailObserver.shift());
				this.ape.parseResponse(resp, options.requestCallback);
			}.bind(this)
		}).send(queryString);
		request.id = $time();

		this.request = request;

		this.requestFailObserver.push(this.ape.requestFail.delay(this.ape.options.pollTime + 10000, this.ape, [-1, request]));

		return request;
	},

	running: function() {
		return this.request ? this.request.running : false;
	},

	cancel: function() {
		if (this.request) this.request.cancel();
		$clear(this.requestFailObserver.shift());
	}
});

APE.Transport.longPolling.browserSupport = function() { return Browser.Features.xhr ? true : 2; };

Commits for namibiapublic/js/vendor/ape-source/Transport/Transport.longPolling.js

Diff revisions: vs.
Revision Author Commited Message
df0489 ... Mark Fri 14 Oct, 2016 10:01:00 +0000

initial commit