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

📄 control.js

📁 vc-mfc编程实例 很简单的东西,以后回多传自己的东西
💻 JS
📖 第 1 页 / 共 5 页
字号:

var RITButton=function(id,text)
{
	this.btText=text
	this.onclick=function(){}
	this.btObj=null;
	this.btID=id;
	this.pChange=function(pObj)
	{
		return function()
		{
			if (event.propertyName=="dsiabled")
			{
				//alert(pObj.btObj.dsiabled)
				if(pObj.btObj.dsiabled)
				{
					
					button_switchStatus(2,pObj.btID+"_RIT",document.getElementById(pObj.btID+"_RIT"))
				}
				else
				{
					button_switchStatus(0,pObj.btID+"_RIT",document.getElementById(pObj.btID+"_RIT"))	
				}
			}
		}
	}
	
	this.attachObj=function(buttonObj)
	{
		this.btObj=buttonObj;
		this.btObj.onpropertychange=this.pChange(this);
		this.btObj.setValue=this.setButotnValue(this);
		this.btObj.GetValue=this.GetButotnValue();
	}
	
	this.setId=function(id)
	{
		this.btID=id;
	}
	this.GetButotnValue=function()
	{
		//return function(val)
//		{
//			if (val.length>20)
//			{
//				
//			}
//			else
//			{
//				var intI=20-val.length+2;
//				intI=parseInt(intI/2);
//				var tmpStr9="";
//				for( var i=0;i<intI;i++)
//				{
//					tmpStr9+="&nbsp;";	
//				}
//				val=tmpStr9+val+tmpStr9;
//			}
//			val=val.replace(/\</g,"&lt;");
//			val=val.replace(/\>/g,"&gt;");
//			document.getElementById(this.id+"_RIT_spanb").innerHTML=val;
//		}
		//return document.getElementById(this.id+"_RIT_spanb").innerHTML;
	}
	this.setButotnValue=function(cusObj)
	{
		return function(val)
		{
			if (val.length>20)
			{
				
			}
			else
			{
				var intI=20-val.length+2;
				intI=parseInt(intI/2);
				var tmpStr9="";
				for( var i=0;i<intI;i++)
				{
					tmpStr9+="&nbsp;";	
				}
				val=tmpStr9+val+tmpStr9;
			}
			val=val.replace(/\</g,"&lt;");
			val=val.replace(/\>/g,"&gt;");
			document.getElementById(this.id+"_RIT_spanb").innerHTML=val;
		}
	}
	this.setText=function(text)
	{
		this.btText=text;
	}
	this.getHTML=function()
	{
		if (this.btID=="" || this.btText=="")
		{
			return "";
		}
		var htmlStr="";
		htmlStr+='<table   id=\"'+this.btID+'_RIT\" border="0" cellspacing="0" cellpadding="0" style="display:inline; cursor:default;" onselectstart="return false">';
		htmlStr+='<tr>';
		htmlStr+='<td>';
		htmlStr+='<span id=\"'+this.btID+'_RIT_spana\" style="margin:0px;height:20px; width:6px; background-image:url(buttonimages/button_left.jpg); float:left;"><img src="buttonimages/spacer.gif" style="width:1px; height:1px;" /></span>';
		if (this.btText.length>14)
		{
			htmlStr+='<span id=\"'+this.btID+'_RIT_spanb\" style="margin:0px;height:20px;background-image:url(buttonimages/button_center.jpg); line-height:20px; display:inline-table; font-family:Tahoma,Arial, Helvetica, sans-serif; font-size:11px; padding-left:3px; padding-right:3px;float:left;" onselectstart="return false">'+this.btText+'</span>';
		}
		else
		{
			var intI=14-this.btText.length+2;
			intI=parseInt(intI/2);
			var tmpStr9="";
			for( var i=0;i<intI;i++)
			{
				tmpStr9+="&nbsp;";	
			}
			htmlStr+='<span id=\"'+this.btID+'_RIT_spanb\" style="margin:0px;height:20px;background-image:url(buttonimages/button_center.jpg); line-height:20px; display:inline-table; font-family:Tahoma,Arial, Helvetica, sans-serif; font-size:11px; padding-left:3px; padding-right:3px;float:left;" onselectstart="return false">'+tmpStr9+this.btText+tmpStr9+'</span>';
		}
		htmlStr+='<span id=\"'+this.btID+'_RIT_spanc\" style="margin:0px;height:20px; width:6px; background-image:url(buttonimages/button_right.jpg); float:left; background-position:right;"><img src="buttonimages/spacer.gif" style="width:1px; height:1px;" /></span>';
		htmlStr+='</td>';
		htmlStr+='</tr>';
		htmlStr+='</table>';
		return htmlStr;
	}
}

