Merged from jdong; lots of escaping fixes
[selectricity] / app / views / quickvote / _pref_table.rhtml
1 <% candidates = @election.candidates.sort.collect {|candidate| candidate.id}-%>
2 <% voters = @election.voters.size %>
3 <% matrix = @election.condorcet_result.matrix %>
4 <% names = Hash.new -%>
5 <% candidates.each do |candidate| -%>
6         <%names[candidate] = Candidate.find(candidate).name -%>
7 <% end -%>
8 <table class="voterbox">
9   <tr>
10         <td> </td>
11         <% candidates.each do |candidate| -%>
12           <th><%=h names[candidate] -%></th>
13   <% end -%>
14 </tr>
15
16 <% candidates.each do |winner| -%>
17   <tr>
18         <th><%=h names[winner] %></th>
19   <% candidates.each do |loser| -%> 
20     <% if winner == loser -%>
21       <td> -- </td>
22     <% else %>        
23       <td><% wins = matrix[winner][loser] unless matrix[winner].nil?%>
24           <%= wins %>
25               <%= sparkline_tag [(wins.to_f/voters.to_f)*100.0], :type => 'pie', 
26                                  :diameter => 25, :share_color => '#74ce00' %>
27           </td>
28     <% end -%>
29   <% end -%>
30  </tr>
31 <% end -%>
32 </table>

Benjamin Mako Hill || Want to submit a patch?