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

📄 toolbar.js

📁 TUSB3410 win9x和win xp 驱动源代码,包含开发测试工具
💻 JS
📖 第 1 页 / 共 2 页
字号:
// ----------------------------------------------------------------------
// FILE NAME: toolbar.js
// DATE: 22 March 1999
// PURPOSE:
//	This is the file that builds the toolbar and banner areas.
// ----------------------------------------------------------------------

var ToolBar_Supported = false;
var Frame_Supported   = false;
var DoInstrumentation = false;

if (navigator.userAgent.indexOf("MSIE")!= -1 && 
	navigator.userAgent.indexOf("Windows") != -1 && 
	navigator.appVersion.substring(0,1) > 3)
{
	ToolBar_Supported = true;
}

if (ToolBar_Supported)
{
	var newLineChar = String.fromCharCode(10);
	var char34 = String.fromCharCode(34);
	var LastMSMenu = "";
	var CurICPMenu = "";
	var IsMSMenu = false;
	var IsMenuDropDown = true;
	var HTMLStr;
	var x = 0;
	var y = 0;
	var x2 = 0;
	var y2 = 0;
	var MSMenuWidth;
	var ToolbarMinWidth;
	var ToolbarMenu;
	var ToolbarBGColor;
	var ToolbarLoaded = false;
	var aDefMSColor  = new Array(3);
	var aDefICPColor = new Array(3);
	var aCurMSColor  = new Array(3);
	var aCurICPColor = new Array(3);
 	var MSFont;
 	var ICPFont;
 	var MaxMenu = 30;
 	var TotalMenu = 0;
 	var arrMenuInfo = new Array(30);
	var ImageDir;

	if (ImageDir == null)
		ImageDir = "/ddk/utility/toolbar/en-us/";

	// Output style sheet and toolbar ID
	document.write("<SPAN ID='StartMenu' STYLE='display:none;'></SPAN>");

	// Build toolbar template
	HTMLStr = 
		"<DIV ID='idToolbar'     STYLE='background-color:white;width:100%'>" +
		"<DIV ID='idRow1'        STYLE='position:relative;height:20;'>" +
		"<DIV ID='idICPBanner'   STYLE='position:absolute;top:0;left:0;height:60;width:250;overflow:hidden;vertical-align:top;'><!--BEG_ICP_BANNER--><!--END_ICP_BANNER--></DIV>" +
		"<DIV ID='idMSMenuCurve' STYLE='position:absolute;top:0;left:250;height:20;width:18;overflow:hidden;vertical-align:top;'><IMG SRC='" + ImageDir + "curve.gif' BORDER=0></DIV>" +
 		"<DIV ID='idMSMenuPane'  STYLE='position:absolute;top:0;left:250;height:20;width:10;background-color:black;float:right;' NOWRAP><!--MS_MENU_TITLES--></DIV>" + 
		"</DIV>" +
  		"<DIV ID='idRow2'        STYLE='position:relative;left:250;height:40;'>" +
 		"<DIV ID='idMSCBanner'   STYLE='position:absolute;top:0;left:0;height:40;width:204;vertical-align:top;overflow:hidden;' ALIGN=RIGHT><!--BEG_MSC_BANNER--><!--END_MSC_BANNER--></DIV>" +
		"</DIV>" +
 		"<DIV ID='idRow3'        STYLE='z-index:5;position:relative;height:20;width:100%;'>" +
 		"<DIV ID='idICPMenuPane' STYLE='position:absolute;top:0;left:0;height:20;background-color:black;' NOWRAP><!--ICP_MENU_TITLES--></DIV>" +
		"</DIV>" +
		"</DIV>" +
		"<SCRIPT TYPE='text/javascript'>" + 
		"   var ToolbarMenu = StartMenu;" + 
		"</SCRIPT>" + 
		"<DIV WIDTH=100%>";

	// Define event handlers
	window.onresize  = resizeToolbar;
 	document.onmouseover = hideMenu;

	// Intialize global variables
	ToolbarBGColor	= "white";				// toolbar background color
 	MSFont  = "xx-small Verdana";
 	ICPFont = "bold xx-small Verdana";
	
	aDefMSColor[0]	= aCurMSColor[0]  = "black";		// bgcolor;
	aDefMSColor[1]	= aCurMSColor[1]  = "white";		// text font color
	aDefMSColor[2]  = aCurMSColor[2]  = "red";		// mouseover font color
	
	aDefICPColor[0]	= aCurICPColor[0] = "#6699CC";		// bgcolor F2AC50;
	aDefICPColor[1] = aCurICPColor[1] = "white";		// text font color
	aDefICPColor[2] = aCurICPColor[2] = "red";		// mouseover font color
}

