freemarkerdor/src/main/resources/cz/xelfi/quoridor/freemarkerdor/UI/index.fmt
author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
Sun, 25 Oct 2009 14:55:51 +0100
changeset 135 232e42153945
parent 119 26685a525ec8
child 139 85bbddead23e
permissions -rw-r--r--
Showing the number of comments associated with each game
     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           ${bundle("comments", game.@comments?number)}
    59           <#assign printed = printed + 1/>
    60       </#macro>
    61 
    62       <#if message?? >
    63         <p>
    64             <span style="color: red">${message}</span>
    65         </p>
    66       </#if>
    67 
    68       <#if (toMove > 0)>
    69       <h5>${bundle.GAME_MOVE}</h5>
    70 
    71       <ol>
    72       <#assign printed = 0/>
    73       <#list doc.gameIds.* as g>
    74         <#if (g.@white = user && g.@status = "whiteMove") ||
    75              (g.@black = user && g.@status = "blackMove")
    76         >
    77             <li>
    78                 <@game g/>
    79             </li>
    80             <#if printed = maxItems><#assign seeAll=true/><#break/></#if>
    81         </#if>
    82       </#list>
    83       </ol>
    84       </#if>
    85 
    86       <#if (toWait > 0)>
    87       <h5>${bundle.GAME_WAIT}</h5>
    88       <ol>
    89       <#assign printed = 0/>
    90       <#list doc.gameIds.* as g>
    91         <#if (g.@white = user && g.@status = "blackMove") ||
    92              (g.@black = user && g.@status = "whiteMove")
    93         >
    94             <li>
    95                 <@game g/>
    96             </li>
    97             <#if printed = maxItems><#assign seeAll=true/><#break/></#if>
    98         </#if>
    99       </#list>
   100       </ol>
   101       </#if>
   102 
   103       <#if (toWon > 0)><!-- ${toWon} -->
   104       <h5>${bundle.GAME_WON}</h5>
   105 
   106       <ol>
   107       <#assign printed = 0/>
   108       <#list doc.gameIds.* as g>
   109         <#if 
   110             (g.@white = user && g.@status = "whiteWon") ||
   111             (g.@black = user && g.@status = "blackWon")
   112         >
   113             <li>
   114                 <@game g/>
   115             </li>
   116             <#if printed = maxItems><#assign seeAll=true/><#break/></#if>
   117         </#if>
   118       </#list>
   119       </ol>
   120       </#if>
   121 
   122       <#if (toLost > 0)>
   123       <h5>${bundle.GAME_LOST}</h5>
   124 
   125       <ol>
   126       <#assign printed = 0/>
   127       <#list doc.gameIds.* as g>
   128         <#if
   129             (g.@white = user && g.@status = "blackWon") ||
   130             (g.@black = user && g.@status = "whiteWon")
   131         >
   132             <li>
   133                 <@game g/>
   134             </li>
   135             <#if printed = maxItems><#assign seeAll=true/><#break/></#if>
   136         </#if>
   137       </#list>
   138       </ol>
   139       </#if>
   140 
   141       <form action="/games/create">
   142             ${bundle.WHITE}: <input type="text" name="white" value="" />
   143             ${bundle.BLACK}: <input type="text" name="black" value="" />
   144             <input type="submit" value="${bundle.CREATE}" />
   145       </form>
   146 
   147       <h5>${bundle.GAME_ALL}</h5>
   148 
   149       <ol>
   150       <#assign printed = 0/>
   151       <#list doc.gameIds.* as g>
   152         <li>
   153             <@game g/>
   154         </li>
   155         <#if printed = maxItems><#assign seeAll=true/><#break/></#if>
   156       </#list>
   157       </ol>
   158 
   159       <#if seeAll>
   160         <p>
   161         <a href="/?maxItems=1024">${bundle.SEE_ALL}</a>...
   162         </p>
   163       </#if>
   164 
   165       <hr/>
   166       ${bundle("copyright", version)}
   167   </body>
   168 </html>