ea5a9738
Geoffrey PREUD'HOMME
Scoreboard : coté...
|
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
|
$(function() {
var socket = io();
var scores = [];
var list = $('#list');
socket.emit('getScores');
socket.on('scores', function(newScores) {
scores = newScores;
redrawScores();
});
socket.on('newScore', addScore);
function redrawScores() {
list.empty();
for (s in scores) {
addScore(scores[s]);
}
}
function addScore(obj) {
list.append($('<li>').text(obj.score + ' by ' + obj.name));
}
});
|