// The hard-coded numbers in functions - drawToolbar() & resizeToolbar()
// correspond to the dimensions of the four gif files:
//	ICP_BANNER: 60h x 250w
//	ADS_BANNER: 40h x 200w (108w) <-- Not in use for CustomerWeb
//	MSC_BANNER: 40h x 112w (204w)
//	Curve:	    20h x 18w

function drawToolbar()
{
	HTMLStr += "</DIV>";
	document.write(HTMLStr);
	ToolbarLoaded = true;

	MSMenuWidth = Math.max(idMSMenuPane.offsetWidth, (204));
	ToolbarMinWidth = (250+18) + MSMenuWidth;

	idToolbar.style.backgroundColor = ToolbarBGColor;
	idMSMenuPane.style.backgroundColor  = aDefMSColor[0];
	idICPMenuPane.style.backgroundColor = aDefICPColor[0];
	resizeToolbar();
 	for (i = 0; i < TotalMenu; i++) 
 	{
 		thisMenu = document.all(arrMenuInfo[i].IDStr);
 		if (thisMenu != null)
 		{
 			if (arrMenuInfo[i].IDStr == LastMSMenu && arrMenuInfo[i].type == "R")
 			{
 				//Last MSMenu has to be absolute width
 				arrMenuInfo[i].type = "A";
 				arrMenuInfo[i].unit = 200;
 			}
 			if (arrMenuInfo[i].type == "A")
				thisMenu.style.width = arrMenuInfo[i].unit;
			else 
				thisMenu.style.width = Math.round(arrMenuInfo[i].width * arrMenuInfo[i].unit) + 'em';
 		}
 	}
}

function resizeToolbar()
{
	if (ToolBar_Supported == false) return;

	w = Math.max(ToolbarMinWidth, document.body.clientWidth) - ToolbarMinWidth;

	idMSMenuCurve.style.left = (250+w);
	idMSMenuPane.style.left  = (250+w+18);
	idMSMenuPane.style.width = MSMenuWidth;

	idMSCBanner.style.left  = (w+18);
	idMSCBanner.style.width = (MSMenuWidth);
		
	idICPMenuPane.style.width = ToolbarMinWidth + w;
}

function setToolbarBGColor(color)
{	
	ToolbarBGColor = color;
	if (ToolbarLoaded == true)
		idToolbar.style.backgroundColor = ToolbarBGColor;
}	

function setMSMenuFont(sFont)
{	MSFont = sFont;
}
 
function setICPMenuFont(sFont)
{	ICPFont = sFont;
}
 
function setDefaultMSMenuColor(bgColor, fontColor, mouseoverColor)
{	
	if (bgColor   != "")	  aDefMSColor[0] = bgColor;
	if (fontColor != "")	  aDefMSColor[1] = fontColor;
	if (mouseoverColor != "") aDefMSColor[2] = mouseoverColor;
}

function setDefaultICPMenuColor(bgColor, fontColor, mouseoverColor)
{
	if (bgColor   != "")	  aDefICPColor[0] = bgColor;
	if (fontColor != "")	  aDefICPColor[1] = fontColor;
	if (mouseoverColor != "") aDefICPColor[2] = mouseoverColor;
}

function setICPMenuColor(MenuIDStr, bgColor, fontColor, mouseoverColor)
{
	if (ToolbarLoaded == false) return;

	// Reset previous ICP Menu color if any
	if (CurICPMenu != "")
	{
		PrevID = CurICPMenu.substring(4);
		CurICPMenu = "";
		setICPMenuColor(PrevID, aDefICPColor[0], aDefICPColor[1], aDefICPColor[2]);
	}

	var id = "AM_" + "ICP_" + MenuIDStr;
	var thisMenu = document.all(id);
	if (thisMenu != null)
	{
		CurICPMenu = "ICP_" + MenuIDStr;
		aCurICPColor[0] = bgColor;
		aCurICPColor[1] = fontColor;
		aCurICPColor[2] = mouseoverColor;

		// Change menu color
		if (bgColor != "")
			thisMenu.style.backgroundColor = bgColor;
		if (fontColor != "")
			thisMenu.style.color = fontColor;

		// Change subMenu color
		id = "ICP_" + MenuIDStr;
		thisMenu = document.all(id);
		if (thisMenu != null)
		{
			if (bgColor != "")
				thisMenu.style.backgroundColor = bgColor;
			
			if (fontColor != "")
			{
				i = 0;
				id = "AS_" + "ICP_" + MenuIDStr;
				thisMenu = document.all.item(id,i);
				while (thisMenu != null)
				{
					thisMenu.style.color = fontColor;
					i += 1;
					thisMenu = document.all.item(id,i);
				}
			}
		}
	}
}

