-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathadmin.js
More file actions
94 lines (88 loc) · 2.51 KB
/
admin.js
File metadata and controls
94 lines (88 loc) · 2.51 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
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
92
93
94
var socket = io.connect(location.protocol + '//' + document.domain + ':'
+ location.port + '/admin');
socket.on('connect', function() {
console.log('Socket connected!')
socket.emit('', {data: 'I\'m connected!'});
});
socket.on('update', function(data) {
if (data.approved_requests) {
$('#approved_requests').fadeOut(250, function() {
$(this).html(data.approved_requests)
.fadeIn(250, init_request_actions);
});
}
if (data.submitted_requests) {
$('#submitted_requests').fadeOut(250, function() {
$(this).html(data.submitted_requests)
.fadeIn(250, init_request_actions);
});
}
if (data.lottery_quantities) {
q = data.lottery_quantities;
for (var i = 0; i < data.lottery_quantities.length; i++) {
q = data.lottery_quantities[i];
var div = $('div[data-item-id='+q['id']+']');
div.find('.item-quantity').html(q['available']);
div.find('.submitted-quantity').html(q['submitted']);
}
}
});
function init_request_actions() {
$('.request-action').api({
method: 'POST',
onSuccess: function(response) {
},
onFailure: function(err) {
console.log(err);
alert(err.message)
}
});
}
$(document).ready(function() {
init_request_actions();
$('.approve-all.button').api({
method: 'POST',
onSuccess: function(response) {
},
onFailure: function(err) {
console.log(err);
alert(err.message)
},
onError: function(err) {
console.log("ERROR!");
console.log(err);
}
});
$('.deny-all.button').api({
method: 'POST',
onSuccess: function(response) {
},
onFailure: function(err) {
console.log("ERROR!");
console.log(err);
},
onError: function(err) {
console.log("ERROR!");
console.log(err);
}
});
$('.run-lottery.button').api({
method: 'POST',
onSuccess: function(response) {
// window.location.reload();
},
onFailure: function(err) {
console.log("ERROR!");
console.log(err);
},
onError: function(err) {
console.log("ERROR!");
console.log(err);
}
});
$('.run-all-lottery.button').api({
method: 'POST',
onSuccess: function(response) {
},
});
});