<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: jQuery: Shuffle Plugin</title>
	<atom:link href="http://yelotofu.com/2008/08/jquery-shuffle-plugin/feed/" rel="self" type="application/rss+xml" />
	<link>http://yelotofu.com/2008/08/jquery-shuffle-plugin/</link>
	<description>"In building standards compliant sites we are creating a better Web for the future."</description>
	<lastBuildDate>Thu, 11 Mar 2010 17:53:20 -0800</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: cordial</title>
		<link>http://yelotofu.com/2008/08/jquery-shuffle-plugin/comment-page-1/#comment-11359</link>
		<dc:creator>cordial</dc:creator>
		<pubDate>Wed, 03 Mar 2010 10:30:57 +0000</pubDate>
		<guid isPermaLink="false">http://yelotofu.com/?p=98#comment-11359</guid>
		<description>this is exactly what i needed!


perfect, thanks!</description>
		<content:encoded><![CDATA[<p>this is exactly what i needed!</p>
<p>perfect, thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bamboolabcode</title>
		<link>http://yelotofu.com/2008/08/jquery-shuffle-plugin/comment-page-1/#comment-10806</link>
		<dc:creator>bamboolabcode</dc:creator>
		<pubDate>Mon, 01 Feb 2010 05:20:51 +0000</pubDate>
		<guid isPermaLink="false">http://yelotofu.com/?p=98#comment-10806</guid>
		<description>Thanks for the info. I appreciate it well.</description>
		<content:encoded><![CDATA[<p>Thanks for the info. I appreciate it well.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ellison</title>
		<link>http://yelotofu.com/2008/08/jquery-shuffle-plugin/comment-page-1/#comment-10113</link>
		<dc:creator>Ellison</dc:creator>
		<pubDate>Thu, 24 Dec 2009 05:25:28 +0000</pubDate>
		<guid isPermaLink="false">http://yelotofu.com/?p=98#comment-10113</guid>
		<description>Hello. I&#039;ve made an attempt at extending this plugin a little to be able to seed a random number generator so that you can repeat sequences given the right seed. I&#039;m very new at jQuery, so if I didn&#039;t do something quite right (style-wise or other), please tell me :)

 
(function($){
	var getNextRandom = Math.random;
	$.fn.shuffle = function() {		
		return this.each(function(){
			var items = $(this).children().clone(true);
			return (items.length) ? $(this).html($.shuffle(items)) : this;
		});
	}
	
	$.shuffleInit = function(options) {
		if(!options &#124;&#124; !Random) return;
		if(typeof options.seed == &quot;number&quot;) {
			var r = new Random(options.seed);
			getNextRandom = function() { return r.next(); };
		}
	}
	
	$.shuffle = function(arr) {
		for(var j, x, i = arr.length; i; j = parseInt(getNextRandom() * i), x = arr[--i], arr[i] = arr[j], arr[j] = x);
		return arr;
	}
	
})(jQuery);

It seems to work fine, assuming that you&#039;ve loaded a class called Random that works appropriately (i.e. a 1-arg constructor to initialize the seed and a next() method to get the next pseudo-random number).

Again, I&#039;d much appreciate tips on how I can improve what I was trying to do.</description>
		<content:encoded><![CDATA[<p>Hello. I&#8217;ve made an attempt at extending this plugin a little to be able to seed a random number generator so that you can repeat sequences given the right seed. I&#8217;m very new at jQuery, so if I didn&#8217;t do something quite right (style-wise or other), please tell me <img src='http://yelotofu.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>(function($){<br />
	var getNextRandom = Math.random;<br />
	$.fn.shuffle = function() {<br />
		return this.each(function(){<br />
			var items = $(this).children().clone(true);<br />
			return (items.length) ? $(this).html($.shuffle(items)) : this;<br />
		});<br />
	}</p>
<p>	$.shuffleInit = function(options) {<br />
		if(!options || !Random) return;<br />
		if(typeof options.seed == &#8220;number&#8221;) {<br />
			var r = new Random(options.seed);<br />
			getNextRandom = function() { return r.next(); };<br />
		}<br />
	}</p>
<p>	$.shuffle = function(arr) {<br />
		for(var j, x, i = arr.length; i; j = parseInt(getNextRandom() * i), x = arr[--i], arr[i] = arr[j], arr[j] = x);<br />
		return arr;<br />
	}</p>
<p>})(jQuery);</p>
<p>It seems to work fine, assuming that you&#8217;ve loaded a class called Random that works appropriately (i.e. a 1-arg constructor to initialize the seed and a next() method to get the next pseudo-random number).</p>
<p>Again, I&#8217;d much appreciate tips on how I can improve what I was trying to do.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: caphun</title>
		<link>http://yelotofu.com/2008/08/jquery-shuffle-plugin/comment-page-1/#comment-6901</link>
		<dc:creator>caphun</dc:creator>
		<pubDate>Fri, 10 Jul 2009 07:07:12 +0000</pubDate>
		<guid isPermaLink="false">http://yelotofu.com/?p=98#comment-6901</guid>
		<description>@hector - makes sense to keep the bindings! I will add that into my code aswell. Thanks!</description>
		<content:encoded><![CDATA[<p>@hector &#8211; makes sense to keep the bindings! I will add that into my code aswell. Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Hector Virgen</title>
		<link>http://yelotofu.com/2008/08/jquery-shuffle-plugin/comment-page-1/#comment-6796</link>
		<dc:creator>Hector Virgen</dc:creator>
		<pubDate>Mon, 06 Jul 2009 21:06:30 +0000</pubDate>
		<guid isPermaLink="false">http://yelotofu.com/?p=98#comment-6796</guid>
		<description>Very nice! Just what I was looking for and it seems quick.

But I ran into a small problem -- all event bindings will be lost after shuffling. I made a small modification that allows you to keep your bindings by using clone(true):

$.fn.shuffle = function()
{
    return this.each(function()
    {
        var items = $(this).children().clone(true);
        return (items.length)
        ? $(this).html($.shuffle(items))      
        : this);
    });
};</description>
		<content:encoded><![CDATA[<p>Very nice! Just what I was looking for and it seems quick.</p>
<p>But I ran into a small problem &#8212; all event bindings will be lost after shuffling. I made a small modification that allows you to keep your bindings by using clone(true):</p>
<p>$.fn.shuffle = function()<br />
{<br />
    return this.each(function()<br />
    {<br />
        var items = $(this).children().clone(true);<br />
        return (items.length)<br />
        ? $(this).html($.shuffle(items))<br />
        : this);<br />
    });<br />
};</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Manish MISTRY</title>
		<link>http://yelotofu.com/2008/08/jquery-shuffle-plugin/comment-page-1/#comment-5273</link>
		<dc:creator>Manish MISTRY</dc:creator>
		<pubDate>Wed, 13 May 2009 06:48:11 +0000</pubDate>
		<guid isPermaLink="false">http://yelotofu.com/?p=98#comment-5273</guid>
		<description>Thanks mate!</description>
		<content:encoded><![CDATA[<p>Thanks mate!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rustam Mester</title>
		<link>http://yelotofu.com/2008/08/jquery-shuffle-plugin/comment-page-1/#comment-4772</link>
		<dc:creator>Rustam Mester</dc:creator>
		<pubDate>Tue, 28 Apr 2009 06:44:01 +0000</pubDate>
		<guid isPermaLink="false">http://yelotofu.com/?p=98#comment-4772</guid>
		<description>Big thanks to author from russian freelancer !</description>
		<content:encoded><![CDATA[<p>Big thanks to author from russian freelancer !</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Implement Array Shuffling in MooTools</title>
		<link>http://yelotofu.com/2008/08/jquery-shuffle-plugin/comment-page-1/#comment-3452</link>
		<dc:creator>Implement Array Shuffling in MooTools</dc:creator>
		<pubDate>Mon, 09 Feb 2009 14:01:46 +0000</pubDate>
		<guid isPermaLink="false">http://yelotofu.com/?p=98#comment-3452</guid>
		<description>[...] useful function, I recently found myself needing to accomplish the task. I found a great post about how to achieve this feat using jQuery.  Here&#8217;s how to implement array shuffling in [...]</description>
		<content:encoded><![CDATA[<p>[...] useful function, I recently found myself needing to accomplish the task. I found a great post about how to achieve this feat using jQuery.  Here&#8217;s how to implement array shuffling in [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Shuffling the DOM - James Padolsey</title>
		<link>http://yelotofu.com/2008/08/jquery-shuffle-plugin/comment-page-1/#comment-3403</link>
		<dc:creator>Shuffling the DOM - James Padolsey</dc:creator>
		<pubDate>Wed, 04 Feb 2009 22:56:17 +0000</pubDate>
		<guid isPermaLink="false">http://yelotofu.com/?p=98#comment-3403</guid>
		<description>[...] was recently looking for a decent way of shuffling a set of elements. I found a jQuery plugin which claimed to do exactly that but unfortunately it only works if all elements are direct [...]</description>
		<content:encoded><![CDATA[<p>[...] was recently looking for a decent way of shuffling a set of elements. I found a jQuery plugin which claimed to do exactly that but unfortunately it only works if all elements are direct [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: caphun</title>
		<link>http://yelotofu.com/2008/08/jquery-shuffle-plugin/comment-page-1/#comment-3347</link>
		<dc:creator>caphun</dc:creator>
		<pubDate>Sat, 17 Jan 2009 18:00:18 +0000</pubDate>
		<guid isPermaLink="false">http://yelotofu.com/?p=98#comment-3347</guid>
		<description>@Elle: Thanks. Yes that&#039;s certainly possible. Try this:

jQuery(function($){
  var randomItem = $.shuffle([1,2,3,4,5,6])[0];
  alert(randomItem);
});

The above will return a random number between 1 and 6.</description>
		<content:encoded><![CDATA[<p>@Elle: Thanks. Yes that&#8217;s certainly possible. Try this:</p>
<p>jQuery(function($){<br />
  var randomItem = $.shuffle([1,2,3,4,5,6])[0];<br />
  alert(randomItem);<br />
});</p>
<p>The above will return a random number between 1 and 6.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
