-
Notifications
You must be signed in to change notification settings - Fork 50
/
stats.js
30 lines (29 loc) · 1.05 KB
/
stats.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
function statsRefresh(_target, _identifier) {
$.ajax({
url: '/json/stats/' + _target + '/' + _identifier,
dataType: 'json',
type: 'GET',
contentType: 'application/json',
success: function (data, textStatus, jQxhr) {
$('.stats-' + _target + '-' + _identifier + '-active').text(data.active);
$('.stats-' + _target + '-' + _identifier + '-inactive').text(data.inactive);
$('.stats-' + _target + '-' + _identifier + '-total').text(data.total);
},
error: function (jqXhr, textStatus, errorThrown) {
var _clientmsg = 'Client: ' + errorThrown;
var _serverJSON = $.parseJSON(jqXhr.responseText);
var _servermsg = 'Server: ' + _serverJSON.message;
console.log('Error getting stats...');
console.log(_clientmsg);
console.log(_servermsg);
}
});
}
function beginStats() {
var _stats = ['environment', 'platform'];
for (var i = 0; i < _stats.length; i++) {
$('input[type="hidden"].stats-' + _stats[i] + '-value').each(function () {
statsRefresh(_stats[i], $(this).val());
});
}
}