8,906
社区成员
发帖
与我相关
我的任务
分享
var tablexml = new ActiveXObject("Microsoft.XMLDOM");
tablexml.async = false;
var tablexsl = new ActiveXObject("Microsoft.XMLDOM");
tablexsl.async = false;
//一个加载临时的xml文件
var showxml = new ActiveXObject("Microsoft.XMLDOM");
showxml.async = false;
var doc ;
var delxml ;
/**升序和降序的控制*/
var bol = true;
//每页显示的记录数
var onePageNum=0;
var count = 0;//每次取的记录数量 10*onePageNum
var curPageNum=0; //当前翻到的页数
var totalPageNum;//总页数
var recordNum;//展现的记录数量(需要后台提供)
//当前总的记录数量,不是前台展现的,是实际页面保存的记录数量,一般是10*onePageNum
var currentTotalPageNum ;
//请求的页码数量(数据不是一次性读取,而是先取10*onePageNum 条,然后根据翻到的页数决定再先后台要对应的量)
var requestPage = 0;
var pris=null;//价格筛选条件
var facilitys="";//设施服务筛选条件
function init(priceScope){
//初始化默认值
onePageNum=5;
count = 0
curPageNum=1
requestPage = 1;
tableDisplay(priceScope);
}
function tableDisplay(price){
tablexml.load("../demo/hotelSearch.xml");//加载xml文件
//加载临时的xml文件
showxml.load("../demo/hotelSearch1.xml");
// tablexml.load("language.xml");//加载xml文件
tablexsl.load("/ECS/modules/holiday/hotel/style/xsl/hotelShow.xsl");//加载xsl文件
//表格分页计算
Paging(price);
pageShow();
}
/**表格分页计算*/
function Paging(pri){
pris=pri;//把传进来的价格的筛选条件赋值
var root;
if(pri==null){
root = tablexml.selectNodes("page/hotelInfos/hotelInfo");
}else{
rootTemp=showxml.getElementsByTagName("page/hotelInfos");
if(pri=='400以下'){
root = tablexml.selectNodes("page/hotelInfos/hotelInfo[0<price and price<400]");
for(var i=0;i<root.length;i++){
rootTemp[0].appendChild(root[i]);
}
}else if(pri=='400-700'){
root = tablexml.selectNodes("page/hotelInfos/hotelInfo[price>400 and price<700]");
for(var i=0;i<root.length;i++){
rootTemp[0].appendChild(root[i]);
}
}else if(pri=='700-1000'){
root = tablexml.selectNodes("page/hotelInfos/hotelInfo[price>700 and price<1000]");
for(var i=0;i<root.length;i++){
rootTemp[0].appendChild(root[i]);
}
}else if(pri=='1000-1500'){
root = tablexml.selectNodes("page/hotelInfos/hotelInfo[price >1000 and price<1500]");
for(var i=0;i<root.length;i++){
rootTemp[0].appendChild(root[i]);
}
}else if(pri=='1500以上'){
root = tablexml.selectNodes("page/hotelInfos/hotelInfo[price>1500]");
for(var i=0;i<root.length;i++){
rootTemp[0].appendChild(root[i]);
}
}
if(rootTemp){
currentTotalPageNum=rootTemp.length;
}else{
currentTotalPageNum=0;
}
}
if(facilitys!=""){
var facility=facilitys.split(",");
rootTemp=showxml.getElementsByTagName("page/hotelInfos");
if(facility.length==1){
root = tablexml.selectNodes("page/hotelInfos/hotelInfo/establishs/establish[name='"+facility[0]+"']");
for(var j=0;j<root.length;j++){
rootTemp[0].appendChild(root[j]);
}
}else if(facility.length==2){
root = tablexml.selectNodes("page/hotelInfos/hotelInfo/establishs/establish[name='"+facility[0]+" and name="+facility[1]+"']");
for(var j=0;j<root.length;j++){
rootTemp[0].appendChild(root[j]);
}
}else if(facility.length==3){
root = tablexml.selectNodes("page/hotelInfos/hotelInfo/establishs/establish[name='"+facility[0]+" and name="+facility[1]+" and name="+facility[2]+"']");
for(var j=0;j<root.length;j++){
rootTemp[0].appendChild(root[j]);
}
}else if(facility.length==4){
root = tablexml.selectNodes("page/hotelInfos/hotelInfo/establishs/establish[name='"+facility[0]+" and name="+facility[1]+" and name="+facility[2]+" and name="+facility[3]+"']");
for(var j=0;j<root.length;j++){
rootTemp[0].appendChild(root[j]);
}
}else if(facility.length==5){
root = tablexml.selectNodes("page/hotelInfos/hotelInfo/establishs/establish[name='"+facility[0]+" and name="+facility[1]+" and name="+facility[2]+" and name="+facility[3]+" and name="+facility[4]+"']");
for(var j=0;j<root.length;j++){
rootTemp[0].appendChild(root[j]);
}
}else if(facility.length==6){
root = tablexml.selectNodes("page/hotelInfos/hotelInfo/establishs/establish[name='"+facility[0]+" and name="+facility[1]+" and name="+facility[2]+" and name="+facility[3]+" and name="+facility[4]+" and name="+facility[5]+"']");
for(var j=0;j<root.length;j++){
rootTemp[0].appendChild(root[j]);
}
}
if(rootTemp){
currentTotalPageNum=rootTemp.length;
}else{
currentTotalPageNum=0;
}
}
if(root){
currentTotalPageNum = root.length;
}else{
currentTotalPageNum = 0;
}
recordNum=currentTotalPageNum;//取总记录数
//priceScreen(root,pri);//调用价格筛选条件
var total = document.getElementById("totalData");
total.innerHTML=recordNum;
//recordNum = tablexml.selectSingleNode("//@linesum").value;//@linesum:是取的xml里面一个属性的值。
for(i=1;i<(recordNum/onePageNum);i++);//循环1到(总记录数/分页大小的值)
totalPageNum = i;
var price="";
//===================重新分页=======================
sortField=tablexsl.selectSingleNode("//@test");//取xsl里面属性是test的值
firstNum=onePageNum*(curPageNum-((requestPage-1)*10)-1)+1;//分页大小*(当前页-((请求页码的数量-1)*10)-1)+1
lastNum=onePageNum*(curPageNum-((requestPage-1)*10)-1)+onePageNum;//分页大小*(当前页-((请求页码的数量-1)*10)-1)+分页大小
text="position()>="+firstNum+" and position()<="+lastNum;
sortField.value=text;
//==========================================
if(pri==null || facilitys!=""){
listLayer.innerHTML=tablexml.transformNode(tablexsl);//用提供的样式,显示xml.输出到HTMl
}else{
listLayer.innerHTML=showxml.transformNode(tablexsl);//用提供的样式,显示xml.输出到HTMl
}
//document.all.totalRecords.innerHTML=recordNum;
document.all.curPage.innerHTML=curPageNum;
document.all.totalPageNum.innerHTML=totalPageNum;
//document.all.onePageNum.innerHTML=onePageNum;
}
/**添加页数的显示*/
function pageShow(){
//var pageStr = "";
var pageStr1 = "";
var showpage = 0;
if(totalPageNum <10)
showpage = totalPageNum;
else if((totalPageNum - (requestPage-1)*10)< 10)//总页数-(请求页数-1)*10<10
showpage = totalPageNum - (requestPage-1)*10;
else if((totalPageNum - (requestPage-1)*10)> 10)
showpage = totalPageNum - (requestPage-1)*10;
else
showpage = 10;
// for(var j=0;j<showpage;j++){
// pageStr = pageStr + " <a style='font-size: 16px;font-weight: bold;' href='javascript:pages1("+(j+1+(Number(requestPage)-1)*10)+");'>"+(j+1+(Number(requestPage)-1)*10)+"</a>";
// }
var start=Number(curPageNum-requestPage);
var end=parseInt(curPageNum+requestPage);
if(start==showpage && showpage==1){
start=1;
}else if(end==showpage){
end=showpage;
}
//pageStr = " <a style='font-size: 16px;font-weight: bold;' href='javascript:pages1("+start+");'>«</a>" +
//pageStr
// + " <a style='font-size: 16px;font-weight: bold;' href='javascript:pages1("+end+");'>»</a>";
pageStr1 = " <img src='../../../common/images/holiday/hotel/images/shy.gif' onclick='pages1("+start+");'>" +
pageStr1 + " <img src='../../../common/images/holiday/hotel/images/xia.gif' onclick='pages1("+end+");'/>";
//document.all.pageStr.innerHTML=pageStr;
document.all.pageStr1.innerHTML=pageStr1;
}