X-Git-Url: https://projects.mako.cc/source/selectricity/blobdiff_plain/58fb91dde4b0a16c1a764dda66e31bc57565e41f..6a1c545f073430dd46bf5ad89b0450a16c659b00:/app/views/quickvote/_pref_tables.rhtml
diff --git a/app/views/quickvote/_pref_tables.rhtml b/app/views/quickvote/_pref_tables.rhtml
new file mode 100644
index 0000000..66e0cbf
--- /dev/null
+++ b/app/views/quickvote/_pref_tables.rhtml
@@ -0,0 +1,54 @@
+<% candidates = @election.condorcet_result.ranked_candidates.flatten -%>
+<% voters = @election.voters.size %>
+<% matrix = @election.condorcet_result.matrix %>
+<% victories = @election.condorcet_result.victories_and_ties %>
+<% names = @election.names_by_id %>
+
+
+
+
+
+ |
+ <% candidates.each do |candidate| -%>
+ <%=h names[candidate] -%> |
+ <% end -%>
+
+
+<% candidates.each do |winner| -%>
+
+ <%=h names[winner] %> |
+ <% candidates.each do |loser| -%>
+ <% if winner == loser -%>
+ -- |
+ <% else %>
+ <% wins = matrix[winner][loser] unless matrix[winner].nil?%>
+ <%= wins %>
+ <%= sparkline_tag [(wins.to_f/voters.to_f)*100.0], :type => 'pie',
+ :diameter => 25, :share_color => '#74ce00' %>
+ |
+ <% end -%>
+ <% end -%>
+
+<% end -%>
+
+
+
+
+ <% candidates.each do |victor| %>
+
+ <%=h names[victor] %> |
+ <% victories[victor].keys.each do |loser| %>
+ <% margin = victories[victor][loser]%>
+ <%=h names[loser] %>
+ <% if margin == 0%>
+ Tied!
+ <% else -%>
+ (<%= margin%>)
+ <% end -%>
+ |
+ <% end -%>
+
+ <% end -%>
+
+