火狐娘&绿坝子升级2.0

火狐子可以点着玩了≡ω≡,添加了事件响应
主要修改代码:

jQuery.preloadImages = function(){
  for(var i = 0; i<arguments.length; i++)  {
    jQuery("<img>").attr("src", arguments[i]);
  }
}
jQuery.preloadImages(wizard_baseurl+"/images/speak-bottom-l.png",wizard_baseurl+"/images/speak-bottom-r.png");
function WizardDialogData(b,w,t){
	return {
		show:function(){
			var box = Wizard[b]
			if(!(box.noDialog||box.isMenuShown))box.show(w,t);
		},
		setTimeout:function(func){
			return setTimeout(func,t);
		}
	};
}
function WizardBox(b){
	return ({
		box:b,
		text:b.find('div.wizard_text'),
		showing:false,
		mousein:false,
		noHide:false,
		noDialog:false,
		isMenuShown:false,
		hide:function(time){
			if(this.showing&&!(this.noHide||this.isMenuShown)){
				this.showing = false;
				this.text.fadeOut(500);
			}
		},
		update:function(word){
			this.text.find("div.content").attr("innerHTML","<p>"+word+"</p>");
		},
		show:function(word,time,append,size){
			if(word){
				var c = this.text.find("div.content")
				if(!append||(!this.showing&&append==Wizard.OVERWRITE_NONE))
					append=Wizard.OVERWRITE_REPLACE;
				switch(append){
					case Wizard.OVERWRITE_REPLACE:{
						c.attr("innerHTML","<p>"+word+"</p>");
						break;
					}
					case Wizard.OVERWRITE_APPEND:{
						c.attr("innerHTML",c.attr("innerHTML")+"<p>"+word+"</p>");
						break;
					}
					case Wizard.OVERWRITE_NONE:{
						break;
					}
				}
				if(size){
					this.text.width(size);
				}else{
					this.text.width(160);
				}
			}

			if(!this.showing){//Only do this if nessary
				this.showing = true;
				this.text.fadeIn(500);
				if(time){
					var _this = this;//avoid "this" refers to something else in inline functions
					setTimeout(function(){_this.hide(time);},time);
				}
			}
		},
		init:function(){
			var _this = this;
			this.box.hover(function(){
				_this.mousein=true;
			},function(){
				_this.mousein=false;
				_this.hide();
			});
			return this;
		}
	}).init();
}
var Wizard = {
	//Constants:
	OVERWRITE_NONE:1,
	OVERWRITE_APPEND:2,
	OVERWRITE_REPLACE:0,
	
	TIMEOUT_INIFINTY:0,
	//Varibles:
	words_left:[
		"好孩子上网要找火狐姐姐哦Nyoron!",
		"Nyoron~绿坝娘你个傲娇抓不到我",
		"用火狐子上网可以不中病毒哦Nyoron!",
		"听说其实绿坝娘是外国人呐Nyoron?",
	],
	words_right:[
		"无路赛!无路赛!无路赛!H是不对的!",
		"大小姐我可是价值47,100,000人民币的哦!",
		"你才傲娇,你全家都是傲娇!",
		"再看H小心我和谐你哦!",
	],
	load_dialog:[
		WizardDialogData("left" ,"=ω= 唔,一不小心就2.0版本了呢。",3000),
		WizardDialogData("right",">_< 无路赛!无路赛!无路赛!",3000),
		WizardDialogData("left" ,"=_,= 喂喂,我说你蹭的累也不用这样吧?",3000),
		WizardDialogData("right",">_< 哼,要你管!",3000),
		WizardDialogData("left" ,"-_- 不理你了,有什么事情记着来找我哦~~",3000),
	],
	
	AIHandler:{
		
		AI_Start:[
			"Yes Master, 请下命令。",
			"Hi, Juizでし、需要帮忙么?",
		],
		AI_End:[
			"任务了解,清除开始。",
			"Noblesse Oblige 今後もあなたが救世主たらんことを。",
		],
		AI_Commands:{
			who:{
				command:function(){
					Wizard.ShowDialog([
						WizardDialogData("left" ,"我?我当然是英明、智慧、伟大、美丽的火狐子咯。",3000),
						WizardDialogData("right","喂,不要吧自己说的那么好!!!",3000),
						WizardDialogData("left" ,"啊,对面那个是绿坝娘,她其实是个蹭的累哦*^_^*~~",3000),
						WizardDialogData("right",'<span style="font-size:200%;">&gt;_&lt 讨厌!</span>',3000),
					])
					return false;
				},
				display:"你是谁?",
			},
			what:{	
				command:function(){
					Wizard.ShowDialog([
						WizardDialogData("left" ,"唔……这的确是个好问题的说。",3000),
						WizardDialogData("right","嘿嘿,其实这个家伙什么都不会干~~",3000),
						WizardDialogData("left" ,"……",1000),
						WizardDialogData("left" ,'仅仅是现在啦!<font color="red" size="120%">现在!</font>',3000),
					])
					return false;
				},
				display:"你能干什么?",
			},
			nothing:{	
				command:function(){
					return true;
				},
				display:"表点我",
			},
			foobar:{	
				command:function(which){
					which.update("-__-||没事不要在人家身上乱点啦……");
					return false;
				},
				display:"没事,我点着玩的",
			},
		},
		AI_SHOW_MENU:0,
		AI_WAIT_ORDER:1,
		AI_DONE:2,
			
		//Varibles
		AI_stat:0,
		
		//Functions
		handle:function(which){
			//document.title=this.AI_stat;
			switch(this.AI_stat){
				case this.AI_SHOW_MENU:
					this.AI_stat=this.AI_WAIT_ORDER;
					this.displayMenu(which);
					break;
			}
		},
		displayMenu:function(which){
			var content=
				'<p>'+this.AI_Start[1]+'</p>'+
				'<ul class="wizard_cmdlist">';
			for(idx in this.AI_Commands){
				content+='<li class="wizard_cmdlist_item"><a id="cmd_'+idx+'">'+this.AI_Commands[idx].display+'</a></li>';
			}
			content+='</ul>';
			which.show(content,0,0,200);
			which.isMenuShown = true;
			var _this = this;
			which.box.find("li.wizard_cmdlist_item a").click(function(){_this.handleCmd(which,$(this));});
		},
		handleCmd:function(which,target){
			which.isMenuShown=false;
			try{
				var idx = target.attr('id').split(/_/)[1];
				if(this.AI_Commands[idx].command(which)){
					which.update(this.AI_End[1]);
				}
			}catch(e){}
			var _this = this;
			setTimeout(function(){
				_this.installMenuHook(which);
			},1);
		},
		installMenuHook:function(which){
			this.AI_stat=this.AI_SHOW_MENU;
			which.box.one('click',function(){
				Wizard.AIHandler.handle(which);
			});
		},
	},
	//Public Functions:
	lastDialog:null,
	ShowDialog:function(data){
		//alert(this.lastDialog);
		if(this.lastDialog)this.lastDialog.stop();
		return (this.lastDialog={
			cancel:false,
			timerID:null,
			start:function(){
				var _this = this;
				function dialog_itr(i){		
					if(i>=data.length||_this.cancel)return;
					data[i].show();
					_this.timerID=data[i].setTimeout(function(){
						dialog_itr(i+1);
					});
				}
				dialog_itr(0);
				return this;
			},
			stop:function(){
				if(this.timerID)clearTimeout(this.timerID);
				cancel=true;
			},
		}).start();
	},

	//Reverved Functions:
	init:function(){
		Wizard.left = WizardBox($('div#wizardbox_left'));
		Wizard.right= WizardBox($('div#wizardbox_right'));
		Wizard.AIHandler.installMenuHook(Wizard.left);
		Wizard.left.box.hover(
			function(){
				if(!Wizard.left.isMenuShown)
				Wizard.left.show(
					Wizard.words_left[Math.floor(Math.random()*Wizard.words_left.length)],
					Wizard.TIMEOUT_INIFINTY,
					Wizard.OVERWRITE_NONE
				);
			}
		);
		Wizard.right.box.hover(
			function(){
				if(!Wizard.right.isMenuShown)
				Wizard.right.show(
					Wizard.words_right[Math.floor(Math.random()*Wizard.words_right.length)],
					Wizard.TIMEOUT_INIFINTY,
					Wizard.OVERWRITE_NONE
				);
			}
		);
		$('div.wizardbox').fadeIn(500);
		Wizard.ShowDialog(Wizard.load_dialog);
	},
}
$(document).ready(Wizard.init);
>_<|| 我手贱!!这个有问题!绝对有问题!!一般般啦,真的很一般般。还不错哦~小表扬一下!GJ!乃就是新世界的神様了,快去拯救世界吧! (1 votes, average: 1.00 out of 5)
Loading...

