summaryrefslogtreecommitdiff
path: root/cao-mobile.js
diff options
context:
space:
mode:
authorJeremie Taboada <taboada.jeremie@gmail.com>2015-06-05 01:14:41 +0100
committerOlivier Gayot <duskcoder@gmail.com>2015-06-08 17:01:45 +0100
commitd45704ef40f3fe68ab583a85674cea8a07d2e005 (patch)
treedfac5ece20b182363ee1c4f898f43680466d36e8 /cao-mobile.js
parentdc8e04f03cb6262d9796795273cd67854719d8d3 (diff)
Add UI and start integration.
Diffstat (limited to 'cao-mobile.js')
-rw-r--r--cao-mobile.js74
1 files changed, 74 insertions, 0 deletions
diff --git a/cao-mobile.js b/cao-mobile.js
new file mode 100644
index 0000000..f639d1b
--- /dev/null
+++ b/cao-mobile.js
@@ -0,0 +1,74 @@
+$(document).ready(function() {
+ cao.on_socket_open = function() {
+ var $joinBtn = $("#join-btn");
+ $joinBtn.show();
+ $joinBtn.on("click", function () {
+ cao.join_game(prompt('Name of the game'));
+ });
+ };
+
+ cao.on_join_game_ok = function() {
+ $('#btn_join').hide();
+ $('#btn_pick_black').show();
+ $('#white_cards').show();
+ };
+
+ cao.on_show_white_card = function(idx, desc) {
+ identifier = 'white_card_' + idx;
+ content = '<li id="' + identifier + '">' + desc + '</li>';
+
+ $('#white_cards').append(content);
+
+ $('#' + identifier).dblclick(this.gen_callback_white_card(idx));
+ };
+
+ cao.on_show_played_card = function(idx, desc) {
+ identifier = 'played_card_' + idx;
+
+ content = '<li id="' + identifier + '">' + desc + '</li>';
+
+ $('#played_cards').append(content);
+
+ $('#' + identifier).dblclick(this.gen_callback_played_card(idx));
+ };
+
+
+ cao.on_pick_black_card_ok = function() {
+ $('#btn_collect').show();
+ $('#btn_pick_black').hide();
+ };
+
+ cao.on_show_black_card = function(desc) {
+ $('#black_card').show();
+ $('#black_card').html(desc);
+ };
+
+
+ cao.on_play_white_card_ok = function(idx) {
+ identifier = 'white_card_' + idx;
+ $('#' + identifier).remove();
+ };
+
+ cao.on_designate_card_ok = function() {
+ $('#played_cards').empty();
+ $('#played_cards').hide();
+ $('#black_card').hide();
+ $('#btn_collect').hide();
+ $('#btn_pick_black').show();
+ };
+
+ cao.on_collect_cards_ok = function() {
+ $('#btn_collect').hide();
+ $('#played_cards').show();
+ };
+
+ cao.on_judge_designed = function() {
+ $('#btn_pick_black').hide();
+ };
+
+ cao.on_judge_needed = function() {
+ $('#btn_pick_black').show();
+ };
+
+ cao.run();
+});