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.
389 lines
12 KiB
JavaScript
389 lines
12 KiB
JavaScript
6 years ago
|
// JavaScript Document
|
||
|
$(document).ready(function(e) {
|
||
|
$("#loading").hide();
|
||
|
$(".flyloading").remove();
|
||
|
$(".relinfo").show();
|
||
|
lowestcss();
|
||
|
$(".flightstop").tablesorter({widthFixed: true}).tablesorterPager({container: $("#mypager"),size:1});
|
||
|
$(".intelFlight").tablesorter({sortList:[[5,0]],cssAsc: "sortDown",cssDesc: "sortUp"});
|
||
|
if(parseInt($("#totalpage").html())==1){$(".prev").hide;$(".next").hide()};
|
||
|
var utcdeparture=$('.utcdeparture').html();
|
||
|
if(utcdeparture!=='' && typeof utcdeparture != 'undefined'){$(".utcdeparture").html('('+getUTCdate(utcdeparture)+')')}
|
||
|
var utcreturn=$('.utcreturn').html();
|
||
|
if(utcreturn!='' && typeof utcreturn != 'undefined'){$(".utcreturn").html('('+getUTCdate(utcreturn)+')')};
|
||
|
var utcmreturn=$('.utcmreturn').html();
|
||
|
if(utcmreturn!='' && typeof utcmreturn != 'undefined'){$(".utcmreturn").html('('+getUTCdate(utcmreturn)+')')};
|
||
|
$(".futcdate").each(function() {
|
||
|
var ut=getUTCdate($(this).html());
|
||
|
$(this).html(ut)
|
||
|
});
|
||
|
dfradio();
|
||
|
if(isFirefox=navigator.userAgent.indexOf("Firefox")>0){$('.ffonly').addClass('flightcode')}
|
||
|
NumStop();
|
||
|
resultCity();
|
||
|
gotop();
|
||
|
});
|
||
|
function resultCity()
|
||
|
{
|
||
|
var ca=$(".dpcity").html();var cb=$(".dtcity").html();var cc=$(".rfcity").html();var cd=$(".rtcity").html()
|
||
|
$(".dpc").html(ca);
|
||
|
$(".dtc").html(cb);
|
||
|
$(".rfc").html(cc);
|
||
|
$(".rtc").html(cd);
|
||
|
}
|
||
|
//goTop
|
||
|
function gotop()
|
||
|
{
|
||
|
var $backToTopTxt = "Top", $backToTopEle = $('<div class="backToTop"></div>').appendTo($("body"))
|
||
|
.text($backToTopTxt).attr("title", $backToTopTxt).click(function() {
|
||
|
$("html, body").animate({ scrollTop: 0 }, 120);
|
||
|
}), $backToTopFun = function() {
|
||
|
var st = $(document).scrollTop(), winh = $(window).height();
|
||
|
(st > 0)? $backToTopEle.show(): $backToTopEle.hide();
|
||
|
//IE6下的定位
|
||
|
if (!window.XMLHttpRequest) {
|
||
|
$backToTopEle.css("top", st + winh - 166);
|
||
|
}
|
||
|
};
|
||
|
$(window).bind("scroll", $backToTopFun);
|
||
|
$(function() { $backToTopFun(); });
|
||
|
}
|
||
|
//设置与lowest相等的单元格样式
|
||
|
function lowestcss()
|
||
|
{
|
||
|
var nonlow=$(".nonlow").html();var onelow=$(".onelow").html();var twolow=$(".twolow").html()
|
||
|
$(".islow").each(function() {
|
||
|
var thislow=$(this).html();
|
||
|
if(thislow==nonlow || thislow==onelow || thislow==twolow)
|
||
|
{
|
||
|
$(this).attr("class","low")
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
//
|
||
|
function NumStop()
|
||
|
{
|
||
|
var non=parseInt($("#stnon").html());var one=parseInt($("#stone").html());var two=parseInt($("#sttwo").html());
|
||
|
if(non==0){$("#snon").hide(); $("#stonon").attr("onclick",""); $("#stonon").attr("title","non flight");}
|
||
|
if(one==0){$("#sone").hide(); $("#stoone").attr("onclick",""); $("#stoone").attr("title","non flight");}
|
||
|
if(two==0){$("#stwo").hide(); $("#stotwo").attr("onclick",""); $("#stotwo").attr("title","non flight");}
|
||
|
}
|
||
|
//搜索框默认选择oneway/roundtrip/multicities
|
||
|
function dfradio()
|
||
|
{
|
||
|
var dfr=$("#rflytype").html();
|
||
|
if(dfr=='oneway'){$('.onetype').click()}else if(dfr=='roundtrip'){$('.roundtype').click()}else if(dfr=="multicities"){$('.multitype').click()}
|
||
|
}
|
||
|
//切换左边的菜单
|
||
|
function Togle(obj,id,callback){
|
||
|
var mObj = $(obj);
|
||
|
var isHiden = true;
|
||
|
var sObj = $("#"+id);
|
||
|
if(sObj.is(":hidden")){
|
||
|
sObj.slideDown("slow");
|
||
|
isHiden = false;
|
||
|
mObj.removeClass("filtercategoryclose").addClass("filtercategory");
|
||
|
}else{
|
||
|
sObj.slideUp("slow");
|
||
|
mObj.removeClass("filtercategory").addClass("filtercategoryclose");
|
||
|
}
|
||
|
if(typeof callback != 'undefined'){
|
||
|
callback(mObj,isHiden);
|
||
|
}
|
||
|
}
|
||
|
//显示或隐藏航程详情
|
||
|
function FlightDetial(DoClass)
|
||
|
{ var tempPartent=DoClass.replace("SD","DoSD");
|
||
|
if($('.'+DoClass).is(":hidden"))
|
||
|
{
|
||
|
$('.'+tempPartent).html('Hide Flight Details')
|
||
|
$('.'+tempPartent).attr('title','Click to Hide Flight Details')
|
||
|
$('.'+DoClass).show()
|
||
|
}else
|
||
|
{
|
||
|
$('.'+tempPartent).html('Show Flight Details')
|
||
|
$('.'+tempPartent).attr('title','Click to Show Flight Details')
|
||
|
$('.'+DoClass).hide()
|
||
|
}
|
||
|
}
|
||
|
//显示或隐藏机场信息
|
||
|
function showairport(DoClass)
|
||
|
{
|
||
|
if($('.'+DoClass).is(":hidden"))
|
||
|
{
|
||
|
$('.'+DoClass).show()
|
||
|
}else{
|
||
|
$('.'+DoClass).hide()
|
||
|
}
|
||
|
}
|
||
|
//排序功能样式
|
||
|
function doSort(Did)
|
||
|
{
|
||
|
$('#'+Did).click();
|
||
|
var tem=$("#"+Did).attr("class");
|
||
|
temarr=tem.split(' ');
|
||
|
thiscss=temarr[2];
|
||
|
$('.sortTable a').attr("class","sortunUp")
|
||
|
if(Did=="Departure"){
|
||
|
$('.sortTable tr:first').find('td').eq(1).find('a').attr("class",thiscss);
|
||
|
}else if(Did=="Arrival"){
|
||
|
$('.sortTable tr:first').find('td').eq(2).find('a').attr("class",thiscss);
|
||
|
}else if(Did=="Stops"){
|
||
|
$('.sortTable tr:first').find('td').eq(3).find('a').attr("class",thiscss);
|
||
|
}else if(Did=="Duration"){
|
||
|
$('.sortTable tr:first').find('td').eq(4).find('a').attr("class",thiscss);
|
||
|
}else if(Did=="sPrice"){
|
||
|
$('.sortTable tr:first').find('td').eq(5).find('a').attr("class",thiscss);
|
||
|
}
|
||
|
}
|
||
|
//显示所有航班
|
||
|
function ftshowall()
|
||
|
{
|
||
|
resetdepartureTime();
|
||
|
resetsegment();
|
||
|
allairline('clear');
|
||
|
$("#notresult").hide();
|
||
|
$("#intelFlight>tbody>tr").show();
|
||
|
$("#ftsult").html($("#intelFlight>tbody>tr:visible").length)
|
||
|
$("#showall").hide();
|
||
|
}
|
||
|
//右侧中转次数
|
||
|
function ftTransit(o)
|
||
|
{
|
||
|
$("#numberStop dt").attr("class","unselect");
|
||
|
$(o).siblings().attr("class","unselect2").end().attr("class","select2");
|
||
|
ftResult();
|
||
|
}
|
||
|
//Departure Time
|
||
|
function DTime(o)
|
||
|
{
|
||
|
$("#departuretime dt").attr("class","unselect");
|
||
|
$(o).siblings().attr("class","unselect2").end().attr("class","select2");
|
||
|
ftResult();
|
||
|
}
|
||
|
|
||
|
//头部中转次数
|
||
|
function ftHTransit(seg)
|
||
|
{
|
||
|
resetdepartureTime();
|
||
|
$("#notresult").hide();
|
||
|
$("#intelFlight>tbody>tr").show();
|
||
|
$("#intelFlight>tbody>tr:visible").filter(function(e){
|
||
|
if($(this).attr("seg")==seg){return false}else{return true}
|
||
|
}).hide();
|
||
|
if($("#intelFlight>tbody>tr:visible").length<1){
|
||
|
$("#notresult").show();
|
||
|
}
|
||
|
$("#ftsult").html($("#intelFlight>tbody>tr:visible").length)
|
||
|
$("#showall").show();
|
||
|
stopcss(seg);
|
||
|
airlinecss(seg);
|
||
|
}
|
||
|
//头部航空公司+经停
|
||
|
function ftTopTransit(seg,airline)
|
||
|
{
|
||
|
resetdepartureTime();
|
||
|
$("#notresult").hide();
|
||
|
$("#intelFlight>tbody>tr").show();
|
||
|
$("#intelFlight>tbody>tr:visible").filter(function(e){
|
||
|
if($(this).attr("seg")==seg && $(this).attr("airline")==airline){return false}else{return true}
|
||
|
}).hide();
|
||
|
if($("#intelFlight>tbody>tr:visible").length<1){
|
||
|
$("#notresult").show();
|
||
|
}
|
||
|
$("#ftsult").html($("#intelFlight>tbody>tr:visible").length)
|
||
|
$("#showall").show();
|
||
|
airlinecss(airline);
|
||
|
stopcss(seg);
|
||
|
}
|
||
|
//最低价格+中转
|
||
|
function ftlowestprice(price,seg)
|
||
|
{
|
||
|
resetdepartureTime();
|
||
|
$("#notresult").hide();
|
||
|
$("#intelFlight>tbody>tr").show();
|
||
|
$("#intelFlight>tbody>tr:visible").filter(function(e){
|
||
|
if(parseInt($(this).attr("totalprice"))==parseInt(price)){return false}else{return true}
|
||
|
}).hide();
|
||
|
//最后提示是否存在结果
|
||
|
if($("#intelFlight>tbody>tr:visible").length<1){
|
||
|
$("#notresult").show();
|
||
|
}
|
||
|
$("#ftsult").html($("#intelFlight>tbody>tr:visible").length)
|
||
|
$("#showall").show();
|
||
|
airlinecss(seg);
|
||
|
stopcss(seg);
|
||
|
}
|
||
|
//Airline
|
||
|
function ftAirline(o){
|
||
|
//resetsegment();
|
||
|
if($(o).attr("class")=="select"){
|
||
|
$(o).attr("class","unselect");
|
||
|
}else{
|
||
|
$(o).attr("class","select")
|
||
|
}
|
||
|
ftResult();
|
||
|
}
|
||
|
//Header Airline
|
||
|
function Hairline(strcode)
|
||
|
{
|
||
|
$("#notresult").hide();
|
||
|
$("#intelFlight>tbody>tr").show();
|
||
|
$("#intelFlight>tbody>tr:visible").filter(function(e){
|
||
|
var re=true;
|
||
|
if($(this).attr("airline")==strcode){re = false}
|
||
|
return re;
|
||
|
}).hide();
|
||
|
if($("#intelFlight>tbody>tr:visible").length<1){
|
||
|
$("#notresult").show();
|
||
|
}
|
||
|
$("#ftsult").html($("#intelFlight>tbody>tr:visible").length)
|
||
|
$("#showall").show();
|
||
|
airlinecss(strcode);
|
||
|
resetsegment();
|
||
|
resetdepartureTime();
|
||
|
}
|
||
|
function ftResult(ar1,ar2,ar3,ar4)
|
||
|
{
|
||
|
$("#notresult").hide()
|
||
|
o1=$("#numberStop"); //中转次数
|
||
|
o2=$("#airlineName"); //航空公司
|
||
|
o3=$("#departuretime"); //时间
|
||
|
var arg1 = "",arg2 = "",arg3 = "",arg4 = "",arg5 = "",mintime="",maxtime="",minarrival="",maxarrival="";
|
||
|
arg1 = o1.find("dt").filter(".select2").attr("val");
|
||
|
o2.find("dt").filter(".select").each(function(){arg2 = arg2?arg2+=(","+$(this).attr("val")):$(this).attr("val");});
|
||
|
arg3=o3.find("dt").filter(".select2").attr("val");
|
||
|
arg1 = ar1?ar1:arg1;
|
||
|
arg2 = ar2?ar2:arg2;
|
||
|
arg3 = ar3?ar3:arg3;
|
||
|
$("#intelFlight>tbody>tr").show(); //显示所有行
|
||
|
//中转次数
|
||
|
if(arg1 != "" && typeof arg1 != "undefined"){
|
||
|
$("#intelFlight>tbody>tr:visible").filter(function(e){
|
||
|
if($(this).attr("seg")==arg1){return false}else{return true}
|
||
|
}).hide();
|
||
|
}
|
||
|
//航空公司
|
||
|
if(arg2 !== ""){
|
||
|
arg2 = arg2.split(",");
|
||
|
$("#intelFlight>tbody>tr:visible").filter(function(e){
|
||
|
var re=true;
|
||
|
for(var i=0;i<arg2.length;i++)
|
||
|
if($(this).attr("airline")==arg2[i]){re = false}
|
||
|
return re;
|
||
|
}).hide();
|
||
|
}
|
||
|
//起飞时间
|
||
|
if(arg3 != "" && typeof arg3 != "undefined"){
|
||
|
$("#intelFlight>tbody>tr:visible").filter(function(e){
|
||
|
if($(this).attr("departuretime")==arg3){return false}else{return true}
|
||
|
}).hide();
|
||
|
}
|
||
|
//最后提示是否存在结果
|
||
|
if($("#intelFlight>tbody>tr:visible").length<1){
|
||
|
$("#notresult").show();
|
||
|
}
|
||
|
$("#ftsult").html($("#intelFlight>tbody>tr:visible").length)
|
||
|
if($("#intelFlight>tbody>tr:visible").length!=parseInt($("#total").html()))
|
||
|
{
|
||
|
$("#showall").show();
|
||
|
}else{
|
||
|
$("#showall").hide();
|
||
|
}
|
||
|
}
|
||
|
//全选或清除航空公司 //结果均显示所有的航空公司
|
||
|
function allairline(sval)
|
||
|
{
|
||
|
//$('.sortTable a').attr("class","sortunUp")
|
||
|
if(sval=="all"){
|
||
|
$("#airlineName dt").attr("class","select")
|
||
|
}else if(sval=="clear"){
|
||
|
$("#airlineName dt").attr("class","unselect")
|
||
|
}
|
||
|
$("#airlineName dt").eq(0).attr("class","choice")
|
||
|
ftResult();
|
||
|
}
|
||
|
//Airline样式关联
|
||
|
function airlinecss(str)
|
||
|
{
|
||
|
$("#airlineName dt").attr("class","unselect")
|
||
|
$("#airlineName dt").eq(0).attr("class","choice")
|
||
|
$("#airlineName dt").each(function() {
|
||
|
if($(this).attr("val")==str){$(this).attr("class","select")}
|
||
|
});
|
||
|
}
|
||
|
//Stop样式关联
|
||
|
function stopcss(seg)
|
||
|
{
|
||
|
$("#numberStop dt").attr("class","unselect2");
|
||
|
$("#numberStop dt").each(function() {
|
||
|
if($(this).attr("val")==seg){$(this).attr("class","select2")}
|
||
|
});
|
||
|
}
|
||
|
//重置日期区间
|
||
|
function resetdepartureTime()
|
||
|
{
|
||
|
$("#departuretime dt").attr("class","unselect2")
|
||
|
$("#alltime").attr("class","select2")
|
||
|
}
|
||
|
//重置经停
|
||
|
function resetsegment()
|
||
|
{
|
||
|
$("#numberStop dt").attr("class","unselect2");
|
||
|
$("#segall").attr("class","select2");
|
||
|
}
|
||
|
//检查当前页(头部经停翻页)
|
||
|
function chkpage(str)
|
||
|
{
|
||
|
var current=parseInt($("#currentpage").html());
|
||
|
var total=parseInt($("#totalpage").html());
|
||
|
if (current>total)
|
||
|
{current==total}
|
||
|
if(str=='next'){
|
||
|
$("#currentpage").html(current+1);
|
||
|
if(current+1>=total){$("#currentpage").html(total);$(".next").hide();$(".prev").show();}else{$(".next").show();$(".prev").show();}
|
||
|
}else if(str=='prev'){
|
||
|
$("#currentpage").html(current-1);
|
||
|
if(current-1<=1){$("#currentpage").html(1);$(".prev").hide();$(".next").show();}else{$(".next").show();$(".prev").show();}
|
||
|
}
|
||
|
}
|
||
|
//格式化时间格式为星期,日期显示(eg.Thu, Dec 06, 2012.参数格式mm/dd/yyyy)
|
||
|
function getUTCdate(str)
|
||
|
{
|
||
|
var weekday=new Array(7)
|
||
|
weekday[0]="Sun";
|
||
|
weekday[1]="Mon";
|
||
|
weekday[2]="Tue";
|
||
|
weekday[3]="Wed";
|
||
|
weekday[4]="Thu";
|
||
|
weekday[5]="Fri";
|
||
|
weekday[6]="Sat";
|
||
|
var month=new Array(12)
|
||
|
month[0]="Jan";
|
||
|
month[1]="Feb";
|
||
|
month[2]="Mar";
|
||
|
month[3]="Apr";
|
||
|
month[4]="May";
|
||
|
month[5]="Jun";
|
||
|
month[6]="Jul";
|
||
|
month[7]="Aug";
|
||
|
month[8]="Sep";
|
||
|
month[9]="Oct";
|
||
|
month[10]="Nov";
|
||
|
month[11]="Dec";
|
||
|
if(str!="" && typeof str!='undefined' && str!= null && str.indexOf("/")>0)
|
||
|
{
|
||
|
var d=new Date(str)
|
||
|
m=str.split("/")[0];
|
||
|
day=str.split("/")[1];
|
||
|
y=str.split("/")[2];
|
||
|
var nd=weekday[d.getDay()]+', '+month[d.getMonth()]+' '+day+' '+y;
|
||
|
return nd;
|
||
|
}
|
||
|
}
|
||
|
//平滑滚动锚点
|
||
|
function Anchor(did)
|
||
|
{
|
||
|
$("html,body").animate({scrollTop: $("#"+did).offset().top}, 1000);
|
||
|
}
|