function setICPMenuColor2(MenuIDStr, bgColor, fontColor, mouseoverColor)
{	
	if (ToolbarLoaded == false) return;

	// Reset previous ICP Menu color if any
	if (CurICPMenu != "")
	{
		PrevID = CurICPMenu.substring(4);
		CurICPMenu = "";
		setICPMenuColor(PrevID, aDefICPColor[0], aDefICPColor[1], aDefICPColor[2]);
	}

	var id = "AM_" + "ICP_" + MenuIDStr;
	var thisMenu = document.all(id);
	if (thisMenu != null)
	{
		CurICPMenu = "ICP_" + MenuIDStr;
		aCurICPColor[0] = bgColor;
		aCurICPColor[1] = fontColor;
		aCurICPColor[2] = mouseoverColor;

		// Change menu color
		if (bgColor != "")
			thisMenu.style.backgroundColor = bgColor;
		if (fontColor != "")
			thisMenu.style.color = fontColor;
		if (mouseoverColor != "")
			thisMenu.style.mouseoverColor = mouseoverColor;

	}
}

function setAds(Gif,Url,AltStr)
{	return true;
}

function setICPBanner(Gif,Url,AltStr)
{	setBanner(Gif,Url,AltStr,"<!--BEG_ICP_BANNER-->","<!--END_ICP_BANNER-->");
}

function setMSBanner(Gif,Url,AltStr)
{	tempGif = Gif;
	setBanner(tempGif,Url,AltStr,"<!--BEG_MSC_BANNER-->","<!--END_MSC_BANNER-->");
}

function setBanner(BanGif, BanUrl, BanAltStr, BanBegTag, BanEndTag)
{
	begPos = HTMLStr.indexOf(BanBegTag);
	endPos = HTMLStr.indexOf(BanEndTag) + BanEndTag.length;
	
	SubStr = HTMLStr.substring(begPos, endPos);
	SrcStr = "";
	if (BanUrl != "")
 		SrcStr += "<A Target='_top' HREF='" + formatURL(BanUrl, BanGif) + "'>";
	SrcStr += "<IMG SRC='" + ImageDir + BanGif + "' ALT='" + BanAltStr + "' BORDER=0>";
	if (BanUrl != "")
		SrcStr += "</A>";
	SrcStr = BanBegTag + SrcStr + BanEndTag;
	HTMLStr = HTMLStr.replace(SubStr, SrcStr);	
}

function setICPSubMenuWidth(MenuIDStr, WidthType, WidthUnit)
{	tempID = "ICP_" + MenuIDStr;
	setSubMenuWidth(tempID, WidthType, WidthUnit);
}

function setMSSubMenuWidth(MenuIDStr, WidthType, WidthUnit)
{	tempID = "MS_" + MenuIDStr;
	setSubMenuWidth(tempID, WidthType, WidthUnit);
}

function setSubMenuWidth(MenuIDStr, WidthType, WidthUnit)
{
 	var fFound = false;
 	if (TotalMenu == MaxMenu)
 	{
 		alert("Unable to process menu. Maximum of " + MaxMenu + " reached.");
 		return;
 	}
 	
 	for (i = 0; i < TotalMenu; i++)
 		if (arrMenuInfo[i].IDStr == MenuIDStr)
 		{
 			fFound = true;
 			break;
 		}
 
 	if (!fFound)
 	{
 		arrMenuInfo[i] = new menuInfo(MenuIDStr);
 		TotalMenu += 1;
 	}
 
 	if (!fFound && WidthType.toUpperCase().indexOf("DEFAULT") != -1)
 	{
 		arrMenuInfo[i].type = "A";
// 		arrMenuInfo[i].unit = 160;
// This works to change the menu width
 		arrMenuInfo[i].unit = 150;
 	}
 	else
 	{
 		arrMenuInfo[i].type = (WidthType.toUpperCase().indexOf("ABSOLUTE") != -1)? "A" : "R";
 		arrMenuInfo[i].unit = WidthUnit;
 	}
}
 
// This function creates a menuInfo object instance.

⌨️ 快捷键说明

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