From a7e69c08104e50db9a693b9c1be4661122d115b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=A4=AA?= Date: Sat, 10 Aug 2013 19:19:52 +1000 Subject: [PATCH 01/33] Basic tournament support --- js/client-chat.js | 17 ++++++- style/client.css | 118 ++++++++++++++++++++++++++++++++++++++++++---- testclient.html | 5 +- 3 files changed, 127 insertions(+), 13 deletions(-) diff --git a/js/client-chat.js b/js/client-chat.js index a6c7453ad..b6345e1e0 100644 --- a/js/client-chat.js +++ b/js/client-chat.js @@ -33,7 +33,7 @@ this.$chatAdd.html('
'); this.$chatbox = this.$chatAdd.find('textarea'); this.$chatbox.autoResize({ - animate: false, + animate: false, extraSpace: 0 }); if (this === app.curSideRoom || this === app.curRoom) { @@ -606,7 +606,7 @@ maxWidth: 1024, isSideRoom: true, initialize: function() { - var buf = '
Connecting...
'; + var buf = '
Connecting...
'; this.$el.addClass('ps-room-light').html(buf); this.$chatAdd = this.$('.chat-log-add'); @@ -614,6 +614,9 @@ this.$chat = this.$('.inner'); this.$chatbox = null; + this.$tournamentWrapper = this.$('.tournament-wrapper'); + this.tournamentBox = new TournamentBox(this, this.$tournamentWrapper); + this.users = {}; this.userCount = {}; @@ -634,10 +637,12 @@ this.$userList.show(); this.$chatFrame.addClass('hasuserlist'); this.$chatAdd.addClass('hasuserlist'); + this.$tournamentWrapper.addClass('hasuserlist'); } else { this.$userList.hide(); this.$chatFrame.removeClass('hasuserlist'); this.$chatAdd.removeClass('hasuserlist'); + this.$tournamentWrapper.removeClass('hasuserlist'); } this.$chatFrame.scrollTop(this.$chat.height()); }, @@ -783,6 +788,11 @@ }); break; + case 'tournament': + case 'tournaments': + if (!this.tournamentBox.parseMessage(row.slice(1), row[0] === 'tournaments')) + break; + case '': this.$chat.append('
' + Tools.escapeHTML(row.slice(1).join('|')) + '
'); break; @@ -793,6 +803,9 @@ } } }, + tournamentButton: function(val, button) { + this.tournamentBox[$(button).data('type')](val, button); + }, parseUserList: function(userList) { this.userCount = {}; this.users = {}; diff --git a/style/client.css b/style/client.css index b03e4983d..1404a1bd8 100644 --- a/style/client.css +++ b/style/client.css @@ -45,7 +45,7 @@ body { padding: 2px 3px; font-family: Verdana, Helvetica, Arial, sans-serif; font-size: 9pt; - + box-shadow: inset 0px 1px 2px #CCCCCC, 1px 1px 0 rgba(255,255,255,.6); background: #F8FBFD; } @@ -816,7 +816,7 @@ p.or:after { padding: 1px 4px 2px 4px; border: 1px solid #BBCCDD; background: #F8FBFD; - + border-radius: 4px; text-decoration: none; color: #336699; @@ -962,6 +962,105 @@ a.ilink:hover { font-family: Verdana, Helvetica, Arial, sans-serif; } +/* Tournaments */ + +.tournament-wrapper { + display: none; + position: absolute; + top: 0; + left: 0; + right: 0; + height: 2em; + line-height: 2em; + text-align: center; + border-bottom: 1px #aaa solid; +} +.tournament-wrapper.active { + display: block; +} +.tournament-wrapper.active + .chat-log { + top: 2.4em; +} + +.tournament-box { + position: absolute; + top: 2em; + left: 0; + right: 0; + z-index: 1; + line-height: 1em; + border-bottom: 1px #aaa solid; + background-color: rgba(242, 247, 250, 0.85); + max-height: 0; + overflow: hidden; + transition: max-height 0.5s ease-in-out; + -o-transition: max-height 0.5s ease-in-out; + -moz-transition: max-height 0.5s ease-in-out; + -webkit-transition: max-height 0.5s ease-in-out; +} + +.tournament-title { + font-weight: bold; +} + +.tournament-bracket { + max-height: 200px; + overflow: auto; + font-size: 8pt; + border-bottom: 1px #aaa solid; +} +.tournament-bracket-table { + margin: 10px auto; + empty-cells: hide; + border-bottom: 1px #aaa solid; + border-collapse: collapse; +} +.tournament-bracket-table td, .tournament-bracket-table th { + border: 1px #aaa solid; + padding: 5px; +} +.tournament-bracket-table .empty, +.tournament-bracket-table .tournament-bracket-table-cell-null { + border-width: 0; +} +.tournament-bracket-table-cell-result-win { + background-color: rgba(0, 255, 0, 0.2) +} +.tournament-bracket-table-cell-result-draw { + background-color: rgba(255, 255, 0, 0.2) +} +.tournament-bracket-table-cell-result-loss { + background-color: rgba(255, 0, 0, 0.2) +} + +.tournament-tools { + padding: 10px; +} + +.tournament-join, +.tournament-leave { + display: none; +} +.tournament-join.active, +.tournament-leave.active { + display: inline; +} + +.tournament-nomatches, +.tournament-challenge, +.tournament-challengeby, +.tournament-challenging, +.tournament-challenged { + display: none; +} +.tournament-nomatches.active, +.tournament-challenge.active, +.tournament-challengeby.active, +.tournament-challenging.active, +.tournament-challenged.active { + display: block; +} + /* Messages */ .message-announce { @@ -1029,7 +1128,8 @@ a.ilink:hover { overflow-scrolling: touch; } .chat-log.hasuserlist, -.chat-log-add.hasuserlist { +.chat-log-add.hasuserlist, +.tournament-wrapper.hasuserlist { left: 146px; } .userlist, @@ -1582,13 +1682,13 @@ a.ilink:hover { height: 127px; width: 626px; margin-top: 8px; - + background-image: linear-gradient(top, rgb(218,229,240) 10%, rgb(203,214,225) 55%); background-image: -o-linear-gradient(top, rgb(218,229,240) 10%, rgb(203,214,225) 55%); background-image: -moz-linear-gradient(top, rgb(218,229,240) 10%, rgb(203,214,225) 55%); background-image: -webkit-linear-gradient(top, rgb(218,229,240) 10%, rgb(203,214,225) 55%); background-image: -ms-linear-gradient(top, rgb(218,229,240) 10%, rgb(203,214,225) 55%); - + box-shadow: inset 1px 1px 0 rgba(255,255,255,.6); } .setcol { @@ -1633,7 +1733,7 @@ a.ilink:hover { font-weight: bold; color: #555555; padding-left: 2px; - + text-shadow: 1px 1px 0 rgba(255,255,255,.6); } .setchart-nickname label { @@ -1781,7 +1881,7 @@ a.ilink:hover { font-size: 9pt; width: 104px; height: 20px; - + box-shadow: inset 0px 1px 2px #CCCCCC, 1px 1px 0 rgba(255,255,255,.6); background: #F8FBFD; color: black; @@ -2040,7 +2140,7 @@ a.ilink:hover { * *********************************************************/ -@-webkit-keyframes blinker { +@-webkit-keyframes blinker { from { opacity: 1.0; } to { opacity: 0.0; } } @@ -2056,6 +2156,6 @@ blink { animation-name: blinker; animation-iteration-count: infinite; animation-timing-function: cubic-bezier(1.0,0,0,1.0); - animation-duration: 1s; + animation-duration: 1s; text-decoration: none; } diff --git a/testclient.html b/testclient.html index 9b527a1c6..cdc791bf0 100644 --- a/testclient.html +++ b/testclient.html @@ -40,14 +40,14 @@