-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
38 lines (33 loc) · 1.15 KB
/
app.js
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
(function() {
var clickCounter = 0,
self = this,
options = {
limit: 1
};
$(function() {
$('#ajaxCall').click(function(evt) {
var clickNum = ++clickCounter;
$('#numOfClicks').html(clickNum);
ajaxCallSimulation(clickNum);
});
$('#turnSyncOn').click(function(evt) {
AjaxSyncHelper.init(self);
$(this).attr('disabled', "disabled");
$('strong').html("ON").css('color', 'blue');
_.each(options, function(value, key) {
$('#syncOptions').show().append(key + ": " + value);
});
clickCounter = 0;
$('#acceptedClicks').append("<div>With AjaxSyncHelper activated:</div>");
});
});
var ajaxCallSimulation = AjaxSyncHelper.ajaxCallerWrapper(function(clickNum) {
$('#requestState').css('visibility', 'visible').html("Waiting for server for click number " + clickNum + "...");
$('#acceptedClicks').append(clickNum + " ");
_.delay(ajaxCallbackSimulation, 2000, clickNum);
}, {limit: options.limit});
var ajaxCallbackSimulation = AjaxSyncHelper.ajaxCallbackWrapper(function(clickNum) {
$('#requestState').css('visibility', 'hidden');
$('#responseState').html("Server responded for click number " + clickNum + "!");
});
})();