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.
400 lines
12 KiB
JavaScript
400 lines
12 KiB
JavaScript
//==============
|
|
//切换左边的菜单
|
|
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 Tomore(obj,ismore){
|
|
if(ismore){
|
|
obj.removeClass("more").addClass("unmore");
|
|
} else {
|
|
obj.removeClass("unmore").addClass("more");
|
|
}
|
|
}
|
|
|
|
function showEachAll(o){
|
|
var obj = $(o);
|
|
var tableObj =obj.parents("table").eq(0);
|
|
|
|
if(!obj.attr("c") || obj.attr("c")=="0"){
|
|
var vistr = tableObj.find("tr:visible").attr("so","1");
|
|
var hidetr = tableObj.find("tr:hidden").attr("so","0");
|
|
vistr.last().after(hidetr);
|
|
hidetr.show("normal");
|
|
obj.attr("c","2");$(o).html("Hide");
|
|
} else if(obj.attr("c")=="2"){
|
|
tableObj.find("tr[so='0']").hide("normal");
|
|
obj.attr("c","1");$(o).html("All Classes");
|
|
} else if(obj.attr("c")=="1"){
|
|
tableObj.find("tr[so='0']").show("normal");
|
|
obj.attr("c","2");$(o).html("Hide");
|
|
}
|
|
|
|
|
|
}
|
|
|
|
//Price
|
|
function ftPrice(o){
|
|
$(o).toggleClass(function(){
|
|
if($(this).attr("class")=="select"){return "unselect"}else{return "select"}
|
|
});
|
|
|
|
$("#timeFL dt").each(function(i){if(i==0){$(this).attr("class","select2")}else{$(this).attr("class","unselect2")}});
|
|
$("#AirlineFL dt,#AirportFL dt").attr("class","unselect");
|
|
$("#classSelect span").text($("#subClassSelect li").eq(0).text());
|
|
|
|
ftResult();
|
|
}
|
|
//Airport
|
|
function ftAirport(o){
|
|
$("#priceFL dt").attr("class","unselect");
|
|
if($(o).attr("class")=="select"){
|
|
$(o).attr("class","unselect");
|
|
}else{
|
|
$(o).attr("class","select")
|
|
}
|
|
ftResult();
|
|
}
|
|
//Time
|
|
function ftTime(o){
|
|
$("#priceFL dt").attr("class","unselect");
|
|
$(o).siblings().attr("class","unselect2").end().attr("class","select2");
|
|
ftResult();
|
|
}
|
|
//Airline
|
|
function ftAirline(o){
|
|
$("#priceFL dt").attr("class","unselect");
|
|
if($(o).attr("class")=="select"){
|
|
$(o).attr("class","unselect");
|
|
}else{
|
|
$(o).attr("class","select")
|
|
}
|
|
ftResult();
|
|
}
|
|
|
|
//排序
|
|
function orderClick(Obj){
|
|
if(Obj=="Depart"){
|
|
if($('#flightresult tr:first').find('th').eq(2).find("a").attr("class")=="sortDown"){
|
|
$('#flightresult tr:first').find('th').eq(2).find("a").attr("class","sortUp");
|
|
}else{
|
|
$('#flightresult tr:first').find('th').eq(2).find("a").attr("class","sortDown");
|
|
}
|
|
$('#flightresult tr:first').find('th').eq(6).find("a").attr("class","sortunUp");
|
|
|
|
$('#flightresult tr').eq(0).find('th').eq(1).trigger('click');
|
|
}else if(Obj == "Price"){
|
|
if($('#flightresult tr:first').find('th').eq(6).find("a").attr("class")=="sortDown"){
|
|
$('#flightresult tr:first').find('th').eq(6).find("a").attr("class","sortUp");
|
|
}else{
|
|
$('#flightresult tr:first').find('th').eq(6).find("a").attr("class","sortDown");
|
|
}
|
|
$('#flightresult tr:first').find('th').eq(2).find("a").attr("class","sortunUp");
|
|
$('#flightresult tr').eq(0).find('th').eq(0).trigger('click');
|
|
}
|
|
}
|
|
function ftResult(ar1,ar2,ar3,ar4,ar5){
|
|
$("#notresult").hide();
|
|
o1 = $("#priceFL"); //最低价格
|
|
o2 = $("#AirportFL"); //到达机场
|
|
o3 = $("#timeFL"); //起飞时间
|
|
o4 = $("#AirlineFL"); //航空公司
|
|
o5 = $("#classSelect"); //舱位选择
|
|
var arg1 = "",arg2 = "",arg3 = "",arg4 = "",arg5 = "";
|
|
arg1 = o1.find("dt").filter(".select").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");
|
|
o4.find("dt").filter(".select").each(function(){arg4 = arg4?arg4+=(","+$(this).attr("val")):$(this).attr("val");});
|
|
arg5 = o5.find(">span").text();
|
|
arg1 = ar1?ar1:arg1;
|
|
arg2 = ar2?ar2:arg2;
|
|
arg3 = ar3?ar3:arg3;
|
|
arg4 = ar4?ar4:arg4;
|
|
arg5 = ar5?ar5:arg5;
|
|
//最低价格
|
|
if (typeof arg1 == "undefined"){
|
|
$("#flightresult>tbody>tr").show();
|
|
}else{
|
|
$("#flightresult>tbody>tr").hide();
|
|
$("#flightresult>tbody>tr").filter(
|
|
function(e){
|
|
var re = false;
|
|
$(">td:first", this).each(function(){
|
|
var nv = parseInt($(this).text());
|
|
if(nv==parseInt(arg1)){re = true}
|
|
});
|
|
return re;
|
|
}
|
|
).show();
|
|
}
|
|
//到达机场
|
|
if(arg2 != ""){
|
|
arg2 = arg2.split(",");
|
|
$("#flightresult>tbody>tr:visible").filter(function(e){
|
|
var re=true;
|
|
for(var i=0;i<arg2.length;i++)
|
|
if($(this).attr("airport")==arg2[i]){re = false}
|
|
return re;
|
|
}).hide();
|
|
}
|
|
//起飞时间
|
|
if(arg3 != ""){
|
|
$("#flightresult>tbody>tr:visible").filter(function(e){
|
|
if($(this).attr("time")==arg3){return false}else{return true}
|
|
}).hide();
|
|
}
|
|
//航空公司
|
|
if(arg4 != ""){
|
|
arg4 = arg4.split(",");
|
|
$("#flightresult>tbody>tr:visible").filter(function(e){
|
|
var re=true;
|
|
for(var i=0;i<arg4.length;i++)
|
|
if($(this).attr("airline")==arg4[i]){re = false}
|
|
return re;
|
|
}).hide();
|
|
}
|
|
|
|
|
|
//舱位筛选
|
|
if(arg5!=""){
|
|
var allTbl = $("#flightresult>tbody>tr:visible").find("table.moreDetails table");
|
|
allTbl.each(function(){
|
|
var eTbl = $(this);
|
|
eTbl.find("tr").hide()
|
|
switch(arg5){
|
|
case "Lowest Class":
|
|
case "Flight Class":
|
|
eTbl.find("tr[gclass=lowprice]").prependTo(eTbl).show();
|
|
break;
|
|
case "Economy Class":
|
|
eTbl.find("tr[gclass=Economy]").prependTo(eTbl).show();
|
|
break;
|
|
case "Business Class":
|
|
eTbl.find("tr[gclass=Business]").prependTo(eTbl).show();
|
|
break;
|
|
case "First Class":
|
|
eTbl.find("tr[gclass=First]").prependTo(eTbl).show();
|
|
break;
|
|
}
|
|
});
|
|
}
|
|
//清理没有任务舱位的行
|
|
$("#flightresult>tbody>tr:visible").filter(function(e){
|
|
if($(this).find("table.moreDetails table tr:visible").length<1){return true}else{return false}
|
|
}).hide();
|
|
//最后提示是否存在结果
|
|
if($("#flightresult>tbody>tr:visible").length<1){
|
|
$("#notresult").show();
|
|
}
|
|
$("#flightresult>tbody>tr>td>table>tbody>tr>td>div>span").attr("c","0").html("Show All Classes");
|
|
|
|
|
|
}
|
|
|
|
function showRecommend(){
|
|
$.facebox.settings.opacity=0.5;
|
|
$.facebox.settings.outClose=false;
|
|
var hrefs = "",comm="";
|
|
$(".viewFlight .flightLine").each(function(){hrefs += comm+$(this).attr("href");comm=","});
|
|
$.facebox({ajax:'/china-flights/recomment.asp?hrefs='+hrefs});
|
|
}
|
|
function serialize(id){
|
|
var obj = $("#"+id),comm="",ids="";
|
|
obj.text("");
|
|
$(".viewFlight .flightLine").each(function(){
|
|
ids += comm+$(this).attr("data");
|
|
comm = ",";
|
|
});
|
|
obj.text(ids);
|
|
}
|
|
function checksearchform(theForm){
|
|
var rt=true;
|
|
if($(theForm).find("#price").val() != "3"){
|
|
if($(theForm).find("#startCode1").val()=="NONE"){
|
|
$(theForm).find("#startCode1").focus();rt= false;
|
|
}
|
|
if($(theForm).find("#destinationCode1").val()=="NONE"){
|
|
$(theForm).find("#destinationCode1").focus();rt= false;
|
|
}
|
|
}else{
|
|
if($(theForm).find("#FlightLine").val()=="NONE"){
|
|
$(theForm).find("#FlightLine").focus();rt= false;
|
|
}
|
|
if($(theForm).find("#takeoffDate1").val()==""){
|
|
$(theForm).find("#takeoffDate1").focus();rt= false;
|
|
}
|
|
}
|
|
return rt;
|
|
}
|
|
|
|
function clickPFBTN(o){
|
|
if(o == 'Calendar'){
|
|
$('#placeholder0').show();$('#placeholder,#clickdata').hide();
|
|
$('.pricegraph').removeClass('finderActive');
|
|
$('.priceCalendar').addClass('finderActive');
|
|
}else{
|
|
$('#placeholder0').hide();$('#placeholder,#clickdata').show();
|
|
$('.priceCalendar').removeClass('finderActive');
|
|
$('.pricegraph').addClass('finderActive');
|
|
}
|
|
}
|
|
|
|
function windowsOnload(){
|
|
$('span[id*=CHtipFl]').CHtip({ClassName:"CHtip"});
|
|
$('span[id*=CHtipAP]').CHtip({ClassName:"CHtip"});
|
|
$('span[id*=hisTip]').CHtip({ClassName:"CHtip"});
|
|
$('span[id*=CHtipPr]').CHtip({ClassName:"CHtip"});
|
|
$("#classSelect").click(function(){$("#subClassSelect").toggle();}).hover(function(){},function(){$("#subClassSelect").hide()});
|
|
$("a.close").click(function(){$("div.priceLine,a.close img").toggle();});
|
|
$("#subClassSelect li").click(function(){
|
|
$("#classSelect span").html($(this).text());
|
|
$("#priceFL dt").attr("class","unselect");
|
|
ftResult();
|
|
});
|
|
|
|
$("#flightSearchBox :radio").click(function(){
|
|
$("#flightSearchBox label:last").hide(1);
|
|
if($(this).val()=="2"){
|
|
$("#flightSearchBox label:last").show(1);
|
|
}
|
|
});
|
|
|
|
$("#takeoffDate1").datepicker(
|
|
{showAnim:"fadeIn",duration:0,minDate: 0,maxDate:"2y",numberOfMonths: 2,showButtonPanel: true}
|
|
);
|
|
$("#takeoffDate2").datepicker(
|
|
{showAnim:"fadeIn",duration:0,minDate: 0,maxDate:"2y",numberOfMonths: 2,showButtonPanel: true,onSelect:function(dateStr){
|
|
if(new Date(dateStr).getTime()<new Date($("#takeoffDate1").val()).getTime()){
|
|
$(this).val("123546");
|
|
}
|
|
}}
|
|
);
|
|
|
|
|
|
$("#flightresult").tablesorter({
|
|
headers:{
|
|
2:{sorter: false},
|
|
3:{sorter: false},
|
|
4:{sorter: false},
|
|
5:{sorter: false},
|
|
6:{sorter: false}
|
|
}
|
|
});
|
|
|
|
$('#flightresult tr:first').find('th').eq(6).find("a").trigger('click');
|
|
|
|
$("#price").change(function(){
|
|
if($(this).val()=="3"){
|
|
window.location.href="/intl-flights/";
|
|
}else{
|
|
$("#triptypeDiv").show();
|
|
$(this).parents("form").attr("action","/china-flights/postquery.asp");
|
|
$("#triptypeDiv").find("span").show();
|
|
$("#inlandFlight").show();
|
|
$("#outlandFlight").hide();
|
|
if($(this).val()=="1"){
|
|
$("#startCode1").html(citystr);
|
|
$("#destinationCode1").html(citystr1);
|
|
}else{
|
|
window.location.href="/intl-flights/";
|
|
}
|
|
}
|
|
});
|
|
|
|
var options = {
|
|
lines: { show: true },
|
|
legend: { noColumns: 2 },
|
|
points: { show: true },
|
|
xaxis: { mode: "time",timeSize:[1,"day"]},
|
|
grid: { markings: weekendAreas,hoverable: true, clickable: true},
|
|
selection: { mode: "x" }
|
|
};
|
|
function weekendAreas(axes) {
|
|
var markings = [];
|
|
var d = new Date(axes.xaxis.min);
|
|
// go to the first Saturday
|
|
d.setUTCDate(d.getUTCDate() - ((d.getUTCDay() + 1) % 7))
|
|
d.setUTCSeconds(0);
|
|
d.setUTCMinutes(0);
|
|
d.setUTCHours(0);
|
|
var i = d.getTime();
|
|
do {
|
|
// when we don't set yaxis the rectangle automatically
|
|
// extends to infinity upwards and downwards
|
|
markings.push({ xaxis: { from: i, to: i + 2 * 24 * 60 * 60 * 1000 } });
|
|
i += 7 * 24 * 60 * 60 * 1000;
|
|
} while (i < axes.xaxis.max);
|
|
|
|
return markings;
|
|
}
|
|
var w = function(){
|
|
if($.browser.msie){
|
|
return document.compatMode == "CSS1Compat"? document.documentElement.clientWidth :
|
|
document.body.clientWidth;
|
|
}else{
|
|
return self.innerWidth;
|
|
}
|
|
}
|
|
function showTooltip(x, y, contents) {
|
|
$("#tooltip").remove();
|
|
var o = $('<div id="tooltip">' + contents + '</div>').css( {
|
|
position: 'absolute',
|
|
display: 'none',
|
|
top: y + 5,
|
|
left: x + 5,
|
|
border: '1px solid #fdd',
|
|
padding: '2px',
|
|
'background-color': '#fee',
|
|
opacity: 0.90
|
|
}).appendTo("body").fadeIn(100).end();
|
|
if(x > w()/2){
|
|
var Jx = $("#tooltip").outerWidth();
|
|
$("#tooltip").css("left",x-Jx);
|
|
}
|
|
|
|
}
|
|
|
|
if(typeof data !="undefined"){
|
|
var plot = $.plot($("#placeholder"), [data,lightdata], options);
|
|
}
|
|
|
|
$("#placeholder").bind("plotclick", function (event, pos, item) {
|
|
if (item) {
|
|
window.location.href = links[item.dataIndex];
|
|
//这里改造成链接地址
|
|
//$("#clickdata").text("You clicked point " + item.dataIndex + " in " + item.datapoint + ".");
|
|
}
|
|
});
|
|
var previousPoint = null;
|
|
$("#placeholder").bind("plothover", function (event, pos, item) {
|
|
if (item) {
|
|
if (previousPoint != item.datapoint) {
|
|
previousPoint = item.datapoint;
|
|
var x = parseInt(item.datapoint[0].toFixed(2)),
|
|
y = parseInt(item.datapoint[1].toFixed(2));
|
|
var lowPriceDate = new Date(x);
|
|
showTooltip(item.pageX, item.pageY, "RMB" + y + ", "+lowPriceDate.getDayName()+", "+lowPriceDate.getMonthName(true)+' '+lowPriceDate.getDate()+", "+lowPriceDate.getFullYear());
|
|
//$("#clickdata").text((new Date(x).asString()) + " LowPrice is:RMB" + y + ".");
|
|
}
|
|
} else {
|
|
$("#tooltip").remove();
|
|
previousPoint = null;
|
|
}
|
|
});
|
|
}
|
|
$(function(){
|
|
windowsOnload();
|
|
}); |