Permalink
Browse files

Upgraded to derby 0.1.8

  • Loading branch information...
ledwards committed Jan 18, 2012
1 parent 9e370e1 commit 7303639dffd7a9e64122a68e8db471bc8892e84c
Showing with 8 additions and 8 deletions.
  1. +7 −8 lib/play/index.js
  2. +1 −0 views/play/index.html
View
@@ -11,9 +11,9 @@ get('/play/:gameId?', function(page, model, params) {
model.subscribe({ _game: 'game.' + params.gameId }, function() {
var nextPlayerCount = (model.get('_game.players.length') || 0) + 1;
- model.push('_game.players', { name: "Player " + nextPlayerCount, });
+ model.push('_game.players', { name: "Player " + nextPlayerCount });
model.set('_game.playerCount', nextPlayerCount);
- model.set('_player', model.ref('_game.players.' + (nextPlayerCount - 1)));
+ model.ref('_player', '_game.players.' + (nextPlayerCount - 1));
page.render({
gameId: gameId,
@@ -25,7 +25,7 @@ get('/play/:gameId?', function(page, model, params) {
// CONTROLLER FUNCTIONS //
ready(function(model) {
- model.on('push', '_game.players.*.cards', function(playerIndex, card){
+ model.on('push', '_game.players.*.cards', function(playerIndex, card) {
jQuery(".card").draggable({
start: function(event, ui) {
jQuery(this).css('cursor', 'move');
@@ -34,14 +34,13 @@ ready(function(model) {
},
stop: function(event, ui) {
- var movedElement = $(this);
- var cardIndex = movedElement.data("card-index");
- var playerIndex = movedElement.data("owner-index");
+ var element = $(this);
+ var card = model.at(element);
var top = ui.position.top + "px";
var left = ui.position.left + "px";
- movedElement.css('cursor', 'default');
- model.set("_game.players." + playerIndex + ".cards." + cardIndex + ".position", { top: top, left: left });
+ element.css('cursor', 'default');
+ card.set('position', { top: top, left: left });
}
});
});
View
@@ -4,6 +4,7 @@
<Scripts:>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js"></script>
+ <script src="/javascripts/skyhopper.js"></script>
<Body:>
<h1>Welcome ((_player.name))</h1>

0 comments on commit 7303639

Please sign in to comment.