/* Script page:$newActivies.js author :Wushitang create date:20110217 last modified:20110217 By Wushitang 描述:用户中心群组首页最近更新逐步显示效果 */ var MaxNum=20; //At most 20 record. var currentNum = 1; //current record. var NextNum = currentNum; //allow the next record var defaultNum = 5; //At the beginning loading five records. var conntinu = true; var LastTimeStory, LastTimePhoto, LastTimeFaq; $(document).ready(function(){ NextNum = defaultNum; GetActivitesItem(); $(window).scroll(function (){continuShow()}); }); function GetActivitesItem(){ SN = "s"+LastTimeStory+",p"+LastTimePhoto+",f"+LastTimeFaq; $.ajax({ type: "GET", url: "/community/usercp.asp?cp=newActivities", dataType: "xml", data: "SN2="+SN, beforeSend:function(){conntinu = false;}, success: successFunction }); } function successFunction(data, textStatus){ var tb = $(data).find("root>tb").text(); var Obj = $("#template"+tb).clone(); //get the template object var tmpStr = Obj.html(); var reg = /##[a-zA-Z]+##/g; //in concordance with IE 6 OR sougo browse //tmpStr = tmpStr.replace(/http:\/\/localhost\/community\/user\/##/g,"##"); tmpStr = tmpStr.replace(/http:\/\/www.chinahighlights.com\/community\/user\/chtList.asp##/g,"##"); matchs = tmpStr.match(reg); for(var tagKey in matchs){ if(tagKey =='input' || tagKey =='index' ||tagKey =='lastIndex' ) continue;//兼容IE与FF而做的判断 var tag = matchs[tagKey]; var Ctag= tag.match(/[a-zA-Z]+/g)[0]; var srcstr = $(data).find("root>"+Ctag).text(); tmpStr = tmpStr.replace(tag,srcstr,"g"); } Obj.html("").attr("id","#template"+tb+currentNum).html(tmpStr).appendTo("#newActivities").show(100); currentNum++; LastTimeStory = $(data).find("root>LastTimeStory").text(); LastTimePhoto = $(data).find("root>LastTimePhoto").text(); LastTimeFaq = $(data).find("root>LastTimeFaq").text(); if(currentNum <= defaultNum ){ GetActivitesItem(); }else{ conntinu = true; } //continuShow(); } function continuShow(){ if($(window).scrollTop() + $(window).height()+300 > $(document).height() && conntinu &¤tNum<=MaxNum){ GetActivitesItem(); } }