function button_switchStatus(flag,id,obj)
{
		if (flag==1)
		{
			//document.getElementById(id+"_spana").style.backgroundImage="url(images/button_left_b.jpg)";
			//document.getElementById(id+"_spanb").style.backgroundImage="url(images/button_center_b.jpg)";
			//document.getElementById(id+"_spanc").style.backgroundImage="url(images/button_right_b.jpg)";
			obj.firstChild.firstChild.firstChild.childNodes[0].style.backgroundImage="url(buttonimages/button_left_b.jpg)";
			obj.firstChild.firstChild.firstChild.childNodes[1].style.backgroundImage="url(buttonimages/button_center_b.jpg)";
			obj.firstChild.firstChild.firstChild.childNodes[1].style.color="#000000";
			obj.firstChild.firstChild.firstChild.childNodes[2].style.backgroundImage="url(buttonimages/button_right_b.jpg)";
		}
		else if (flag==0)
		{
			//document.getElementById(id+"_spana").style.backgroundImage="url(images/button_left.jpg)";
			//document.getElementById(id+"_spanb").style.backgroundImage="url(images/button_center.jpg)";
			//document.getElementById(id+"_spanc").style.backgroundImage="url(images/button_right.jpg)";
			obj.firstChild.firstChild.firstChild.childNodes[0].style.backgroundImage="url(buttonimages/button_left.jpg)";
			obj.firstChild.firstChild.firstChild.childNodes[1].style.backgroundImage="url(buttonimages/button_center.jpg)";
			obj.firstChild.firstChild.firstChild.childNodes[1].style.color="#000000";
			obj.firstChild.firstChild.firstChild.childNodes[2].style.backgroundImage="url(buttonimages/button_right.jpg)";
		}
		else if (flag==2)
		{
			//document.getElementById(id+"_spana").style.backgroundImage="url(images/button_left.jpg)";
			//document.getElementById(id+"_spanb").style.backgroundImage="url(images/button_center.jpg)";
			//document.getElementById(id+"_spanc").style.backgroundImage="url(images/button_right.jpg)";
			obj.firstChild.firstChild.firstChild.childNodes[0].style.backgroundImage="url(buttonimages/button_left_c.jpg)";
			obj.firstChild.firstChild.firstChild.childNodes[1].style.backgroundImage="url(buttonimages/button_center_c.jpg)";
			obj.firstChild.firstChild.firstChild.childNodes[1].style.color="#999999";
			obj.firstChild.firstChild.firstChild.childNodes[2].style.backgroundImage="url(buttonimages/button_right_c.jpg)";
		}
}


