Skip to content

Commit

Permalink
Leaderboard tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
gschmidt committed Apr 10, 2012
1 parent 3dcfe65 commit dbd7b1e
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions examples/leaderboard/leaderboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Players = new Meteor.Collection("players");

if (Meteor.is_client) {
Template.leaderboard.players = function () {
return Players.find({}, {sort: {score: -1}});
return Players.find({}, {sort: {score: -1, name: 1}});
};

Template.leaderboard.selected_name = function () {
Expand All @@ -31,11 +31,15 @@ if (Meteor.is_client) {
}

// On server startup, create some players if the database is empty.

if (Meteor.is_server) {
Meteor.startup(function () {
if (Players.find().count() === 0) {
var names = ["Mario", "Luigi", "Toad", "Yoshi", "Princess Peach"];
var names = ["Ada Lovelace",
"Grace Hopper",
"Marie Curie",
"Carl Friedrich Gauss",
"Nikola Tesla",
"Claude Shannon"];
for (var i = 0; i < names.length; i++)
Players.insert({name: names[i], score: Math.floor(Math.random()*10)*5});
}
Expand Down

0 comments on commit dbd7b1e

Please sign in to comment.