-<h3>Approval Result</h3>
<p><font size="-1">(This algorithm assumes that top two choices are "approved.")</font></p>
-<%= render :partial => 'result', :object => @election.approval_result %>
-
<div class="rbmoreinfo">
<h4>About Approval Voting</h4>
accept or not.</p>
</div>
-
-<%= render :partial => 'approval_table' %>
\ No newline at end of file
-<h3>Borda Count Results</h3>
-
-<%= render :partial => 'result', :object => @election.borda_result %>
-
<div class="rbmoreinfo">
<h4>About Borda Count</h4>
-<h3>Simple Condorcet Results</h3>
-
-<%= render :partial => 'result', :object => @election.condorcet_result %>
-
<div class="rbmoreinfo">
<h4>About Simple Cordorcet Voting</h4>
-<h3>Plurality Results</h3>
-
-<%= render :partial => 'result', :object => @election.plurality_result %>
-
<div class="rbmoreinfo">
<h4>About Plurality Voting</h4>
voting.</p>
</div>
+
<%= image_tag(graph_url( :action => 'plurality_pie', :id => @election ) )%>
-<div class="resultbox">
-<h3>Instant Runoff (IRV) Results</h3>
-
<div class="rbmoreinfo">
<h4>About Instant Runoff Voting</h4>
by several other names.</p>
</div>
-
-</div>
\ No newline at end of file
-<h3>Schulze Method Results</h3>
-
-<%= render :partial => 'result', :object => @election.ssd_result %>
-
<div class="rbmoreinfo">
<h4>About the Schulze Method</h4>
-<% %>
+<div class="winner">
<% if result.winner? and result.winners.length == 1%>
- <p><em>The winner is:
- <strong><%=h @candidates[result.winner].name.capitalize %></strong></em></p>
+ <p>The winner is:
+ <strong><%=h @candidates[result.winner].name.capitalize %></strong></p>
<% elsif result.winner? and result.winners.length > 1 %>
- <p><em>There was a tie. The winners are: <strong><%=h( result.winners.collect {|w| @candidates[w].to_s.capitalize}.join(", ") )%></strong></em></p>
+ <p>There was a tie. The winners are: <strong><%=h( result.winners.collect {|w| @candidates[w].to_s.capitalize}.join(", ") )%></strong></p>
<% else %>
- <p><em>There is no winner using this method. </em></strong></p>
+ <p>There is no winner using this method. </strong></p>
<% end %>
+</div>
--- /dev/null
+<div id="<%= method %>_result" class="resultbox"<%= ' style="display: none;"' unless @election.election_method == method %>>
+<div class="normal-header">
+ <span class="header"><%= ELECTION_TYPES[method]%> </span>
+ <span class="subheader">
+ <% if @election.election_method == method %>
+ Selected Method
+ <% else %>
+ Alternative Method
+ <% end %></span>
+</div>
+
+<%= render :partial => 'methodinfo_' + method,
+ :object => @results[@election.election_method] %>
+
+</div>
+
+<h2>Winner</h2>
+<%= render :partial => 'result', :object => @results[@election.election_method] %>
+
+<p>This election was run using:
+<strong><%= ELECTION_TYPES[@election.election_method] %></strong></p>
+
+<p>View results with other methods:<br />
+<% type_hash = {}; ELECTION_TYPES.each {|k,v| type_hash[v] = k} %>
+<%= select_tag 'election_type_select', options_for_select(type_hash, @election.election_method) %></p>
+
+<script>
+var election_methods = new Array(<%= ELECTION_TYPES.keys.collect {|k| "'#{k}'"}.join(', ') %>);
+var method_select = $('election_type_select');
+
+function show_results_for() {
+ var test = $('test');
+
+ method_select.value;
+ var result_boxes = document.getElementsByClassName('resultbox');
+ for (i = 0; i < result_boxes.length; i++) {
+ result_box = result_boxes[i];
+ if (result_box.id == (method_select.value + "_result")) {
+ Element.show(result_box);
+ } else {
+ Element.hide(result_box);
+ }
+ }
+
+ //alert(method_select.value);
+}
+
+Event.observe(method_select, 'change', show_results_for);
+</script>
+
+<h2>Statistics</h2>
<%= image_tag( graph_url( :action => 'votes_per_interval', :id => @election ))%>
<%= @election.voters.reject {|v| not v.voted? }.length %> (see below for details)
</blockquote>
-<div class="normal-header">
- <span class="header">Winner</span>
- <span class="subheader">Computed with
- <%= ELECTION_TYPES[@election.election_method] %></span>
-</div>
+<%= render :partial => 'result_box',
+ :locals => { :method => @election.election_method } %>
-<div class="mainresultbox">
-<%= render :partial => 'result_' + @election.election_method,
- :object => @results[@election.election_method] %>
-</div>
+<% for result_type in @election.other_methods %>
-<div class="normal-header">
- <span class="header">Other Voting Methods</span>
- <span class="subheader"></span>
-</div>
+<%= render :partial => 'result_box',
+ :locals => { :method => result_type } %>
-<% for result_type in @election.other_methods %>
-<div class="resultbox">
-<%= render :partial => 'result_' + result_type,
- :object => @results[result_type] %>
-</div>
<% end %>
<div class="clear-div"></div>
-<h2>Voters <%= link_to "[Stalk Voters]", :controller => "quickvote", :action => "mapvoters", :id => @election.id %></h2>
+<div class="normal-header">
+ <span class="header">Voter Report</span>
+ <span class="subheader"></span>
+</div>
+
+<p><%= link_to "[Stalk Voters]", :controller => "quickvote", :action => "mapvoters", :id => @election.id %></p>
<table class="voterbox">
<tr>
<th>IP/Host</th>
require 'gruff-0.2.8/lib/gruff'
require 'sparklines'
require 'rubyvote'
-ELECTION_TYPES = {'ssd' => "Schulze Sequential Dropping",
- 'plurality' => "Plurality/First Past the Post",
- 'approval' => "Approval (Top Two)",
- 'condorcet' => "Simple Condorcet",
+ELECTION_TYPES = {'ssd' => "Schulze Method",
+ 'plurality' => "Plurality",
+ 'approval' => "Approval",
+ 'condorcet' => "Condorcet",
'borda' => "Borda Count"}
class String
}
body {
- font-size: 11px;
+ font-size: 0.9em;
font-family: Trebuchet, Verdana, Arial, Helvetica, sans-serif;
}
}
.normal-header {
- margin: 0 -20px 1em -20px;
+ margin: 1.3em -20px 1.3em -20px;
height: 32px;
background-color: #e5e5e5;
}