You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

74 lines
2.1 KiB
JavaScript

/*
Script page:$newActivies.js
author :Wushitang
create date:20110217
last modified:20110217 By Wushitang
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ⱥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾЧ<EFBFBD><EFBFBD>
*/
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\/##/g,"##");
matchs = tmpStr.match(reg);
for(var tagKey in matchs){
if(tagKey =='input' || tagKey =='index' ||tagKey =='lastIndex' ) continue;//<2F><><EFBFBD><EFBFBD>IE<49><45>FF<46><46><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
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 &&currentNum<=MaxNum){
GetActivitesItem();
}
}