-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathelrond-list.js
42 lines (32 loc) · 1.15 KB
/
elrond-list.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
39
40
41
$(document).ready(function () {
// Handler for .ready() called.
function round(value, decimals) {
return Number(Math.round(value + 'e' + decimals) + 'e-' + decimals);
}
function addZero(i) {
if (i < 10) {
i = "0" + i;
}
return i;
}
var total = 0;
const appendLine = (herotag, amount, message) => {
total += parseFloat(amount);
$("#total").text(round(total, 8));
let date = new Date();
$('#listDonations > tbody:last-child').prepend('<tr>' +
'<td>'+ herotag +'</td>' +
'<td> '+ amount +' eGLD</td>' +
'<td>'+ message +'</td>' +
'<td>'+ addZero(date.getDate()) + '/' + addZero(date.getMonth()) + '/' + date.getFullYear() + ' à ' + addZero(date.getHours()) + ':'+ addZero(date.getMinutes()) + ':' + addZero(date.getSeconds()) + '</td>' +
'</tr>');
}
const socket = io("https://streamparticles.io", {
query: {
streamerHerotag: 'loic2665.elrond',
},
});
socket.on("newDonation", (data) => {
appendLine(data.herotag, data.amount, data.message);
});
});