blob: 052d17650561ac5578ccadda1b2832d9e357b4fa (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
<h1><%= @tournament.name %> - Matches</h1>
<table class="table">
<thead>
<tr>
<th>Status</th>
<th>Name</th>
<th>Winner</th>
<th></th>
</tr>
</thead>
<tbody class="table-hover">
<% @tournament.matches.each do |match| %>
<tr>
<td><%= match.status %></td>
<td><%= match.id%></td>
<td><%= match.name %></td>
<td><%= link_to "Show", tournament_match_path(@tournament, match) %>
<td> <%# If user is the host, let them start the tournment %>
<% if @tournament.hosts.include?(current_user) %>
<%= form_tag(tournament_match_path(@tournament, match), method: "put") do %>
<input type="hidden" name="update_action" value="start">
<%= submit_tag("Start Match") %>
<% end %>
<% end %>
</div></td>
</tr>
<% end %>
</tbody>
</table>
<br>
<div id="match-tree">
<SVG version="1.1"
baseProfile="full"
width="<%= @width %>" height="<%= @height = [@height, 500].max %>"
xmlns="http://www.w3.org/2000/svg">
<script type="text/ecmascript"><![CDATA[
function redirect(i){
window.location.replace("<%= request.original_url %>"+"/"+i);
}
]]>
</script>
<% (1..@matches.count).each do |i| %>
<g id="svg-match-<%= i %>" onmouseover="dispStats(<%= i %>)" onclick="redirect(<%= @matches[i-1].id %>)" cursor="pointer">
<rect height="120px" width="213px"
x="<%= @width - (i-1)*50 - 250*(Math.log2(i).floor+1) %>"
y="<%= (@height/(Math.log2(i).floor+2)) - 60 + 250*(i - 2**(Math.log2(i).floor)) %>"
fill="#ffd281"
rx="20px"
stroke-width="2"
<% case @matches[i-1].status %>
<% when 0 %>
<% if @matches[i-1].teams.count < @tournament.min_teams_per_match %>
stroke="red"
fill-opacity="0.6"
<% else %>
stroke="green"
<% end %>
<% when 1 %>
stroke="orange"
<% when 2 %>
stroke="yellow"
<% when 3 %>
stroke="grey"
<% end %>
/>
</g>
<% if i > 1 %>
<line
stroke="black"
x1="<%= @width - (i-2)*50 - 250*(Math.log2(i-1).floor+1) %>"
y1="<%= (@height/(Math.log2(i-1).floor+2)) - 60 + 250*((i-1) - 2**(Math.log2(i-1).floor)) + 60 %>"
x2="<%= @width - (i-1)*50 - 250*(Math.log2(i).floor+1) + 213 %>"
y2="<%= (@height/(Math.log2(i).floor+2)) - 60 + 250*(i - 2**(Math.log2(i).floor)) + 60 %>"
/>
<% end %>
<% end %>
</SVG>
</div>
|