r87466 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r87465‎ | r87466 | r87467 >
Date:22:55, 4 May 2011
Author:tparscal
Status:resolved
Tags:
Comment:
Replaced random pitch selection math with something that doesn't penalize the first and last index.
Modified paths:
  • /trunk/extensions/ArticleFeedback/modules/jquery.articleFeedback/jquery.articleFeedback.js (modified) (history)

Diff [purge]

Index: trunk/extensions/ArticleFeedback/modules/jquery.articleFeedback/jquery.articleFeedback.js
@@ -640,7 +640,9 @@
641641 }
642642 if ( pitches.length ) {
643643 // Select randomly using equal distribution of available pitches
644 - var key = pitches[Math.round( Math.random() * ( pitches.length - 1 ) )];
 644+ var randomIndex = Math.round( Math.random() * Number.MAX_VALUE )
 645+ % pitches.length;
 646+ var key = pitches[randomIndex];
645647 context.$ui.find( '.articleFeedback-pitches' )
646648 .css( 'width', context.$ui.width() )
647649 .find( '.articleFeedback-pitch[rel="' + key + '"]' )

Follow-up revisions

RevisionCommit summaryAuthorDate
r87467Improved on r87466 - this is much simpler and more fair.tparscal23:04, 4 May 2011

Status & tagging log