You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
858 B
39 lines
858 B
8 years ago
|
HandlebarsIntl.registerWith(Handlebars);
|
||
|
|
||
|
$(function() {
|
||
|
window.state = {};
|
||
|
var userLang = (navigator.language || navigator.userLanguage) || 'en-US';
|
||
|
window.intlData = { locales: userLang };
|
||
|
var source = $("#stats-template").html();
|
||
|
var template = Handlebars.compile(source);
|
||
|
refreshStats(template);
|
||
|
|
||
|
setInterval(function() {
|
||
|
refreshStats(template);
|
||
|
}, 5000)
|
||
|
});
|
||
|
|
||
|
function refreshStats(template) {
|
||
|
$.getJSON("/stats", function(stats) {
|
||
|
$("#alert").addClass('hide');
|
||
|
|
||
|
// Sort miners by ID
|
||
|
if (stats.miners) {
|
||
|
stats.miners = stats.miners.sort(compare)
|
||
|
}
|
||
|
// Repaint stats
|
||
|
var html = template(stats, { data: { intl: window.intlData } });
|
||
|
$('#stats').html(html);
|
||
|
}).fail(function() {
|
||
|
$("#alert").removeClass('hide');
|
||
|
});
|
||
|
}
|
||
|
|
||
|
function compare(a, b) {
|
||
|
if (a.name < b.name)
|
||
|
return -1;
|
||
|
if (a.name > b.name)
|
||
|
return 1;
|
||
|
return 0;
|
||
|
}
|