/////////////////////Class progressControl 用于显示进度//////////////////////////////
//						progressControl(int width,DomObj parentNodeObj)
//							width:宽度
//							parentNodeObj:需要展开到的节点对象或者是id
//----------------------------------------------
//	Method				setProgress(int progress);	//设置进度
//						getProgress();				//得到进度	返回当前进度
//
//
//	Event				onEnd;		//结束时触发
//
/////////////////progress control////////////////
var progressControl=function(width,parentNodeObj)
{
	this.pNode=null;
	this.cWidth=width;
	this.currentProgress=0;
	
	this.getElementPosition=function(element)
	{
		if (element==null)
		{
			return "";
		}
		var vParent=null;
		var vleft=0;
		var vtop=0;
		vParent=element;
    	while (vParent.tagName.toUpperCase() != "BODY")
		{
			var scroTop=vParent.scrollTop;
			vleft += vParent.offsetLeft;
			vtop += (vParent.offsetTop-scroTop);
			vParent = vParent.offsetParent;
		}
		return vleft+"|"+vtop;
	}
	
	
	if (typeof(parentNodeObj)=="object")
	{
		this.pNode=parentNodeObj;
	}
	else if (typeof(parentNodeObj)=="string")
	{
		this.pNode=document.getElementById(parentNodeObj);
		if (this.pNode==null)//////////////parent node not fund
		{
			return false;
		}
	}
	else//////////////parent node not fund
	{
		return false;
	}
	if(typeof(width)!="number") {return false}///////
	
	this.pNode.style.position="relative";
	
	this.progressDiv=document.createElement("div");
	this.progressDiv.style.width=width+"px";
	this.progressDiv.style.height="21px";
	this.progressDiv.style.backgroundImage='url(progressimages/progress_base_mid.jpg)';
	
	this.progressDiv_base_left=document.createElement("div");
	this.progressDiv_base_left.style.width=width+"px";
	this.progressDiv_base_left.style.height="21px";
	this.progressDiv_base_left.style.backgroundImage='url(progressimages/progress_base_left.jpg)';
	this.progressDiv_base_left.style.backgroundRepeat='no-repeat';
	
	this.progressDiv_base_right=document.createElement("div");
	this.progressDiv_base_right.style.width=width+"px";
	this.progressDiv_base_right.style.height="21px";
	this.progressDiv_base_right.style.backgroundImage='url(progressimages/progress_base_right.jpg)';
	this.progressDiv_base_right.style.backgroundRepeat='no-repeat';
	this.progressDiv_base_right.style.backgroundPosition="right";
	
	this.progressDiv_top=document.createElement("div");
	this.progressDiv_top.style.width="1px";
	this.progressDiv_top.style.height="21px";
	this.progressDiv_top.style.backgroundImage='url(progressimages/progress_top_mid.jpg)';

	this.progressDiv_top_left=document.createElement("div");
	this.progressDiv_top_left.style.width="1px";
	this.progressDiv_top_left.style.height="21px";
	this.progressDiv_top_left.style.backgroundImage='url(progressimages/progress_top_left.jpg)';
	this.progressDiv_top_left.style.backgroundRepeat='no-repeat';
	
	this.progressDiv_top_right=document.createElement("div");
	this.progressDiv_top_right.style.width="1px";
	this.progressDiv_top_right.style.height="21px";
	this.progressDiv_top_right.style.backgroundImage='url(progressimages/progress_top_right.jpg)';
	this.progressDiv_top_right.style.backgroundRepeat='no-repeat';
	this.progressDiv_top_right.style.backgroundPosition="right";
	
	
	this.progressDiv_top_left.appendChild(this.progressDiv_top_right);
	this.progressDiv_top.appendChild(this.progressDiv_top_left);
	this.progressDiv_base_right.appendChild(this.progressDiv_top);
	this.progressDiv_base_left.appendChild(this.progressDiv_base_right);
	this.progressDiv.appendChild(this.progressDiv_base_left);
	

	this.progressText=document.createElement("div");
	this.progressText.style.position="absolute";
	this.progressText.style.top="0px";
	this.progressText.style.textAlign="center";
	this.progressText.style.fontSize="12px";
	this.progressText.style.paddingTop="4px";
	this.progressText.style.width=width+"px";
	this.progressText.style.height="21px";
	this.progressText.style.color="#000000";
	this.progressText.innerHTML="0%";
	
	
	

	this.pNode.appendChild(this.progressDiv);
	this.pNode.appendChild(this.progressText);
	
	
	this.setProgress=function(num)
	{
		if (num>100)
		{
			num=100;
		}
		this.currentProgress=num;
		var newWidth=Math.floor(this.cWidth*num/100);
		
		this.progressDiv_top.style.width=newWidth+"px";
		this.progressDiv_top_left.style.width=newWidth+"px";
		this.progressDiv_top_right.style.width=newWidth+"px";
		this.progressText.innerHTML=num+"%";
		if (num==100)
		{
			if(typeof(this.onEnd)=="function")
			{
				this.onEnd();
			}
		}
	}
	

	
	
	this.getProgress=function()
	{
		return this.currentProgress;
	}
	
	this.onEnd=function()
	{
		
	}
	
	
}
/////////////////progress control end////////////////





