From de25bd15fc3a6b197b8005d75e75c5c595fd087e Mon Sep 17 00:00:00 2001 From: Olivier Gayot Date: Tue, 9 Jun 2015 02:27:25 +0100 Subject: mobile: allow a player to select a card Signed-off-by: Olivier Gayot --- cao-mobile.html | 2 +- cao-mobile.js | 30 ++++++++++++++++++++---------- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/cao-mobile.html b/cao-mobile.html index 49f5dfa..232efb1 100644 --- a/cao-mobile.html +++ b/cao-mobile.html @@ -28,7 +28,7 @@
You have 0 cards!
-
+
Choose a card...
diff --git a/cao-mobile.js b/cao-mobile.js index 2db978f..963f9e0 100644 --- a/cao-mobile.js +++ b/cao-mobile.js @@ -24,11 +24,12 @@ $(document).ready(function() { cao.pick_black_card(); }); + $join_btn.click(function () { + cao.join_game(prompt('Name of the game')); + }); + cao.on_socket_open = function() { $join_btn.show(); - $join_btn.on("click", function () { - cao.join_game(prompt('Name of the game')); - }); }; cao.on_join_game_ok = function() { @@ -50,15 +51,19 @@ $(document).ready(function() { $judge_choose.show(); } else { $player_wait.show(); - $white_cards.addClass("read-only"); + $white_cards.attr('disabled', true); + $white_cards.addClass('read-only'); } break; case 'waiting_collection': if (cao.is_judge()) { $judge_collect.show(); + $white_cards.attr('disabled', true); + $white_cards.addClass('read-only'); } else { $player_choose.show(); - $white_cards.removeClass("read-only"); + $white_cards.removeAttr('disabled'); + $white_cards.removeClass('read-only'); } break; default: @@ -69,17 +74,17 @@ $(document).ready(function() { cao.on_show_white_card = function(idx, desc) { var identifier = 'white-card-' + idx; - var content = ''; + var content = ''; $white_cards.append(content); var self = this; $('#' + identifier).click(function () { var $this = $(this); - if (!$white_cards.hasClass("read-only")) { + if (!$white_cards.attr('disabled')) { if ($this.hasClass("active")) { - self.gen_callback_white_card(idx); + cao.get_white_card_event($this.prop('name'))(); } else { $white_cards.find("> .card").removeClass("active"); - $(this).addClass("active"); + $this.addClass("active"); } } }); @@ -92,7 +97,12 @@ $(document).ready(function() { }; cao.on_play_white_card_ok = function(idx) { - $('#white-card-' + identifier).remove(); + $white_cards.attr('disabled', true); + $white_cards.addClass('read-only'); + + $player_wait.show(); + + $('#white-card-' + idx).remove(); }; cao.on_updated_score = function(score) { -- cgit v1.2.3