4 人次吐槽

  1. KC说道:
    骑着 Firefox 3.0.11 Firefox 3.0.11 和 Windows XP Windows XP
    Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.0.11) Gecko/2009060215 Firefox/3.0.11 (.NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)

    话说这种代码高亮的JS有点慢?
    SSWORD推荐的那个似乎快很多~

    1. Bearice说道:
      骑着 Firefox 3.0.11 Firefox 3.0.11 和 Windows Vista Windows Vista
      Mozilla/5.0 (Windows; U; Windows NT 6.0; zh-CN; rv:1.9.0.11) Gecko/2009060215 Firefox/3.0.11 (.NET CLR 3.5.30729)

      没觉得慢≡ω≡
      这个插件我改过了,吧若干js压缩合并为一个了。

  2. int说道:
    骑着 IceWeasel 3.0.6 IceWeasel 3.0.6 和 Debian GNU/Linux Debian GNU/Linux
    Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.7) Gecko/2009032803 Iceweasel/3.0.6 (Debian-3.0.6-1)

    看门娘超萌啊!(鼻血

  3. 穴居小恶魔说道:
    骑着 Firefox 3.6.13 Firefox 3.6.13 和 Windows 7 Windows 7
    Mozilla/5.0 (Windows; U; Windows NT 6.1; zh-CN; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13

    学习了~

春菜 对话 相声
双击调戏
双击调戏