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

📄 webthunderdetect.js

📁 驱动开发的一些资料
💻 JS
📖 第 1 页 / 共 2 页
字号:
				
				}
			}
			return oAtmp;
		}
		return null;		
	},	
	companySetup:function(sCompany,sPid){
		try {
			sPid=sPid?sPid:this.pId;

           vhref = "http://analytics.xunlei.com/PV?peerid=" + sPid + "&uri=" + sCompany + "&src=" + document.location.href + "&screensize=" +window.screen.width +"*" +window.screen.height;
           image1 = new Image(1,1);
           image1.src = vhref;
         }catch(e){}
	},
	setParameter: function(cid, url, refer, stat){
		
		cid=cid?cid:this.pId;
		
		var inputs = ["thunder_cid", "thunder_down_url", "thunder_down_pageurl", "thunder_stat_pageurl"];
		var input;
		for (var i=0; i<inputs.length; i++){
			if (isUndef(input = $(inputs[i]))){
				input = document.createElement("input");
				input.type = "hidden";
				input.id = inputs[i];
				document.body.appendChild(input);
			}
			input.value = arguments[i];
		}
	},
	
	download: function( url, refer, name, stat,cid){
		 var client;
		 client=this.getInstance();	
		 
		 this.pId=this.pId?this.pId:(cid?cid:"");
		 cid=cid?cid:this.pId;
		if(!client){						
			if(!this.isIE && (client==0)){}else{this.showSetUpInfo(cid);}
		}else{					
			if (this.isIE)
			{				
				client.download(cid, url, refer, name, stat);
			}else{
				switch(this.thunderType){
					case 4:
						client.download(cid, url, refer, name, stat,1);
						break;
					case 3: default:
						client.download(cid, url, refer, name, stat,2);						
				}	
				
			}
			
		}
		return false;
	},
	 openWindow:function(url,flag){		
	 
		var s=flag?flag:false;

		if(!this.isOpenNew)
		{
			var Info;
			if(this.mustUseSelected)
			{
				if(this.thunderType==3)
					Info=thunderLanguage["WebThunderSetUpInfo"];
				else
					Info=thunderLanguage["Thunder5SetUpInfo"];
			}else{
				Info=thunderLanguage["AllSetUpInfo"];
			}
		}
		
		//Open a dialogbox which tell user to setup thunder client
		if(Info) alert(Info);

		if(this.infoType == 10 && !s)
			top.location.href =url;
		else
			window.open(url,"WEBTHUNDER_SET_UP");
	},
	
	showSetUpInfo:function(pid){
		var url;
		
		pid=pid?pid:this.pId;
		if(this.isOpenNew){
			//Goto thunder download page
			if(pid.substr(0,1)=="g")
				url="http://my.xunlei.com/setup.htm?gid=g"+pid;
			else
				url="http://cop.my.xunlei.com/setup/index.html?pid="+ pid;			
		}else{
			if(this.isIE)
			{
				if(this.mustUseSelected)
				{
					if(this.thunderType==3)
						url=wtd_ChangFolder(pid);
					else
						url=wtd_ChangFolder(pid);
				}else{
					url=wtd_ChangFolder(pid);
				}
			}else{
				if(this.mustUseSelected)
				{
					if(this.thunderType==3)
						url=wtd_ChangFolder(pid);
					else
						url=wtd_ChangFolder(pid);
				}else{
					url=wtd_ChangFolder(pid);
				}
			}
		}
		this.openWindow(url);			
	}
}

Thunder.WebThunder = Class.create();
Thunder.WebThunder.getInstance = function(){

	if (isUndef(this._thunder))
	{
		//Web app initialized here
		try{
			this._thunder = new Thunder.WebThunder();							
		}catch(e){
			this._thunder=null;
		}
	}	

	return this._thunder;
}
Thunder.WebThunder.prototype = {	
	initialize: function(){	
		try{
			this.__thunder = this.getThunder();
		}catch(e){
			throw(e);
		}
	},
	getThunder:function(){
		try{
			return new ActiveXObject("ThunderServer.webThunder.1");
		}catch(e){
			throw(e);
		}
	},	
	/*get server build version*/
	getVersion: function(){
		return parseInt(this.__thunder.GetVersion().split(".")[3]);
	},
	
	download: function(cid,url,refer,name,stat){	
		if ((url.indexOf("mms://") != -1) || (url.indexOf("rtsp://")!= -1))
		{
			return true;
		}else{
			this.__thunder.CallAddTask2(Decode(url),Decode(stat),Decode(refer),1, "", Decode(name),document.cookie);
			//this.__thunder.CallAddTask(Decode(url),Decode(stat),Decode(refer),1, "", Decode(name));			
			return false;
		}

	}
}

