/* [Discuz!] (C)2001-2099 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: autoloadpage.js 33246 2013-05-09 02:07:17Z kamichen $ */ (function() { var autopbn = $('autopbn'); var nextpageurl = autopbn.getAttribute('rel').valueOf(); var curpage = parseInt(autopbn.getAttribute('curpage').valueOf()); var totalpage = parseInt(autopbn.getAttribute('totalpage').valueOf()); var picstyle = parseInt(autopbn.getAttribute('picstyle').valueOf()); var forumdefstyle = parseInt(autopbn.getAttribute('forumdefstyle').valueOf()); picstyle = picstyle && !forumdefstyle; var autopagenum = 0; var maxpage = (curpage + autopagenum) > totalpage ? totalpage : (curpage + autopagenum); var loadstatus = 0; autopbn.onclick = function() { var oldloadstatus = loadstatus; loadstatus = 2; autopbn.innerHTML = '正在加载, 请稍后...'; getnextpagecontent(); loadstatus = oldloadstatus; }; if(autopagenum > 0) { window.onscroll = function () { var curtop = Math.max(document.documentElement.scrollTop, document.body.scrollTop); if(curtop + document.documentElement.clientHeight + 500 >= document.documentElement.scrollHeight && !loadstatus) { loadstatus = 1; autopbn.innerHTML = '正在加载, 请稍后...'; setTimeout(getnextpagecontent, 1000); } }; } function getnextpagecontent() { if(curpage + 1 > totalpage) { window.onscroll = null; autopbn.style.display = 'none'; return; } if(loadstatus != 2 && curpage + 1 > maxpage) { autopbn.innerHTML = '下一页 »'; if(curpage + 1 > maxpage) { window.onscroll = null; } return; } curpage++; var url = nextpageurl + '&t=' + parseInt((+new Date()/1000)/(Math.random()*1000)); var x = new Ajax('HTML'); x.get(url, function (s) { s = s.replace(/\n|\r/g, ''); if(s.indexOf("id=\"autopbn\"") == -1) { $("autopbn").style.display = "none"; window.onscroll = null; } if(!picstyle) { var tableobj = $('threadlisttableid'); var nexts = s.match(/\
(.+?)\<\/tbody>/g); for(i in nexts) { if(i == 'index' || i == 'lastIndex') { continue; } var insertid = nexts[i].match(//); if(!$('normalthread_' + insertid[1])) { var newbody = document.createElement('tbody'); tableobj.appendChild(newbody); var div = document.createElement('div'); div.innerHTML = '