refactored the results page
author<mako@atdot.cc> <>
Fri, 31 Aug 2007 01:00:22 +0000 (21:00 -0400)
committer<mako@atdot.cc> <>
Fri, 31 Aug 2007 01:00:22 +0000 (21:00 -0400)
13 files changed:
app/views/quickvote/_methodinfo_approval.rhtml [moved from app/views/quickvote/_result_approval.rhtml with 77% similarity]
app/views/quickvote/_methodinfo_borda.rhtml [moved from app/views/quickvote/_result_borda.rhtml with 84% similarity]
app/views/quickvote/_methodinfo_condorcet.rhtml [moved from app/views/quickvote/_result_condorcet.rhtml with 82% similarity]
app/views/quickvote/_methodinfo_plurality.rhtml [moved from app/views/quickvote/_result_plurality.rhtml with 83% similarity]
app/views/quickvote/_methodinfo_runoff.rhtml [moved from app/views/quickvote/_result_runoff.rhtml with 90% similarity]
app/views/quickvote/_methodinfo_ssd.rhtml [moved from app/views/quickvote/_result_ssd.rhtml with 83% similarity]
app/views/quickvote/_result.rhtml
app/views/quickvote/_result_box.rhtml [new file with mode: 0644]
app/views/quickvote/_results_sidebar.rhtml
app/views/quickvote/results.rhtml
config/environment.rb
public/stylesheets/common.css
public/stylesheets/main.css

similarity index 77%
rename from app/views/quickvote/_result_approval.rhtml
rename to app/views/quickvote/_methodinfo_approval.rhtml
index a7e11ce52ad7c87224ed781a017ccb631a030c8a..979c876285af39153b47ca18a961be3f0dcebbe9 100644 (file)
@@ -1,8 +1,5 @@
-<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>
 
@@ -14,5 +11,3 @@ range that voters are allowed to express is extremely constrained:
 accept or not.</p>
 
 </div>
-
-<%= render :partial => 'approval_table' %>
\ No newline at end of file
similarity index 84%
rename from app/views/quickvote/_result_borda.rhtml
rename to app/views/quickvote/_methodinfo_borda.rhtml
index f81cbdba2814bb7dc31209597d2dfa53e928b848..cc3167cf9b1dd1379fe50ee008415d21cf756dd0 100644 (file)
@@ -1,7 +1,3 @@
-<h3>Borda Count Results</h3>
-
-<%= render :partial => 'result', :object => @election.borda_result %>
-
 <div class="rbmoreinfo">
 <h4>About Borda Count</h4>
 
similarity index 82%
rename from app/views/quickvote/_result_condorcet.rhtml
rename to app/views/quickvote/_methodinfo_condorcet.rhtml
index 77ce6585f8bc88b7133d0d7ce150f263f836178f..a02c1d7ecdacfddae2da2ff7b15eed39a3e0d653 100644 (file)
@@ -1,7 +1,3 @@
-<h3>Simple Condorcet Results</h3>
-
-<%= render :partial => 'result', :object => @election.condorcet_result %>
-
 <div class="rbmoreinfo">
 <h4>About Simple Cordorcet Voting</h4>
 
similarity index 83%
rename from app/views/quickvote/_result_plurality.rhtml
rename to app/views/quickvote/_methodinfo_plurality.rhtml
index 86a94691170027c538c96ec7755c1aab8adb843d..9411611c569462f59faca0b3a87309bd1fc55534 100644 (file)
@@ -1,7 +1,3 @@
-<h3>Plurality Results</h3>
-
-<%= render :partial => 'result', :object => @election.plurality_result %>
-
 <div class="rbmoreinfo">
 <h4>About Plurality Voting</h4>
 
@@ -15,4 +11,5 @@ post," "winner-take-all," "majoritarian" or "simple majority"
 voting.</p>
 
 </div>
+
 <%= image_tag(graph_url( :action => 'plurality_pie', :id => @election ) )%>
similarity index 90%
rename from app/views/quickvote/_result_runoff.rhtml
rename to app/views/quickvote/_methodinfo_runoff.rhtml
index f2422909436fde22a203cc04c9d6c8d88f11c8ad..eaba2b1d73b5a99a10d1efa1f7962b67e60096dd 100644 (file)
@@ -1,6 +1,3 @@
-<div class="resultbox">
-<h3>Instant Runoff (IRV) Results</h3>
-
 <div class="rbmoreinfo">
 <h4>About Instant Runoff Voting</h4>
 
@@ -16,5 +13,3 @@ preferences (and so on), until one candidate achieves a majority.</p>
 by several other names.</p>
 
 </div>
-
-</div>
\ No newline at end of file
similarity index 83%
rename from app/views/quickvote/_result_ssd.rhtml
rename to app/views/quickvote/_methodinfo_ssd.rhtml
index e1811840828a9c52e19a629b45b92bc872ca5717..e3ff831bdaf32d41c214c8ddd78f8c5ebc0bb867 100644 (file)
@@ -1,7 +1,3 @@
-<h3>Schulze Method Results</h3>
-
-<%= render :partial => 'result', :object => @election.ssd_result %>
-
 <div class="rbmoreinfo">
 <h4>About the Schulze Method</h4>
 
index b64322455fefcd8c554d5c1f362232c824db9df4..e0ead6de4e3f27b60524554f0b06241578fcd169 100644 (file)
@@ -1,9 +1,10 @@
-<% %>
+<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>
diff --git a/app/views/quickvote/_result_box.rhtml b/app/views/quickvote/_result_box.rhtml
new file mode 100644 (file)
index 0000000..41d9d17
--- /dev/null
@@ -0,0 +1,16 @@
+<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>
+
index 704c052cba543a42b253dfc59f230e37265857ef..c60ed3ddfc1cf90a31e10cddf936a2e2d4283fc7 100644 (file)
@@ -1,2 +1,37 @@
+<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 ))%>
 
index a51ca1db2e5bd7e6deaa8a0bd82d524817a1d164..f4f6f2d812aa93e98ad46c453d728a7c9900a79d 100644 (file)
      <%= @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>
index 82c746617b7da09e2ca108fe147f9e934ca55afd..ccd9ad0990874b6b4bb92d6260caa52a891b9982 100644 (file)
@@ -66,10 +66,10 @@ require 'randarray'
 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
index 01cd7c052e53363d8dffd1468d9fbc4511deb55a..42390e32436a7021a9af457d1ca621d6b15bdcca 100644 (file)
@@ -29,7 +29,7 @@ table, caption, tbody, tfoot, thead, tr, th, td {
 }
 
 body {
-       font-size: 11px;
+       font-size: 0.9em;
        font-family: Trebuchet, Verdana, Arial, Helvetica, sans-serif;
 }
 
index 3608063a4ae355fe2e331e1ea2a10359fe25edb4..13626a13bd67f4a807535390e38f603e9ef76c8c 100644 (file)
@@ -160,7 +160,7 @@ h5 {
 }
 
 .normal-header {
-    margin: 0 -20px 1em -20px;
+    margin: 1.3em -20px 1.3em -20px;
     height: 32px;
        background-color: #e5e5e5;
 }

Benjamin Mako Hill || Want to submit a patch?