Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script type='text/javascript'>
- //<![CDATA[
- // Shuffle and limit count of Blogger popular posts using jQuery / MS-potilas 2011
- // Put this code in a html/javascript gadget or before </body>.
- // See http://yabtb.blogspot.com/2011/12/shuffle-and-limit-popular-post-gadget.html
- var popcount = 8;
- var ul = $('.popular-posts ul');
- var lis = $('.popular-posts ul li').detach();
- if(lis.length>1) {
- for(var i=lis.length-1;i;i--) { // fisher-yates/knuth
- var j=parseInt(Math.random()*i);
- lis[j] = lis.splice(i,1,lis[j])[0]; // swap lis[i]&lis[j]
- }
- lis.slice(-popcount).appendTo(ul);
- }
- //]]>
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement