You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In case it is of use to others, I added randomization by manipulating the DOM prior to calling NewsBox from the in-page script. I pulled out the relevant list items, randomized them, and put them back and then called NewsBox. This was a lot easier than hacking the NewsBox plugin to add randomization.
My particular implementation, with code by Yair Even Or (ref), looks like this:
<scripttype="text/javascript">
$(
function ()
{//Randomize comments before bootstrap Newsvarul=document.querySelector("ul.comments")//clone the listtemp=ul.cloneNode(true);//shuffle the cloned list for better performancefor(vari=temp.children.length+1;i--;)temp.appendChild(temp.children[Math.random()*i|0]);//copy shuffled list back to 'ul'ul.parentNode.replaceChild(temp,ul);$("ul.comments").bootstrapNews({newsPerPage: 3,autoplay: true,pauseOnHover: true,navigation: true,direction: 'down',newsTickerInterval: 2500,onToDo: function(){//console.log(this);}});}
);
</script>
It would be great to add a random option (default false).
I found a likely jQuery randomization function on Stack Overflow
ref: http://stackoverflow.com/questions/14555415/how-to-randomly-sort-list-items
Thanks for the excellent plugin!
The text was updated successfully, but these errors were encountered: