📄 control.js
字号:
}
if (storeType!="hdd")
{
if (Math.floor(spaceNeeded/onePieceSpace)==spaceNeeded/onePieceSpace)
{
pieceNeeded=Math.floor(spaceNeeded/onePieceSpace)
}
else
{
pieceNeeded=Math.floor(spaceNeeded/onePieceSpace)+1
}
this.totalDiscNum=pieceNeeded;
onePieceWidth=Math.floor(width/pieceNeeded)
errWidth=width-(onePieceWidth*pieceNeeded)
lastPiecePercent=(spaceNeeded-((pieceNeeded-1)*onePieceSpace))/onePieceSpace
lastPiecePercent=Math.floor(lastPiecePercent*100)
}
else
{
hddBgPersent=(spaceNeeded/total)*100
tmpStr+='<ul style="width:'+width+'px; margin:0px; height:16px; background-image:url(images/progresswaiting.jpg); background-repeat:repeat-x;">'
tmpStr+=this.getOnePieceShow(width,hddBgPersent,"")
tmpStr+="</ul>"
return tmpStr;
}
tmpStr+='<ul style="width:'+width+'px; margin:0px; height:16px; background-image:url(images/progresswaiting.jpg); background-repeat:repeat-x;">'
for (i=0;i<pieceNeeded;i++)
{
if (errWidth>0)
{
errWidth=errWidth-1;
addCount=1;
}
else
{
addCount=0;
}
if (i==pieceNeeded-1)
{
if (onePieceWidth<13)
{
tmpStr+=this.getOnePieceShow(onePieceWidth+addCount,lastPiecePercent,"")
}
else if (onePieceWidth<37)
{
tmpStr+=this.getOnePieceShow(onePieceWidth+addCount,lastPiecePercent,(i+1))
}
else
{
tmpStr+=this.getOnePieceShow(onePieceWidth+addCount,lastPiecePercent,"Disk"+(i+1))
}
}
else
{
if (onePieceWidth<13)
{
tmpStr+=this.getOnePieceShow(onePieceWidth+addCount,100,"")
}
else if (onePieceWidth<37)
{
tmpStr+=this.getOnePieceShow(onePieceWidth+addCount,100,(i+1))
}
else
{
tmpStr+=this.getOnePieceShow(onePieceWidth+addCount,100,"Disk"+(i+1))
}
}
}
tmpStr+="</ul>"
return tmpStr;
}
this.getOnePieceShow=function(width,percent,innerText)
{
var outStr;
var lastShowWidth;
lastShowWidth=(width*percent/100)-500;
outStr='<li style="list-style:none; height:15px; font-size:12px; background-image:url(images/progressfinished.jpg); width:'+width+'px; border-left:1px solid #ffffff; text-align:center; float:left; line-height:15px;background-position-x:'+lastShowWidth+'px; background-repeat:no-repeat; overflow:hidden;">'+innerText+'</li>'
return(outStr)
}
}
///////////////numBox Class///////////////
//构造:(name,width,defaultNum,step,editable)
// name:控件名字
// width:宽度
// defaultNum:默认值
// step:步长
// editable:是否可编辑
//
//方法 :display(parentNode)
// parentNode:父节点的ID
// :setValue(value)
// value:改变的值
// :getValue() :得到当前的值
//属性: minimumNum:最小值
// maximalNum:最大值
// value :当前值
//事件:onChange() :当值改变的时候触发
/////////////////////////////////////////
var numBox=function(name,width,defaultNum,step,editable)
{
if(isNaN(parseInt(width)) || isNaN(parseInt(defaultNum)) || isNaN(parseInt(step)))
{
alert("Create numBox failed.");
return;
}
this.randID=Math.floor(Math.random()*10000);
this.CtrName=name;
this.width=width;
this.defaultNumber=defaultNum;
this.step=step;
this.editable=editable;
this.boderColor="#666666";
this.minimumNum=0;
this.maximalNum="";
this.iniMinNum=0;
this.iniMaxNum="";
this.value=defaultNum
this.timeOutObj=null;
this.onChange=function(){};
this.changeValTimeout=null;
this.outTimeout=null;
this.display=function(parentNode)
{
var parentObject=null
if(typeof(parentNode)=="string")
{
parentObject=document.getElementById(parentNode);
}
else if (typeof(parentNode)=="object")
{
parentObject=parentNode
}
else
{
alert("Object display failed!\nPlease specify the Parent Node.")
return;
}
parentObject.cusObj=this;
parentObject.innerHTML='<div style="float:left; width:20px;">'
+'<input maxlength="12" value='+this.defaultNumber+' id="'+this.randID+this.CtrName+'_input" type="text" name="textfield" style="height:20px; width:'+this.width+'px; border-bottom:1px solid #666666; border-left:1px solid #666666; border-right:0px; border-top:1px solid #666666; margin:0px; line-height:16px;ime-mode:disabled"/>'
+'</div>'
+'<div style="float:left;border-bottom:1px solid #666666; border-right:1px solid #666666; border-left:0px; border-top:1px solid #666666; line-height:18px; height:18px; font-size:11px; margin-top:1px;">'
+' <div id="'+this.randID+this.CtrName+'_up_button" style="width:16; height:9px; background-image:url(numimages/num_up_arr.jpg); background-repeat:no-repeat; background-position-y:1px;"><img src="images/spacer.gif" width="1" height="1"/></div>'
+' <div id="'+this.randID+this.CtrName+'_down_button" style="width:16; height:9px; background-image:url(numimages/num_down_arr.jpg); background-repeat:no-repeat;background-position-y:1px;"><img src="images/spacer.gif" width="1" height="1"/></div>'
+'</div>'
//document.getElementById(this.randID+this.CtrName+'_down_button').onclick=this.getDonwFunction(this);
document.getElementById(this.randID+this.CtrName+'_down_button').onmouseout=this.getDownMouseOutFun(this);
document.getElementById(this.randID+this.CtrName+'_down_button').onmousedown=this.getDownMouseDownFun(this);
document.getElementById(this.randID+this.CtrName+'_down_button').onmouseup=this.getDownMouseUpFun(this);
document.getElementById(this.randID+this.CtrName+'_up_button').onmouseout=this.getUpMouseOutFun(this);
document.getElementById(this.randID+this.CtrName+'_up_button').onmousedown=this.getUpMouseDownFun(this);
document.getElementById(this.randID+this.CtrName+'_up_button').onmouseup=this.getUpMouseUpFun(this);
document.getElementById(this.randID+this.CtrName+'_input').onkeydown=this.getKeydownFunction(this);
document.getElementById(this.randID+this.CtrName+'_input').onpropertychange=this.getPropertyChangeFunction(this);
document.getElementById(this.randID+this.CtrName+'_input').onblur=this.getBlurFunction(this);
document.getElementById(this.randID+this.CtrName+'_input').onbeforepaste=this.getBeforepasteFunction(this);
if (this.defaultNumber<=this.minimumNum)
{
document.getElementById(this.randID+this.CtrName+'_down_button').style.filter="Gray()";
}
}
this.setValue=function(value)
{
if (value<this.minimumNum)
{
document.getElementById(this.randID+this.CtrName+'_input').value=this.minimumNum;
}
else if (this.maximalNum!="")
{
if (value>this.maximalNum)
{
document.getElementById(this.randID+this.CtrName+'_input').value=this.maximalNum;
}
else
{
document.getElementById(this.randID+this.CtrName+'_input').value=value;
}
}
else
{
document.getElementById(this.randID+this.CtrName+'_input').value=value;
}
}
this.getValue=function()
{
if (parseInt(this.value)<this.minimumNum)
{
return (this.minimumNum*1);
}
if (parseInt(this.value)>this.maximalNum && this.maximalNum!="")
{
return (this.maximalNum*1);
}
return (this.value*1);
}
this.getPropertyChangeFunction=function(obj)
{
return function()
{
if(event.propertyName=="value")
{
var inputObj=document.getElementById(obj.randID+obj.CtrName+'_input');
if (inputObj.value=="")
{
inputObj.value=0;
}
if ((inputObj.value+"")!=(parseInt(inputObj.value)+""))
{
if (isNaN(parseInt(inputObj.value,10)))
{
inputObj.value=0;
}
else
{
inputObj.value=parseInt(inputObj.value,10);
}
}
clearTimeout(obj.timeOutObj);
//obj.timeOutObj=setTimeout(obj.checkInput(obj),1000);
}
var oldObjValue=obj.value;
obj.value=this.value;
if(oldObjValue!=this.value)
{
obj.onChange();
}
//alert(obj.minimumNum);
document.getElementById(obj.randID+obj.CtrName+'_down_button').style.filter="";
document.getElementById(obj.randID+obj.CtrName+'_up_button').style.filter="";
if (parseInt(this.value)<=obj.minimumNum)
{
document.getElementById(obj.randID+obj.CtrName+'_down_button').style.filter="Gray()";
}
if(parseInt(this.value)>=obj.maximalNum)
{
document.getElementById(obj.randID+obj.CtrName+'_up_button').style.filter="Gray()";
}
}
}
this.getBlurFunction=function(obj)
{
return function()
{
obj.checkInput(obj)();
}
}
this.getBeforepasteFunction=function(obj)
{
return function()
{
try{
clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))
}
catch(ssss){}
}
}
this.checkInput=function(obj)
{
return function()
{
var inputObj=document.getElementById(obj.randID+obj.CtrName+'_input');
if (parseInt(inputObj.value)<obj.minimumNum)
{
inputObj.value=obj.minimumNum;
}
else if (parseInt(inputObj.value,10)>obj.maximalNum && obj.maximalNum!="")
{
inputObj.value=obj.maximalNum;
}
}
}
this.getKeydownFunction = function (obj)
{
return function()
{
var code=event.keyCode;
if(code==40)
{
obj.getDonwFunction(obj)();
}
else if (code==38)
{
obj.getUpFunction(obj)();
}
return true;
}
}
this.getDonwFunction=function(obj)
{
return function()
{
var inputObj=document.getElementById(obj.randID+obj.CtrName+'_input');
if ( isNaN(parseInt(inputObj.value),10) )
{
return;
}
var currentNum=parseInt(inputObj.value,10);
dstNum=currentNum-obj.step;
if (dstNum<=obj.minimumNum)
{
inputObj.value=obj.minimumNum;
document.getElementById(obj.randID+obj.CtrName+'_down_button').style.filter="Gray()";
}
else
{
inputObj.value=dstNum;
document.getElementById(obj.randID+obj.CtrName+'_up_button').style.filter="";
}
}
}
this.getDownMouseOutFun=function(obj)
{
return function()
{
clearTimeout(obj.outTimeout);
clearInterval(obj.changeValTimeout);
}
}
this.getDownMouseDownFun=function(obj)
{
return function()
{
obj.getDonwFunction(obj)();
obj.outTimeout=setTimeout(function(){obj.changeValTimeout=setInterval(obj.getDonwFunction(obj),200)},500)
}
}
this.getDownMouseUpFun=function(obj)
{
return function()
{
clearTimeout(obj.outTimeout);
clearInterval(obj.changeValTimeout);
}
}
this.getUpFunction=function(obj)
{
return function()
{
var inputObj=document.getElementById(obj.randID+obj.CtrName+'_input');
if (inputObj.value=="")
{
inputObj.value=0;
}
if ( isNaN(parseInt(inputObj.value,10)) )
{
return;
}
var currentNum=parseInt(inputObj.value,10);
dstNum=currentNum+obj.step;
if (obj.maximalNum=="")
{
inputObj.value=dstNum;
}
else
{
if (dstNum>=obj.maximalNum)
{
inputObj.value=obj.maximalNum
document.getElementById(obj.randID+obj.CtrName+'_up_button').style.filter="Gray()";
}
else
{
inputObj.value=dstNum;
document.getElementById(obj.randID+obj.CtrName+'_down_button').style.filter="";
}
}
}
}
this.getUpMouseOutFun=function(obj)
{
return function()
{
clearTimeout(obj.outTimeout);
clearInterval(obj.changeValTimeout);
}
}
this.getUpMouseDownFun=function(obj)
{
return function()
{
obj.getUpFunction(obj)();
obj.outTimeout=setTimeout(function(){obj.changeValTimeout=setInterval(obj.getUpFunction(obj),200)},500)
}
}
this.getUpMouseUpFun=function(obj)
{
return function()
{
clearTimeout(obj.outTimeout);
clearInterval(obj.changeValTimeout);
}
}
this.setMaxNum=function(intNum)
{
if (intNum<this.minimumNum)
{
return;
}
this.maximalNum=intNum;
var inputObj=document.getElementById(this.randID+this.CtrName+'_input');
if (intNum<=parseInt(this.getValue()))
{
inputObj.value=intNum;
document.getElementById(this.randID+this.CtrName+'_up_button').style.filter="Gray()";
}
else
{
document.getElementById(this.randID+this.CtrName+'_up_button').style.filter="";
}
//document.getElementById(obj.randID+obj.CtrName+'_down_button').style.filter="Gray()";
}
this.setMinNum=function(intNum)
{
if (intNum>this.maximalNum)
{
return;
}
this.minimumNum=intNum
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -