?? train.js
字號:
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="";};
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -