moves += image_tag('go_prev.jpg', :id => 'go_prev', :onclick => 'goPrev();') :onmouseover => 'new Effect.Scale("go_prev", 110)', :onmouseout => 'new Effect.Scale("go_prev", 90)') + ' '
moves += image_tag('go_refresh.jpg', :id => 'go_refresh', :onclick => 'goRefresh();') :onmouseover => 'new Effect.Scale("go_refresh", 110)', :onmouseout => 'new Effect.Scale("go_refresh", 90)') + ' '
moves += image_tag('go_next.jpg', :id => 'go_next', :onclick => 'goNext();'):onmouseover => 'new Effect.Scale("go_next", 110)', :onmouseout => 'new Effect.Scale("go_next", 90)') + ' '
moves += image_tag('go_end.jpg', :id => 'go_end', :onclick => 'goEnd();')#:onmouseover => 'new Effect.Scale("go_end", 110)', :onmouseout => 'new Effect.Scale("go_end", 90)') + ' '
moves += "</td></tr>"
moves += "</table>";
moves
end
def render_board
return "<table class=\"board\" id=\"board\">
<tr>
<td class=\"board_label_digit\">8</td>
<td class=\"board_white_field\" id=\"fieldA8\"></td>
<td class=\"board_black_field\" id=\"fieldB8\"></td>
<td class=\"board_white_field\" id=\"fieldC8\"></td>
<td class=\"board_black_field\" id=\"fieldD8\"></td>
<td class=\"board_white_field\" id=\"fieldE8\"></td>
<td class=\"board_black_field\" id=\"fieldF8\"></td>
<td class=\"board_white_field\" id=\"fieldG8\"></td>
<td class=\"board_black_field\" id=\"fieldH8\"></td>
</tr>
<tr>
<td class=\"board_label_digit\">7</td>
<td class=\"board_black_field\" id=\"fieldA7\"></td>
<td class=\"board_white_field\" id=\"fieldB7\"></td>
<td class=\"board_black_field\" id=\"fieldC7\"></td>
<td class=\"board_white_field\" id=\"fieldD7\"></td>
<td class=\"board_black_field\" id=\"fieldE7\"></td>
<td class=\"board_white_field\" id=\"fieldF7\"></td>
<td class=\"board_black_field\" id=\"fieldG7\"></td>
<td class=\"board_white_field\" id=\"fieldH7\"></td>
</tr>
<tr>
<td class=\"board_label_digit\">6</td>
<td class=\"board_white_field\" id=\"fieldA6\"></td>
<td class=\"board_black_field\" id=\"fieldB6\"></td>
<td class=\"board_white_field\" id=\"fieldC6\"></td>
<td class=\"board_black_field\" id=\"fieldD6\"></td>
<td class=\"board_white_field\" id=\"fieldE6\"></td>
<td class=\"board_black_field\" id=\"fieldF6\"></td>
<td class=\"board_white_field\" id=\"fieldG6\"></td>
<td class=\"board_black_field\" id=\"fieldH6\"></td>
</tr>
<tr>
<td class=\"board_label_digit\">5</td>
<td nowrap class=\"board_black_field\" id=\"fieldA5\"></td>
<td nowrap class=\"board_white_field\" id=\"fieldB5\"></td>
<td nowrap class=\"board_black_field\" id=\"fieldC5\"></td>
<td nowrap class=\"board_white_field\" id=\"fieldD5\"></td>
<td nowrap class=\"board_black_field\" id=\"fieldE5\"></td>
<td nowrap class=\"board_white_field\" id=\"fieldF5\"></td>
<td nowrap class=\"board_black_field\" id=\"fieldG5\"></td>
<td nowrap class=\"board_white_field\" id=\"fieldH5\"></td>
</tr>
<tr>
<td class=\"board_label_digit\">4</td>
<td class=\"board_white_field\" id=\"fieldA4\"></td>
<td class=\"board_black_field\" id=\"fieldB4\"></td>
<td class=\"board_white_field\" id=\"fieldC4\"></td>
<td class=\"board_black_field\" id=\"fieldD4\"></td>
<td class=\"board_white_field\" id=\"fieldE4\"></td>
<td class=\"board_black_field\" id=\"fieldF4\"></td>
<td class=\"board_white_field\" id=\"fieldG4\"></td>
<td class=\"board_black_field\" id=\"fieldH4\"></td>
</tr>
<tr>
<td class=\"board_label_digit\">3</td>
<td class=\"board_black_field\" id=\"fieldA3\"></td>
<td class=\"board_white_field\" id=\"fieldB3\"></td>
<td class=\"board_black_field\" id=\"fieldC3\"></td>
<td class=\"board_white_field\" id=\"fieldD3\"></td>
<td class=\"board_black_field\" id=\"fieldE3\"></td>
<td class=\"board_white_field\" id=\"fieldF3\"></td>
<td class=\"board_black_field\" id=\"fieldG3\"></td>
<td class=\"board_white_field\" id=\"fieldH3\"></td>
</tr>
<tr>
<td class=\"board_label_digit\">2</td>
<td class=\"board_white_field\" id=\"fieldA2\"></td>
<td class=\"board_black_field\" id=\"fieldB2\"></td>
<td class=\"board_white_field\" id=\"fieldC2\"></td>
<td class=\"board_black_field\" id=\"fieldD2\"></td>
<td class=\"board_white_field\" id=\"fieldE2\"></td>
<td class=\"board_black_field\" id=\"fieldF2\"></td>
<td class=\"board_white_field\" id=\"fieldG2\"></td>
<td class=\"board_black_field\" id=\"fieldH2\"></td>
</tr>
<tr>
<td class=\"board_label_digit\">1</td>
<td class=\"board_black_field\" id=\"fieldA1\"></td>
<td class=\"board_white_field\" id=\"fieldB1\"></td>
<td class=\"board_black_field\" id=\"fieldC1\"></td>
<td class=\"board_white_field\" id=\"fieldD1\"></td>
<td class=\"board_black_field\" id=\"fieldE1\"></td>
<td class=\"board_white_field\" id=\"fieldF1\"></td>
<td class=\"board_black_field\" id=\"fieldG1\"></td>
<td class=\"board_white_field\" id=\"fieldH1\"></td>
</tr>
<tr>
<td class=\"board_lebel_letter\"> </td>
<td class=\"board_lebel_letter\">A</td>
<td class=\"board_lebel_letter\">B</td>
<td class=\"board_lebel_letter\">C</td>
<td class=\"board_lebel_letter\">D</td>
<td class=\"board_lebel_letter\">E</td>
<td class=\"board_lebel_letter\">F</td>
<td class=\"board_lebel_letter\">G</td>
<td class=\"board_lebel_letter\">H</td>
</tr>
</table>"
end
def render_result
"1/2 - 1/2"
end
def render_black_time
"-:--:--"
end
def render_white_time
"-:--:--"
end
end
Представление (view)
layout/main.rhtml
---
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
<title>Стартовая страница: <%= controller.action_name %></title>
<%= stylesheet_link_tag 'scaffold' %>
<%= stylesheet_link_tag 'main' %>
<%= stylesheet_link_tag 'game' %>
<%= javascript_include_tag :defaults %>
<%= javascript_include_tag 'game' %>
</head>
<body style='background-color: #000000'>
<table bgcolor="#f4f4f4" border="0" width="80%" align="center" cellpadding="0" cellspacing="0" >
<tr>
<td width='3%'></td>
<td>
<h1><%= link_to(image_tag('dgt.gif', :size => '42x25', :border => 0, :alt => 'http://dgtprojects.com'), 'http://dgtprojects.com') %>
Сервер трансляции шахматных партий <%= link_to 'rDGT', 'http://rdgt.org' %>
<%= link_to(image_tag('home.gif', :size => '12x12', :border => 0), '/main/index') %>
<%= link_to(image_tag('email.gif', :size => '12x12', :border => 0), '') %>
<%= link_to(image_tag('search.gif', :size => '12x12', :border => 0), '')%>
</h1><hr />
</td>
<td width='3%'></td>
</tr>
<tr>
<td></td>
<td>
<p style="color: green"><%= flash[:notice] %></p>
<%= yield %>
</td>
<td></td>
</tr>
<tr>
<td></td>
<td align="right"><br /><hr />
<%= mail_to 'zarstudio@gmail.com', '[ Разработчики ]' %><br />
</td>
<td></td>
</tr>
</table>
</body>
</html>
main/enter.rhtml
---
<% form_tag '/main/login' do %>
<table align='center' width='100%'>
<tr>
<td width='41%' align="right"><strong>Имя: <strong></td>
<td align="left"><%= text_field_tag :login, params[:login] %></td>
</tr>
<tr>
<td align="right"><strong>Пароль: </strong></td>
<td align="left"><%= password_field_tag :password, params[:password] %></td>
</tr>
<tr>
<td align="center" colspan="2"><%= submit_tag 'Войти' %></td>
</tr>
<tr>
<td align="center" colspan="2"><%= link_to '[ Регистрация ]', { :action => 'register' }%></td>
</tr>
<tr>
<td align="center" colspan="2"><%= link_to '[ Забыли логин или пароль? ]', { :action => 'remind' }%></td>
</tr>
</table>
<% end %>
<br />
main/game.rhtml
---
<%= render_game_info %>
<br />
<br />
<table width='100%' cellspacing="0" cellpadding="0" border="0" id='table_board'>
<tr align="center">
<td width='1%'></td>
<td width='50%' align="left"><%= image_tag 'seek_black.png', :size => '16x16' %></td>
<td></td>
<td width='45%'><%= link_to @game.black_player.to_s, { :controller => 'players', :action => 'show', :id => @game.black_player.id } %></td>
<td width='1%'></td>
</tr>
<tr align="center">
<td></td>
<td></td>
<td></td>
<td><%= render_black_time %></td>
<td></td>
</tr>
<tr>
<td></td>
<td><%= render_board %></td>
<td></td>
<td style="background-color: #dadada"><%= render_moves %></td>
<td></td>
</tr>
<tr align="center">
<td></td>
<td></td>
<td></td>
<td><%= render_white_time%></td>
<td></td>
</tr>
<tr align="center">
<td></td>
<td align="left"><%= image_tag 'seek_white.png', :size => '16x16' %></td>
<td></td>
<td><%= link_to @game.white_player.to_s, { :controller => 'players', :action => 'show', :id => @game.white_player.id} %></td>
<td></td>
</tr>
<tr align="center">
<td></td>
<td></td>
<td></td>
<td><%= render_result %></td>
<td></td>
</tr>
<tr>
<td colspan="5"></td>
</tr>
</table>
<%= link_to_remote 'Обновить', :update => 'moves', :url => { :action => 'game_moves', :id => @game.id } %>
<div id='debug'></div>
main/logo.rhtml
---
<table align='center'><tr><td align='center'>
<%= image_tag 'logo.jpg', :alt => 'Шахматный портал rDGT', :width => '400px', :height => '280px' %>
<br />
<br /><%= link_to '[ Трансляции ]', { :action => 'online' }%>
<br /><%= link_to '[ Турниры ]' , { :action => 'offline' }%>
<br /><%= link_to '[ Кабинет ]', { :action => 'enter' } %>
</td></tr></table>
main/online.rhtml
---
<!-- <%= link_to '[ Просмотр ]', { :action => 'game' }%>-->
<table width='80%' align='center'>
<tr>
<th></th>
<th width='10%'>Начало</th>
<th width='25%'>Турнир</th>
<th width='30%'>Белые</th>
<th width='30%'>Черные</th>
</tr>
<% @online_games.each do |game| %>
<tr align='center'>
<td class='td_info'><%= link_to(image_tag('eye.gif', :size => '16x16', :onclick => '', :alt => 'Просмотр трансляции'), { :action => 'game', :id => game.id }) %></td>
<td class='td_info'><%= game.begin.to_s %></td>
<td class='td_info'><%= link_to game.tournament.to_s, { :controller => 'tournaments', :action => 'show', :id => game.tournament.id } %></td>
<td class='td_info'><%= link_to game.white.to_s, { :controller => 'players', :action => 'show', :id => game.white.id } %></td>
<td class='td_info'><%= link_to game.black.to_s, { :controller => 'players', :action => 'show', :id => game.black.id } %></td>