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

📄 pet.js

📁 某网页游戏的前台JS控制程序2
💻 JS
📖 第 1 页 / 共 5 页
字号:
	function go(u){		petWin.location.href=u;	}/////state///////////////////////var _state1_opacity_left=100;var _state1_opacity_right=100;function state(obj,side,num){	try{		if(num!='x'){			obj.innerHTML=num;		}		obj.style.display="";		if(!huaLi){return;}		obj.style.top=delPx(obj.style.top)-6;		if(side=="left"){			_state1_opacity_left-=8;			obj.style.filter='alpha(opacity='+(_state1_opacity_left)+')';		}else if(side=="right"){			_state1_opacity_right-=8;			obj.style.filter='alpha(opacity='+(_state1_opacity_right)+')';		}		if((side=="left"&&_state1_opacity_left>0)||side=="right"&&_state1_opacity_right>0){			setTimeout("try{state(petWin."+obj.id+",'"+side+"','x');}catch(x){if(debug)alert(x);}",100);		}else{			if(side=="left"){				_state1_opacity_left=100;			}else if(side=="right"){				_state1_opacity_right=100;			}			obj.style.top=135;			obj.style.display="none";			obj.style.filter='alpha(opacity=100)';		}	}catch(x){if(debug)alert(x);}}///////////////////set linevar petIsDie;function  petDie(){	getObj("_petRace").style.filter="Gray";	petIsDie=true;}function setLine(objStr,num,nowNum){	if(objStr=="hpLine_left"&&nowNum==0){		petDie();	}else if(petIsDie){		if(nowNum>0){			getObj("_petRace").style.filter="";			petIsDie=false;		}	}	try{		_setLine(objStr,num,nowNum);		petWin.document.all(objStr+"_no").innerHTML=nowNum;		var obj=petWin.document.all(objStr);		var t=num;		if(t<0){			obj.style.width=0;		}else{			obj.style.width=t;		}	}catch(x){err(x);}}function _setLine(objStr,num,nowNum){	try{		var obj=document.all(objStr);		var t=num;		if(t<0){			obj.style.width=0;		}else{			obj.style.width=t;		}		document.all(objStr+"_no").innerHTML=nowNum;	}catch(x){err(x);}}//p.setLine(p.petWin.hpLine_right,"+FMath.getBarWidth(enemy.getHP(),enemy.getMaxHP(),90)+",'-');////////////////////att2(obj,30,"img/slug/5[2].gif",true,side);function att1(obj,side){	try{		if(!huaLi){return;}		if(side=="left"){			obj.style.left=getLeftFighterX()+130;			setTimeout("try{petWin."+obj.id+".style.left="+getLeftFighterX()+";}catch(x){if(debug)alert(x);}",100);		}else if(side=="right"){			obj.style.left=getRightFighterX()-130;			setTimeout("try{petWin."+obj.id+".style.left="+getRightFighterX()+";}catch(x){if(debug)alert(x);}",100);		}	}catch(x){err(x);}}//slug///////function att2(obj,speed,slug,fan,side,notMoveMy){	try{		if(!huaLi){return;}		var _tOld=delPx(obj.style.left);		if(!notMoveMy){			if(side=='left'){				obj.style.left=delPx(obj.style.left)+50;			}else if(side=='right'){				obj.style.left=delPx(obj.style.left)-50;			}		}		var slugObj=petWin.document.all(obj.id+"s");		_cachePic(slugObj,slug);		slugObj.style.left=_tOld;		if(side=='left'){			_attLeft(slugObj,speed,fan,side);		}else if(side=='right'){			_attRight(slugObj,speed,fan,side);		}				if(!notMoveMy){			if(side=='left'){				setTimeout("try{petWin."+obj.id+".style.left="+148+";}catch(x){if(debug)alert(x);}",100);			}else{				setTimeout("try{petWin."+obj.id+".style.left="+308+";}catch(x){if(debug)alert(x);}",100);			}		}	}catch(x){err(x);}}var _opacity_left=100;function _attLeft(obj,speed){	try{		if(!huaLi){return;}		obj.style.display="";		obj.style.left=delPx(obj.style.left)+20;		_opacity_left-=7;		obj.style.filter='alpha(opacity='+(_opacity_left)+') fliph';		if(_opacity_left>0){			setTimeout("try{_attLeft(petWin."+obj.id+","+speed+");}catch(x){if(debug)alert(x);}",speed);		}else{			_opacity_left=100;			obj.style.display="none";		}	}catch(x){err(x);}}var _opacity_right=100;function _attRight(obj,speed){	try{				if(!huaLi){return;}		obj.style.display="";		obj.style.left=delPx(obj.style.left)-20;		_opacity_right-=7;		obj.style.filter='alpha(opacity='+(_opacity_right)+')';				if(_opacity_right>0){			setTimeout("try{_attRight(petWin."+obj.id+","+speed+");}catch(x){if(debug)alert(x);}",speed);		}else{			_opacity_right=100;			obj.style.display="none";		}			}catch(x){err(x);}}//////////////function changePic(obj,pic){	//obj.src=pic;	_cachePic(obj,pic);}function win(obj){	try{		if(obj.side=='left'){			if(obj.src.indexOf("180.gif")!=-1){				changePic(obj,'img/pet/win/'+Math.round(Math.random()*1)+'.gif');			}		}	}catch(x){err(x);}}function lost(obj){	//if(Math.round(Math.random()*1)==0){		try{			setTimeout("try{fly(petWin."+obj.id+");}catch(x){if(debug)alert(x);}",200);		}catch(x){err(x);}	//}else{	//	changePic(obj,'img/pet/lost/'+Math.round(Math.random()*2)+'.gif');	//}}function test(obj){	try{		setTimeout("try{shake(petWin."+obj.id+",11);}catch(x){if(debug)alert(x);}",200);	}catch(x){err(x);}}var _opacity=100;function fly(obj){	try{		if(!huaLi){obj.style.display='none';return;}		var side="right";		if(obj.id=="fighter_1"){			side="left";		}		if(side=="right"){			obj.style.left=delPx(obj.style.left)+20;		}else{			obj.style.left=delPx(obj.style.left)-20;		}		_opacity-=5;		if(side=="right"){			obj.style.filter='alpha(opacity='+(_opacity)+')';		}else{			obj.style.filter='alpha(opacity='+(_opacity)+') fliph';		}		if(_opacity>0){			setTimeout("try{fly(petWin."+obj.id+");}catch(x){if(debug)alert(x);}",5);		}else{			if(side=="right"){				obj.style.left=delPx(obj.style.left)-(100/5*20);			}else{				obj.style.left=delPx(obj.style.left)+(100/5*20);			}			_opacity=100;		}	}catch(x){err(x);}}function delPx(pos){	return (parseInt(pos.substring(0,pos.length-2)));}///////////////////////////////////场景描述相关function roomDesc(str){	try{		//petWin.roomDescStr.innerHTML=str;		setRoomText(str);		//petWin.roomDescStr.innerHTML="<iframe width=100% height=100% src=map/maoyin.html frameborder=0></iframe>";	}catch(x){err(x);}}function selectGo(room){	if(room!=null&&room!=""){		cmd('gto '+room);	}}function delUser(id){	try{		var allUsers=petWin.playerList.getElementsByTagName("dt");		for(var i=0;i<allUsers.length;i++){			if(allUsers[i].userid==id){				var s_node = petWin.document.getElementById("user_"+id);				var parentE = petWin.playerList;				parentE.removeChild(s_node);			}		}	}catch(x){err(x);}}function _hasUser(id){ //是否在在线列表存在	try{		var allUsers=petWin.playerList.getElementsByTagName("dt");		for(var i=0;i<allUsers.length;i++){			if(allUsers[i].userid==id){				return true;			}		}	}catch(x){err(x);}	return false;}function addUser(id,str){	if(id!=myId){	try{		if(!_hasUser(id)){			petWin.playerList.insertAdjacentHTML("beforeEnd",str);		}	}catch(x){err(x);}	}}function addNpcs(s){	try{		petWin.npcList.innerHTML=s;	}catch(x){err(x);}}function _getToolsBar(){	var obj=document.all("toolsbar");	if(obj==null){		var obj=document.createElement('toolsbar');		obj.id="toolsBar";		with(obj.style){			position="absolute";			zIndex=999999;			left=1;			top=1;			display="none";		}		document.body.appendChild(obj);	}	return obj;}function showParentMenu(body){//显示菜单	try{		var obj=_getToolsBar();		obj.innerHTML=body;		with(obj.style){			top=event.y+document.body.scrollTop;			left=event.x+document.body.scrollLeft;			display='';		}	}catch(x){err(x);}}function hideParentMenu(){//隐藏菜单	try{		_getToolsBar().style.display='none';	}catch(x){err(x);}}function showMenu(body){//显示菜单	try{		var obj=_getToolsBar();		obj.innerHTML=body;		with(obj.style){			top=petWin.event.y+petWin.document.body.scrollTop+91;			left=petWin.event.x+petWin.document.body.scrollLeft+26;			display='';		}	}catch(x){err(x);}}function hideMenu(){//显示菜单	hideParentMenu();}//actionfunction userAction(userId,userName){	//clear	var allDt=petWin.document.getElementsByTagName("dt");	for(var i=0;i<allDt.length;i++){		allDt[i].style.color="#000000";	}	//set	var _t=petWin.document.getElementById("user_"+userId);	_t.style.color="#FF0000";	var o="";	if(myName!=userName){		//petWin.menuDiv.innerHTML="<nobr>"		o+="<nobr>"		+"<input type=button value='查看' onclick=\"p.showPetInfo('"+userName+"','"+userName+"');p.hideMenu();\" class=smallFont>"		+"<input type=button value='交谈' onclick=\"p.talkTo("+userId+",'"+userName+"');p.hideMenu();\" class=smallFont>"		+"<input type=button value='跟随' onclick=\"p.cmd('follow "+userName+"');p.hideMenu();\" class=smallFont>"		+"<input type=button value='交易' onclick=\"p.cmd('deal "+userName+"');p.hideMenu();\" class=smallFont>"		+(openPKButton==1?"<input type=button value='攻击' onclick=\"p.cmd('bar34 "+userId+"');p.hideMenu();\" class=smallFont>":"")		+"</nobr>";	}else{		o+="<nobr>"		+"<input type=button value='查看' onclick=\"p.cmd('l "+userName+"');p.hideMenu();\" class=smallFont>"		+"</nobr>";	}	showMenu(o);}var _canTalk=false;var _noKill=false;function npcAction(npcIndex,npcName,code){	//clear	var allDt=petWin.document.getElementsByTagName("dt");	for(var i=0;i<allDt.length;i++){		allDt[i].style.color="#000000";	}	//set	var _t=petWin.document.getElementById("npc_"+npcIndex);	_t.style.color="#FF0000";		var str="<nobr>"		+"<input type=button value='查看' onclick=\"p.showPetInfo("+npcIndex+",'"+npcName+"',"+code+",[false,false,"+_canTalk+","+!_noKill+"]);p.hideMenu();\" class=smallFont>";		if(_canTalk){			str+="<input type=button value='交谈' onclick=\"p.cmd('talk "+npcIndex+"');p.hideMenu();p.hideWelcome();\" class=smallFont>";		}		if(!_noKill){			str+="<input type=button value='攻击' onclick=\"p.cmd('dsr234 "+npcIndex+" "+code+"');p.hideMenu();\" style=\"display:none\">"			str+="<input type=button value='攻击' onclick=\"p.cmd('bar34 "+npcIndex+" "+code+"');p.hideMenu();\" class=smallFont>"		}		+"</nobr>";		//petWin.menuDiv.innerHTML=str;	showMenu(str);}function showMP(mp){	 topMP.innerHTML=mp;}function showMM(mm){	 topMM.innerHTML=mm;}var enemyHashCode=-1;//page statefunction cps(state){	changePageState(state);}function changePageBody(b){	getOutReader().insertAdjacentHTML("beforeEnd",b);}function changePageState(state){	petWin.pageState=state;	hideMenu();	if("zone"==state){		changePageBody(_getDiv());	}	//map	try{		if("combat"==state){			document.all("mapWin").style.display="none";			//document.all("innerReader").style.display="none";			with(document.all("innerReader").style){				height=125;				width=508;				left= (3+pLeft);				top= (225+pTop);			}			goDown(document.all("innerReader"));		}else{			document.all("mapWin").style.display="";			//document.all("innerReader").style.display="";			with(document.all("innerReader").style){				height=90;				width=330;				left= (3+pLeft);				top= (260+pTop);

⌨️ 快捷键说明

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