freemarkerdor/src/main/resources/cz/xelfi/quoridor/freemarkerdor/UI/index.fmt
author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
Mon, 05 Oct 2009 10:23:27 +0200
changeset 119 26685a525ec8
parent 104 e37b229e238b
child 135 232e42153945
permissions -rw-r--r--
By default show only ten games from each category on the main page
     1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
     2 <html>
     3   <#assign toMove = 0/>
     4   <#assign toWait = 0/>
     5   <#assign toWon = 0/>
     6   <#assign toLost = 0/>
     7   <#if ! maxItems??>
     8     <#assign maxItems = 10/>
     9   </#if>
    10   <#assign seeAll = false/>
    11   <#list doc.gameIds.* as g>
    12     <#if (g.@white = user && g.@status = "whiteMove") ||
    13          (g.@black = user && g.@status = "blackMove")
    14     >
    15         <#assign toMove = toMove + 1/>
    16     </#if>
    17     <#if (g.@white = user && g.@status = "blackMove") ||
    18          (g.@black = user && g.@status = "whiteMove")
    19     >
    20         <#assign toWait = toWait + 1/>
    21     </#if>
    22     <#if
    23         (g.@white = user && g.@status = "whiteWon") ||
    24         (g.@black = user && g.@status = "blackWon")
    25     >
    26         <#assign toWon = toWon + 1/>
    27     </#if>
    28     <#if
    29         (g.@white = user && g.@status = "blackWon") ||
    30         (g.@black = user && g.@status = "whiteWon")
    31     >
    32         <#assign toLost = toLost + 1/>
    33     </#if>
    34   </#list>
    35   <head>
    36     <title>
    37         <#if (toMove > 0)>${bundle.YourTurn} - </#if>
    38         ${bundle.TITLE_PLAIN}
    39     </title>
    40     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    41     <meta http-equiv="REFRESH" content="60;URL=/">
    42   </head>
    43   <body>
    44       <h1>${bundle.TITLE}</h1>
    45 
    46       <#macro before t>
    47         <#assign seconds = (t / 1000)?int/>
    48         <#assign minutes= (seconds / 60)?int/>
    49         <#assign hours= (minutes / 60)?int/>
    50         <#assign days= (hours / 24)?int/>
    51         <!--millis: ${t}, seconds: ${seconds}, minutes: ${minutes} hours: ${hours}, days: ${days} -->
    52         ${bundle("LastMove", t?int, seconds?int, minutes?int, hours?int, days?int)}
    53       </#macro>
    54 
    55       <#macro game game>
    56           ${bundle("gameWhiteBlack", game.@white?string, game.@black?string)} 
    57           <a href="/games/${game.@id}/"><@before (now - game.@modified?number)?int/></a>
    58           <#assign printed = printed + 1/>
    59       </#macro>
    60 
    61       <#if message?? >
    62         <p>
    63             <span style="color: red">${message}</span>
    64         </p>
    65       </#if>
    66 
    67       <#if (toMove > 0)>
    68       <h5>${bundle.GAME_MOVE}</h5>
    69 
    70       <ol>
    71       <#assign printed = 0/>
    72       <#list doc.gameIds.* as g>
    73         <#if (g.@white = user && g.@status = "whiteMove") ||
    74              (g.@black = user && g.@status = "blackMove")
    75         >
    76             <li>
    77                 <@game g/>
    78             </li>
    79             <#if printed = maxItems><#assign seeAll=true/><#break/></#if>
    80         </#if>
    81       </#list>
    82       </ol>
    83       </#if>
    84 
    85       <#if (toWait > 0)>
    86       <h5>${bundle.GAME_WAIT}</h5>
    87       <ol>
    88       <#assign printed = 0/>
    89       <#list doc.gameIds.* as g>
    90         <#if (g.@white = user && g.@status = "blackMove") ||
    91              (g.@black = user && g.@status = "whiteMove")
    92         >
    93             <li>
    94                 <@game g/>
    95             </li>
    96             <#if printed = maxItems><#assign seeAll=true/><#break/></#if>
    97         </#if>
    98       </#list>
    99       </ol>
   100       </#if>
   101 
   102       <#if (toWon > 0)><!-- ${toWon} -->
   103       <h5>${bundle.GAME_WON}</h5>
   104 
   105       <ol>
   106       <#assign printed = 0/>
   107       <#list doc.gameIds.* as g>
   108         <#if 
   109             (g.@white = user && g.@status = "whiteWon") ||
   110             (g.@black = user && g.@status = "blackWon")
   111         >
   112             <li>
   113                 <@game g/>
   114             </li>
   115             <#if printed = maxItems><#assign seeAll=true/><#break/></#if>
   116         </#if>
   117       </#list>
   118       </ol>
   119       </#if>
   120 
   121       <#if (toLost > 0)>
   122       <h5>${bundle.GAME_LOST}</h5>
   123 
   124       <ol>
   125       <#assign printed = 0/>
   126       <#list doc.gameIds.* as g>
   127         <#if
   128             (g.@white = user && g.@status = "blackWon") ||
   129             (g.@black = user && g.@status = "whiteWon")
   130         >
   131             <li>
   132                 <@game g/>
   133             </li>
   134             <#if printed = maxItems><#assign seeAll=true/><#break/></#if>
   135         </#if>
   136       </#list>
   137       </ol>
   138       </#if>
   139 
   140       <form action="/games/create">
   141             ${bundle.WHITE}: <input type="text" name="white" value="" />
   142             ${bundle.BLACK}: <input type="text" name="black" value="" />
   143             <input type="submit" value="${bundle.CREATE}" />
   144       </form>
   145 
   146       <h5>${bundle.GAME_ALL}</h5>
   147 
   148       <ol>
   149       <#assign printed = 0/>
   150       <#list doc.gameIds.* as g>
   151         <li>
   152             <@game g/>
   153         </li>
   154         <#if printed = maxItems><#assign seeAll=true/><#break/></#if>
   155       </#list>
   156       </ol>
   157 
   158       <#if seeAll>
   159         <p>
   160         <a href="/?maxItems=1024">${bundle.SEE_ALL}</a>...
   161         </p>
   162       </#if>
   163 
   164       <hr/>
   165       ${bundle("copyright", version)}
   166   </body>
   167 </html>