$(function() { var socket = io(); var scores = []; var list = $('#scores ol'); socket.emit('getScores'); socket.on('scores', function(newScores) { scores = newScores; redrawScores(); }); socket.on('newScore', function addScore(obj) { scores.push(obj); redrawScores(); }); socket.on('msg', function(msg) { $('#sub').text(msg); }); function redrawScores() { var sortable = []; scores.sort(function(b, a) {return a.score - b.score}) var list = $('#scores ol'); list.empty(); for (i in scores) { if (i < 15) { var obj = scores[i]; list.append($('