<script>var last_page=[Blog_Page_Count]+1,pagesPath='pages/':
function loadPage(thePage){
try{
var loadingP=document.getElementById('pageLoading'),
http=window.XMLHttpRequest?new XMLHttpRequest():new ActiveXObject('Microsoft.XMLHTTP');
loadingP.style.display='';
http.onreadystatechange=function(){
if(http.readyState==4 && http.status==200){
loadingP.style.display='none';
window.location.hash='#pageArticleContents';
var source=http.responseText,
allEls=document.createElement('div');
allEls.innerHTML=source;
currentPage=thePage;
makePages();
var i=0,
articles=allEls.getElementsByTagName('article'),
main=document.getElementById('pageArticleContents'),
currentArticles=main.getElementsByTagName('article');
var stopChangeArticles=setInterval(function(){
currentArticles.style.opacity=0;
if(++i>=currentArticles.length){
clearInterval(stopChangeArticles);
setTimeout(function(){
main.innerHTML='';
i=0;
var stopAddingArticle=setInterval(function(){
var ar=document.createElement('article');
ar.style.transform='rotateX(540deg)';
ar.innerHTML=articles.innerHTML;
main.appendChild(ar);
setTimeout(function(){
ar.style.transform='';
}, 10);
if(++i>=articles.length){
clearInterval(stopAddingArticle);
updatePostsAvatars();
}
}, 100);
}, 500);
}
}, 100);
}
};
http.open('GET','/'+pagesPath+thePage,true);
http.send();
return false;
}
catch(e){}
}
function makePages(){
var i=0,stopRemoving=setInterval(function(){
var el=pagesArea.getElementsByTagName('li');
if(el.length==pageCount)
el.style.opacity='0';
if(++i>=pageCount || el.length!=pageCount){
clearInterval(stopRemoving);
setTimeout(function(){
i=0
pagesArea.innerHTML='';
var stopAdding=setInterval(function(){
var a=document.createElement('a'),
li=document.createElement('li');
a.innerHTML=pages.start+i;
a.href='/'+pagesPath+(pages.start+i);
a.setAttribute('onclick', 'return loadPage('+(pages.start+i)+');');
if(pages.start+i==currentPage)
a.className='currentPage';
li.style.transform='rotateY(180deg)';
li.style.opacity=0;
li.appendChild(a);
pagesArea.appendChild(li);
setTimeout(function(){
li.style.transform='';
li.style.opacity='';
}, 100*i+(pageCount+10));
if(++i>=pageCount || pages.start+i>=last_page)
clearInterval(stopAdding);
}, 0);
}, 500);
}
}, 20);
}
function nextPage(){
if(pages.end==last_page){
pages.start=1;
pages.end=pageCount;
}
else{
pages.end+=pageCount;
pages.start+=pageCount;
fixPages();
}
makePages();
}
function previousPage(){
if(pages.start==1){
pages.start=last_page-pageCount;
pages.end=last_page;
}
else{
pages.start-=pageCount;
pages.end-=pageCount;
fixPages();
}
makePages();
}
function fixPages(){
if(pages.start<1)
pages.start=1;
if(pages.end>last_page)
pages.end=last_page;
}
function setZero(p){
p-=5;
if(p<=1)
return 1;
return p;
}
last_page=typeof(last_page)!='undefined'?last_page:false;
if(last_page){
var currentPage=1,
pages={},
pageCount=13,
pagesArea=document.getElementById('pagesArea'),
loc=window.location.href;
currentPage=Math.max(1,parseInt(loc.slice(loc.lastIndexOf('/')+1))) || 1;
pages.start=setZero(currentPage);
pages.end=pages.start+pageCount;
makePages();
}
</script>
<div class="loading"><div style="display:none;" id="pageLoading"></div></div>
<div onclick="previousPage();" id="previousBtn"></div>
<div onclick="nextPage();" id="nextBtn"></div>
<ul id="pagesArea"></ul>