Permalink
Browse files

Merge commit 'c1cb88702ae9151e756fb286d4a9c69b82a1ca4c'

Conflicts:
	setwithme/static/css/base.css
	setwithme/static/js/base.js
  • Loading branch information...
2 parents 8e127c3 + c1cb887 commit 4f6919ca29a666ec2ee0673308538cad749956f6 @alarin alarin committed Jul 30, 2011
Showing with 25 additions and 22 deletions.
  1. +1 −1 setwithme/apps/game/views.py
  2. +1 −0 setwithme/static/css/base.css
  3. +23 −21 setwithme/static/js/base.js
@@ -47,8 +47,8 @@ def get_status(request, game_id):
users = [gs.serialize(self_id) for gs in \
game.gamesession_set.all()]
desc_cards = game.desk_cards_list
- rem_cards_cnt = len(game.rem_cards_list)
desc_cards.extend(game.pop_cards(quantity=12 - len(desc_cards)))
+ rem_cards_cnt = len(game.rem_cards_list)
return {'users': users,
'cards': [Card(id=card_id).as_text() for card_id in desc_cards],
'cards_left': rem_cards_cnt}
@@ -46,6 +46,7 @@ a.pseudo:hover {
.footer {
height: 100px;
background: #4d545a url(../images/bg.png);
+ height: 100px;
overflow: hidden;
padding: 15px 0 0 0;
clear: both;
@@ -96,6 +96,9 @@ SetWithMe.Game.init = function(gameId) {
* @param {String} id
*/
init: function(id) {
+ this.$cards = $('#js_cards');
+ this.$users = $('#js_players');
+ this.$cardsLeft = $('#js_cards_left');
this._cardsContainer = $('#js_cards');
this._id = id;
this._poller = new SetWithMe.Poller('/game/get_status/' + this._id);
@@ -167,27 +170,26 @@ SetWithMe.Game.init = function(gameId) {
this._cards = data.cards;
this._renderCards();
}
- }
+ var player = null;
+ for(var i=0; i<data.users.length; i++) {
+ player = data.users[i];
+ var $player = $('#p'+player.user_id);
+ if (!$player.length) {
+ SetWithMe.Game.$users.append($(this._renderPlayer(player)));
+ $player = $('#p' + player.user_id);
+ }
+ $player.find('.sets .count').text(player.sets_found);
+ $player[0].class = 'player ' + player.state;
+ }
+ },
- var player = null;
- for(var i=0; i<status.users.length; i++) {
- player = status.users[i];
- var $player = $('#p'+player.user_id);
- if (!$player.length) {
- SetWithMe.Game.$users.append($(SetWithMe.Game.renderPlayer(player)));
- $player = $('#p' + player.user_id);
- }
- $player.find('.sets .count').text(player.sets_found);
- $player[0].class = 'player ' + player.state;
+ _renderPlayer: function(player) {
+ return '<li class="player" id="p' + player.user_id + '">'+
+ '<div class="photo"><div><img src="/static/images/nophoto.png"></div></div>'+
+ '<div class="info">'+
+ '<a href="#" class="name">'+ player.user_name +'</a>'+
+ '<span class="sets"><span class="count"></span> sets</a>'+
+ '</div>'
+ '</li>'
}
-}
-
-SetWithMe.Game.renderPlayer = function(player) {
- return '<li class="player" id="p' + player.user_id + '">'+
- '<div class="photo"><div><img src="/static/images/nophoto.png"></div></div>'+
- '<div class="info">'+
- '<a href="#" class="name">'+ player.user_name +'</a>'+
- '<span class="sets"><span class="count"></span> sets</a>'+
- '</div>'
- '</li>'
};

0 comments on commit 4f6919c

Please sign in to comment.