| changeset 1783: |
995bd65e4da2 |
| parent 1782: | 6775dc34e273 |
| child 1784: | 1d599e16185b |
| author: |
Johan Euphrosine <proppy@aminche.com> |
| date: |
Fri Jan 22 13:05:40 2010 +0100 (7 months ago) |
| files: |
jpoker/js/jquery.jpoker.js jpoker/js/test-jpoker.js |
| description: |
jpoker.plugins.tableList.getHTML add css classes for full and empty table |
--- a/jpoker/js/jquery.jpoker.js Thu Jan 21 16:11:23 2010 +0100
+++ b/jpoker/js/jquery.jpoker.js Fri Jan 22 13:05:40 2010 +0100
@@ -2522,6 +2522,13 @@
var link = t.link.supplant({link: link_pattern.supplant({game_id: subpacket.game_id}), name: subpacket.name});
subpacket.name = link;
}
+ if (subpacket.players == subpacket.seats) {
+ subpacket.status_class = 'jpoker_table_list_table_full';
+ } else if (subpacket.players === 0) {
+ subpacket.status_class = 'jpoker_table_list_table_empty';
+ } else {
+ subpacket.status_class = '';
+ }
html.push(t.rows.supplant(subpacket));
}
html.push(t.footer);
@@ -2531,7 +2538,7 @@
jpoker.plugins.tableList.templates = {
header : '<table><thead><tr><th>{name}</th><th>{players}</th><th>{seats}</th><th>{betting_structure}</th><th>{average_pot}</th><th>{hands_per_hour}</th><th>{percent_flop}</th></tr></thead><tbody>',
- rows : '<tr id=\'{id}\' title=\'' + _("Click to join the table") + '\'><td>{name}</td><td>{players}</td><td>{seats}</td><td>{betting_structure}</td><td>{average_pot}</td><td>{hands_per_hour}</td><td>{percent_flop}</td></tr>',
+ rows : '<tr id=\'{id}\' title=\'' + _("Click to join the table") + '\' class=\'{status_class}\'><td>{name}</td><td>{players}</td><td>{seats}</td><td>{betting_structure}</td><td>{average_pot}</td><td>{hands_per_hour}</td><td>{percent_flop}</td></tr>',
footer : '</tbody></table>',
link: '<a href=\'{link}\'>{name}</a>',
pager: '<div class=\'pager\'><input class=\'pagesize\' value=\'10\'></input><ul class=\'pagelinks\'></ul></div>',
--- a/jpoker/js/test-jpoker.js Thu Jan 21 16:11:23 2010 +0100
+++ b/jpoker/js/test-jpoker.js Fri Jan 22 13:05:40 2010 +0100
@@ -3758,6 +3758,26 @@
element.html(jpoker.plugins.tableList.getHTML(id, TABLE_LIST_PACKET));
equals($("table tbody tr", element).length, 1, 'one table');
equals($("table tbody tr td").html(), "Cayrryns");
+ cleanup(id);
+ });
+
+test("jpoker.plugins.tableList getHTML add class for full and empty table", function(){
+ expect(6);
+
+ var TABLE_LIST_PACKET = {"players": 4, "type": "PacketPokerTableList", "packets": []};
+ TABLE_LIST_PACKET.packets.push({"observers":0,"name":"Cayrryns1","percent_flop":0,"average_pot":0,"skin":"default","variant":"holdem","hands_per_hour":0,"betting_structure":"100-200-no-limit","currency_serial":1,"muck_timeout":5,"players":0,"waiting":0,"tourney_serial":0,"seats":10,"player_timeout":60,"type":"PacketPokerTable","id":40});
+ TABLE_LIST_PACKET.packets.push({"observers":0,"name":"Cayrryns2","percent_flop":0,"average_pot":0,"skin":"default","variant":"holdem","hands_per_hour":0,"betting_structure":"100-200-no-limit","currency_serial":1,"muck_timeout":5,"players":10,"waiting":0,"tourney_serial":0,"seats":10,"player_timeout":60,"type":"PacketPokerTable","id":41});
+ TABLE_LIST_PACKET.packets.push({"observers":0,"name":"Cayrryns3","percent_flop":0,"average_pot":0,"skin":"default","variant":"holdem","hands_per_hour":0,"betting_structure":"100-200-no-limit","currency_serial":1,"muck_timeout":5,"players":5,"waiting":0,"tourney_serial":0,"seats":10,"player_timeout":60,"type":"PacketPokerTable","id":42});
+
+ var id = jpoker.uid();
+ var element = $('<div class=\'jpoker_table_list\' id=\'' + id + '\'></div>').appendTo("#main");
+ element.html(jpoker.plugins.tableList.getHTML(id, TABLE_LIST_PACKET));
+ equals($("table tbody tr", element).length, 3, '3 tables');
+ equals($("table tbody tr").eq(0).hasClass('jpoker_table_list_table_empty'), true);
+ equals($("table tbody tr").eq(0).hasClass('jpoker_table_list_table_full'), false);
+ equals($("table tbody tr").eq(1).hasClass('jpoker_table_list_table_empty'), false);
+ equals($("table tbody tr").eq(1).hasClass('jpoker_table_list_table_full'), true);
+ equals($("table tbody tr").eq(2).attr('class'), '');
cleanup(id);
});