forked from altitudelabs/web
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
60 lines (51 loc) · 1.44 KB
/
script.js
File metadata and controls
60 lines (51 loc) · 1.44 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
// Innitialize vars
var container = document.getElementById("container1");
// Set content to the center of the window
window.onload = function(){
resize();
}
window.onresize = resize;
function resize(){
var width = window.innerWidth;
container.style.width = width + "px";
var top = (window.innerHeight - container.offsetHeight)/2;
var left = (window.innerWidth - container.offsetWidth)/2;
container.style.top = top + "px";
container.style.left = left + "px";
}
// Refresh the leaderboard
$(document).ready( function() {
var options = {
frequency: 15,
limit: 5
};
poller = new window.massrel.Poller(options, function callback(result) {
$("#leaderboard tr").remove();
result.forEach(function(band) {
// Numerical processing
var count_number = "";
if (band.count >= 1000){
var thousand = Math.floor(band.count/1000);
var hundred = band.count % 1000;
if (hundred < 10){
hundred = "00"+hundred;
}else if (hundred < 100){
hundred = "0"+hundred;
}
count_number = thousand+","+hundred;
}else{
count_number = band.count.toString();
}
// Update table content
$('#leaderboard').append("\
<tr>\
<td class='bandName'>" + band.name + "</td>\
<td class='bandCount'><span class='countNumber'>" + count_number + "</span> Mentions</td>\
</tr>");
});
// Refresh animation at every 15s
$('#leaderboard td').delay(14200).fadeOut("slow");
});
// Start poller
poller.start();
});