popouttimecode.js

来自「java swing源码 欢迎下载 有问题请联系 我一定负责到底」· JavaScript 代码 · 共 104 行

JS
104
字号
function funcTimeCode(){
	var qssm=document.all.qssm;
	var jmcd=document.all.jmcd;
	var jssm=document.all.jssm;
	try{
		if(qssm.value!=""){
			if((jmcd.value!="" && event.srcElement.name=="jmcd")|| (event.srcElement.name=="qssj" && jmcd.value!="" ) ){
				jssm.value=timeToTimeCode(timeCodeToTime(qssm.value) + timeCodeToTime(jmcd.value));
			}
			if(jssm.value!="" && event.srcElement.name=="jssm"){
				jmcd.value=timeToTimeCode(timeCodeToTime(jssm.value) - timeCodeToTime(qssm.value));
			}
		}
		var tmpTime=timeCodeToTime(qssm.value);
	}catch(e){
		alert(e.description);
	}
}

function timeCodeToTime(strInput){
	errMsg="";
	var reg =/^(\d{1,2}):(\d{1,2}):(\d{1,2}):(\d{1,2})$/; 
	var r = strInput.match(reg); 
	if(r==null){
		errMsg="不是有效的条码";
		return 0; 
	}
	
	//parseInt,当参数为08,或者07,09的时候会产生错误,需要预先进行以下处理
	for(j=1;j<=4;++j)
		if(r[j].charAt(0)=="0")
			r[j]=r[j].charAt(1);
	
	var hour=parseInt(r[1]);
	var minute=parseInt(r[2]);
	var second=parseInt(r[3]);
	var frame=parseInt(r[4]);
	var returnValue;
	returnValue=hour * 60 * 60 * 25 + minute * 60 * 25 + second * 25 + frame;
	return returnValue;
}

function timeToTimeCode(tmpTime){
	try{
		var hour=0;
		var minute=0;
		var second=0;
		var frame=0;
		var returnValue=0;
		tmpTime=parseInt(tmpTime);
		hour= parseInt(tmpTime / (60 * 60 * 25));
		tmpTime = tmpTime % (60 * 60 * 25);
		minute = parseInt(tmpTime / ( 60 * 25));
		tmpTime = tmpTime % ( 60 * 25 );
		second = parseInt(tmpTime / 25 );
		tmpTime = tmpTime % 25 ;
		frame = parseInt(tmpTime);
		if(hour==0){
			hour="00";
		}else if(hour<10){
			hour="0"+hour;
		}
		
		if(minute==0){
			minute="00";
		}else if(minute<10){
			minute="0"+minute;
		}
		
		if(second==0){
			second="00";
		}else if(second<10){
			second="0"+second;
		}
		
		if(frame==0){
			frame="00";
		}else if(frame<10){
			frame="0"+frame;
		}
		
		return hour +":" + minute + ":" + second +":" + frame;
	}catch(e){
		alert("timeToTimecode error:"+ e.description);
	}
}

function funcTimeCodeInit(){
	try{
		document.all.qssm.onblur=funcTimeCode;
		document.all.jmcd.onblur=funcTimeCode;
		document.all.jssm.onblur=funcTimeCode;
		
		document.all.qssm.value=window.dialogArguments[0];
		document.all.jmcd.value=window.dialogArguments[1];
		
		document.all.jssm.value=timeToTimeCode(timeCodeToTime(document.all.qssm.value) + timeCodeToTime(document.all.jmcd.value));
		
	}catch(e){
		alert("funcTimeCodeInit error:" + e.description);
	}
}

document.onreadystatechange=funcTimeCodeInit;

⌨️ 快捷键说明

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