ensl.org/app/views/brackets/_bracket.html.erb
Luke Barratt 5487854a6c Start to cleanup old assets
Added new ISO country code flag icons to asset pipeline
Lots and lots of new style changes
Began converting to JS to coffeescript
2014-04-09 00:28:53 +01:00

43 lines
1.6 KiB
Text

<table class="brackets">
<% rows = bracket.slots*2-1 %>
<% cols = 2+(bracket.slots/4) %>
<% content = Array.new((bracket.slots*2-1)/4) %>
<% (0..rows).each do |row| %>
<tr>
<% (0..cols).each do |col| %>
<% exp = 2**(col+1) %>
<% element_class = "empty" %>
<% bracketer = bracket.get_bracketer(row, col) %>
<% if (row % exp) == exp/2 %>
<% if bracketer %>
<% element_class = "team" %>
<% else %>
<% element_class = "empty" %>
<% end %>
<% elsif ( (((row+exp/2) - (row+exp/2) % exp) / exp) % 2 == 1 ) and col < cols-1 %>
<% if ( (((row+exp/2) - (row+exp/2) % exp) / exp) % 2 == 1 ) and col < cols-1 %>
<% element_class = "connector" %>
<% end %>
<% end %>
<td class="<%= element_class %>">
<% if element_class == "team" %>
<% if params[:action] == "edit" %>
<%= select_tag "cell[#{row}][#{col}]", options_for_select(bracket.options, :selected => bracket.default(row, col)) %>
<% elsif bracketer %>
<% if bracketer.match %>
<%= link_to bracketer, bracketer.match %>
<% elsif bracketer.contester %>
<table>
<td class="flag"><%= flag bracketer.contester.team.country %></td>
<td class="bracket"><%= link_to bracketer.contester, bracketer.contester %></td>
</table>
<% end %>
<% end %>
<% end %>
</td>
<% end %>
</tr>
<% end %>
</table>