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

📄 editors.js

📁 java script web控件 包含了树 列表 表单的操作
💻 JS
字号:

var calendar_base_url = "";

function parseInteger(s){
	var v = [];
	for(var i=0;i<s.length;i++){
		var c = s.charAt(i);
		if(c=='0' && v.length ==0){

		}else{
			v[v.length] = c;
		}
	}
	if(v.length==0){
		return 0;
	}
	return parseInt(v.join(""));
}

function parseNumber(s){
	var v = [];
	if(s==null)
		return 0;
	for(var i=0;i<s.length;i++){
		var c = s.charAt(i);
		if(c=='0' && v.length ==0){

		}else{
			v[v.length] = c;
		}
	}
	if(v.length==0){
		return 0;
	}
	return parseFloat(v.join(""));
}

function isNumber(s){
	if(s==null || s=="")
		return false;
	for(var i=0;i<s.length;i++){
		var c = s.charAt(i);
		if(c<'0' || c>'9'){
			if(c!='.')
				return false;
		}
	}
	return true;
}



function StringEditor(input){
	this.input = input;
	input.onfocusout = function(){
		if(this.notNull=="true" && this.value==""){
			alert(this.caption + "不能为空");
			this.focus();
		}
	}
}


function DateEditor(input){
	this.input = input;
	input.onclick = function(){
		if(this.readOnly==true){
			return ;
		}
		var v = openDialog(calendar_base_url+"calendar.htm",input.value,238,290);
		if(v=="cancel"){
		}else{
			this.value = v;
		}
	}
}


function MoneyEditor(input){
	this.input = input;
	var oThis = this;
	var status = "display";
	
	if(this.input.value == null)
		this.input.value = 0;

	this.getValue = function(){
		return this.value;
	}

	this.setValue  = function(s){
		this.value = s;
		if(status == "display"){
			var v = formatToMoney("" + s);
			input.value = v;
		}else{
			input.value = s;
		}
	}

	if(input.value==null||input.value=="")
		input.value = "0.00";

	this.setValue(parseNumber(input.value));

	input.onkeyup = function(){
		if(event.keyCode!=13){
			if(!isNumber(this.value)){
				alert(this.caption + "的值必须是数字");
			}else{
				
			}
		}
	}

	input.onfocus = function(){
		status = "edit"
		oThis.setValue(oThis.value);
	}

	input.onblur = function(){
		status = "display";
		oThis.setValue(this.value);
	}
}



function NumberEditor(input){
	this.input = input;
	var oThis = this;
	if(input.value==""){
		input.value = "0";
	}
	
	input.onfocusout = function(){
		if(!isNumber(this.value)){
			alert(this.caption + "必须是数字");
			this.focus();
		}else{
			var v = parseNumber(this.value);
			this.value = v;
		}
	}
}

function SelectEditor(input){
	var select = document.createElement("select");
	input.parentNode.appendChild(select);
	input.removeNode(true);
	input = select;
}


⌨️ 快捷键说明

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