]> git.example.dev Git - binbsis50.git/commitdiff
minor refactor and fix
authorLuigi Pinca <luigipinca@gmail.com>
Mon, 11 Nov 2013 16:59:13 +0000 (17:59 +0100)
committerLuigi Pinca <luigipinca@gmail.com>
Mon, 11 Nov 2013 16:59:13 +0000 (17:59 +0100)
public/js/app.js

index 0a8e5aec6efe1788d06ce2e076b5bc030f8c5131..ccfa571416d13fb7a3a6354be240b6a3435498f7 100644 (file)
@@ -11,7 +11,7 @@
     , pvtmsgto
     , subscriber = false
     , roundpoints = 0
-    , roomname = window.location.pathname.replace('/', '')
+    , roomname = window.location.pathname.replace(/\//g, '')
     , socket
     , stopanimation = false
     , touchplay
     html += '<th><div class="icons cups stand3"></div></th><th>Guessed</th><th>Mean time</th>';
     html += '</thead><tbody>';
 
-    for(var i=0;i<3;i++) {
-      if (podium[i]) {
-        html += '<tr><td><div class="icons medals rank'+(i+1)+'"></div></td>';
-        html += '<td class="name">'+podium[i].nickname+'</td>';
-        html += '<td>'+podium[i].points+'</td>';
-        html += '<td>'+podium[i].golds+'</td><td>'+podium[i].silvers+'</td>';
-        html += '<td>'+podium[i].bronzes+'</td><td>'+podium[i].guessed+'</td>';
-        var meantime = "N/A";
-        if (podium[i].guessed !== 0) {
-          meantime = podium[i].totguesstime / podium[i].guessed;
-          meantime = (meantime / 1000).toFixed(1)+' s';
-        }
-        html += '<td>'+meantime+'</td></tr>';
-      }
-    }
+    podium.forEach(function(player, i) {
+      html += '<tr><td><div class="icons medals rank'+(i+1)+'"></div></td>';
+      html += '<td class="name">'+player.nickname+'</td>';
+      html += '<td>'+player.points+'</td>';
+      html += '<td>'+player.golds+'</td><td>'+player.silvers+'</td>';
+      html += '<td>'+player.bronzes+'</td><td>'+player.guessed+'</td>';
+      var meantime = "N/A";
+      if (player.guessed !== 0) {
+        meantime = player.totguesstime / player.guessed;
+        meantime = (meantime / 1000).toFixed(1)+' s';
+      }
+      html += '<td>'+meantime+'</td></tr>';
+    });
 
     html +='</tbody></table></div>';
     html += '<div class="modal-footer align-left">A new game will start in ';