(function () { "use strict"; function request(querytext, func, errorfunc) { var req = new XMLHttpRequest(); req.onreadystatechange = function() { if (req.readyState !== 4) { return; } if (req.status !== 200) { errorfunc(); return; } func(req.responseText); }; req.open("GET",querytext); req.send(); } function getvar(name) { var re=new RegExp("[?&]"+name+"=\([^&]*\)"); var value=window.location.search.match(re); if(value===null || value.length<2) return(name+"="); return(name+"="+value[1]); } gotonewpost.onclick = function(e) { window.location="/newpost.html?"+getvar("s"); }; document.getElementById("posts").innerHTML='Loading posts...'; document.getElementById("account").href='/account.html?'+getvar("s"); var postsarray=[]; var functionsarray=[]; var lastpost=-1; var toppost=-1; var postsperpage=5; function changepost(postnum,data) { var p=JSON.parse(data); var postdate=new Date(0); postdate.setUTCSeconds(parseInt(p.date)); var header=[]; var body=[]; var comments=[]; header.push('
'); header.push('

'); header.push(decodeURIComponent(p.title)); header.push('#'); header.push(postnum); header.push('

'); header.push('

Por '); header.push(p.author); header.push(' el '); header.push(postdate.toString()); header.push('

'); header.push('
') body.push('
'); body.push(decodeURIComponent(p.text)); body.push('
'); comments.push('
'); for(var i in p.comments) { var c=p.comments[i]; comments.push('
'); comments.push('
'); var commentdate=new Date(0); commentdate.setUTCSeconds(parseInt(c.date)); comments.push(''); comments.push(decodeURIComponent(c.author)); comments.push(' '); comments.push(commentdate.toString()); comments.push('
'); comments.push(decodeURIComponent(c.text)); comments.push('
'); comments.push('
'); } comments.push('

'); comments.push(''); comments.push(''); comments.push('

'); postsarray[toppost-postnum]='
'+header.join("")+body.join("")+'
'+comments.join("") /*+JSON.stringify(p) */; functionsarray[toppost-postnum]=function() { var requri=[]; requri.push("/newcomment?"); requri.push(getvar("s")); requri.push("&n="+postnum); requri.push("&t="); requri.push(encodeURIComponent(document.getElementById("comment"+(toppost-postnum)).value)); request(requri.join(""),function(r) { refreshpost(postnum); },function() {}); } } function clearpost(postnum) { postsarray[toppost-postnum]=undefined; functionsarray[toppost-postnum]=undefined; } function displayposts() { var contents=[] for(var i=0;iPágina:'); curpage=Math.floor(((Number(lastpost)-Number(toppost))/postsperpage))+1; totalpages=Math.floor((Number(lastpost)-1)/postsperpage)+1; for(var page=1;(Number(lastpost)-(page-1)*postsperpage)>0;page+=inc) { if(Number(toppost)<=(Number(lastpost)-(page-1)*postsperpage) && Number(toppost)>(Number(lastpost)-(page)*postsperpage)) { nav.push(" "+page); } else { nav.push(' 1) { nav.push('&p='); nav.push(Number(toppost)-(page-1)*postsperpage); } nav.push('" class="pagenum">'); nav.push(page); nav.push(''); } if(Math.abs(curpage-page)<5) { inc=1; } else { inc=Math.floor((Math.abs(curpage-page)/totalpages)*maxinc); inc=(inc<=0)?1:inc; if(pagetotalpages) inc=totalpages-page; } } nav.push(' '); nav.push(''); if(toppostPosts más nuevos'); } else nav.push("Posts más nuevos"); nav.push(" | "); if((Number(toppost)-Number(postsperpage))>0) { nav.push(' Posts más antiguos'); } else nav.push('Posts más antiguos'); nav.push(''); document.getElementById("prevnext").innerHTML=nav.join(""); } request("/lastpost?"+getvar("s"),function(r) { var p; lastpost=r; toppost=r p=getvar("p"); if(p.length>2) toppost=Number(p.slice(2)); if(toppost<0 || toppost>lastpost) toppost=lastpost; refreshprevnext(); for(var i=0;i