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.
174 lines
5.2 KiB
JavaScript
174 lines
5.2 KiB
JavaScript
//Javascript
|
|
//hotel index page script
|
|
//create date:2011-03-30
|
|
//author :wst
|
|
//copy right : chinahighlight
|
|
//TrunMenu("citySwitch","active","li","dealHotels");
|
|
|
|
|
|
|
|
//各个函数区
|
|
//Obj 单击对像,calback回调函数
|
|
function TrunMenu2(Obj,callback){
|
|
$(Obj).siblings("li").removeClass("active").end().addClass("active");
|
|
var cmid = $(Obj).attr("mid");
|
|
var data = $(Obj).attr("data").split("|");
|
|
if($("#"+cmid).size()<1){
|
|
$("#waitingtable").siblings("div .dealBox").hide().end().show();
|
|
$.ajax({
|
|
type:"POST",
|
|
url:'/api/api.asp',
|
|
dataType:'json',
|
|
data:"method=cht.hotel.monthpromotion&cityID="+data[0],
|
|
success:function(data){
|
|
ListStr = "";
|
|
$.each(data.Hotel,function(i,n){
|
|
|
|
ListStr += "<div class=\"hotelList\" onclick=\"location.href=$(this).find('a').eq(0).attr('href')\"> \
|
|
<div class=\"hotelsmaPic\"><a href=\""+n.HotelUrl+"\" url=\""+n.HotelPic.replace('-s.','-m.')+"\" class=\"jq_preview\"><img src=\""+n.HotelPic+"\" class=\"hotelSmal\" alt='"+n.HotelName+"'/></a></div>\
|
|
<div class=\"hotelIndexPro\">\
|
|
<h4><a href=\""+n.HotelUrl+"\">"+n.HotelName+"</a> "+n.HotelStar+"</h4>\
|
|
<div class=\"hotelCheapPrice\">"+ (n.HotelLowPrice>0?"From <span class=\"priceredFont\">$"+n.HotelLowPrice+"</span>":"")+"</div>\
|
|
<div class=\"ratingNum\">"+(n.HotelIntRate>0?"Customers' Rating: "+EGAP(n.HotelIntRate)+","+n.HotelIntRate:"")+"</div>\
|
|
<div class=\"clear\"></div>\
|
|
</div>\
|
|
<div class=\"clear\"></div>\
|
|
</div>"
|
|
});
|
|
ListStr = '<div class="dealBox roundCorner" name="dealHotels" id='+cmid+'>'+ListStr+'<div class="clear"></div></div>';
|
|
$("#waitingtable").hide();
|
|
$("#hotelDeals").append(ListStr);
|
|
$("#"+cmid).siblings("table:visible,div .dealBox").hide().end().show();
|
|
$(".dealBox.roundCorner[id="+cmid+"]").find("a.jq_preview").preview();
|
|
if(typeof callback =="function"){
|
|
callback(Obj);
|
|
}
|
|
}
|
|
});
|
|
} else {
|
|
$("#"+cmid).siblings("table:visible,div .dealBox").hide().end().show();
|
|
if(typeof callback =="function"){
|
|
callback(Obj);
|
|
}
|
|
}
|
|
}
|
|
|
|
function GetLength(str) {
|
|
var realLength = 0, len = str.length, charCode = -1;
|
|
for (var i = 0; i < len; i++) {
|
|
charCode = str.charCodeAt(i);
|
|
if (charCode >= 0 && charCode <= 128) realLength += 1;
|
|
else realLength += 2;
|
|
}
|
|
return realLength;
|
|
};
|
|
|
|
|
|
function more_option(a)
|
|
{ //a=0关闭city,1打开city
|
|
var obj = document.getElementById("showmoreOption");
|
|
switch(a){
|
|
case 0:
|
|
obj.style.display="none";
|
|
obj=document.getElementById("show");
|
|
obj.style.display="";
|
|
obj=document.getElementById("hide");
|
|
obj.style.display="none";
|
|
|
|
break;
|
|
case 1:
|
|
document.getElementById("otherPromo").style.display = "";
|
|
obj.style.display="";
|
|
obj=document.getElementById("show");
|
|
obj.style.display="none";
|
|
break;
|
|
}
|
|
}
|
|
|
|
function ds(){document.hotelsearchpanelform.submit();}
|
|
|
|
|
|
//显示主推酒店
|
|
function getMaimHotel(city){
|
|
if(city=="Shanghai" || city=="Beijing" || city=="Guangzhou" || city=="Xian" || city=="Shenzhen" || city=="Guilin"){
|
|
$("#citySwitch li").filter(function(index){return $(this).text()==city}).trigger("click");
|
|
} else {
|
|
$.ajax({
|
|
type: "GET",
|
|
url: "/hotel/ajax-index.asp",
|
|
dataType: "html",
|
|
data: "city="+city,
|
|
success: function(msg){
|
|
if(msg=="0"){return;}
|
|
var kpNum = $("#citySwitch li").length;
|
|
if(kpNum>6){
|
|
$("#citySwitch li").eq(0).text(city);
|
|
$(".dealBox.roundCorner").eq(0).html(msg);
|
|
}else{
|
|
var oldHTML = $("#citySwitch").html();
|
|
$("#citySwitch").prepend("<li mid='de_"+city+"' data=''>"+city+"</li>");
|
|
$('<div class="dealBox roundCorner" style="display: none;" name="dealHotels" id="de_'+city+'">'+msg+'</div>').insertBefore(".dealBox.roundCorner:first");
|
|
}
|
|
$(".dealBox.roundCorner[id=de_"+city+"]").find("a.jq_preview").preview();
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
$(function(){
|
|
var shcity= $("input[name='city']");
|
|
shcity.click(function(){
|
|
$("#hotelcities").fadeIn(200);
|
|
});
|
|
|
|
$(".closeIt").click(function(){
|
|
$("#hotelcities").fadeOut(200);
|
|
});
|
|
$("#hotelcities a").click(function(){
|
|
shcity.val($(this).text());
|
|
$("#hotelcities").hide();
|
|
getMaimHotel($(this).text());
|
|
});
|
|
|
|
$("#hotelstarttime").datepicker({
|
|
showAnim:"fadeIn",
|
|
duration:0,
|
|
minDate: 0,
|
|
maxDate:"2y",
|
|
numberOfMonths: 3,
|
|
showButtonPanel: true
|
|
}).bind('dateSelected',
|
|
function(e, selectedDate, $td){
|
|
$("#hotelendtime").val(new Date(selectedDate).addDays(3).asString());$("#hotelendtime").focus();$.datepicker.dpDiv;
|
|
}
|
|
);
|
|
$("#hotelendtime").datepicker({
|
|
showAnim:"fadeIn",
|
|
duration:0,
|
|
minDate: 0,
|
|
maxDate:"2y",
|
|
numberOfMonths: 3,
|
|
showButtonPanel: true,
|
|
ortherDP:'hotelstarttime'
|
|
});
|
|
|
|
//鼠标移动显示大图
|
|
if( typeof $.fn.preview == 'function' ){ $("a.jq_preview").preview();}
|
|
|
|
//鼠标移到显示提示
|
|
$("img.newReview").hover(
|
|
function () {
|
|
$("#"+$(this).attr("cm")).show();
|
|
},
|
|
function () {
|
|
$("#"+$(this).attr("cm")).hide();
|
|
}
|
|
);
|
|
$("#citySwitch li").live('click',function(i){
|
|
TrunMenu2(this);
|
|
});
|
|
$("#citySwitch li").filter(function(index){return $(this).text()==$("input[name=city]").val()}).trigger("click");
|
|
TrunMenu2($("#citySwitch li").eq(0));
|
|
});
|