Thunder.Thunder5 = Class.create();
Thunder.Thunder5.getInstance = function(){
	if (isUndef(this._thunder))
	{
		try{
			this._thunder = new Thunder.Thunder5();}
		catch(e){
			this._thunder = null;}
	}
	return this._thunder;
}
Thunder.Thunder5.prototype = {
	initialize: function(){
		try{
			this.__thunder = new ActiveXObject("ThunderAgent.Agent.1");
		}catch(e){throw(e);}
	},
	
	download: function(cid, url, refer, name, stat){
		try{			

			name=name?name:"";
			this.addTask('', url, refer, name, stat);
			this.commitTasks();
		}catch(e){
			alert(e.message);
		}
	},
	
	addTask: function(cid, url, refer, name, stat){
		var _addTask = [
			Delegate.create(this, function(){this.__thunder.AddTask4(url, "", "", name, refer, -1, 0, -1, document.cookie, cid, stat);}),
			Delegate.create(this, function(){this.__thunder.AddTask3(url, "", "", name, refer, -1, 0, -1, document.cookie, cid);}),
			Delegate.create(this, function(){this.__thunder.AddTask2(url, "", "", name, refer, -1, 0, -1, document.cookie);}),
			Delegate.create(this, function(){this.__thunder.AddTask(url, "", "", name, refer, -1, 0, -1);})
		];
		for (var i=0; i<_addTask.length; i++){
			try{
				_addTask[i]();
				return;
			}catch(e){	
			}
		}
		throw thunderLanguage["MethodUnSupported"];
	},
	
	commitTasks: function(){
		var _commitTasks = [
			Delegate.create(this, function(){this.__thunder.CommitTasks2(1);}),
			Delegate.create(this, function(){this.__thunder.CommitTasks();})
		];
		for (var i=0; i<_commitTasks.length; i++){
			try{
				_commitTasks[i]();
				return;
			}catch(e){
			}
		}
		throw thunderLanguage["MethodUnSupported"];
	}
}

Thunder.ffThunder= Class.create();
Thunder.ffThunder.getInstance=function(){		
		if(isUndef(this._thObj) || this._thObj==0){
			//thunder Object for firefox initialized here
			try{
				netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");					
				try{
					this._thObj = new Thunder.ffThunder();}			
				catch(e){
					this._thObj = null;
				}
			}catch(e){
				alert(thunderLanguage["FFDenied"]);
				this._thObj = 0;
			}			
		}
		return this._thObj;
}
Thunder.ffThunder.prototype={
		initialize:function(){		
			if(isUndef(this.__thObj)){
				try{
					netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");					
				}catch(e){
					this.__thObj = '';
				}
				try{
					this.__thObj = Components.classes["@xunlei.com/ThunderLoader;1"].createInstance();
					this.__thObj = this.__thObj.QueryInterface(Components.interfaces.IThunderDownload);  					
				}catch(err){					
					throw(err);
				}
				
			}

			return this.__thObj;
		},
		getClientType:function(){		
			netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
			if(!isUndef(this.__thObj))
			{									
				return this.__thObj.GetThunderClientInfo();
			}else{
				return 0;
			}
		},
		getVersion:function(t){
			netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
			if(!isUndef(this.__thObj))
			{
				var ct=this.__thObj.getClientType();
				t=t?t:ct;
				
				switch(t)
				{
					case 2:
					case 3:
						return this.__thObj.GetClientBuildVersion(1);
						break;
					case 1:
						return this.__thObj.GetClientBuildVersion(2);				
				}					
			}
			return "";			
		},
		download:function(cid,url,refer,name,stat,type){
			netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
			type=type?type:2;						
			var stype=this.getClientType();			
			if(stype==3) stype=type;
			if(stype==1) cid='';
			name=name?name:"";
			stat=stat?stat:"";
			this.__thObj.CallThunderClient(stype,url,refer,stat,"",name,cid,document.cookie);
		}
}

⌨️ 快捷键说明

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