train代码

来源:互联网 发布:字符串数组 strstr 编辑:程序博客网 时间:2024/05/01 20:24
var sUrl="http://assistant.mail.yeah.net/assistant/train.do";
function fQueryS2S()
{var from=$("from").value;
if(from.trim()=="")
{alert("请输入出发站");
$("from").focus();
return false;
};
var end=$("end").value;
if(end.trim()=="")
{alert("请输入到达站");
$("end").focus();
return false;
};
var sParam="&op=searchs2s&start=0&size=100&queryFrom="+from+"&queryTo="+end,sExtend="&extend={'op':'searchs2s','from':'"+from+"','to':'"+end+"'}";
fTrainCall(sUrl,"fTrainS2SCallBack",sParam,sExtend);
$("queryDiv").style.display="none";
$("loadDiv").style.display="";
return false;
};
function fQueryStation()
{var station=$("station").value;
if(station.trim()=="")
{alert("请输入要查询的车站");
$("station").focus();
return false;
};
var sParam="&op=searchstation&start=0&size=1000&queryStation="+station;
fTrainCall(sUrl,"fTrainStationCallBack",sParam,"&extend={'op':'searchstation'}");
$("queryDiv").style.display="none";
$("loadDiv").style.display="";
return false;
};
function fQueryNumber()
{var stationNumber=$("number").value;
if(stationNumber.trim()=="")
{alert("请输入要查询的车次");
$("number").focus();
return false;
};
var sParam="&op=searchcheci&start=0&size=100&cls="+stationNumber,sExtend="&extend={'op':'searchcheci','cls':'"+stationNumber+"'}";
fTrainCall(sUrl,"fTrainNumberCallBack",sParam,sExtend);
$("queryDiv").style.display="none";
$("loadDiv").style.display="";
return false;
};
function fGoQuery()
{$("numberDiv").style.display="none";
$("stationDiv").style.display="none";
$("s2sDiv").style.display="none";
$("failDiv").style.display="none";
$("queryDiv").style.display="";
return false;
};
function fTrainCall(sUrl,sEvent,sParams,sExtend,sCharSet)
{sUrl+="?event="+sEvent;
if(sParams)
{sUrl+=sParams;
};
if(sExtend)
{sUrl+=sExtend;
};
sUrl+="&patch="+Date.parse(new Date());
fCommonGetScript(sUrl,"gbk");
};
function fTrainNumberCallBack(nCode,oJson,oExtend)
{var nLength=oJson.length;
if(nCode>=0)
{if(nLength==0)
{$("numCheci").innerHTML=oExtend.cls;
$("numberResultDiv").innerHTML='<div class="Cont hbinfo" >无此车次信息</div>';
$("numberDiv").style.display="";
$("loadDiv").style.display="none";
}else{$("numCheci").innerHTML=oJson[0].cls;
$("numCourse").innerHTML=oJson[0].distant;
$("numTime").innerHTML=oJson[0].duration;
var sHtml='<table class="lieche_tab" cellspacing="0" cellpadding="0"><tr><th>站次</th> <th>站名</th><th>到达时间</th> <th>开车时间</th><th>停留时间</th> <th>行车时间</th><th>里程</th> <th>硬座</th><th>硬卧下</th> <th>软卧下</th></tr>',nLength=oJson[0].detailList.length;
for(var i=0;
i<nLength;
i++)
{var oTrain=oJson[0].detailList[i];
sHtml+='<tr>';
sHtml+='<td title="站次">'+i+"</td>";
sHtml+='<td title="站名">'+oTrain.zhanming+"</td>";
sHtml+='<td title="到达时间">'+oTrain.reachtime+"</td>";
sHtml+='<td title="开车时间">'+oTrain.leavetime+"</td>";
sHtml+='<td title="停留时间">'+oTrain.waitinterval+"</td>";
sHtml+='<td title="行车时间">'+oTrain.duration+"</td>";
sHtml+='<td title="里程">'+oTrain.distant+" 公里</td>";
sHtml+='<td title="硬座"><span class="CEA5E00">'+((oTrain.price_yingzuo&&oTrain.price_yingzuo!=0)?oTrain.price_yingzuo+" 元":"-")+"</span></td>";
sHtml+='<td title="硬卧下价格">'+((oTrain.price_yingwo&&oTrain.price_yingwo!=0)?oTrain.price_yingwo+" 元":"-")+"</td>";
sHtml+='<td title="软卧下价格">'+((oTrain.price_ruanwo&&oTrain.price_ruanwo!=0)?oTrain.price_ruanwo+" 元":"-")+"</td>";
sHtml+='</tr>';
};
$("numberResultDiv").innerHTML=sHtml;
$("numberDiv").style.display="";
$("loadDiv").style.display="none";
};
}else{$("failDiv").style.display="";
$("loadDiv").style.display="none";
};
};
function fTrainStationCallBack(nCode,oJson,oExtend)
{if(nCode>=0)
{var sHtml='<table class="lieche_tab" cellspacing="0" cellpadding="0"><tr><th> 车次</th> <th>列车类型</th><th>起点站—终点站</th> <th>始发时—终点时</th><th>总里程</th> <th>总时间</th><th>停留站</th> <th>到站时间</th><th>停留时间</th></tr>  ',nLength=oJson.length;
for(var i=0;
i<nLength;
i++)
{var oTrain=oJson[i];
if(i==0)
{$("stationName").innerHTML=oTrain.reachstation;
};
sHtml+='<tr id="stationTr'+i+'">';
sHtml+='<td title="车次"><a href="#" onclick="fTrainStationExtend('+i+',false,/''+oTrain.cls+'/');
return false;
" >'+oTrain.cls+"</a></td>";
sHtml+='<td title="列车类型">'+oTrain.type+"</td>";
sHtml+='<td title="起点站—终点站"><a href="#" id="stationHref'+i+'" onclick="fTrainStationExtend('+i+',false,/''+oTrain.cls+'/');
return false;
"class="a_k">'+oTrain.startstation+"-"+oTrain.endstation+"</a></td>";
sHtml+='<td title="始发时—终点时">'+oTrain.starttime+"-"+oTrain.endtime+"</td>";
sHtml+='<td title="总里程">'+oTrain.distant+"</td>";
sHtml+='<td title="总时间">'+oTrain.duration+"</td>";
sHtml+='<td title="停留站">'+oTrain.reachstation+"</td>";
sHtml+='<td title="到站时间">'+oTrain.reachtime+"</td>";
sHtml+='<td title="停留时间">'+oTrain.waitinterval+"</td>";
sHtml+='</tr>';
sHtml+='<tr class="lieche_kcont">';
sHtml+='<td id="station'+i+'" colspan="9" style="display:none"><img src="/assist/res/hbload.gif" /> 正在查询列车数据,请稍候...</td>';
sHtml+='</tr>';
};
$("stationLine").innerHTML=nLength;
$("stationResultDiv").innerHTML=sHtml;
$("stationDiv").style.display="";
$("loadDiv").style.display="none";
}else{$("failDiv").style.display="";
$("loadDiv").style.display="none";
};
};
function fTrainStationExtend(index,bHide,checi)
{var oHref=$("stationHref"+index),oTr=$("stationTr"+index);
if(oHref.className=="a_g")
{$("station"+index).style.display="none";
oHref.className="a_k";
oTr.className="";
return;
};
if(oHref.className=="a_k")
{oHref.className="a_g";
oTr.className="lieche_ktit";
};
var sInnerHtml=$("station"+index).innerHTML;
if(sInnerHtml.toLowerCase().indexOf("<img")==0)
{$("station"+index).style.display="";
var sParam="&op=searchcheci&cls="+checi;
fTrainCall(sUrl,"fTrainStationToNumberCallBack",sParam,"&extend={'op':'searchcheci','index':"+index+"}");
return;
}else{$("station"+index).style.display="";
return;
};
};
function fTrainStationToNumberCallBack(nCode,oJson,oExtend)
{if(nCode>=0)
{var oTrainLine=oJson[0],nLength=oTrainLine.detailList.length,sHtml='<div class="lieche_nei"><strong>'+oTrainLine.cls+'</strong> 次列车详细信息<br /><table class="lieche_nei_tab" cellspacing="0" cellpadding="0"><tr><th>站次</th> <th>站名</th><th>到达时间</th> <th>开车时间</th><th>停留时间</th> <th>行车时间</th><th>里程</th> <th>硬座</th><th>硬卧下</th> <th>软卧下</th></tr>';
for(var i=0;
i<nLength;
i++)
{var oTrain=oTrainLine.detailList[i],sClass="";
if(i%2==1)
{sClass="lc_trbg";
};
sClass+=" lc_trblack";
sHtml+='<tr class="'+sClass+'">';
sHtml+='<td title="站次">'+(i+1)+"</td>";
sHtml+='<td title="站名">'+oTrain.zhanming+"</td>";
sHtml+='<td title="到达时间">'+oTrain.reachtime+"</td>";
sHtml+='<td title="开车时间">'+oTrain.leavetime+"</td>";
sHtml+='<td title="停留时间">'+oTrain.waitinterval+"</td>";
sHtml+='<td title="行车时间">'+oTrain.duration+"</td>";
sHtml+='<td title="里程">'+oTrain.distant+" 公里</td>";
sHtml+='<td title="硬座价格"><span class="CEA5E00">'+((oTrain.price_yingzuo&&oTrain.price_yingzuo!=0)?oTrain.price_yingzuo+" 元":"-")+"</span></td>";
sHtml+='<td title="硬卧下价格">'+((oTrain.price_yingwo&&oTrain.price_yingwo!=0)?oTrain.price_yingwo+" 元":"-")+"</td>";
sHtml+='<td title="软卧下价格">'+((oTrain.price_ruanwo&&oTrain.price_ruanwo!=0)?oTrain.price_ruanwo+" 元":"-")+"</td>";
sHtml+='</tr>';
};
sHtml+='</table><div class="lieche_zk_bot">';
sHtml+='车次:<span>'+oTrainLine.cls+'</span>';
sHtml+='|  全程时间:<span>'+oTrainLine.duration+'</span> ';
sHtml+='|  全程里程:<span>'+oTrainLine.distant+'</span>';
sHtml+='|  乘车里程:<span>'+oTrainLine.passdistant+'</span> <a href="#" onclick="fTrainStationExtend('+oExtend.index+',true);
return false">[收起此列车信息↑]</a></div></div>';
$("station"+oExtend.index).innerHTML=sHtml;
$("station"+oExtend.index).style.display="";
}else{$("failDiv").style.display="";
$("loadDiv").style.display="none";
};
};
var aLastS2STrain;
function fTrainS2SCallBack(nCode,oJson,oExtend)
{if(nCode>=0)
{aLastS2STrain=oJson;
var sHtml='<table class="lieche_tab" cellspacing="0" cellpadding="0"><tr><th> 车次</th> <th>始发站—终点站</th><th>列车类型</th> <th>出发站—目的站</th><th>发车时—到达时</th> <th>乘车时间</th><th>票价</th></tr>  ',nLength=oJson.length;
$("s2sArea").innerHTML=oExtend.from+" - "+oExtend.to;
$("s2sLine").innerHTML=nLength;
for(var i=0;
i<nLength;
i++)
{var oTrain=oJson[i];
sHtml+='<tr id="s2sTr'+i+'">';
sHtml+='<td title="车次"><a href="#" onclick="fTrainS2SExtend('+i+');
return false;
">'+oTrain.cls+"</a></td>";
sHtml+='<td title="始发站—终点站">'+oTrain.startstation+" - "+oTrain.endstation+"</td>";
sHtml+='<td title="列车类型">'+oTrain.type+"</td>";
sHtml+='<td title="出发站—目的站"><a href="#" id="s2sHref'+i+'" onclick="fTrainS2SExtend('+i+');
return false;
" class="a_k">'+oTrain.fromstation+" - "+oTrain.tostation+"</a></td>";
sHtml+='<td title="发车时—到达时">'+oTrain.leavetime+" - "+oTrain.reachtime+"</td>";
sHtml+='<td title="乘车时间">'+(oTrain.passduration?oTrain.passduration:" - ")+"</td>";
sHtml+='<td title="票价">硬座:<span class="Cc00">'+((oTrain.priceyingzuo&&oTrain.priceyingzuo!=0)?oTrain.priceyingzuo:"-")+'</span> 元 | 硬卧下:<span class="Cc00">'+((oTrain.priceyingwodown&&oTrain.priceyingwodown!=0)?oTrain.priceyingwodown:"-")+'</span> 元</td>';
sHtml+='</tr>';
sHtml+='<tr class="lieche_kcont">';
sHtml+='<td id="s2s'+i+'" colspan="7" style="display:none"></td>';
sHtml+='</tr>';
};
$("s2sResultDiv").innerHTML=sHtml;
$("s2sDiv").style.display="";
$("loadDiv").style.display="none";
}else{$("failDiv").style.display="";
$("loadDiv").style.display="none";
};
};
function fTrainS2SExtend(index,bHide)
{var oHref=$("s2sHref"+index),oTr=$("s2sTr"+index);
if(oHref.className=="a_g")
{$("s2s"+index).style.display="none";
oHref.className="a_k";
oTr.className="";
return;
};
if(oHref.className=="a_k")
{oHref.className="a_g";
oTr.className="lieche_ktit";
};
if($("s2s"+index).innerHTML!="")
{$("s2s"+index).style.display="";
return;
};
var oTrainLine=aLastS2STrain[index],nLength=oTrainLine.detailList.length,sHtml='<div class="lieche_nei"><strong>'+oTrainLine.cls+'</strong> 次列车详细信息<br /><table class="lieche_nei_tab" cellspacing="0" cellpadding="0"><tr><th>站次</th> <th>站名</th><th>到达时间</th> <th>开车时间</th><th>停留时间</th> <th>行车时间</th><th>里程</th> <th>硬座</th><th>硬卧下</th> <th>软卧下</th></tr>',bBlack=false;
for(var i=0;
i<nLength;
i++)
{var oTrain=oTrainLine.detailList[i],sClass="";
if(i%2==1)
{sClass="lc_trbg";
};
if(oTrainLine.fromstation==oTrain.zhanming)
{bBlack=true;
};
if(bBlack)
{sClass+=" lc_trblack";
};
if(sClass)
{sHtml+='<tr class="'+sClass+'">';
}else{sHtml+='<tr>';
};
if(oTrainLine.tostation==oTrain.zhanming)
{bBlack=false;
};
sHtml+='<td title="站次">'+oTrain.zhanci+"</td>";
sHtml+='<td title="站名">'+oTrain.zhanming+"</td>";
sHtml+='<td title="到达时间">'+oTrain.reachtime+"</td>";
sHtml+='<td title="开车时间">'+oTrain.leavetime+"</td>";
sHtml+='<td title="停留时间">'+oTrain.waitinterval+"</td>";
sHtml+='<td title="行车时间">'+oTrain.duration+"</td>";
sHtml+='<td title="里程">'+oTrain.distant+" 公里</td>";
sHtml+='<td title="硬座价格">'+(oTrain.price_yingzuo&&oTrain.price_yingzuo!=0?oTrain.price_yingzuo+" 元":"-")+"</td>";
sHtml+='<td title="硬卧下价格">'+(oTrain.price_yingwo&&oTrain.price_yingwo!=0?oTrain.price_yingwo+" 元":"-")+"</td>";
sHtml+='<td title="软卧下价格">'+(oTrain.price_ruanwo&&oTrain.price_ruanwo!=0?oTrain.price_ruanwo+" 元":"-")+"</td>";
sHtml+='</tr>';
};
sHtml+='</table><div class="lieche_zk_bot">';
sHtml+='车次:<span>'+oTrainLine.cls+'</span>';
sHtml+='|  全程时间:<span>'+oTrainLine.duration+'</span> ';
sHtml+='|  全程里程:<span>'+oTrainLine.distant+'</span>';
sHtml+='|  乘车里程:<span>'+oTrainLine.passdistant+'</span> <a href="#" onclick="fTrainS2SExtend('+index+',true);
return false">[收起此列车信息↑]</a></div></div>';
$("s2s"+index).innerHTML=sHtml;
$("s2s"+index).style.display="";
};
原创粉丝点击