/**
 * Handles palette randomization.
 *
 * @return {object}
 */
var RandomColor = function() {};

RandomColor.prototype = (function() {

    /**
     * @private
     */
    var palette = [],
        delivered = [],
        lastColor = false;

    /**
     * Get a random number from 0 to max items in palette.
     *
     * @return {int}
     */
    function randomizer() {
        return Math.floor(Math.random() * palette.length);
    }

    /**
     * Keep track of each color delivered to the requestor incrementing its
     * per-color counter and last color drafted.
     *
     * @param  {string}     color
     */
    function updateDelivered(color) {
        if (!(color in delivered)) {
            delivered[color] = 0;
        }

        lastColor = color;
        delivered[color]++;
    }

    /**
     * @public
     */
    return {

        /**
         * Initialize the palette of colors to randomize from.
         */
        initialize: function(colors) {
            palette = colors;
        },

        /**
         * Get a random color from the configured palette, without repeating the
         * previous one.
         *
         * @return {string}
         */
        getColor: function() {
            var color = false;

            do {
                color = palette[randomizer()];
            } while(color === lastColor) ;

            updateDelivered(color);

            return color;
        },

        getStats: function() {
            console.log(delivered);
        }
    };

})();

@@ -76,16 +76,17 @@
 Color = 
+(
 function
@@ -93,128 +93,329 @@
 () %7B
-%7D;%0A%0ARandomColor.prototype = (function() %7B%0A%0A    /**%0A     * @private%0A     */%0A    var palette = %5B%5D,%0A        delivered = %5B%5D,
+%0A%0A    /**%0A     * Class Constructor.%0A     *%0A     * @param %7Barray%7D   palette  Colors to randomize from.%0A     */%0A    function Plugin(palette) %7B%0A        this.setPalette(palette);%0A    %7D%0A%0A    /**%0A     * Set the current palette%0A     */%0A    Plugin.prototype.setPalette = function(palette) %7B%0A        this._palette = palette %7C%7C %5B%5D;
 %0A   
@@ -411,32 +411,38 @@
  %7C%7C %5B%5D;%0A        
+this._
 lastColor = fals
@@ -439,24 +439,61 @@
 lor = false;
+%0A        this._delivered = %5B%5D;%0A    %7D;
 %0A%0A    /**%0A  
@@ -514,44 +514,83 @@
 dom 
-numbe
+colo
 r from 
-0 to max items in palett
+the configured palette, without repeating the%0A     * previous on
 e.%0A 
@@ -615,11 +615,14 @@
 rn %7B
+str
 in
-t
+g
 %7D%0A  
@@ -635,96 +635,419 @@
     
-function randomizer() %7B%0A        return Math.floor(Math.random() * palette.length
+Plugin.prototype.getColor = function() %7B%0A        var color = false;%0A%0A        do %7B%0A            color = this._palette%5Bthis._getRandom(this._palette.length)%5D;%0A        %7D while(color === this._lastColor) ;%0A%0A        this._updateDelivered(color);%0A%0A        return color;%0A    %7D;%0A%0A    /**%0A     * DEBUG%0A     * @return %7Barray%7D%0A     */%0A    Plugin.prototype.getStats = function() %7B%0A        console.log(this._delivered
 );%0A    %7D
 %0A%0A  
@@ -1034,32 +1034,33 @@
 elivered);%0A    %7D
+;
 %0A%0A    /**%0A     *
@@ -1231,25 +1231,34 @@
  */%0A    
-function 
+Plugin.prototype._
 updateDe
@@ -1260,24 +1260,35 @@
 ateDelivered
+ = function
 (color) %7B%0A  
@@ -1308,16 +1308,22 @@
 olor in 
+this._
 delivere
@@ -1332,32 +1332,38 @@
 ) %7B%0A            
+this._
 delivered%5Bcolor%5D
@@ -1387,16 +1387,22 @@
         
+this._
 lastColo
@@ -1420,16 +1420,22 @@
         
+this._
 delivere
@@ -1447,24 +1447,25 @@
 or%5D++;%0A    %7D
+;
 %0A%0A    /**%0A  
@@ -1473,344 +1473,120 @@
   * 
-@public%0A     */%0A    return %7B%0A%0A        /**%0A         * Initialize the palette of colors to randomize from.%0A         */%0A        initialize: function(colors) %7B%0A            palette = colors;%0A        %7D,%0A%0A        /**%0A         * Get a random color from the configured palette, without repeating the%0A         * previous one
+Get a random number from 0 to max items in palette.%0A     *%0A     * @param %7Bint%7D max     Upper limit
 .%0A     
-    
 *%0A     
-    
 * @r
@@ -1596,55 +1596,48 @@
 rn %7B
-str
 in
-g
+t
 %7D%0A     
-    
 */%0A    
-    getColor: function(
+function _getRandom(max
 ) %7B%0A
@@ -1648,297 +1648,72 @@
     
-    var color = false;%0A%0A            do %7B%0A                color = palette%5Brandomizer()%5D;%0A            %7D while(color === lastColor) ;%0A%0A            updateDelivered(color);%0A%0A            return color;%0A        %7D,%0A%0A        getStats: function() %7B%0A            console.log(delivered);%0A        %7D%0A    %7D
+return Math.floor(Math.random() * max);%0A    %7D%0A%0A    return Plugin
 ;%0A%0A%7D

Rewrite of RandomColor to use prototype chain