chess/src/main/webapp/pages/index.html
author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
Tue, 24 Sep 2013 23:52:32 +0200
branchchess
changeset 52 6bb4070d2c20
parent 49 945fbfff28f3
child 53 bc0094a5f88c
permissions -rw-r--r--
Removing the server communication stuff
     1 <!--
     2 
     3     The MIT License (MIT)
     4 
     5     Copyright (C) 2013 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
     6 
     7     Permission is hereby granted, free of charge, to any person obtaining a copy
     8     of this software and associated documentation files (the "Software"), to deal
     9     in the Software without restriction, including without limitation the rights
    10     to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    11     copies of the Software, and to permit persons to whom the Software is
    12     furnished to do so, subject to the following conditions:
    13 
    14     The above copyright notice and this permission notice shall be included in
    15     all copies or substantial portions of the Software.
    16 
    17     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    18     IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    19     FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    20     AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    21     LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    22     OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    23     THE SOFTWARE.
    24 
    25 -->
    26 <!DOCTYPE html>
    27 <html lang="en">
    28     <head>
    29         <meta charset="utf-8">
    30         <title>Chess Client</title>
    31         <meta name="viewport" content="width=device-width, initial-scale=1.0">
    32         <meta name="description" content="">
    33         <meta name="author" content="">
    34 
    35         <!-- Le styles -->
    36         <link href="./css/bootstrap.css" rel="stylesheet">
    37         <link href="./css/bootstrap-responsive.css" rel="stylesheet">
    38         <link href="./css/chess.css" rel="stylesheet">
    39         <!-- Target tablets -->
    40         <link href="./css/chess-tablet-large.css" media="(min-width:560px) and (max-width:710px)" rel="stylesheet" />
    41         <link href="./css/chess-tablet-small.css" media="(min-width:460px) and (max-width:560px)" rel="stylesheet" />
    42         <!-- Target phones -->
    43         <link href="./css/chess-phone-large.css" media="(min-width:370px) and (max-width:460px)" rel="stylesheet" />
    44         <link href="./css/chess-phone-small.css" media="(max-width:370px)" rel="stylesheet" />
    45         <link href="./css/spinner.css" rel="stylesheet">
    46     </head>
    47     <body>
    48         <div class="navbar">
    49             <div class="navbar-inner">
    50                 <a id="apptitle" class="brand" data-bind="css: { active: viewGamesActive }, click: activateSettings" href="#">JavaOne Chess</a>
    51                 <ul class="nav" data-bind="foreach: boards">
    52                     <li data-bind="css: { active: active }, click: $root.activateGame">
    53                         <span data-bind="visible: myTurn" class="badge badge-warning myturn">&rarrhk;</span> 
    54                         <span data-bind="visible: justObserving" class="badge myturn">&infin;</span> 
    55                         <a href="#" data-bind="text: title"></a>
    56                     </li>
    57                 </ul>
    58             </div>
    59         </div>
    60         <div data-bind="template: { name: 'render-games', data: viewGames, ifnot: selectedBoard }"></div>
    61         <div data-bind="template: { name: 'render-board', data: selectedBoard, if : selectedBoard }"></div>
    62 
    63         <script type="text/html" id="render-board">
    64             <div class="container-fluid">
    65                 <div class="row-fluid">
    66                     <div class="span12">
    67                         <h1><span data-bind="text: status"></span></h1>
    68                         <p style="position: relative; left: 0px; top: 0px; height: 25px">
    69                             <span data-bind="visible: blackTurn" class="badge badge-black-turn">Black's turn</span>
    70                             <span data-bind="visible: whiteTurn" class="badge badge-white-turn">White's turn</span>
    71                             <span data-bind="text: alertMessage" class="badge badge-warning badge-status"></span>
    72                         </p>
    73                         <p>
    74                         <table class="board">
    75                             <tbody>
    76                                 <!-- ko foreach: rows -->
    77                                 <tr>
    78                                     <td class="row-label">
    79                                         <span data-bind='text: y'></span>
    80                                     </td>
    81                                     <!-- ko foreach: columns -->
    82                                     <td data-bind="click: $parents[1].selected, css: squareColor" >
    83                                         <span data-bind='html: pieceEntity, css: { blackPiece: pieceColor() === "B", whitePiece: pieceColor() === "W" }' class="figure"></span>
    84                                     </td>
    85                                     <!-- /ko -->
    86                                 </tr>
    87                                 <!-- /ko -->
    88                                 <tr>
    89                                     <td class="col-label"></td>
    90                                     <!-- ko foreach: columnNames -->
    91                                     <td class="row-label">
    92                                         <span data-bind='text: $data'></span>
    93                                     </td>
    94                                     <!-- /ko -->
    95                                 </tr>
    96                             </tbody>
    97                         </table>
    98                         <button data-bind="click: rotateBoard" class="but-orientation">Rotate Board</button>
    99                         <button data-bind="click: $root.leave" class="but-orientation">Leave Game</button>
   100                         </p>
   101                     </div>
   102                 </div>
   103                 <div class="row-fluid">
   104                     <div class="span12 log-div">
   105                         <h3 class="log-h">Game Log</h3>
   106                         <div class="log">                            
   107                             <div data-bind="foreach: moves">
   108                                 <span>
   109                                     <!-- ko if: whiteMove -->
   110                                     <span data-bind="text: round" class="badge"></span> 
   111                                     <!-- /ko -->
   112                                     <a href="#" data-bind="html: html, click: $parent.showPosition"></a>,&nbsp;
   113                                 </span>
   114                             </div>                            
   115                         </div>
   116                     </div>
   117                 </div>
   118             </div>
   119         </script>
   120 
   121         <script type="text/html" id="render-games">
   122             <div class="container-fluid">
   123                 <div data-bind="visible: $root.viewGamesActive">
   124                     <h3>List of Games</h3>
   125                     <p>
   126                         Status: <span data-bind="text: $root.status"></span>
   127                     </p>
   128                     <div class="input-append" class="select">
   129                         <input type="text" data-bind="value: whitePlayer, valueUpdate: 'afterkeydown'" 
   130                         class="input-small" placeholder="White Player"></input>
   131                      vs.
   132                         <input type="text" data-bind="value: blackPlayer, valueUpdate: 'afterkeydown'" 
   133                         class="input-small" placeholder="Black Player"></input>
   134                     </div>
   135                     <br/>
   136                     <button data-bind="click: $root.createGame, enable: correctNames"
   137                         class="btn btn-success" >Create Game!</button>
   138                     <br/>
   139                     <div data-bind="foreach: $root.boards">
   140                         <div class="input-append">
   141                         <input type="text" data-bind="value: status" disabled></input>
   142                         <button class="btn" data-bind="click: $root.joinGame">
   143                             Show
   144                         </button>
   145                         </div>
   146                         <br/>
   147                     </div>
   148                 </div>
   149             </div>
   150             <div id="chesscube">
   151                 <div id="spinner">
   152                     <div>&#9812;</div>
   153                     <div>&#9819;</div>
   154                     <div>&#9814;</div>
   155                     <div>&#9821;</div>
   156                     <div>&#9816;</div>
   157                     <div>&#9823;</div>
   158                 </div>
   159             </div>
   160         </script>
   161         <center data-bind="visible: false">
   162             <img src="DukeHTML.png" width="320" height="200" alt="Loading...">
   163             <h3>Initializing the virtual machine...</h3>
   164         </center>
   165         <script type="text/javascript" src="bck2brwsr.js"></script>
   166         <script>
   167             var vm = bck2brwsr('${project.build.finalName}.jar');
   168             vm.loadClass('org.apidesign.html.demo.chess.LoadMain');
   169         </script>
   170     </body>
   171 </html>