//////////////////////////////////////////////
//需要空间 , 剩余空间 图形显示。
//
/////////////////////////////////////////////
var onePartitionInfoBar=function(width,id,text,size,type)
{
	this.pNode=null;
	this.cWidth=width;
	this.currentProgress=0;
	this.id=id;
	this.text=text;
	this.size=size;
	this.isEndOne=false;
	if (type=="end")
	{
		this.isEndOne=true;
		this.rightPadding=5;
	}
	else
	{
		this.rightPadding=4;
	}
	
	while (id>=1)
	{
		id-=4;	
	}
	this.id=id+4;
	
	this.getBar=function()
	{
		if(typeof(this.cWidth)!="number") {return null}///////
		this.spaceInfoDiv=document.createElement("div");
		this.spaceInfoDiv.style.width=this.cWidth+"px";
		this.spaceInfoDiv.style.height="44px";
		this.spaceInfoDiv.style.backgroundImage='url(controlimages/space_info_color'+this.id+'_mid.jpg)';
		this.spaceInfoDiv.style.styleFloat="left";
	
		this.spaceInfoDiv_base_left=document.createElement("div");
		this.spaceInfoDiv_base_left.style.width=this.cWidth+"px";
		this.spaceInfoDiv_base_left.style.height="44px";
		this.spaceInfoDiv_base_left.style.backgroundImage='url(controlimages/space_info_color'+this.id+'_left.jpg)';
		this.spaceInfoDiv_base_left.style.backgroundRepeat='no-repeat';
	
		this.spaceInfoDiv_base_right=document.createElement("div");
		this.spaceInfoDiv_base_right.style.width=this.cWidth+"px";
		this.spaceInfoDiv_base_right.style.height="44px";
		this.spaceInfoDiv_base_right.style.backgroundImage='url(controlimages/space_info_color'+this.id+'_right.jpg)';
		this.spaceInfoDiv_base_right.style.backgroundRepeat='no-repeat';
		//this.spaceInfoDiv_base_right.style.backgroundPosition="right";
		this.spaceInfoDiv_base_right.style.backgroundPositionX=(this.cWidth-this.rightPadding)+"px";
		this.spaceInfoDiv_base_right.innerText=this.text;
		this.spaceInfoDiv_base_right.title="Partition "+this.text+"\nSize "+this.size;
		this.spaceInfoDiv_base_right.style.color="#1C4478";
		this.spaceInfoDiv_base_right.style.paddingLeft="6px";
		this.spaceInfoDiv_base_right.style.paddingTop="4px";
		this.spaceInfoDiv_base_right.style.fontSize="12px";
		this.spaceInfoDiv_base_right.style.fontFamily="Tahoma, Arial";
		this.spaceInfoDiv_base_right.style.overflow="hidden";
	
		this.spaceInfoDiv_base_left.appendChild(this.spaceInfoDiv_base_right);
		this.spaceInfoDiv.appendChild(this.spaceInfoDiv_base_left);
		return this.spaceInfoDiv;
	}

}


var partitionInfoBar=function()
{
	this.pNode=null;
	this.totalSize=0;
	
	this.showInfo=function(array1,width,parentNodeId)
	{
		var tmpArray=new Array();
		var tmpNumber=0;
		var tmpOneBarLength=0;
		var tmpCreateNodeObj;
		var returnElementArray=new Array();
		if (typeof(parentNodeId)=="object")
		{
			this.pNode=parentNodeId;
		}
		else if (typeof(parentNodeId)=="string")
		{
			this.pNode=document.getElementById(parentNodeId);
			if (this.pNode==null)//////////////parent node not fund
			{
				return false;
			}
		}
		if (typeof(array1)!="object")
		{
			return false;	
		}
		if(array1.length){}else{return false;}
		if(typeof(width)!="number") {return false}
		
		for (i=0;i<array1.length;i++)
		{
			tmpArray=array1[i].split("|");
			tmpNumber=parseInt(tmpArray[1]);
			this.totalSize+=tmpNumber;
		}
		if (this.totalSize==0)
		{
			return false;	
		}
		
		
		for (i=0;i<array1.length;i++)
		{
			tmpArray=array1[i].split("|");
			tmpNumber=parseInt(tmpArray[1]);
			tmpOneBarLength=Math.floor((width/this.totalSize)*tmpNumber);
			if (i==array1.length-1)//if it's last one;
			{
				tmpCreateNodeObj=new onePartitionInfoBar(tmpOneBarLength,i,tmpArray[0],tmpArray[1],"end");
			}
			else
			{
				tmpCreateNodeObj=new onePartitionInfoBar(tmpOneBarLength,i,tmpArray[0],tmpArray[1]);
			}
			returnElementArray[i]=tmpCreateNodeObj.getBar();

⌨️ 快捷键说明

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