Skip to content

Commit

Permalink
Fixed multiple loser drop bug caused by duplicate ids when testing wi…
Browse files Browse the repository at this point in the history
…th fake data.
  • Loading branch information
Dishwasha committed May 20, 2012
1 parent ed9d5f2 commit 55f14b5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 29 deletions.
1 change: 0 additions & 1 deletion Gemfile
Expand Up @@ -35,7 +35,6 @@ end
group :development, :test do group :development, :test do
# To use debugger (ruby-debug for Ruby 1.8.7+, ruby-debug19 for Ruby 1.9.2+) # To use debugger (ruby-debug for Ruby 1.8.7+, ruby-debug19 for Ruby 1.9.2+)
#gem 'ruby-debug' #gem 'ruby-debug'
gem 'ruby-debug19', :require => 'ruby-debug'
gem 'rspec-rails' gem 'rspec-rails'
gem 'jasmine' gem 'jasmine'
gem 'jasmine-headless-webkit' gem 'jasmine-headless-webkit'
Expand Down
15 changes: 0 additions & 15 deletions Gemfile.lock
Expand Up @@ -30,7 +30,6 @@ GEM
i18n (~> 0.6) i18n (~> 0.6)
multi_json (~> 1.0) multi_json (~> 1.0)
addressable (2.2.7) addressable (2.2.7)
archive-tar-minitar (0.5.2)
arel (3.0.0) arel (3.0.0)
bcrypt-ruby (3.0.1) bcrypt-ruby (3.0.1)
builder (3.0.0) builder (3.0.0)
Expand All @@ -47,7 +46,6 @@ GEM
coffee-script-source coffee-script-source
execjs execjs
coffee-script-source (1.2.0) coffee-script-source (1.2.0)
columnize (0.3.6)
date_validator (0.6.3) date_validator (0.6.3)
activemodel (~> 3.0) activemodel (~> 3.0)
devise (2.0.1) devise (2.0.1)
Expand Down Expand Up @@ -86,8 +84,6 @@ GEM
thor (~> 0.14) thor (~> 0.14)
json (1.6.5) json (1.6.5)
kgio (2.7.2) kgio (2.7.2)
linecache19 (0.5.12)
ruby_core_source (>= 0.1.4)
mail (2.4.1) mail (2.4.1)
i18n (>= 0.4.0) i18n (>= 0.4.0)
mime-types (~> 1.16) mime-types (~> 1.16)
Expand Down Expand Up @@ -171,17 +167,7 @@ GEM
activesupport (>= 3.0) activesupport (>= 3.0)
railties (>= 3.0) railties (>= 3.0)
rspec (~> 2.8.0) rspec (~> 2.8.0)
ruby-debug-base19 (0.11.25)
columnize (>= 0.3.1)
linecache19 (>= 0.5.11)
ruby_core_source (>= 0.1.4)
ruby-debug19 (0.11.6)
columnize (>= 0.3.1)
linecache19 (>= 0.5.11)
ruby-debug-base19 (>= 0.11.19)
ruby-openid (2.1.8) ruby-openid (2.1.8)
ruby_core_source (0.1.5)
archive-tar-minitar (>= 0.5.2)
rubyzip (0.9.6.1) rubyzip (0.9.6.1)
sass (3.1.15) sass (3.1.15)
sass-rails (3.2.4) sass-rails (3.2.4)
Expand Down Expand Up @@ -243,7 +229,6 @@ DEPENDENCIES
pg pg
rails (= 3.2.0) rails (= 3.2.0)
rspec-rails rspec-rails
ruby-debug19
sass-rails sass-rails
slim-rails slim-rails
uglifier uglifier
Expand Down
28 changes: 15 additions & 13 deletions app/assets/javascripts/rafflr.js
Expand Up @@ -31,17 +31,17 @@
}); });


// Uncomment to add more names to the data // Uncomment to add more names to the data
self.data = self.data.concat([ // self.data = self.data.concat([
{id: 2, name: "Bob Jones"}, // {id: 20000, name: "Bob Jones"},
{id: 3, name: "Nancy Reed"}, // {id: 20001, name: "Nancy Reed"},
{id: 4, name: "Larry David"}, // {id: 20002, name: "Larry David"},
{id: 5, name: "George Foreman"}, // {id: 20003, name: "George Foreman"},
{id: 6, name: "Barry Lither"}, // {id: 20004, name: "Barry Lither"},
{id: 7, name: "Cary Grant"}, // {id: 20005, name: "Cary Grant"},
{id: 8, name: "Penelope Cruz"}, // {id: 20006, name: "Penelope Cruz"},
{id: 9, name: "Steven Segal"}, // {id: 20007, name: "Steven Segal"},
{id: 10, name: "Rasputin"} // {id: 20008, name: "Rasputin"}
]); // ]);


var divElem = d3.select(".page"); var divElem = d3.select(".page");


Expand Down Expand Up @@ -141,13 +141,13 @@
_bootLosers: function() { _bootLosers: function() {
var self = this; var self = this;
var selection = self.svg.selectAll("g"); var selection = self.svg.selectAll("g");
// Set bounding box property so we know what the text size is


// Set bounding box property so we know what the text size is
self.svg.selectAll("g").each(function(d, i) { self.svg.selectAll("g").each(function(d, i) {
d.bbox = this.getBBox(); d.bbox = this.getBBox();
}); });


self.data.splice(Math.floor(Math.random() * selection[0].length), 1); self.data.splice(Math.floor(Math.random() * self.data.length), 1);
selection.data(self.data, function(d) { return d.id; }) selection.data(self.data, function(d) { return d.id; })
.exit() .exit()
.transition() .transition()
Expand Down Expand Up @@ -175,6 +175,8 @@


var scale = 2; var scale = 2;


$("button.start").html("Restart");

self.data = _.shuffle(self.data); self.data = _.shuffle(self.data);
selection.sort(function(a, b) { selection.sort(function(a, b) {
var aIndex = self.data.indexOf(a); var aIndex = self.data.indexOf(a);
Expand Down

0 comments on commit 55f14b5

Please sign in to comment.