From 5337f923eccdad4a9f2ef8f1df52fde72550e827 Mon Sep 17 00:00:00 2001 From: Kenneth Li Date: Sun, 3 Apr 2016 12:46:42 -0400 Subject: [PATCH] Leaderboard --- public/js/game/Leaderboard.js | 7 +++++-- public/styles/index.less | 10 ++++++++++ views/index.jade | 1 + 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/public/js/game/Leaderboard.js b/public/js/game/Leaderboard.js index 5d57c7d..97b299a 100644 --- a/public/js/game/Leaderboard.js +++ b/public/js/game/Leaderboard.js @@ -26,12 +26,15 @@ Leaderboard.prototype.update = function(players) { this.element.removeChild(this.element.firstChild); } + var header = document.createElement('h1'); + header.appendChild(document.createTextNode('Leaderboard')); + this.element.appendChild(header); + for (var i = 0; i < this.players.length; ++i) { var playerElement = document.createElement('li'); playerElement.appendChild(document.createTextNode( this.players[i].name + - ": Kills: " + this.players[i].kills + - " Deaths: " + this.players[i].deaths)); + ": Score: " + this.players[i]['score'])); this.element.appendChild(playerElement); }; }; diff --git a/public/styles/index.less b/public/styles/index.less index 10838d6..320e6d4 100644 --- a/public/styles/index.less +++ b/public/styles/index.less @@ -30,6 +30,16 @@ html, body { opacity: 0; } +#leaderboard { + position: absolute; + width: 20%; + height: 80%; + top: 10%; + left: 5%; + background-color: #eeeeee; + list-style: none; +} + #canvas { width: 768px; height: 1024px; diff --git a/views/index.jade b/views/index.jade index c679303..5410d64 100644 --- a/views/index.jade +++ b/views/index.jade @@ -34,6 +34,7 @@ block body span About #container div#leaderboard + h1 Leaderboard canvas#canvas block scripts