⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 in.js

📁 城市输入提示
💻 JS
📖 第 1 页 / 共 2 页
字号:
     if(null != o){     	 this.hideSelect=o;     }}apsug.prototype.init = function(){	if(this.sugdiv==null){		this.sugdiv=document.createElement('DIV');		this.maskdiv=document.createElement('DIV'); 			this.sugdiv.style.display='none';		this.maskdiv.style.display='none';		this.maskdiv.style.border='0px';	 		this.sugdiv.className='sug';		this.maskdiv.className='sug';		//clone(this.sugdiv,this.maskdiv);		this.sugdiv.style.zIndex=100;		this.maskdiv.style.zIndex=99;		 //		alert(mask);		this.maskdiv.innerHTML='<iframe src="" style="border:0px;position:absolute;top:0px; left:0px; width:100px; height:200px;filter=\"progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)\""></iframe>'; 		this.sugdiv.innerHTML='';		this.sugdiv.onscroll=OnSugScroll;		var bs=document.getElementsByTagName('BODY');		//document.body.appendChild(this.maskdiv);		bs[0].appendChild(this.maskdiv);		bs[0].appendChild(this.sugdiv);	}	this.focusBySelect = false;}function OnSugScroll(){	if(gsug.currInputObj==null){return;}	gsug.focusBySelect=true;	gsug.currInputObj.focus();}function OnDocClick(e){	var x,y,t,b,l,r;	var d;	if(window.event){		e=window.event;		x=e.clientX+document.body.parentNode.scrollLeft;		y=e.clientY+document.body.parentNode.scrollTop;	}else{		x=e.pageX;		y=e.pageY;	}	d=gsug.currInputObj;	if(!d){document.onclick=gsug.onDocumentClick;return;}	t=gETop(d);	l=gELeft(d);	b=gEBottom(d);	r=gERight(d);	if(x>=l && x<r && y>=t && y<b){return;}	d=gsug.sugdiv;	t=gETop(d);	l=gELeft(d);	b=gEBottom(d);	r=gERight(d);	if(x>=l && x<r && y>=t && y<b){return;}	gsug.select();}var global_focus_flag=false;var inString ='汉字/拼音或首字母';function OnInputFocus(){	global_focus_flag = true;	gsug.currInputObj = this;	gsug.prevInputValue = null;	if(this.value == inString) {		this.value= '';		 //this.select();	}	this.style.color = '';	if(gsug.focusBySelect){		gsug.focusBySelect=false;		return;	}	gsug.focusBySelect=false;	InputChecking();}function OnInputFocus1(){	if(this.value == "酒店名/区域/标志性建筑等") {		this.value= '';	}	this.style.color = '';}function OnInputBlur(){	gsug.select();	return;}function InputChecking(){	if(gsug.currInputObj == null)	{	return;}	var v=gsug.currInputObj.value;	if(gsug.prevInputValue==null || gsug.prevInputValue!=v){		gsug.update(v);	}else{		//gsug.update(v);	}	setTimeout("InputChecking()", 10);}function OnInputKeyDown(e){	if(gsug.currInputObj==null){		gsug.currInputObj = this;		gsug.prevInputValue = null;		InputChecking();	}	var bCtrlDown=0;	if(!e && window.event){		e=window.event;	}	if(window.event){		bCtrlDown=e.ctrlKey;	}else{		bCtrlDown=(e.modifiers & Event.CONTROL_MASK) > 0;	}	if(bCtrlDown){		return true;	}	var kc=e.keyCode;	if(isCtrlKey(kc)){		return true;	}	return (InputRealKeyDown(kc));}function InputRealKeyDown(kc) {	global_focus_flag = false;	if(isUpDownKey(kc)){		if(kc==38){// up			gsug.move(1,0);		}else if(kc==40){//down			gsug.move(1,1);		}else if(kc==33){//pageup			gsug.move(0,0);		}else if(kc==34){//pagedown			gsug.move(0,1);		}		return false;	}else if(kc==13){//enter		gsug.select();		return false;	}else if(kc==9){//tab		gsug.select();		return true;	}else if(kc==27){//esc		gsug.hide();		return true;	}	return true;}apsug.prototype.select = function() {	if(this.sugdiv.style.display=='none'){return false;}else{		 clonePos(this.sugdiv,this.maskdiv);	}	if(this.showfocus>=0 && this.showarr!=null && this.showfocus<this.showarr.length && this.currInputObj!=null){		var i=this.showarr[this.showfocus];		this.currInputObj.value=apdata[i][1];		this.focusBySelect=true;		this.currInputObj.focus();		if(window.event){			var r=this.currInputObj.createTextRange();			r.move("character", r.text.length);			r.select();		}else{			var v=apdata[i][1].length;			this.currInputObj.setSelectionRange(v, v);		}	}	this.hide();	//this.currInputObj=null;}apsug.prototype.highlight = function(idx) {	if(this.sugdiv.style.display=='none'){return false;}	if(idx==this.showfocus){return true;}	var i;	var ls = this.sugdiv.getElementsByTagName('LI');	if(this.showfocus>=0&&this.showfocus<ls.length){		ls[this.showfocus].className='';	}	if(idx>=0&&this.showfocus<ls.length){		ls[idx].className='hover';	}	this.showfocus=idx;}apsug.prototype.move = function(m,n){	var a=this.showfocus;	if(m==1&&n==0){		a--;	}else if(m==1&&n==1){		a++;	}else if(m==0&&n==0){		a-=5;	}else if(m==0&&n==1){		a+=5;	}	if(a<0){		a=0;	}else if(a>=this.showarr.length){		a=this.showarr.length-1;	}	var i,j,k;	i=(this.sugdiv.scrollTop)/20;	if(a<=i){		this.sugdiv.scrollTop=a*20;	}else if(a>=i+10){		this.sugdiv.scrollTop=(a-9)*20;	}	this.highlight(a);}apsug.prototype.hide = function(v) {	if(this.sugdiv.style.display!='none'){		this.sugdiv.style.display='none';		this.maskdiv.style.display='none';		if(null !=this.hideSelect){	   		this.hideSelect.style.visibility="visible";	   	}		document.onclick=this.onDocumentClick;	}}apsug.prototype.update = function(v) {	this.prevInputValue = v;	v=v.toLowerCase();	this.showfocus = -1;	if(this.showarr==null){		this.showarr = new Array();	}else{		this.showarr.length = 0;	}	var i,j,s;	if(v.length==0){//all		for(i=0;i<apdata.length;i++){			this.showarr[i]=i;		}	}else{		for(i=0;i<apdata.length;i++){			for(j=1;j<apdata[i].length;j++){				if(apdata[i][j].toLowerCase().indexOf(v) == 0){					this.showarr[this.showarr.length]=i;					break;				}			}		}	}	if(this.showarr.length<=0||(this.showarr.length==1&&v==apdata[this.showarr[0]][1])){		this.hide();		return;	}	if(global_focus_flag){		return;//some="some";	}      	if(null !=this.hideSelect){	   		this.hideSelect.style.visibility="hidden";	 }	this.sugdiv.style.top=gEBottom(this.currInputObj)+"px";	this.sugdiv.style.left=gELeft(this.currInputObj)+"px";	this.sugdiv.style.width=this.currInputObj.offsetWidth;	clonePos(this.sugdiv,this.maskdiv);	s='<ul>';		for(i=0;i<this.showarr.length;i++){		s+='<li'+(i==0?' class="hover"':'')+' onmousemove="gsug.highlight('+i+')" onclick="OnSugClick();">'+apdata[this.showarr[i]][1]+'('+apdata[this.showarr[i]][3]+')</li>';	}	s+='</ul>';	//s="<iframe src=\"\" style=\"position:absolute;top:200px;width:100px; height:50px;z-index:150;filter='progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)';\"></iframe>"+s;	//this.sugdiv.innerHTML=document.getElementById("sug").innerHTML+s;	this.sugdiv.innerHTML=s;	this.showfocus=0;	this.sugdiv.style.zIndex=200;	this.sugdiv.scrollTop = 0;	this.sugdiv.style.display='block';	//alert(IfrRef);        //IfrRef.style.zIndex = this.sugdiv.style.zIndex - 1;        //document.getElementById("debug").innerHTML=IfrRef.style.zIndex;	//alert(this.sugdiv.style.zIndex);	//alert(IfrRef.style.zIndex);	this.onDocumentClick=document.onclick;	document.onclick=OnDocClick;}function OnSugClick(){	gsug.select();}function onUrl(From,to){var i,From_v,to_v,be_f;	var be_f1 = false;	var be_f2 = false;	var flag = false;	for(i=0;i<apdata.length;i++){		if(From==inString || to ==inString){			flag = true;		}		if(apdata[i][1]==From){			From_v = apdata[i][0];			be_f1 = true;		}		if(apdata[i][1]==to){			to_v = apdata[i][0];			be_f2 = true;		}		if (be_f1 && be_f2) break;	}	if((!be_f1 || !be_f2)&&!flag){		alert ("请输入正确的城市名!");return false;	}	else if(document.s.t.value == inString || document.s.q.value == inString){		return false;	}	else if(From == to&&!flag) { alert("起始城市和到达城市重复!");return false;}	if(From_v!=''){document.s.From.value = From_v;}else document.s.From.value = "";	if(to_v!=''){document.s.to.value = to_v;}else document.s.to.value = "";	return true;}function on_load_url(){	var i,f_v,t_v;	var result;	for(i=0;i<apdata.length;i++){		if(apdata[i][0]==st_city){			f_v = apdata[i][1];		}		 if(apdata[i][0]==en_city){			t_v = apdata[i][1];		}			}//document.getElementById('frmcity').value = f_v;//document.getElementById('tocity').value = t_v;	//	document.s.t.value = f_v;//	document.s.t.value = f_v;//	document.s.q.value = t_v;	//g_q=document.s.q.value = t_v;	result = new Array(f_v,t_v);	return result;} function on_load_url_index(){	var fromcity;	fromcity = document.sjipiao.fromCity.value;	if(fromcity=='其它'){		document.sjipiao.t.value = inStringa;		document.sjipiao.t.style.color="#CCC";	}else if(fromcity=='北京'){		 document.sjipiao.t.value = "北京首都";		 document.sjipiao.t.style.color="";	}else if(fromcity=='上海'){		document.sjipiao.t.value = "上海虹桥";		document.sjipiao.t.style.color="";	}else{		 document.sjipiao.t.value = fromcity;		 document.sjipiao.t.style.color="";	}	document.sjipiao.q.value = inStringa;	if(document.sjipiao.q.value == inStringa){		document.sjipiao.q.style.color="#CCC";	}	else{		document.sjipiao.q.style.color="#FFF";	}	return true;}var old = window.onload;window.onload = function(){	if(old) old();			on_load_url_index();	textInit();	textInita();	gsug.setInputObj(document.s.city);	gsug.setInputObj(document.s.hotel);	jsug.setInputObj(document.sjipiao.t);	jsug.setInputObj(document.sjipiao.q);	try	{		//gsug.setInputObj(document.xianluform.From);		gsug.setInputObj(document.xianluform0.From);		gsug.setInputObj(document.xianluform1.From);		gsug.setInputObj(document.xianluform2.From);	}catch(Ex){}	gsug.setHideSelect(document.getElementById("hotel_price"));	if(""==document.s.city.value){		document.s.city.value = inString;		document.s.hotel.value = "酒店名/区域/标志性建筑等";		document.s.hotel.style.color="#CCC";			if(document.s.city.value == inString){					document.s.city.style.color="#CCC";			}			else{					document.s.city.style.color="#FFF";			}	}		if(document.s.city.value == inString)		document.s.city.style.color="#CCC";	if(document.s.hotel.value == "酒店名/区域/标志性建筑等")		document.s.hotel.style.color="#CCC";	return true;	//					gsug.setInputObj(document.s.q);} 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -