chess/src/main/webapp/pages/index.html
author Jaroslav Tulach <jtulach@netbeans.org>
Wed, 25 Sep 2013 04:27:55 +0200
branchchess
changeset 54 386d1f27e2e6
parent 53 bc0094a5f88c
permissions -rw-r--r--
More natural layout
     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                         <a href="#" data-bind="text: title"></a>
    54                     </li>
    55                 </ul>
    56             </div>
    57         </div>
    58         <div data-bind="template: { name: 'render-games', data: viewGames, ifnot: selectedBoard }"></div>
    59         <div data-bind="template: { name: 'render-board', data: selectedBoard, if : selectedBoard }"></div>
    60 
    61         <script type="text/html" id="render-board">
    62             <div class="container-fluid">
    63                 <div class="row-fluid">
    64                     <div class="span12">
    65                         <h1><span data-bind="text: status"></span></h1>
    66                         <p style="position: relative; left: 0px; top: 0px; height: 25px">
    67                             <span data-bind="visible: blackTurn" class="badge badge-black-turn">Black's turn</span>
    68                             <span data-bind="visible: whiteTurn" class="badge badge-white-turn">White's turn</span>
    69                             <span data-bind="text: alertMessage" class="badge badge-warning badge-status"></span>
    70                         </p>
    71                         <p>
    72                         <table class="board">
    73                             <tbody>
    74                                 <!-- ko foreach: rows -->
    75                                 <tr>
    76                                     <td class="row-label">
    77                                         <span data-bind='text: y'></span>
    78                                     </td>
    79                                     <!-- ko foreach: columns -->
    80                                     <td data-bind="click: $parents[1].selected, css: squareColor" >
    81                                         <span data-bind='html: pieceEntity, css: { blackPiece: pieceColor() === "B", whitePiece: pieceColor() === "W" }' class="figure"></span>
    82                                     </td>
    83                                     <!-- /ko -->
    84                                 </tr>
    85                                 <!-- /ko -->
    86                                 <tr>
    87                                     <td class="col-label"></td>
    88                                     <!-- ko foreach: columnNames -->
    89                                     <td class="row-label">
    90                                         <span data-bind='text: $data'></span>
    91                                     </td>
    92                                     <!-- /ko -->
    93                                 </tr>
    94                             </tbody>
    95                         </table>
    96                         <button data-bind="click: rotateBoard" class="but-orientation">Rotate Board</button>
    97                         <button data-bind="click: $root.leave" class="but-orientation">Leave Game</button>
    98                         </p>
    99                     </div>
   100                 </div>
   101                 <div class="row-fluid">
   102                     <div class="span12 log-div">
   103                         <h3 class="log-h">Game Log</h3>
   104                         <div class="log">                            
   105                             <div data-bind="foreach: moves">
   106                                 <span>
   107                                     <!-- ko if: whiteMove -->
   108                                     <span data-bind="text: round" class="badge"></span> 
   109                                     <!-- /ko -->
   110                                     <a href="#" data-bind="html: html, click: $parent.showPosition"></a>,&nbsp;
   111                                 </span>
   112                             </div>                            
   113                         </div>
   114                     </div>
   115                 </div>
   116             </div>
   117         </script>
   118 
   119         <script type="text/html" id="render-games">
   120             <div class="container-fluid">
   121                 <div data-bind="visible: $root.viewGamesActive">
   122                     <h3>List of Games</h3>
   123                     <p>
   124                         Status: <span data-bind="text: $root.status"></span>
   125                     </p>
   126                     <span class="input-append" class="select">
   127                         <input type="text" data-bind="value: whitePlayer, valueUpdate: 'afterkeydown'" 
   128                         class="input-small" placeholder="White Player"></input>
   129                      </span>
   130                      vs.
   131                      <span>
   132                         <input type="text" data-bind="value: blackPlayer, valueUpdate: 'afterkeydown'" 
   133                         class="input-small" placeholder="Black Player"></input>
   134                     </span>
   135                     <br/>
   136                     <button data-bind="click: $root.createGame, enable: correctNames"
   137                         class="btn btn-success" >Create Game!</button>
   138                     <br/>
   139                     <br/>
   140                     <br/>
   141                     <div data-bind="foreach: $root.boards">
   142                         <div class="input-append">
   143                         <input type="text" data-bind="value: status" disabled></input>
   144                         <button class="btn" data-bind="click: $root.joinGame">
   145                             Show
   146                         </button>
   147                         </div>
   148                         <br/>
   149                     </div>
   150                 </div>
   151             </div>
   152             <div id="chesscube">
   153                 <div id="spinner">
   154                     <div>&#9812;</div>
   155                     <div>&#9819;</div>
   156                     <div>&#9814;</div>
   157                     <div>&#9821;</div>
   158                     <div>&#9816;</div>
   159                     <div>&#9823;</div>
   160                 </div>
   161             </div>
   162         </script>
   163         <center data-bind="visible: false">
   164             <img src="DukeHTML.png" width="320" height="200" alt="Loading...">
   165             <h3>Initializing the virtual machine...</h3>
   166         </center>
   167         <script type="text/javascript" src="bck2brwsr.js"></script>
   168         <script>
   169             var vm = bck2brwsr('${project.build.finalName}.jar');
   170             vm.loadClass('org.apidesign.html.demo.chess.LoadMain');
   171         </script>
   172     </body>
   173 </html>