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

📄 common.js

📁 各种芯片资料
💻 JS
字号:
var gblSelectedImage="NONE";

// Images
function diSwap(imgName, imgObj) { 
	if(typeof(window[imgObj])!="undefined")
		document[imgName].src = window[imgObj].src;	
}

function diSwapOn(imgName) { 
	// check if try on the current page selected image
	if(document[imgName].src.indexOf(",on")>0) {
		gblSelectedImage=imgName;	
		return;
	}

	if( (typeof(window[imgName + "_on"])!="undefined")
	&& (typeof(window[imgName + "_on"].src)!="undefined"))
	{
		diSwap(imgName, imgName + "_on");
	} else {
		diLoad(imgName); 
		diSwap(imgName, imgName + "_on");
	}
}

function diSwapOff(imgName) { 
	// check if try off the current page selected image
	if(gblSelectedImage==imgName) return;
	
	if( (typeof(window[imgName + "_off"])!="undefined")
	&& (typeof(window[imgName + "_off"].src)!="undefined"))
	{
		diSwap(imgName, imgName + "_off");
	} else {
		diLoad(imgName); 
		diSwap(imgName, imgName + "_off");
	}
}

function diLoad(imgName) { 
	if( typeof(document[imgName])!="undefined")
	{	
		var imgsrc = document[imgName].src;
		eval(imgName +"_on = new Image()");
		eval(imgName +"_off = new Image()");
		
		imgsrc=imgsrc.replace(",off",",on");
		eval(imgName +"_on.src =\""+imgsrc +"\"");			
		imgsrc=imgsrc.replace(",on",",off");
		eval(imgName +"_off.src =\""+imgsrc +"\"");
	}
}

// Tools
function dtPopup(target, width, height, style, wnd, otop, oleft)
{
	if(!width) width=600;
	if(!height) height=400;
	if(!wnd) wnd="_blank";
	if(!style) style="toolbar=yes,menubar=yes,resizable=yes,scrollbars=yes";
	
	if(typeof(otop) != "undefined") wtop=otop;
	else {
		wtop= (window.screen.availHeight - height  - 120) / 2 ;
		if(wtop>50) wtop-=40;
	}
	if(typeof(oleft) != "undefined") wleft=oleft;
	else wleft= (window.screen.availWidth - width) / 2;
	
	style +=",left="+wleft+",top="+wtop+",height="+height+",width="+width;
	window.open(target,wnd,style);	
}	

function dtPopImg(imgName) {
	if( typeof(document[imgName])!="undefined")	{			
		dtPopup(document[imgName].src);
	} else {
		alert("Image :"+imgName+" not found");
	}
}

// Raymond 2005-04-04
function DIY_Browser() {
 d=document;
 this.agent=navigator.userAgent.toLowerCase();
 this.major = parseInt(navigator.appVersion);
 this.dom=(d.getElementById)?1:0; // true for ie6, ns6
 this.ns=(d.layers);
 this.ns4up=(this.ns && this.major >=4);
 this.ns6=(this.dom&&navigator.appName=="Netscape");
 this.op=(this.agent.indexOf('opera')!=-1&&this.major<7);
 this.opera5=(this.agent.indexOf("Opera 5")>-1);
 this.ie=(d.all);
 this.ie4=(d.all&&!this.dom)?1:0;
 this.ie4up=(this.ie && this.major >= 4);
 this.ie5=(d.all&&this.dom);
 this.ie6=(this.agent.indexOf("msie 6")>-1 && this.dom && !this.opera5)?1:0;
 this.win=((this.agent.indexOf("win")!=-1) || (this.agent.indexOf("16bit")!=-1));
 this.mac=(this.agent.indexOf("mac")!=-1);
 
 // new
 this.isFirefox = ( this.agent != null && this.agent.indexOf( "firefox" ) != -1 );
 this.isMSIE = ( this.agent != null && this.agent.indexOf( "msie" ) != -1 );
}


var oBw = new DIY_Browser();

/* _w : which ID (1) or (2) */
/* _h : (h)ide or (s)how */
function setShow(_w,_h) {
	if (oBw.dom)
	{
		if (_h=='s') document.getElementById(_w).style.visibility='visible';
		if (_h=='s') document.getElementById(_w).style.display='block';
		if (_h=='h') document.getElementById(_w).style.visibility='hidden';
		if (_h=='h') document.getElementById(_w).style.display='none';
	}
	else if (oBw.ie) {
		if (_h=='s') eval("document.all."+_w+".style.visibility='visible';");
		if (_h=='s') eval("document.all."+_w+".style.display='block';");
		if (_h=='h') eval("document.all."+_w+".style.visibility='hidden';");
		if (_h=='h') eval("document.all."+_w+".style.display='none';");
	}
	else if(oBw.ns)
	{
		if (_h=='s') eval("document.layers['"+_w+"'].visibility='show';");
		if (_h=='s') eval("document.layers['"+_w+"'].display='block';");
		if (_h=='h') eval("document.layers['"+_w+"'].visibility='hide';");
		if (_h=='h') eval("document.layers['"+_w+"'].display='none';");
	}
}

function showMore(){
	setShow("morePrd","s");
	setShow("lessBut","s");
	setShow("moreBut","h");
}

function hide(){
	setShow("morePrd","h");
	setShow("lessBut","h");
	setShow("moreBut","s");
}

function prnDIYAd(langID) {
	var clink="http://www.diytrade.com?rds=site&curLangID="+langID;
	var imgsrc="http://tpl.diytrade.com/sitetpl-img/diy_fsad_"+langID+".gif";
	var adcode='<a href="'+clink+'" target="_blank"' +
		' onmouseover="window.status=\'Go To DIYTrade.com!\'; return true" onmouseout="window.status=\'\'; return true">'+
		'<img src="'+imgsrc+'" border="0" width="468" height="60"/></a>';
	document.write(adcode);
}

function prnGoogleAd(langID) {
	var ranForDIY = Math.round(5*Math.random());
	if(ranForDIY==1) {
		prnDIYAd(langID);
		return;
	}
	
	//google_ad_client = "pub-6000707639731910";
	google_ad_client = "pub-1749648274355825";
	google_ad_width = 468;
	google_ad_height = 60;
	google_ad_format = "468x60_as";
	google_color_border = "CDCABB";
	google_color_bg = "FFFFFF";
	google_color_link = "0000FF";
	google_color_url = "008000";
	google_color_text = "000000";
	google_ad_type = "text";		
	google_ad_channel=(langID==4)?"0247381677":"7149479591";
	document.write('<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"><\/script>');
}

// diyepvd
if(oBw.isFirefox) {
	document.onmousedown=pvdClickFireFox; 
} else {
	document.onmousedown=pvdClickIE; 
}
function pvdClickFireFox(e) {pvdClick(e);}
function pvdClickIE() 		{pvdClick(window.event);}
function pvdClick(evt) { 
 if(typeof(evt)=="undefined") return; 
 if (evt && evt.ctrlKey  &&  (evt.button==1 || evt.button==0) ) { 
	window.open("http://pvd.diytrade.com/diyep/pvd-act/main/pvdst?r="+document.location,"_blank","");	
 } 
} 

⌨️ 快捷键说明

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