<section><h1id="random-link">Random Posts</h1><spanid="random-shuffle"class="link_btn">Shuffle!</span>{% if site.random_local %}
<ulclass="posts"> {% for post in page.random_posts %}
{% include post_list.html %}
{% endfor %}
</ul>{% else %}
<divid="random-posts"><div><ul></ul></div><scripttype="text/javascript">vargetEntryList=function(){console.log('getEntryList');if(!('entry_list'inwindow)){console.log('no entry_list!');$.ajax({url:'/posts.html',type:'GET',dataType:'html'}).done(function(data){entry_list=$(data).find('li');randomList();});}};getEntryList();varrandomList=function(){console.log('randomList');if(!('entry_list'inwindow)){console.log('still no entry_list!');return;}varnentries=entry_list.length;varrand=[];varf=document.createDocumentFragment();while(rand.length<{%ifsite.random_posts%}{{site.random_posts}}{%else%}10{%endif%}&&rand.length<nentries){varr=Math.floor(Math.random()*nentries);if(rand.indexOf(r)!=-1)continue;f.appendChild(entry_list[r]);rand.push(r);}$('#random-posts ul li').remove();$('#random-posts ul').append(f);varrandom_url=$(entry_list[Math.floor(Math.random()*nentries)]).find('.click_box_link')[0].href;$('#random-link').wrap($('<a href="Random Fly!"/>'));$('#random-link').click(function(){window.location=random_url;returnfalse;});};$(function($){$('#random-shuffle').click(function(){randomList();});});</script>{% endif %}
</section>